"You can't have both fish and bear's paw?
As a very low-level hardware programmable logic chip, FPGA is very flexible to realize digital logic circuit, but for students who are used to C language and MCU programming, it still takes some time to write from the low-level circuit to the upper application.
So if you want to design the underlying circuit flexibly in FPGA and develop applications as quickly as Arduino, can you have both fish and bear's paw?
We know that MCU (microcontroller unit) runs CPU hard core, such as Intel 8051 core, arm Cortex-M core, AVR core used on Arduino board, etc. major semiconductor manufacturers have integrated a variety of peripheral modules on the basis of CPU core to meet different application requirements. What users need to care about is what resources this MCU has and how to configure registers. What if I want to customize an MCU according to my application requirements, but the semiconductor manufacturer ignores me? There is always a way, so go back to the state before MCU was born. By porting the processor core to FPGA, using the internal logic resources and storage resources of FPGA to build a soft MCU, and then mounting the required peripheral circuits through the internal bus to form a customized MCU, which we call soft core.
Mustang fighter in soft core - fp51-1t
At present, transplanting soft cores in FPGA is a common practice, but most MCU soft cores are customized by FPGA manufacturers, such as Nios II of Altera, MicroBlaze of Xilinx and mico32 / mico8 of lattice. These soft cores are not completely open source and have many restrictions on users.
A foreign company called pulserain technology has developed and opened source a high-performance MCU soft core fp51-1t. Although the soft core is based on the 8-bit 8051 system, it cleverly implements the RISC architecture and optimizes the instruction set. Most instructions can be implemented in a single clock cycle, and the main frequency can be increased to more than 100MHz, The soft core is named after the fierce Mustang fighter p51 in World War II.
In order to facilitate debugging, OCD (on chip debugger) module is integrated in the soft core. As long as the PC host can realize program download, single-step execution, breakpoint debugging and other functions through RS232 interface. The greatest flexibility of this soft core lies in the attachment of timer, SPI / I2C, UART, PWM, voice codec, microSD, serial SRAM and other peripheral interfaces through the wishbone bus. To facilitate software development, pulserain technology provides Arduino compatible board support package and software development library. After transplanting the soft core to FPGA, you can use Arduino to develop FPGA.
Fp51-1t structure diagram
Fp51-1t soft core adopts minimum resource allocation and is transplanted to Altera max10 series FPGA. Resource occupation:
8051 1T MCU Core
16KB Code Memory,16KB Data Memory
2 Timer
1 Watchdog Timer / LED Controller
1 RS-232 UART,1 JTAG UART
OCD
Pulserain fp51-1t provides two licensing methods, one is open source licensing (GPL) V3), another commercial license. All open source code has been placed in the GitHub warehouse, but if it is to be used for commercial purposes, it still needs to obtain a commercial license Fp51-1t MCU core details ☞ fp51-1t MCU core: a Mustang in FPGA The M10 development board launched by pulserain uses Arduino to develop in detail
☞ PulseRain M10: Play FPGA like Arduino Now fp51-1t has been successfully transplanted to step-max10 development board, and Arduino board support package is provided. Let's use the step FPGA development board to experience this magical operation!
Developing step-max10 FPGA with Arduino
preparation
Xiaojiaoya FPGA development board step-max10 08 series
Intel quantum prime software
Arduino IDE
Preparation 1: step-max10 FPGA development board -- FPGA model Intel max10-08 series
Step-max10 is an FPGA development board based on Intel / Altera's FPGA chip max10m08 in xiaojiaoya FPGA series. It also adopts dip40 package, which is small, easy to carry and rich in onboard resources, including:
Xiaojiaoya FPGA development board step-max10 08 series
Intel quantum prime software
Arduino IDE
In addition, the board integrates a downloader, which can realize the power supply and download of the development board with a general microusb data cable. The max1008 chip used on the development board has 8000 Le resources, a maximum of 172kb user flash memory and 378kbit ram. Rich logic and storage resources ensure that there is enough margin to design other peripheral circuits after transplanting the soft core.
Small foot step-max10
Preparation 2: Intel quantum prime software
Quartus prime is a free and powerful design software launched by Altera after its acquisition by Intel. It includes all functions required in all stages from design input to synthesis to optimization, verification and simulation. Quartus prime Lite is an ideal design tool for a large number of device series, which can be downloaded and used for free.
Downloading, installing and using quartus prime ☞: Quartus Prime
Preparation 3: Arduino ide software
Arduino is a convenient, flexible and easy to use open source electronic prototype platform, which includes two core parts: Hardware (various models of Arduino boards) and software (Arduino IDE). Arduino IDE is developed based on the processing IDE, which is easy for beginners to master and flexible enough. Arduino language is developed based on wiring language. It is the secondary packaging of AVR GCC library. It does not need too much MCU foundation and programming foundation. After simple learning, you can develop quickly. Download and installation of Arduino IDE Arduino ide Download
Operation steps
Obtain pulserain fp51-1t MCU soft core
Arduino ide installation board and software support package
Developing applications in the Arduino IDE
Configure the soft core to the step-max10 FPGA development board
Customize your own hardware peripherals
The operation flow chart of developing step-max10 FPGA with Arduino IDE is as follows:
M10 BSP for Arduino IDE(Copy from PulseRain)
Step 1: obtain pulserain fp51-1t MCU soft core
1. Clone soft core source code
The project source code of fp51-1t has been open source on GitHub. You can get the code with the following command
git clone -b step_ fpga https://github.com/PulseRain/Mustang.git step_ fpga
This operation will create a step in the local directory_ FPGA directory You can also click the link directly https://github.com/PulseRain/Mustang.git , Note that there are two branches under the repository. Select branch: step_ fpga In the clone or download option of the web page, download the zip file,
cd step_ fpga
Enter this directory
git submodule update --init --recursive
Update all submodules The project is compiled with quartus prime 16.1 Lite edition, and the project file is in synth / Mustang_ fast.qpf
(please keep the copyright notice at the beginning of the source code when forwarding the source code)
2. Introduction to soft core peripherals
Fp51-1t is a high-performance 8-bit MCU compatible with 8051 system. It is cleverly implemented by RISC architecture. Most instructions can be implemented in a single cycle, and the main frequency can run to 96mhz. In order to facilitate debugging, OCD (on chip debugger) module is integrated in the soft core. The PC host can realize the debugging functions such as program download, single-step execution, setting breakpoints and so on as long as it passes through the RS232 interface. In addition, the soft core mounts multiple peripheral modules through the wishbone bus, such as timer, UART, SPI / I2C, PWM, voice codec, microSD socket, SRAM, onchip ADC, etc. users can cut and add these peripherals.
Fp51-1t MCU structure diagram
Open the project file Mustang using quartus prime_ fast.qpf。 The project includes fp51-1t core and common peripheral modules, which are applicable to step-max10 and Step FPGA baseboard development board, including rotary encoder, seven segment nixie tube, PS / 2 keyboard interface, PWM backlight control, LED display and LCD display. If we need to connect other peripherals, we can also modify the soft core, but we need to modify the compiler file at the same time. Here, we default that the existing peripherals will not be modified.
The default onboard resources on the step-max10 FPGA development board are:
2-digit seven segment nixie tube;
2 RGB three color LEDs;
4-way dial switch;
4-way keys;
36 user scalable I / OS that can be connected to backplane peripherals
The baseboard peripheral module is shown in the figure below:
step_ base_ board_ Demo module division
The project has been compiled by default. After connecting PC and development board with micro USB cable, quartus prime software can be directly downloaded to step-max10 chip.
Compilation results of fp51-1t in step-max10
If you are not familiar with the use of quartus prime, you can first learn the tutorial quartus here_ Use of prime.
If you are not familiar with FPGA development, you can first learn the introductory tutorial step-max10 introductory tutorial.
Step 2: install board support package and software library in Arduino IDE
1. Install the board support package
Arduino ide can support the development of third-party boards, but the support package of third-party boards needs to be installed. Open the Arduino IDE and open the File - preferences - additional development board Manager Web site, add the following link:
https://raw.githubusercontent.com/PulseRain/Arduino_ M10_ IDE/step_ fpga/package_ M10_ index.json
Add card support package link in Arduino
After confirmation, open Tools - development board - development board manager, enter "stepfpga" in the search box, and the name stepfpga will appear_ M10 board support package, click Install
Installing the card support package in Arduino
After the download and installation is completed, the option stepfpga M10 is available in the board manager. The BSP mainly includes three parts: fp51 core and Sdcc Compiler and target download tools
2. Install software library
Arduino's development is simple and fast because Arduino officials and many open source hardware enthusiasts have contributed a large number of application software libraries. The software libraries of common peripheral interfaces or modules can be downloaded from the Internet and can be easily embedded in our programs. Pulserain provides ft51-1t MCU with software libraries of common peripheral interfaces, such as I2C, microSD, codec, PWM, esp8266, etc., and has detailed documentation ☞ https://www.pulserain.com/m10 。
We open it in the Arduino ide Project - load Library - manage library. Enter "M10" in the search box of the library manager window, and there will be m10lcd, m10pwm and other peripheral libraries. click install Required library files. Here we install three library files: m10lcd, m10pwmm and 10sevenseg.
Install library files in Arduino
If you need to use a library in the program, you only need to load the library in the project and select the corresponding library to include the header file of the library in the application.
Step 3: develop the application in the Arduino IDE
In the Arduino IDE Tools bar, select The development board is stepfpga M10. After setting up the software and hardware environment, we can start developing our own applications. Here we write an application to realize the following functions:
Output Hello world at 115200 BPS on the serial port! Then output scancode of PS2 keyboard
The number of rotary encoder is displayed on the 7-section tube. Rotating the rotary encoder will increase or decrease the number, the LED will change accordingly with the rotary encoder, and the brightness of the 8'lcd will also change.
The LCD displays a picture with small feet and pulserain logo
Key 1 is set as the reset key of MCU
Application ☛ Play F
Our other product: