Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ risc-v simulator homework for compiler class. Implementation supports rv32imf_zb

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

## Build

Expand All @@ -18,3 +20,16 @@ cmake --build build
```bash
./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](images/decode_tree.svg)
Loading