What you practice
External interrupt request port (4.5). Qualify the external irq_i port with the mstatus MIE enable bit to control interrupt servicing. It is in External IRQ input port — Part 4 · CSR, Trap & IRQ Interface 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 qualify the external interrupt request signal with the machine status interrupt enable bit. This ensures that interrupts are only serviced when the CPU is explicitly enabled to handle them.
Learning objectives
- Understand the role of the MIE bit in
mstatusfor interrupt gating. - Implement the logic to combine
irq_iwith the MIE enable bit. - Verify that interrupts are masked when MIE is cleared.
- Verify that interrupts are passed when MIE is set.
Theory
The RISC-V privileged specification requires that external interrupts be masked by the MIE bit in the mstatus CSR. The mstatus register controls the global interrupt enable state for machine mode. The hardware must logically AND the external interrupt request irq_i with the MIE bit (bit 3 of mstatus). This prevents the processor from entering a trap handler while interrupts are globally disabled. The trap_req signal is the output of this qualification logic.
Practice
Open the student/rtl/ip/riscv/rv32i_csr.sv file in RtlStudio. Locate the always_comb block that assigns csr_rdata. Replace the __TODO__ placeholders with the correct register names (mstatus, mtvec, mepc) for the read data. Locate the assign statement for trap_req. Replace the __TODO__ with the correct logic to AND irq_i with mstatus[3]. Open student/tb/tb_top.sv in RtlStudio. Run the simulation from the sidebar. Check the Log panel for the INFO lines. Ensure the testbench reports PASS.
Summary
In this lesson, you implemented the logic to qualify the external interrupt request signal using the MIE bit from the mstatus register. This ensures that trap requests are only generated when global machine interrupts are enabled. The simulation results confirm that the interrupt masking behavior functions correctly as intended.
© 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 External interrupt request port. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.