A five-stage RV32I CPU, a 16x16 signed INT8 matrix accelerator, memory-mapped control registers, and a word-packed DMA engine.
Tested with standard RISC-V ACT tests and CoreMark benchmarks.
Accelerator achieves 87.7x speedup (cycles) on matrix multiplication tasks.
The CPU implements the RV32I base integer instruction set:
- Five stages: instruction fetch (IF), instruction decode (ID), execute (EX), memory (MEM), and writeback (WB).
- Thirty-two 32-bit integer registers, with
x0hardwired to zero. - A 32-bit little-endian address/data interface and synchronous one-cycle instruction and data memory reads/writes.
- Load-use hazard detection, pipeline stalls, flushes, and forwarding from later pipeline stages.
- 16-entry BTB and two-bit direction counters.
- Machine CSRs including
mstatus,mie,mtvec,mscratch,mepc,mcause,mtval, andmip, plusecall,ebreak, andmrethandling. - Byte, halfword, and word loads/stores with sign extension or zero extension and misalignment detection.
The SoC provides an integration layer for the CPU, RAM, and accelerator. The accelerator contains a 16x16 signed 8-bit systolic array. It consumes streamed A and B values for the configured K dimension and produces signed 32-bit C values. Accelerator A and B memories are byte addressed internally; C memory stores 32-bit result words.
The CPU uses MMIO for control, status, and DMA descriptors.
rtl/core/: 5-Stage RV32I CPU Core — Contains the pipeline stages (frontend/BTB, decode, execute), common execution components (ALU, decoder, regfile, BRAM memory), pipeline registers, CSR logic, and the hazard/forwarding unit.rtl/accelerator/: 16x16 Systolic Matrix Accelerator — Contains the top-level accelerator wrapper, control state machine, 16x16 INT8 processing element (PE) array, and dedicated input/output matrix memories (A, B, and C).rtl/: SoC Top-Level & System Bus — Integrates the CPU, memory, DMA engine, and accelerator viasoc.sv, alongside the word-packed DMA controller (dma.sv) and MMIO address decoder (mmio.sv).sim/: Verilator Testbenches — C++ simulation runners for standalone CPU execution (tb_cpu.cpp) and full SoC integration testing (tb_soc.cpp) with cycle and wall-clock performance tracking.software/: Bare-Metal Firmware & Benchmarks — Assembly and C workloads used for validation and profiling, including the bare-metal CoreMark port, custom standalone test binaries, and CPU vs. accelerator comparison suites.
- Verilator
- GNU Make
- RV32-capable
riscv64-linux-gnu-gcc, riscv64-linux-gnu-objcopy- Spike
sv2v- Yosys
| Command | Purpose |
|---|---|
make sim |
Build and run the standalone CPU smoke test. |
make soc-sim |
Build and run the default program on the complete SoC. |
make compare-sim |
Run both identical matrix calculations, verify all 256 results, and report cycle and wall-clock speedups including DMA transfers. |
make csr-test |
Run the machine CSR, ecall, trap, mepc, and mret regression. |
make golden-cpu |
Run CoreMark on Spike and the RTL CPU, compare the tohost result, and report CPU performance statistics. |
make golden-soc |
Run the same CoreMark image on Spike and the complete SoC, compare results, and report SoC performance statistics. |
make coremark-soc |
Run the SoC CoreMark integration image, including its accelerator matrix check and performance markers. |
make test-act |
Run the 39 generated RISC-V architectural compliance tests. |
make act-run ACT_ELF=path/to/test.elf |
Convert and run one ACT ELF on the CPU simulator. |
make run-custom |
Assemble and run software/custom_sample.s on the CPU. |
make run-custom CUSTOM_PROGRAM=software/test.s |
Assemble and run a different CPU program. |
make run-custom-soc |
Assemble and run software/custom_accelerator_sample.s on the SoC. |
make run-custom-soc CUSTOM_SOC_PROGRAM=software/test.s |
Assemble and run a different SoC/accelerator program. |
make run_hex TOHOST=0x80001000 |
Run an already selected image with the CPU simulator. |
make synth-xilinx |
Convert the CPU and SoC to Yosys-compatible Verilog and generate XC7 resource reports. |
make coverage-cpu |
Run CPU simulation with Verilator coverage instrumentation. |
make coverage-soc |
Run the SoC comparison with Verilator coverage instrumentation. |
make clean |
Remove generated simulators, images, coverage files, and reports. |
Useful variables include MAX_CYCLES, TOHOST, COREMARK_ITERATIONS,
COREMARK_FREQ_MHZ, COREMARK_OPT, and COREMARK_DIR. For example:
make run-custom CUSTOM_PROGRAM=software/my_program.s MAX_CYCLES=200000
make golden-cpu COREMARK_ITERATIONS=5 COREMARK_FREQ_MHZ=100The current generated XC7 estimates are:
| Top | LUT6 | Flip-flops | DSP48E1 | Memory bits |
|---|---|---|---|---|
| CPU | 3,188 | 2,863 | 0 | 8,388,608 |
| SoC | 9,858 | 8,165 | 267 | 9,437,184 |
The LUT, flip-flop, and DSP values exclude BRAM.
make run-custom assembles and runs software/custom_sample.s on the
standalone CPU. The sample computes 6 times 7 using RV32I instructions and
writes tohost=1 when the result is correct. Run another RV32I assembly
program with:
make run-custom CUSTOM_PROGRAM=software/your_program.sThe custom program should use software/link.ld, define _start, and write
1 to the tohost symbol on success or 2 on failure. Optional controls are
MAX_CYCLES=1000000 and TOHOST=0x80001000.
make run-custom-soc assembles and runs
software/custom_accelerator_sample.s through the complete SoC. It uses DMA
to load two 16-byte vectors into accelerator memory, runs the accelerator with
K=1, DMA-reads the 16x16 result back into CPU RAM, verifies every result in
software, and writes tohost=1 on success. Run another SoC program with:
The MMIO base is 0x90000000:
| Offset | Function |
|---|---|
0x00 |
Accelerator start |
0x04 |
K dimension |
0x08 |
Accelerator status |
0x0c |
A base offset |
0x10 |
B base offset |
0x20 |
DMA source byte address in CPU RAM |
0x24 |
DMA destination byte address; 0x91...=A, 0x92...=B, 0x93...=C, 0x80...=CPU RAM |
0x28 |
DMA transfer size in bytes; use a multiple of 4 |
0x2c |
DMA start write and completion read |
DMA transfers use little-endian 32-bit words. A/B transfers unpack each word into four consecutive signed INT8 elements. C transfers move 32-bit result words into CPU RAM.
The compliance directory is retained because it is the external RISC-V test
suite used by scripts/run_act_tests.sh.