riscy is a terminal UI debugger for small RISC-V programs, focused on studying and debugging the processors built in a computer architecture course.
It can load assembly or hex programs, execute them instruction by instruction on a Python reference model, and show the architectural state (PC, registers, memory, decoded fields) in a compact terminal UI with breakpoints and step controls.
- Loads
.sand.asmfiles and assembles them throughtools/riscv_asm_to_hex.py - Loads
.txtand.hexfiles containing 32-bit instruction words - Loads
.binraw binaries (e.g. exported from CPUlator) at address0x0 - Executes programs on a Python single-cycle reference model
- Displays:
- current
PC - current instruction
- decoded instruction fields
- register file contents
- memory contents
- effects of the last executed instruction
- current
- Supports step-by-step execution and short runs
- Uses only Python standard library modules
The course workflow often requires writing a small assembly test, converting it to hex, running the processor, and then manually checking registers and memory. This debugger shortens that loop by providing a lightweight way to inspect the architectural state directly.
The current focus is architectural visibility:
- instructions
PC- registers
- memory
- decoded instruction fields
It is not yet a Verilog waveform replacement or a direct HDL simulator frontend.
The current backend models single-cycle architectural behavior in Python. It is designed as the first execution model in a larger roadmap that can later include:
- a multicycle Python backend
- a pipelined Python backend
- a project-connected backend that integrates more directly with the HDL flow
The single-cycle backend implements the RV32I base integer set, over a byte-addressable little-endian memory:
- Loads:
lblhlwlbulhu - Stores:
sbshsw - ALU (imm):
addisltisltiuxorioriandisllisrlisrai - ALU (reg):
addsubsllsltsltuxorsrlsraorand - Upper:
luiauipc - Branches:
beqbnebltbgebltubgeu - Jumps:
jaljalr nop
The stack pointer (sp) is initialised on reset so programs that use a stack
(recursive code, etc.) run without extra setup.
- Python 3.10 or newer
- A terminal with
cursessupport
No third-party Python packages are required.
No installation step is required beyond having Python available.
git clone git@github.com:stiffis/riscy.git
cd riscyRun the debugger from inside the repository:
python3 app.py tools/riscv_asm_to_hex_example.spython3 app.py path/to/program.txtThe module form also works when running from the parent directory:
python3 -m riscy.app riscy/tools/riscv_asm_to_hex_example.ss: execute one instructionn: execute 10 instructionsc: continue (run until the next breakpoint or until the CPU halts)g: run to end (run until the CPU halts, with a safety step limit)t: run to the cursor line (run until thePCreaches the selected line)b: toggle a breakpoint at the cursor line in the Program panelr: reset CPU and memoryCtrl+h/j/k/l: move window focus (Program / Memory / Registers)j/k: scroll the focused window (Program cursor, Memory, or Registers)p: recenter the focused window on the currentPCm: select the execution backend?: toggle the keybindings help overlayq: quit
The focused window is highlighted with a cyan border. Breakpoints are shown with
a ● marker in the Program panel, and the selected line is highlighted. continue,
run to end, and run to cursor all stop on a safety step limit so an infinite
loop cannot hang the UI.
m opens a popup to switch the execution backend:
-
single-cycle: the Python reference model (
s= one instruction). -
pipeline (verilog): the actual
week13RISC-V pipeline driven through Verilator (s= one clock cycle). When active, a Pipeline panel below Memory shows the five datapath stages (IF / ID / EX / MEM / WB) with the instruction flowing through each one. This backend is only available once the shared library is built:make -C hdl
See
hdl/HDL_NOTES.mdfor how the Verilog model is vendored (verbatim, never modified) and driven.
The UI currently shows four main areas:
- Program: nearby instructions, current instruction highlight, decoded fields, and last-step summary
- Registers: all 32 integer registers in a vertical view
- Memory: a word-oriented memory window
- Status/Header: current
PC, step count, and CPU state
riscy/
├── __init__.py
├── app.py # curses TUI
├── asm_loader.py # loads .s/.asm/.txt/.hex inputs
├── reference_cpu.py # instruction semantics and core helpers
├── single_cycle_cpu.py # single-cycle backend wrapper
├── assets/
│ └── screenshot.png
├── tests/
│ └── test_reference_cpu.py
├── tools/
│ ├── riscv_asm_to_hex.py # assembler used by the TUI
│ └── riscv_asm_to_hex_example.s # example program
└── README.md
python3 -m unittest discover -s tests- The UI is implemented with
cursesto avoid external dependencies. - The current backend is intentionally a Python architectural model instead of a direct Verilog interface.
- This keeps the debugger fast to start, easy to run on any lab machine, and useful for studying even before HDL integration.
- This is not yet connected directly to the
week12/week13Verilog processors. - It does not show internal HDL signals, waveform data, or pipeline hazard behavior.
- The assembler intentionally supports a restricted course-oriented subset rather than a full GNU assembler feature set.
- It does not currently model data sections such as
.word,.data, or.text.
Planned or likely next steps:
- add a multicycle Python backend
- add a pipelined Python backend
- add a project backend tied more directly to the HDL workflow
- improve program navigation and memory views
- expand assembler conveniences only when they match the course workflow
This tool is currently course-project oriented, so changes should prioritize:
- compatibility with the current RISC-V subset used in the repo
- low setup cost
- clarity for debugging and studying architecture concepts
- small, understandable changes over large framework-heavy rewrites
riscy is free software, licensed under the GNU General Public License v3.0.
See the LICENSE file for the full text.
