What you practice
LUI and AUIPC upper immediate paths (2.3). Route the U-type immediate through the ALU for LUI and AUIPC instructions. It is in LUI & AUIPC — Part 2 · Execute Path of the RISC-V RV32I Core Masterclass.
The RV32I core is Verilog you simulate in the browser IDE. Verilator runs the program; the waveform shows PC, the instruction, and the register write.
What you will learn
You will learn how to route the U-type immediate through the ALU for LUI and AUIPC instructions. This completes the upper immediate path in the execute stage.
Learning objectives
- Connect the decoder outputs to the DUT ports.
- Route the U-type immediate to the ALU operand B.
- Verify LUI and AUIPC execution in the testbench.
Theory
LUI (Load Upper Immediate) and AUIPC (Add Upper Immediate to Program Counter) are RISC-V instructions that operate on the upper 20 bits of a 32-bit immediate. The immediate is extracted by the rv32i_imm module and placed on the imm_u port. For LUI, the ALU adds zero to the immediate. For AUIPC, the ALU adds the program counter to the immediate. The decoder asserts lui or auipc to select the correct ALU operand A.
Practice
Open this chapter in RtlStudio and navigate to the Explore tree. Open student/rtl/design.sv in the editor. Locate the u_dec instance and replace the __TODO__[0] placeholders with the correct signal names. The inst port should be connected to the inst input. The lui port should be connected to the lui output. The auipc port should be connected to the auipc output. Save the file. Open student/tb/tb_top.sv in the editor. Verify that the testbench stimulus matches the expected LUI and AUIPC operations. Run Simulation from the sidebar. Check the Log panel for INFO: PASS.
Summary
You successfully connected the decoder control signals to the ALU operand muxes to complete the upper immediate path. This practice demonstrated how LUI and AUIPC instructions route the U-type immediate through the ALU for correct result generation. The simulation verified that the immediate extraction and ALU operations function as expected for both instruction types.
© 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 RV32I lesson in the IDE. Fetch, decode, and execute are source you can simulate.
- Run Verilator and watch PC, the instruction, and the register write on the waveform.
- Treat a program printout as done only after the ISA step this lesson names matches the wave.
- Change the RTL in the editor, rerun Verilator, and read the waveform again in the same tab.
The lesson is done when the simulation matches LUI and AUIPC upper immediate paths. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.