Skip to content

About

Lite implementation of a RISC V processor

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RISC_V_Lite

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/.

What’s in here

Top level hierarchy (RTL)

Memories

Software / program generation helpers

others/minv-project/ contains a small RV32I bare-metal program and scripts to dump text/data:

  • makefile expects a riscv32-unknown-elf-* toolchain.
  • main.c, crt0.s, riscv32-isa.ld etc.
  • main.txt appears to be the plain instruction words.
  • enc.txt appears to be the encrypted instruction words that are embedded into IRAM.
  • key.txt contains the XOR keys used for encryption/decryption (matches the key_mem constants 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.

Quickstart: simulation (ModelSim/Questa)

The main simulation flow is driven by sim/resim.tcl, which compiles RTL + SRAM model and runs the SRAM-based testbench.

Option A: run the provided wrapper script

From sim/:

  • GUI: ./init_sim.sh 1
  • CLI: ./init_sim.sh 0

Notes:

  • init_sim.sh sources 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.

Option B: run directly inside Questa/ModelSim

  1. Start vsim.
  2. cd into the sim/ directory.
  3. 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_riscv from src/test_bench/tb_RISCV_SSRAM.vhd
  • Adds a useful set of waveforms and runs 500 ns

Synthesis (Synopsys Design Compiler)

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.tcl via set CLK_T 5 (units: ns).

Program “encryption” / IRAM contents

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 key from key_mem using 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_mem consistent with how you produced enc.txt).

The reference files used to generate/inspect those values are in:

Folder map

Troubleshooting

  • init_sim.sh / init_syn.sh can’t find ~/../../eda/scripts/...: those are lab environment init scripts. Either source your own tool setup, or run vsim / dc_shell manually and invoke resim.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.tcl references unrelated files: it appears to be leftover from a different project (fp/"fpnew") and is not part of the main RISC_V_Lite flow.

About

Lite implementation of a RISC V processor

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages