§ 5.1.3. RV32IMFiveStageCore¶
The complete RV32IM processor: the advanced five-stage pipeline of § 4.6 (forwarding, load-use handling, branch prediction, memory waits) with the M parts of § 5.1.2. It is the processor of every machine in this chapter, where its two memory ports become two masters on the bus.
| Component | Description | Structural | Behavioral |
|---|---|---|---|
RV32IMFiveStageCore |
RV32I + M, five stages, two request/response ports | Yes | Yes |
Catalog: rv32im.core.educational-five-stage; parameters prediction
and prediction_entries as for the advanced RV32I core.
prediction is not-taken (default), taken, backward-taken, one-bit
or two-bit; prediction_entries is a power of two in 1–256 (default 16).
Two more parameters come from chapter 6: multiplier is iterative
(default) or array, the M unit with the one-pass multiplier
(§ 6.1.2); overlapped_fetch=1
starts the next fetch in the cycle a fetch answer is taken
(§ 6.3.2, default 0).
These configure hardware at construction, independently of fidelity. The
core alone keeps the iterative multiplier and plain fetch by default; the
machines of § 5.3 set multiplier=array and
overlapped_fetch=1 in their descriptions (their default since
2026-11-13).
IO pins¶
| Pin | Direction | Width | Meaning |
|---|---|---|---|
CLK, RST |
Input | 1 each | Clock; active-high reset (the PC restarts at 0) |
ENABLE |
Input | 1 | Low holds the whole pipeline |
<P>REQ_VALID, <P>REQ_OP, <P>REQ_ADDR, <P>REQ_WRITE_DATA, <P>REQ_WRITE_MASK |
Output | 1, 3, 32, 32, 4 | Requests, for each prefix P = IMEM_, DMEM_ |
<P>REQ_READY |
Input | 1 | The corresponding request is taken |
<P>RSP_VALID, <P>RSP_READ_DATA, <P>RSP_STATUS |
Input | 1, 32, 3 | The corresponding answer |
<P>RSP_READY |
Output | 1 | The core can take that answer |
COMMIT_VALID |
Output | 1 | An instruction retires this cycle |
HALTED, TRAPPED, TRAP_CAUSE |
Output | 1, 1, 4 | EBREAK stopped the core; a trap stopped it, and why |
IF_ID_VALID, ID_EX_VALID, EX_MEM_VALID, MEM_WB_VALID |
Output | 1 each | Whether each packet register holds an instruction |
IF_ID_PC, ID_EX_PC, EX_MEM_PC, MEM_WB_PC, FETCH_PC |
Output | 32 each | Packet PCs and current fetch PC |
PIPELINE_STALL, PIPELINE_FLUSH, LOAD_USE_STALL, MEMORY_STALL, DATA_PORT_STALL, EXECUTION_STALL |
Output | 1 each | Why the pipeline is not moving |
BRANCH_RESOLVED, BRANCH_MISS, PREDICTION_RECOVERY, INSTRUCTION_ATTEMPT |
Output | 1 each | Prediction and retirement events |
Both ports are the transaction port of § 3.4: any memory, cache, arbiter or bus can answer them.
Behavior¶
RV32I integer instructions as in § 4.6, plus MUL, MULH, MULHSU,
MULHU, DIV, DIVU, REM, REMU with the results of the RISC-V M
specification. An M instruction stalls the pipeline for its 33 edges. A fetch
or data response with a nonzero status stops the core with an access-fault
trap. No privilege modes, interrupts, compressed, atomic or floating-point
instructions.
Reset discards pipeline and outstanding-request state, clears the register
file and restarts fetch at address 0. It does not clear an external memory.
After reset, drive ENABLE = 1 and service both ports; each endpoint must
hold an answer until its own RSP_READY handshake. The two ports can be
waiting independently.
EBREAK is the clean stop used by the program fixtures. Traps are terminal:
there is no handler entry/return, machine CSR bank, mtvec or MRET.
Writing rd = x0 still executes the instruction, but architectural x0 remains
zero. The compact-core comparison domain is known binary inputs after reset
with setup met; arbitrary X/Z clocks and controls are outside that domain.
Implementation¶
Structural implementation¶
The same five-stage assembly as the advanced RV32I core, with the RV32IM decode stage, execute stage and coordinator. Packet registers, forwarding, prediction, memory requesters, writeback and retirement observation are unchanged. The core offers the register and retirement views the recorded runs use to check every instruction.
Behavioral implementation¶
The compact core runs a compiled gate list of this core's own gates with characterized register state, and publishes on delays proven on the same circuit. It holds for known binary inputs after reset with setup met, and is observed at instruction commits. The independent instruction oracle is used only to check it.
Timing. Alone, with binary inputs changing one tick after falling edges, the structural core certifies minimum clock periods of 84 unit ticks, 3900 ps (embedded) and 2716 ps (desktop). Connected to memories, buses and devices, the whole machine is certified separately (§ 5.7).
The selected default-table paths below assume reset inactive. Setup and clock-to-output delays describe propagation around an edge; the arithmetic algorithm's 33-edge latency is separate. The table's internal period is not the assembled-machine certificate. Prediction variants have their own tables.
Latest time each path can still change after its input (for a setup row: how long before the edge the input must be stable), proven on the gate-level form.
| Path | unitticks | embeddedps | desktopps |
|---|---|---|---|
Fetch request after an edge CLK ↑ → IMEM_REQ_VALID | 10 | 457 | 317 |
Retirement after an edge CLK ↑ → COMMIT_VALID | 31 | 1,461 | 1,017 |
Fetch data setup IMEM_RSP_READ_DATA before CLK ↑ | 33 | 1,723 | 1,200 |
Enable setup ENABLE before CLK ↑ | 40 | 1,867 | 1,302 |
Examples¶
This recording isolates fetch backpressure, request retention, disable and reset. The recorded programs run complete instruction sequences, and § 5.6 runs the games.
All 7 recorded rows of RV32IMFiveStageCoreScenarioTest, in checkpoint order. Outputs are test expectations verified against the simulation. Time is the absolute settled checkpoint time in simulator units, not milliseconds or CPU cycles.
Default scenario profile: fidelity-logic-v1 / structural (3c048584c5332bb2). Changing fidelity or the circuit can change these times.
| Checkpointzero-based number · timeline label | Timesimulator units | CLKInput · 1 bit |
DMEM_REQ_READYInput · 1 bit |
DMEM_RSP_READ_DATAInput · 32 bit |
DMEM_RSP_STATUSInput · 3 bit |
DMEM_RSP_VALIDInput · 1 bit |
ENABLEInput · 1 bit |
IMEM_REQ_READYInput · 1 bit |
IMEM_RSP_READ_DATAInput · 32 bit |
IMEM_RSP_STATUSInput · 3 bit |
IMEM_RSP_VALIDInput · 1 bit |
RSTInput · 1 bit |
BRANCH_MISSExpected output · 1 bit |
BRANCH_RESOLVEDExpected output · 1 bit |
COMMIT_VALIDExpected output · 1 bit |
DATA_PORT_STALLExpected output · 1 bit |
DMEM_REQ_ADDRExpected output · 32 bit |
DMEM_REQ_OPExpected output · 3 bit |
DMEM_REQ_VALIDExpected output · 1 bit |
DMEM_REQ_WRITE_DATAExpected output · 32 bit |
DMEM_REQ_WRITE_MASKExpected output · 4 bit |
DMEM_RSP_READYExpected output · 1 bit |
EXECUTION_STALLExpected output · 1 bit |
EX_MEM_PCExpected output · 32 bit |
EX_MEM_VALIDExpected output · 1 bit |
FETCH_PCExpected output · 32 bit |
HALTEDExpected output · 1 bit |
ID_EX_PCExpected output · 32 bit |
ID_EX_VALIDExpected output · 1 bit |
IF_ID_PCExpected output · 32 bit |
IF_ID_VALIDExpected output · 1 bit |
IMEM_REQ_ADDRExpected output · 32 bit |
IMEM_REQ_OPExpected output · 3 bit |
IMEM_REQ_VALIDExpected output · 1 bit |
IMEM_REQ_WRITE_DATAExpected output · 32 bit |
IMEM_REQ_WRITE_MASKExpected output · 4 bit |
IMEM_RSP_READYExpected output · 1 bit |
INSTRUCTION_ATTEMPTExpected output · 1 bit |
LOAD_USE_STALLExpected output · 1 bit |
MEMORY_STALLExpected output · 1 bit |
MEM_WB_PCExpected output · 32 bit |
MEM_WB_VALIDExpected output · 1 bit |
PIPELINE_FLUSHExpected output · 1 bit |
PIPELINE_STALLExpected output · 1 bit |
PREDICTION_RECOVERYExpected output · 1 bit |
TRAPPEDExpected output · 1 bit |
TRAP_CAUSEExpected output · 4 bit |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
#0reset | 34 | 0 |
0 |
0x00000000 |
0x0 |
0 |
1 |
0 |
0x00000000 |
0x0 |
0 |
1 |
not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked | not checked | 0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked | not checked | 0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked |
#1ready | 57 | 0 |
0 |
0x00000000 |
0x0 |
0 |
1 |
0 |
0x00000000 |
0x0 |
0 |
0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked |
#2fetch-backpressure | 130 | 0 |
0 |
0x00000000 |
0x0 |
0 |
1 |
0 |
0x00000000 |
0x0 |
0 |
0 |
not checked | not checked | 0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked | not checked | not checked | not checked | 0x00000000 |
not checked | 1 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked |
#3request-retained | 199 | 0 |
0 |
0x00000000 |
0x0 |
0 |
1 |
0 |
0x00000000 |
0x0 |
0 |
0 |
not checked | not checked | 0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked | not checked | not checked | not checked | 0x00000000 |
not checked | 1 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked |
#4disabled | 208 | 0 |
0 |
0x00000000 |
0x0 |
0 |
0 |
0 |
0x00000000 |
0x0 |
0 |
0 |
not checked | not checked | 0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked |
#5reset-request | 222 | 0 |
0 |
0x00000000 |
0x0 |
0 |
0 |
0 |
0x00000000 |
0x0 |
0 |
1 |
not checked | not checked | 0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked |
#6restart | 231 | 0 |
0 |
0x00000000 |
0x0 |
0 |
1 |
0 |
0x00000000 |
0x0 |
0 |
0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | not checked | 0 |
not checked |
Scroll within the table for all rows and pins. Buses use hexadecimal; values containing X/Z use MSB-first binary. Inputs show the declared values in effect at each checkpoint, including retained inputs. Sequential tests also replay preparation changes between checkpoints, such as lowering the clock. Use the matching checkpoint label in the simulation below.
Source and tests¶
| Test | Coverage |
|---|---|
RV32IMFiveStageCoreTest |
Programs on the structural and compact cores, identical protocol and retirement timing; every prediction mode |
RV32IMCompiledProgramTest |
A compiled C program checked against the instruction oracle |
RV32IMTimingTest |
Certified clock periods in every timing profile |
| Programs 23–27 | Recorded programs, every commit checked |