UTOSS/risc-v: The 5-Stage CPU That Teaches You Where the Clock Gets Mean
A clean SystemVerilog pipeline, a synchronous-memory fetch stage, and the hazard logic that keeps a real RISC-V core honest.
- UTOSS/risc-v turns pipeline timing into the main lesson, so the reader sees why synchronous memory changes the meaning of fetch, not just the shape of the datapath.
- Its fetch stage is honest about latency, using PC tracking and a skid buffer to keep instructions matched to the cycle that produced them.
- The hazard unit is not an add-on here, but the control center that makes forwarding, stalls, and flushes work as one timing system.
- The codebase reads cleanly because interfaces and structs keep the top level legible without hiding the hardware realities underneath.
Most student CPUs are too polite. They draw the five stages, wire the arrows, and quietly assume instruction memory behaves like a spreadsheet. UTOSS/risc-v does something better: it makes the clock a character in the story.
That matters because the core problem is not whether a pipeline exists. It is whether the design still works when memory answers one cycle later, a load result arrives too late for decode, or a branch decision forces the front end to forget what it just saw. This repo is interesting because it treats those delays as the real subject.
The part tutorials gloss over: timing
On paper, a 5-stage RISC-V core is familiar territory. Fetch, decode, execute, memory, write-back. In UTOSS/risc-v, that textbook shape is only the starting point, because the fetch stage has to live with synchronous instruction memory and the one-cycle lag that comes with it.
That one detail changes everything. The core needs to remember which program counter belongs to which instruction while the instruction is still in flight, and it needs a place to hold a late arrival when the pipeline stalls. The result is a design that feels less like a toy model and more like a real timing problem that has been named, isolated, and solved.
The University of Toronto Open Source Society (UTOSS) is UofT's first student club dedicated to Open Source. Our goal is to build the open source leaders of tomorrow, through student contributions today.
Why UTOSS built it this way
The repository comes out of the University of Toronto Open Source Society, and the intent is clear from the organization itself: student contributions, real hardware, serious habits. This is not framed as a curiosity project. It is a learning platform that is also trying to be a correct CPU.
That combination is what gives the repo its shape. The code is meant to be read by students, but it is also built to survive compliance tests, FPGA targets, and the discipline of hardware tooling. That is a much harder bar than "it simulates."
Focusing on the metal—CPU design, embedded systems, and digital logic.
Fetch is where the truth shows up
The most revealing code is in the fetch stage. UTOSS tracks the pipeline with separate program counter states, including pc_prev, pc_cur, and pc_next, because the instruction that arrives now was requested earlier. That sounds small. It is the difference between a clean classroom diagram and a core that can actually explain itself under latency.
The fetch logic also keeps a stalled_instr buffer. When the front end cannot advance but memory still returns an instruction, the core does not lose the data or guess at ownership. It parks the instruction, preserves the timeline, and resumes with the right PC-instruction pairing once the stall clears.
The hazard unit is the pipeline’s referee
Once fetch is honest about time, the hazard unit has to be equally honest about dependencies. It handles forwarding, load-use stalls, and control flushes so the stages can behave like a coherent machine instead of a string of independent guesses.
The key idea is simple. If the next instruction needs data that is already on its way from execute or write-back, the core should forward it. If the data is not ready yet, the pipeline should stall exactly long enough to stay correct. If control flow changes, the front end should flush the wrong-path work and move on.
if (rd_wb == rs1 && reg_write_w && rd_wb != 0) rd1_safe = data;
if (result_src_e && (rd_e == rs1_d || rd_e == rs2_d)) lw_stall = 1'b1;
if (branch_taken_e) flush_d = 1'b1;
That is the real control center of the core. A textbook pipeline is easy to sketch because every stage looks self-contained. A working pipeline needs a referee that knows when to move, when to wait, and when to erase a wrong assumption before it becomes a bug.
Why the code reads like modern software
One reason this repo is unusually legible is the way it uses SystemVerilog interfaces and structs. Instead of scattering dozens of single-purpose wires across the top level, the design bundles stage inputs and outputs into named packets. That makes the core read like architecture, not wiring residue.
The register-at-input pattern helps too. Each stage hands its result to an explicit pipeline register before the next stage consumes it, so the dataflow is visible without being noisy. For a student project, that is not just tidy. It is a strong signal that the authors cared about maintainability, synthesis, and debugging at the same time.
What it looks like next to other small RISC-V cores
UTOSS/risc-v sits in a useful middle ground. It is not trying to be the smallest core, the fastest core, or the most configurable core. It is trying to teach a classic pipeline with enough realism that the lesson survives contact with actual timing.
| Core | Style | Main strength | How UTOSS differs |
|---|---|---|---|
| PicoRV32 | Compact single-/multi-cycle controller | Very small footprint | UTOSS is more textbook and pipeline-centered. |
| SERV | Bit-serial RISC-V | Extreme area efficiency | UTOSS is easier to map to standard computer architecture courses. |
| VexRiscv | High-level HDL, FPGA-friendly | Feature-rich and mature | UTOSS is written in SystemVerilog and reads closer to the metal. |
| Hazard3 | Lean high-performance 3-stage core | Speed and polish | UTOSS teaches a classic 5-stage design with more timing transparency. |
That comparison matters because it clarifies the product shape. UTOSS is not a contest entry for minimal gates. It is a bridge between the classroom diagram and the hardware habits you need once the clock stops being generous.
Why this matters beyond the classroom
The broader lesson is bigger than one repository. A CPU design becomes valuable when it can explain itself under delay, and UTOSS/risc-v does that in a way that is readable, testable, and close enough to real silicon to matter.
That is why the compliance and tooling side is important. RISCOF integration, linting, containerized tooling, and FPGA support turn the project into more than a learning artifact. They make it a reproducible path from concept to implementation.
For students, that is the point. For everyone else, it is a reminder that the interesting part of a processor is not the block diagram. It is the discipline required to keep the diagram true when time gets mean.





