Skip to content

rv32imf_zbb (+zicsr) simulator homework for compiler class

License

Notifications You must be signed in to change notification settings

fogInSingularity/riscv-sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

riscv-sim

risc-v simulator homework for compiler class. Implementation supports rv32imf_zbb(+zicsr) arch.

Prerequisites

  • C++ compiler (with C++20 support)
  • CMake (3.21+)
  • Python (3.12+)
  • Graphviz (optional)

Build

cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build

Usage

./build/riscv-sim.x <elf_bin> <args for elf_bin...>

Notes

This project use generator to produce instruction decoder from the ISA description (src/isa/include/isa/isa_ext.inc, the MNEMONIC(name, mask, match) table). During the CMake build, the Python generator (decode/pygen/gen_decoder.py) builds a decision tree over instruction bits/slices and emits decode.cpp as nested if/switch code. You can select the decoder backend at configure time: -DDECODE_BACKEND=generated (default) or -DDECODE_BACKEND=linear. Optionally, add -DDECODE_EMIT_DOT=ON to produce .dot representation of decision tree.

Example of generated decision tree for rv32i:

generated decode tree

About

rv32imf_zbb (+zicsr) simulator homework for compiler class

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published