What you practice
EX MEM WB stages (4.3). Complete the IF/ID pipeline register connections in the RV32I pipelined core to ensure correct instruction flow from fetch to decode. It is in EX/MEM/WB stages — 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
You will complete the IF/ID pipeline register connections in the RV32I pipelined core. This ensures instructions flow correctly from fetch to decode. Proper pipeline register handling is critical for correct instruction execution in a multi-stage pipeline.
Learning objectives
- Complete the IF/ID pipeline register assignments for reset, flush, and normal operation.
- Understand how
imem_rdataandstall/flushsignals control pipeline data flow. - Verify correct instruction execution using the testbench simulation.
Theory
The IF/ID pipeline register holds the Program Counter (PC) and the fetched Instruction between the IF and ID stages. It must handle three conditions: reset, flush, and normal capture. On reset, the register initializes to a known state (PC=0, Instruction=NOP). On a flush, it also loads a NOP to prevent execution of mispredicted or invalid instructions. During normal operation, it captures the current PC and the instruction from memory (imem_rdata), unless a stall is active. If a stall is active, the register holds its previous value. The stop_fetch signal is used to insert a NOP when the fetch is stopped but not stalled, ensuring the pipeline doesn't execute garbage data.
| Condition | id_pc | id_inst | Explanation |
|---|---|---|---|
Reset (!rst_n) | 32'h0 | NOP_INST | Initialize to zero and NOP. |
Flush (flush) | 32'h0 | NOP_INST | Clear pipeline, insert NOP. |
Normal (!stall) | pc | imem_rdata | Capture new PC and Instruction. |
Stalled (stall) | (Hold) | (Hold) | Keep previous values. |
Practice
- Open
student/rtl/ip/riscv/rv32i_core_pipelined.svin the Explore panel. - Open
student/tb/tb_top.svto understand the testbench stimulus. - Locate the IF/ID pipeline register
always_ffblock in the core. - Replace
__TODO__placeholders with the correct signals to complete the stage register connections. - Ensure the reset and flush conditions load
32'h0andNOP_INST. - Ensure the normal condition loads
pcandimem_rdata(respectingstop_fetch). - Run Simulation and check the Log panel for
INFO: PASS.
Summary
You successfully connected the IF/ID pipeline register to complete the instruction fetch and decode flow. By implementing correct data propagation and control signal handling, you enabled the processor to execute an unrolled sum with forwarding. This exercise demonstrated how pipeline registers maintain state between stages to support parallel instruction execution. Verifying the simulation with a passing log confirmed that your hazard resolution and forwarding logic function correctly.
© 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 EX MEM WB stages. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.