Introduction
The following components are used for smooth RISC-V development on a FPGA:
This is my development environment which I use for RISC-V development. There are certainly
other products here that can be used for this.
This tutorial here will cover the software development with
SEGGER Embedded Studio.
CPU support package
After installing and starting Embedded Studio it should look like this:
(Click inside the picture to expand)
It may look a little different in your case because it could be possible that
I have installed other toolboxes:
(Click inside the picture to expand)
You will need to install a CPU support package.Therefore use "Tools > Package Manager...":
The next window now looks like this:
Press "Yes" and a CPU support package can be installed:
(Click inside the picture to expand)
Sorry, there is currently no CPU support package for NEORV32. But I wanted to show you how
to install a CPU support package. But that is not a problem, the project can also be created
without a CPU support package.
In the next step I will show you the default way to create a project.
Create a project
Now I will show you how to create a project. Here I am assuming that part 2 "FPGA Design Software"
has been processed. For the next step, the following directory must be created first "C:\my_design\de0n-neorv32-sdram-qsys\sw".
To create a project choose "File > New Project":
The next window now looks like this:
(Click inside the picture to expand)
Use "C:\my_design\de0n-neorv32-sdram-qsys\sw" for the
"Location" (1) and "de0n-neorv32-blinky" for the
"Name" (2). Since there is currently no CPU support package for the NEORV32,
we have to use the generic version here. Therefore select
"A C/C++ executable for a RISC-V processor" (3) and then close the
dialog with the "Next" button.
For the target device select "RV32":
Press "Next" and set the following settings:
Set "Toolchain Variant" to "Standard" (1), "Linker and
Section Placement" to "GNU-LD Flash Placement" (2), "Compiler"
to "gcc" (3) and press "Next" (4).
Yes, "GNU-LD Flash Placement" is the correct setting here, even if the CPU
has no real flash. "Flash placement" means that code and data are stored in different
areas. In the case of NEORV32, IMEM and DMEM are used here.
Deselect "Source/main.c" in the next dialog, because we have our own main.c:
And press "Next". The next window now looks like this:
Press "Finish" and accept the license in the next dialog, and you have now created
your first Embedded Studio project. After that, Embedded Studio looks like this:
(Click inside the picture to expand)
The "sw" directory should now look like this:
Next, the NEORV32 sources must be added to the project.
Add sources
The "Project Explorer" is required to add sources to the project:
First we will add a virtual folder named "Source" for the sources. To do this,
right-click on "Project de0n-neorv32-blinky". This gives you the opportunity to
create a new virtual folder:
The "Project Explorer" then looks like this:
Next, the actual sources will be added to the project. To do this, right-click on the
"Source" folder and select "Add Existing File ...":
Now add the file "main.c" from the following folder
"C:\my_design\de0n-neorv32-sdram-qsys\hw\src\neorv32\sw\example\blink_led".
The "Project Explorer" then looks like this:
Now add the files from the Lib folder
"C:\my_design\de0n-neorv32-sdram-qsys\hw\src\neorv32\sw\lib\source"
in the same way too. The "Project Explorer" then looks like this:
First of all, these are all sources that are required for the project. Next,
the path information for the include files must be set.
User Include Directories
The "Project Explorer" is required to add or change the settings for
the user include directories too. Right-click on "Project de0n-neorv32-blinky"
and use "Options...":
It is very important to set the configuration to "Common" in the next window.
This is the only way to apply the next changes to all configurations:
The window should now look like this:
(Click inside the picture to expand)
Make sure "Common" (1) is selected. Then click on "Preprocessor" (2),
"User Include Directories" (3) and then on (4) to enter the include directories.
The next window should now look like this:
Use "..\hw\src\neorv32\sw\lib\include" for the include path:
And press "OK".T he new settings should now be in place:
(Click inside the picture to expand)
Next, the segments must be changed in the "Linker" settings.
Linker settings
Within the linker settings, the memory segments must be checked and, if necessary, changed:
(Click inside the picture to expand)
The current settings do not match the actual DE0-Nano design and must be changed. The
settings for the DE0-Nano design are:
Segment |
Start |
Size |
IMEM |
0x00000000 |
0x8000 |
DMEM |
0x80000000 |
0x4000 |
With these values, the settings for "Memory Segments" must look like this:
(Click inside the picture to expand)
Press "OK", and we can start to compile the blinky software.
Compile
The project can be built with the "Build" function:
And the result looks like this:
The "Symbol Browser" shows useful information about the linked application and
complements the information displayed in the Project Explorer window:
The "Memory Usage" window displays a graphical summary of how memory has been used
in each memory segment of a linked application:
And in the next step we will use the debugger.
Debug
Before we can use the debugger via JTAG, the "Target Connection" must be changed
from "Simulator" to "J-Link":
(Click inside the picture to expand)
The debug session can be started by "Start Debugging":
And the result looks like this:
(Click inside the picture to expand)
And what you can do with a debugger you have to find out by yourself now ;o)
Download
And here the complete Quartus project which was created in the tutorial.
Quartus de0n-neorv32-sdram-qsys_20220101
project, for the DE0-Nano board (5.93 MB)
For other Intel FPGA boards there is my neorv32-examples repository on GitHub available.
|