RTL Studio Open IDE

4.2 · RV SYS CLASS

IF ID pipeline regs

Build the IF/ID pipeline register to latch the fetched PC and instruction, handling stalls and resets.

Video coming soon. This lesson page stays at the same URL when the lecture publishes.

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_pc and if_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.

SignalDirectionDescription
clkInputClock signal for synchronous updates.
rst_nInputActive-low reset to initialize pipeline registers.
stallInputHigh signal to hold current PC and instruction.
if_id_pcOutputLatched PC value for the ID stage.
if_id_instOutputLatched instruction for the ID stage.

Practice

  1. Open RtlStudio and select this chapter from the Examples list.
  2. Confirm that student/rtl/design.sv and student/tb/tb_top.sv appear in the Explore tree.
  3. Open student/rtl/design.sv and locate the always_ff block.
  4. Replace the __TODO__ placeholders with the correct signals to latch pc and imem_inst.

- Use pc for if_id_pc. - Use imem_inst for if_id_inst.

  1. Ensure the reset condition initializes the registers to safe values as shown in the golden reference.
  2. 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

  1. Open the system lesson in the IDE. The RV32I core and the mini-SoC fabric simulate together.
  2. Run Verilator and trace the program through MMIO: address, load/store data, and the peripheral response.
  3. Interrupts and DMA belong on the waveform next to the instruction stream, not only in a pass/fail line.
  4. 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.