Tiny-Vedas: a generic accelerator interface for RISC-V, from PyTorch op to GDS Tiny Vedas released an open-source RISC-V AI accelerator stack whose shipping RTL is a 4-stage pipelined RV32IM processor in SystemVerilog paired with an 8×8 int8 GEMM MMIO accelerator sharing DCCM over AXI4, with PyVedas compiling torch.compile output to C and then to RV32 ELF for on-core inference kernels. The repo also ships a Python instruction-set simulator for RTL trace comparison, YAML-driven decode tables, and an optional sv2v plus OpenROAD ASIC flow for core_gemm_top, while presets for VLIW, superscalar, and out-of-order variants are scaffolded but only rv32im_scalar matches implemented RTL today. The project is used as a reference for a free course on RISC-V Processor Design. Tiny Vedas is an open-source stack for designing, verifying, and bringing up RISC-V AI accelerators — from synthesizable processor RTL and spec-driven decode, through ISS/RTL co-simulation, to a PyTorch JIT that targets bare-metal firmware on the core. Today , the repo ships a complete RV32IM reference core: a 4-stage in-order pipeline with Harvard memory, hazard handling, and end-to-end test infrastructure. Next , the same contracts extend to additional microarchitectures VLIW, superscalar, out-of-order and vector units — hardware presets and software hooks are already scaffolded in hw/ https://github.com/spzbrnmrc/Tiny-Vedas/blob/main/hw/README.md so RTL, simulation, and PyVedas can evolve together without breaking the workflow. It is also used as a reference for the free course on RISC-V Processor Design https://youtu.be/izPdo7n1uI . | Layer | Role | |---|---| | RTL | Synthesizable RISC-V cores, GEMM accelerator, and SoC integration rtl/ | | Verification | Python ISS + RTL trace comparison tools/rv iss.py , sim manager.py ; GEMM directed/random co-sim tools/gemm cosim.py | | Decode | YAML-driven instruction tables → SystemVerilog open-decode-tables/ | | Primitives | Reusable arithmetic and register blocks SVLib/ | | Software | Bare-metal runtime, printf, assembly/C/PyTorch tests | | PyVedas | torch.compile → C → RV32 ELF for on-core inference kernels | | PD | Optional ASIC flow: sv2v + OpenROAD pd/ — core gemm top CPU + GEMM | The shipping RTL is a 4-stage pipelined RV32IM processor written in SystemVerilog, plus an 8×8 int8 GEMM MMIO accelerator that shares DCCM over AXI4. The CPU flavor hw/presets/rv32im scalar.yaml is the baseline used by CI, examples, and the course. Tiny Vedas is built to support multiple CPU organizations behind one hardware-config contract. Presets in hw/presets/ https://github.com/spzbrnmrc/Tiny-Vedas/blob/main/hw/presets already describe scalar, VLIW, superscalar, and out-of-order variants with optional vector units; only rv32im scalar matches implemented RTL today. As new microarchitectures land, sim manager , PyVedas, and the test suite will target them through the same --hw-config YAML — so accelerator exploration stays one toolchain, not a fork per design. - ISA : RISC-V RV32IM 32-bit integer + multiply/divide - Pipeline : 4-stage IFU → IDU0 → IDU1 → EXU - Memory : Harvard architecture — separate ICCM and DCCM true dual-port, both ports RW . The core keeps custom fetch/LSU ports; soc top and the FPGA SoC convert those to AXI4 32-bit, ID width 4, two DCCM masters into on-chip CCM slaves. FPGA muxes DCCM port B between the core and the host halt-and-load . ASIC PD synthesizes core gemm top CPU + GEMM; memories stay off-chip IOs . - GEMM : Output-stationary 8×8 PE array int8 × int8 → int32 , K-tile 32 at MMIO GEMM ADDR 0x00300000 . Packed AXI4 INCR DMA loads A/B from DCCM and writes C; the core is held via accel hold for the duration of one START job software does not poll DONE . - Decode : Spec-driven via the open-decode-tables submodule YAML → SystemVerilog - Verification : Python instruction-set simulator ISS compared against RTL traces - Arithmetic : ADD, SUB, ADDI, LUI, AUIPC - Logical : AND, OR, XOR, ANDI, ORI, XORI - Shifts : SLL, SRL, SRA, SLLI, SRLI, SRAI - Comparison : SLT, SLTU, SLTI, SLTIU - Branches : BEQ, BNE, BLT, BGE, BLTU, BGEU - Jumps : JAL, JALR - Memory : LB, LH, LW, LBU, LHU, SB, SH, SW - Multiply/Divide : MUL, MULH, MULHU, MULHSU, DIV, DIVU, REM, REMU - System : NOP addi x0, x0, 0 , ECALL decoded; no trap handler yet — behaves as NOP - Register forwarding from EXU to IDU1 - Pipeline flush on taken branches and jumps - Register scoreboard for RAW hazard detection - Multi-cycle multiplier and divider - Booth-encoded 32×32 multiplier with per-operand signedness MUL / MULH / MULHU / MULHSU - Non-restoring divider with combinational Kogge-Stone adders on the iteration path - Unaligned load/store support with byte-strobe DCCM writes no store RMW and strobe-aware store-to-load forwarding. Dual RW DCCM ports complete both beats of an unaligned access in one cycle stall only on a same-cycle load/store port conflict . One START programs a single 2-D DCCM matrix multiply C = A × B : | Item | Value | |---|---| | Array | 8×8 output-stationary PEs | | Datatypes | int8 × int8 → int32 accumulators | | K tiling | 32-element tiles, dual ping-pong A/B buffers | | DMA | 32-bit AXI4 INCR bursts A along K, B along N, C int32 along N | | Wait | Core accel hold for the job; tests must not poll STATUS before reading C | CSRs rtl/include/gemm csrs.svh : BASE A/B/C , M , N , K , CTRL START / soft reset , STATUS BUSY / DONE . DONE is sticky until the next START. Firmware examples: tests/asm/gemm 8x8.s , tests/c/gemm 8x8.c , tests/c/gemm multi.c . Tiny-Vedas/ ├── rtl/ Processor + accelerator RTL │ ├── core top.sv CPU pipeline memory ports exposed │ ├── soc top.sv core top + GEMM + AXI4 adapters + ICCM/DCCM │ ├── core top.flist Sim file list core + SoC + bus + GEMM │ ├── accel/ GEMM MMIO engine CSR, DMA, 8×8 PE array │ │ ├── gemm top.sv Job FSM + ping-pong tile orchestration │ │ ├── gemm csr.sv AXI-Lite CSRs at 0x00300000 │ │ ├── gemm dma.sv Packed AXI4 INCR bursts to DCCM │ │ ├── gemm datapath.sv Systolic array + accumulators │ │ └── gemm pe.sv int8 MAC PE │ ├── bus/ AXI4 fetch/LSU masters, CCM slaves, master mux │ ├── ifu/ Instruction fetch unit │ ├── idu/ Decode stages, regfile, scoreboard │ │ ├── rv32im decoder.sv Generated — do not hand-edit │ │ └── decode out t.svh Generated — do not hand-edit │ ├── exu/ ALU, MUL, DIV, LSU │ ├── include/ global.svh, types.svh, axi4.svh, gemm csrs.svh, mmio map.svh │ └── lib/ Byte-write ICCM/DCCM sync tdp mem ├── fpga/alveo u280/ Alveo U280 bitstream, host load, card smoke ├── pd/ ASIC PD: sv2v + OpenROAD core gemm top │ ├── rtl/core gemm top.sv PD wrapper: core top + gemm top │ ├── platforms/ ASAP7 / sky130 YAML │ └── README.md ├── dv/ │ ├── sv/ core top tb.sv, gemm top tb.sv, lsu tb.sv │ └── verilator/ Verilator C++ harness ├── hw/ Hardware presets scalar, VLIW, OoO + vector │ ├── presets/ YAML configs shared by RTL/SW see hw/README.md │ ├── soc/ SoC device map UART, GEMM, EOT │ └── types.py Typed HwConfig loader ├── tests/ │ ├── asm/ Assembly test programs incl. gemm 8x8 │ ├── c/ C tests helloworld, iaxpy, gemm 8x8, gemm multi │ ├── elf/ Prebuilt ELF binaries dhrystone │ ├── pyvedas/ PyTorch → JIT model specs incl. gemm mmio │ ├── smoke.tlist Regression test list │ └── gemm.tlist GEMM-only regression ├── pyvedas/ PyTorch → Tiny-Vedas JIT ├── tools/ │ ├── sim manager.py Main test runner compile → ISS → RTL → compare │ ├── rv iss.py Reference instruction-set simulator │ └── gemm cosim.py Directed / random GEMM co-simulation ├── sw/ │ ├── include/ soc defines.h generated — do not hand-edit │ └── vedas printf/ Bare-metal printf library for C tests ├── SVLib/ Git submodule — reusable SystemVerilog primitives ├── open-decode-tables/ Git submodule — YAML decode table generator ├── scripts/ │ ├── install deps.sh Dependency installer make deps │ ├── env.sh Generated PATH + venv by make deps │ ├── with env.sh Wrapper used by Makefile targets │ └── pd docker.sh OpenROAD Docker wrapper for rtl2gds ├── .github/workflows/ci.yml GitHub Actions CI pipeline ├── Makefile ├── requirements.txt └── LICENSE | Tool | Purpose | |---|---| | Verilator | RTL simulation primary; used in CI | | riscv64-unknown-elf-gcc | Bare-metal cross-compiler for test programs RV32IM / ILP32 | | Python 3 | sim manager.py , rv iss.py , decode generation | | Xilinx Vivado optional | XSim simulation — only needed if you prefer make smoke over Verilator | Tested on Ubuntu 22.04 and 24.04. Other Linux distributions should work with equivalent packages installed manually. git clone --recurse-submodules https://github.com/siliscale/Tiny-Vedas.git cd Tiny-Vedas If you already cloned without submodules: git submodule update --init --recursive On Ubuntu, make deps installs everything needed for simulation and verification: - System build packages build-essential , Verilator build deps - Python virtual environment with packages from requirements.txt - Prebuilt RISC-V GNU bare-metal toolchain riscv64-unknown-elf-gcc into .local/riscv/ - Latest stable Verilator compiled from source into .local/verilator/ make deps make deps also generates scripts/env.sh PATH + venv and verifies the toolchain. All Makefile test targets use it automatically via scripts/with env.sh , so CI and local runs work without manual setup. For interactive shells, source the environment once per session: source scripts/env.sh riscv64-unknown-elf-gcc --version verilator --version Override pinned versions if needed: RISCV TOOLCHAIN VERSION=2026.06.05 make deps default VERILATOR TAG=v5.048 make deps pin a specific Verilator release FORCE RISCV TOOLCHAIN REINSTALL=1 make deps re-download toolchain FORCE VERILATOR REBUILD=1 make deps rebuild Verilator Do not run make deps with sudo — only the apt step needs elevated privileges. If a previous sudo make deps left deps/verilator root-owned, fix ownership then rebuild: sudo chown -R "$USER:$USER" deps/verilator FORCE VERILATOR REBUILD=1 make deps Verilator recommended; same as CI make smoke-verilator Xilinx XSim requires Vivado — optional make smoke ./tools/sim manager.py -s verilator -n asm.basic alu r ./tools/sim manager.py -s verilator -n c.helloworld ./scripts/with env.sh ./tools/sim manager.py -s verilator -n pyvedas.vector add Tiny Vedas compiles bare-metal test programs with riscv64-unknown-elf-gcc using -march=rv32im -mabi=ilp32 . Do not use the Linux cross-compiler riscv64-linux-gnu-gcc or distribution packages that lack newlib — they will not produce working bare-metal ELFs. make deps downloads a prebuilt riscv64-unknown-elf toolchain from the riscv-collab/riscv-gnu-toolchain releases https://github.com/riscv-collab/riscv-gnu-toolchain/releases page and installs it to .local/riscv/ . The Ubuntu series 22.04 or 24.04 is detected automatically. 1. Go to riscv-gnu-toolchain releases https://github.com/riscv-collab/riscv-gnu-toolchain/releases . 2. Download the riscv64-elf-ubuntu-