Small RV32 (RISC‑V 32-bit) core in VHDL with a simple 5-stage pipelined datapath, plus SRAM-based instruction/data memories and ready-to-run ModelSim/Questa + Synopsys Design Compiler flows.
This folder is a lab deliverable: the RTL is in src/, simulation scripts are in sim/, synthesis scripts are in syn/, and synthesized outputs/reports are in netlist/.
-
RISCV_top(src/RISCV_top.vhd)- Instantiates:
RISCVcoreIRAM_wrapper(instruction SRAM wrapper)DRAM_wrapper(data/stack SRAM wrapper)
- Includes a very simple instruction “encryption”/obfuscation step: the 32-bit word read from IRAM is XOR’ed with a per-address “key” (see
key_mem) to produce the decrypted instruction delivered to the core.
- Instantiates:
-
RISCV(src/RISCV.vhd)- Structural wrapper that connects:
CUcontrol unit (src/CU.vhd)DataPathpipelined datapath (src/DataPath.vhd)
- Exposes IRAM/DRAM interfaces (addresses, data, enable, load/store direction).
- Structural wrapper that connects:
-
DataPathinternals (src/DataPath.core/)- Stages:
FETCH,DEC,EXE,MEM,WB - Includes forwarding and basic hazard/stall logic (see src/DataPath.core/DEC/stall_detection_unit.vhd and src/DataPath.core/EXE/forwarding_unit.vhd).
- Stages:
-
SRAM macro model (simulation): Verilog SRAM under src/memories/ssram/
- The simulation script compiles
sram_32_1024_freepdk45.vandsram_32_1024_freepdk45_d.v.
- The simulation script compiles
-
IRAM wrapper: src/memories/IRAM_wrapper.vhd
- Preloads instruction SRAM from a constant array (
IRAM_mem). - The values in
IRAM_memmatch others/minv-project/enc.txt.
- Preloads instruction SRAM from a constant array (
-
DRAM wrapper: src/memories/DRAM_wrapper.vhd
- Implements two SRAMs:
- “main memory” region
- a “stack” region selected by comparing the address to
stack_start(see src/globals.vhd).
- Implements two SRAMs:
others/minv-project/ contains a small RV32I bare-metal program and scripts to dump text/data:
makefileexpects ariscv32-unknown-elf-*toolchain.main.c,crt0.s,riscv32-isa.ldetc.main.txtappears to be the plain instruction words.enc.txtappears to be the encrypted instruction words that are embedded into IRAM.key.txtcontains the XOR keys used for encryption/decryption (matches thekey_memconstants in the RTL/testbench).
There is also a rars_27a7c1f.jar at the repo root, which can be used as a RISC‑V assembler/simulator for quick experiments.
The main simulation flow is driven by sim/resim.tcl, which compiles RTL + SRAM model and runs the SRAM-based testbench.
From sim/:
- GUI:
./init_sim.sh 1 - CLI:
./init_sim.sh 0
Notes:
init_sim.shsources a lab-specific environment script (~/../../eda/scripts/init_questa_core_prime). If you don’t have that environment, use Option B.- On Windows, you’ll typically run this via WSL or Git Bash.
- Start
vsim. cdinto thesim/directory.- Run:
do resim.tcl
What it does:
- Compiles
globals.vhd(packages/constants) - Compiles the SRAM Verilog models
- Compiles the datapath/core RTL
- Runs
work.tb_riscvfrom src/test_bench/tb_RISCV_SSRAM.vhd - Adds a useful set of waveforms and runs
500 ns
The synthesis flow is in syn/resyn.tcl and targets RISCV_top.
Run from syn/:
- GUI:
./init_syn.sh 1 - CLI:
./init_syn.sh 0
Outputs are written to netlist/:
- Reports:
RISCV_area.rpt,RISCV_timing.rpt,RISCV_power.rpt, … - Netlists:
RISCV.v,RISCV.vhdl,RISCV.dcc - Constraints:
RISCV.sdc
Important DC notes:
- The environment is lab-specific (see syn/.synopsys_dc.setup) and references Nangate45 + an SRAM .db.
- The default clock period is set in
resyn.tclviaset CLK_T 5(units: ns).
The provided top-level/testbench use a simple XOR scheme:
- IRAM stores encrypted 32-bit instruction words.
- The top-level (or testbench) derives a 32-bit
keyfromkey_memusing the instruction address upper bits. - The decrypted instruction is
instr_dec = instr_enc XOR key.
Practical implication:
- If you change the program, you must update the embedded IRAM contents in src/memories/IRAM_wrapper.vhd (and keep
key_memconsistent with how you producedenc.txt).
The reference files used to generate/inspect those values are in:
- others/minv-project/main.txt (plain)
- others/minv-project/enc.txt (encrypted)
- others/minv-project/key.txt (keys)
- src/ — RTL (VHDL) + SRAM wrappers
- src/DataPath.core/ — pipeline stage RTL
- src/memories/ — IRAM/DRAM wrappers and SRAM models
- src/test_bench/ — testbenches (the sim script uses
tb_RISCV_SSRAM.vhd)
- sim/ — Questa/ModelSim scripts
- syn/ — DC scripts
- netlist/ — synthesized netlists and reports
- others/ — extra examples and the
minv-project
init_sim.sh/init_syn.shcan’t find~/../../eda/scripts/...: those are lab environment init scripts. Either source your own tool setup, or runvsim/dc_shellmanually and invokeresim.tcl/resyn.tcl.- Windows path issues: the provided scripts assume a Unix-like shell. Use WSL/Git Bash, or copy/paste the commands into the tool GUIs and adjust paths.
sim/resim_net.tclreferences unrelated files: it appears to be leftover from a different project (fp/"fpnew") and is not part of the main RISC_V_Lite flow.