LiteX Framework and Signaloid C0-microSD Integration
By following this guide, you should be able to build, flash, and run the LiteX-based SoC on your Signaloid C0-microSD. Feel free to explore and modify the design to suit your specific needs!
What is LiteX?
LiteX is an open-source digital hardware design framework that simplifies the creation of complex digital systems, particularly System-on-Chip (SoC) designs. It is built on top of Migen, a Python-based hardware description language and provides a high-level abstraction for designing digital circuits.
LiteX offers rapid prototyping with pre-built components and high-level abstractions, flexibility in customization and extension, portability across FPGA platforms, easy integration of IP cores and peripherals, and community support. It also serves as a learning tool for software engineers transitioning to hardware design.
Key features of LiteX include:
- Python-based design flow
- Modular architecture
- Support for multiple CPU cores (including RISC-V)
- Built-in peripherals and interfaces
- Vendor-agnostic approach (supports multiple FPGA families)
Using the Signaloid C0-microSD LiteX integration example
The Signaloid-C0-microSD-LiteX-Integration repository provides an example RISC-V SoC implementation for the Signaloid C0-microSD using LiteX. It includes Makefiles for building and flashing both the FPGA bitstream and firmware binary.
Prerequisites
Before you begin, ensure you have the following tools installed:
- Python 3.10 or later, because LiteX and Migen are Python tools. See Python Environment.
- Yosys
- nextpnr
- IceStorm
- RISC-V GNU toolchain with support for the
RV32IMinstruction set
We recommend using the OSS CAD Suite to install Yosys, nextpnr, and IceStorm.
Getting started
-
Clone the repository:
git clone --recursive git@github.com:signaloid/Signaloid-C0-microSD-litex-integration -
Navigate to the project root directory:
cd Signaloid-C0-microSD-litex-integration -
Configure the build environment:
- Open the
config.mkfile. - Set the
CROSS_COMPILE_PATHvariable to your RISC-V GNU Toolchain installation path. - Set the
DEVICEvariable to the correct device path for your Signaloid C0-microSD (follow the Identify your module guide).
- Open the
-
Build and flash both gateware and firmware:
make flash
Gateware details
For this example, we use the default Signaloid C0-microSD target design from LiteX-boards, featuring:
- VexRISC-V-Lite SoC with IM support
- UART interface for serial communication
- 12MHz default system clock
- 128KB SRAM
- 14MB binary and files storage on SPI Flash
Firmware details
The example firmware implements:
- LED blinking (red and green) every 250ms.
- Printing the active LED identifier ('r' for red, 'g' for green) to the UART serial port.
- UART echo functionality (
txtorx).
Serial communication
You can interact with the SoC via the UART serial interface.
- Connect your Signaloid C0-microSD UART serial port to your computer using a compatible 3.3V USB-to-serial adapter, such as the FTDI FT232RL, or the Tigard.
UART port pins:- TX:
SD_CMD(A4) - RX:
SD_CLK(B3)
- TX:
- Configure your serial terminal with a baud rate of 115200.
Example usingscreenon Linux:screen /dev/ttyACM0 115200
Customizing the design
To modify the SoC design:
- Edit the
signaloid_c0_microsd.pyfile in thegateware/directory. - Rebuild the gateware using
make gateware.
To modify the firmware:
- Edit the source files in the
firmware/src/directory. - Rebuild the firmware using
make firmware.
Troubleshooting
If you encounter issues:
- Ensure all prerequisites are correctly installed.
- Ensure that the Signaloid-C0-microSD-LiteX-Integration repository was cloned recursively.
- Verify that
CROSS_COMPILE_PATHandDEVICEinconfig.mkare set correctly. - Check the console output for specific error messages.
- If flashing fails, ensure you have the necessary permissions to access the device.
For further assistance, please contact Signaloid Developer Support at developer-support@signaloid.com.
Further resources
We also provide a more advanced LiteX SoC design that uses the Lattice iCE40 hard I2C IP to communicate with peripherals. You can find that in the Signaloid-C0-microSD-LiteX-I2C-demo repository. You can also read more in the official LiteX wiki and Migen documentation pages.
Next steps
- Using the Open-Source Toolchain, the synthesis flow underneath the LiteX build.
- Modes and Custom Bitstream, how a custom bitstream is stored and selected at power-up.
- Flash the C0-microSD, the full toolkit reference for writing the generated bitstream.
- Examples and Demos, more designs built on this integration.