What you practice
IF ID pipeline regs (4.2). Build the IF/ID pipeline register to latch the fetched PC and instruction, handling stalls and resets. It is in IF/ID pipeline registers — Part 4 · Pipeline of the RISC-V on SoC & System Masterclass.
The core and the mini-SoC simulate as one workspace in the IDE. Follow MMIO, interrupts, and the program on the Verilator waveform, not only a pass line.
What you will learn
Today you will build the first pipeline stage.
You will latch the fetched PC and instruction into the IF/ID register.
Learning objectives
- Understand the role of the IF/ID register in holding fetched data.
- Implement the synchronous update logic for
if_id_pcandif_id_inst. - Handle the stall signal to prevent overwriting valid pipeline data.
- Verify the pipeline behavior using the provided testbench.
Theory
The IF/ID register sits between the Instruction Fetch (IF) and Instruction Decode (ID) stages.
It captures the Program Counter (PC) and the Instruction fetched from memory on every clock cycle.
This latching allows the decode stage to work on the previous instruction while the fetch stage retrieves the next one.
A stall signal can freeze the register contents to prevent fetching new instructions when the pipeline is blocked.
| Signal | Direction | Description |
|---|---|---|
clk | Input | Clock signal for synchronous updates. |
rst_n | Input | Active-low reset to initialize pipeline registers. |
stall | Input | High signal to hold current PC and instruction. |
if_id_pc | Output | Latched PC value for the ID stage. |
if_id_inst | Output | Latched instruction for the ID stage. |
Practice
- Open RtlStudio and select this chapter from the Examples list.
- Confirm that
student/rtl/design.svandstudent/tb/tb_top.svappear in the Explore tree. - Open
student/rtl/design.svand locate thealways_ffblock. - Replace the
__TODO__placeholders with the correct signals to latchpcandimem_inst.
- Use pc for if_id_pc. - Use imem_inst for if_id_inst.
- Ensure the reset condition initializes the registers to safe values as shown in the golden reference.
- Run Simulation from the sidebar and check the Log panel for
INFO: PASS.
Summary
You implemented the IF/ID pipeline register to latch the program counter and instruction from the fetch stage.
This design handles reset initialization and respects the stall signal to prevent unwanted updates.
The exercise demonstrates how pipeline registers isolate combinational logic between pipeline stages.
© 2026 RtlStudio. Licensed under CC BY-NC-ND 4.0. Commercial use and modifications by third parties are not permitted.
Run it in the Verilog IDE
- Open the system lesson in the IDE. The RV32I core and the mini-SoC fabric simulate together.
- Run Verilator and trace the program through MMIO: address, load/store data, and the peripheral response.
- Interrupts and DMA belong on the waveform next to the instruction stream, not only in a pass/fail line.
- Edit the integration RTL, resimulate, and run Yosys on the structural block when you want a netlist.
The lesson is done when the simulation matches IF ID pipeline regs. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.