This is an example RISC-V SoC implementation on the Signaloid C0-microSD FPGA that can run C/C++ software.
This project offers Makefiles to build and flash the FPGA bitstream, and the firmware binary.
This example utilizes the default Signaloid C0-microSD target design from litex-boards. It consists of:
- VexRISC-V-Lite SoC, with IM support.
- UART interface for serial communication support.
- 12MHz default system clock.
- 128kiB SRAM.
- 14MiB binary & files storage on SPI Flash.
The firmware implements a "blink" example, with UART serial communication support.
- Blinking the Signaloid C0-microSD on-board red and green LEDs every 250ms.
- Printing the turned-on LED.
- Echoing the UART
tx
bytes onrx
.
Note
This repository assumes that you have already installed the following tools.
- Yosys
- nextpnr
- IceStorm
- RISC-V GNU Toolchain for RV32IM ISA extension
We recommend using the OSS CAD Suite to install Yosys
, nextpnr
, and IceStorm
.
To clone this repository recursively, run the following command:
git clone --recursive [email protected]:signaloid/C0-microSD-litex-integration
If you forgot to clone with --recursive
and end up with empty submodule directories, you can remedy this with:
git submodule update --init --recursive
You can update all submodules with the following commands:
git pull --recurse-submodules
git submodule update --remote --recursive
Run the environment preparation make command, on the project's root directory:
make prep
Before running this, make sure that the CROSS_COMPILE_PATH
variable is properly set in the config.mk
file with the installation path of the RISC-V GNU Toolchain for RV32IM ISA extension. Its default value is set to opt/riscv32im/bin
. Also, make sure that the DEVICE
variable in the config.mk
file is set to the correct device path (follow the Identify the Signaloid C0-microSD guide).
Run this in the project's root directory:
make flash
This repository consists of several subdirectories.
gateware/
: LiteX SoC design.firmware/
: C based code example.build/
: Litex generated directory after the building process. Contains the FPGA design bitstream, the Litex generated C libraries, the compiled firmware binary, and the Litex autogenerated documentation.submodules/
: Dependencies on tools outside this repository.- C0-microSD-utilities: C0-microSD-toolkit for flashing purposes.
This repository contains two Makefiles, one for the gateware, the main Makefile
, and one for the firmware, the firmware/Makefile
. The firmware Makefile targets are also accessible from the main Makefile, so you can run its commands from both the firmware/
and the project's root directory. For details on the firmware Makefile, see the firmware/README.md
file.
You should run the following commands from the project's root directory, where the main Makefile is located.
To build both gateware and firmware run:
make
This command:
- Prepares the environment for development, if haven't already.
- Builds the Litex gateware, and software libraries.
- Proceeds with synthesize, place 'n' route, and pack.
- Builds the Litex autogenerated SoC documentation, in the
build/signaloid_c0_microsd/docs/html/
directory. - Builds the C firmware.
To flash both gateware and firmware run:
make flash
To delete all generated files except the virtual environment run:
make clean
make clean-env
To prepare the environment run:
make prep
This command:
- Downloads all git submodules in the submodules directory.
- Creates a python virtual environment at .venv.
- Installs all python required packages defined on the requirements.txt file using pip.
To build the SoC bitstream run:
make gateware
To flash the SoC bitstream to the Signaloid C0-microSD run:
make flash-gateware
This is useful for debugging the target script. To test for verilog compilation errors run:
make test-target
To build the SoC firmware run:
make firmware
To flash the SoC firmware to the Signaloid C0-microSD run:
make flash-firmware
To clean the SoC firmware build files run:
make clean-firmware
To print all the variables of the firmware Makefile run:
make print-vars-firmware
To print all the variables of the main Makefile run:
make print-vars
The gateware bitstream is stored in the build/signaloid_c0_microsd/gateware/
directory with the name signaloid_c0_microsd.bin
.
The firmware binary is stored in the build/signaloid_c0_microsd/software/
directory with the name signaloid_c0_microsd_firmware.bin
.