Software, hardware designs, and notes from my CPU design/computer architecture independent study. The goal of this independent study project was to design a fully functional and standards-compliant RISC-V rv32im microprocessor and SoC.
-
Pipelined
rv32imCPU and SoC capable of running on a ColorLight 5A-75B board (Lattice ECP5 LFE5U-25F) at 50MHz. 33.386 MIPS @ 50MHz, with the Dhrystone benchmark (1.5 CPI). -
Multi-cycle
rv32imCPU and SoC capable of running on an Upduino board (Lattice ICE40UP5K) at 25MHz (overclocked). 4.7MIPS according @ 25MHz with the Dhrystone benchmark (5.32 CPI) -
2-bit-color memory-mapped text mode VGA display adapter (640x480, 8x16 bitmap font, fg&bg color)
-
Memory-mapped parallel IO and SPI host controller
-
SPI Flash memory bootloader for Upduino SoC (flash memory->SPRAM)
-
rv32imsimulator written in C, side-by-side comparative verification by simulation of HDL designs (Verilator) alongside the software simulator. Running the official RISC-Vrv32imtest suite. -
SDL-based emulator for the Upduino SoC with VGA display emulation.
-
Add SRAM support as a bus device for stack memory
-
Pipelining (eek)
-
Caching & programs from external memory
-
Compressed instruction decoding & support
-
Branch prediction
-
Test VGA peripheral (black & white text mode) graphics adapter
-
Multicore? (A extension & other stuff)
-
M extension
-
B extension
-
CSRs for perf, interrupt control, core ID, etc.
-
Interrupt support (learn more about the ISA in this aspect)
-
GPIO periperal
-
SPI / PWM / I2C, other peripherals, GPIO muxing!
softwaresimulatorsimulator for emulation & verificationtestofficial RISC-Vrv32imtest programssim_emulatorSDL-based emulator for the ice40UP5K (Upduino) SoC.sim_clibasic simulator for debugging.
librarybasic SoC support for programming in C (and linker scripts)crt0.SC-runtime startup routinecrt0_minimal.SC bootstrapping without libc initializationmap_bootloaded.ldlinker script for programs to be bootloadedmap_ecp5.ldnormal memory model (Von Neumann), 100KiB RAM for ECP5 SoCmap_minimal.ld1KiB RAM, 256B stack, used for the bootloader that fits in 256 words of memory.map_spram.ldbootloader for 10KiB BRAM and 128KiB SPRAM onsoc_upduinowithout bootloadermap.ldbasic 10KiB BRAM forsoc_icefun
programsmiscellaneous programs for the SoCtest_baremetalfirst steps usingriscv32-unknown-elf-gccwith no libctest_embeddedprograms using newlib, customcrt0, and SoC support library.bootloadersimilar totest_embedded, but linked to be loaded from SPI flash memory using the bootloader.qr_codeprogram (bootloaded) using an open-source library to generate and display a QR codeimagesprogram that can display low-resolution images using the 2-bit color text-mode graphics adapter.
rtlHDL code (SystemVerilog designs)aluALU module used by both versions of the CPU. supports multiplication and division (M extension)commonshared modules (memory, bus hub generator, etc.)cpuV1 multi-cyclerv32imCPU, Von Neumann architecturecpu_v2V2 pipelinedrv32imCPU, Harvard architecturepipeline_testersimple Verilator testbench for producing a VCD waveform from running a specified programsimulatorco-simulator for verification and testing (make testruns the test suite)sim_cocotbCoCoTB testbench using Icarus Verilog for timing and more detailed testing.
fpgaFPGA-specific (more hardware oriented) modules (debouncers, IO, SPI, LED controller, etc.)graphicstext-mode graphics adapter (b/w and color, font ROM)soc_ecp5complete SoC using the V2 processor for the ColorLight 5A-75B board. Timed at 50MHz. WIP IO.soc_fpgaSoCs for ice40 HX8K and UP5K (iceFUN and Upduino). Upduino runs at 25MHz (overclocked) with 2-bit color graphics, 128KiB RAM, and SPI bootloader.soc_simSoC for basic testing and verification of the V1 processorverilatorco-simulator for verification of the non-pipelined processor and basic bus architecture.