Decode¶
Overview¶
Status: RTL complete, interim documentation
The instruction decoder, how fetched instructions become decoded packets for rename, and its RVA23 coverage.
Related: Blog: What RVA23 Actually Asks of a Decoder; IA tasks: DECODE-002, DECODE-010, DECODE-011
Working specification
This page shows the planning documents and specifications for RTL tag fe-1.0.0.
dcd_decisions.md
planning/arch/dcd_decisions.md on GitHub
Decode Implementation Decisions¶
FILE: dcd_decisions.md
SOURCE: session-069
STATUS: DRAFT
UPDATED: 2026-10-09
CONTACT: Jeff Nye
Owns the DCD-N, TD-DCD-N and DCD-UN registries.
1. Scope and reference¶
The RISC-V unprivileged specification is the reference for every instruction encoding, immediate format and register field named here. This document does not restate them. It contains only what the specification does not decide.
instr_decoder.sv's instruction ENCODINGS are not in scope: they
are the specification's. What the specification does not decide IS
in scope: the boundary of section 10a, and since session-077 the
representation decode hands rename, and which encodings decode
treats as illegal, section 10b. This read "instr_decoder.sv is not
in scope for its instruction decode. It is Complete", which left
the representation undecided; BP-123 found the decoder rejecting
mandatory instructions and mapping others onto placeholders.
The RVC expander is not in scope either. Its encodings are the
compressed-instruction chapter of the specification, and the
project's decisions about it are placement and ordering, which
belong with the stage that holds it: ifu_decisions.md IFU-1 puts
it in the IFU ahead of the ibuf, and IFU-4 runs it before
predecode.
The predecoder replaces predecode.sv. Its bundle view is a NEW
struct, ifu_pd_pkt_t, not a redefinition of predecode_pkt_t
(Jeff, session-074). The old struct stays for the built decode
until decode moves to the new one, TD#143. Neither the existing
module nor the existing struct constrains anything below.
2. One predecoder, two views¶
DCD-1 There is one predecoder. It produces two views of one
classification.
The block view is `ftq_pd_info_t` at each of the 16
halfword positions of the prediction block. It goes to the FTQ
writeback and its shape is fixed by `ftq_ifu.sv`.
The bundle view is `ifu_pd_pkt_t`, one per instruction
slot. It goes through the ibuf to `instr_decoder`.
The two differ in width because their consumers do. The FTQ needs
an answer at every position in the block, including positions that
are not instruction starts. Decode needs SLOTS of 8. The
classification is computed once.
THE ARRAY WIDTH BELONGS TO THE PORT, NOT TO THE TYPE.
ifu_pd_pkt_t is a per-slot struct and both ibuf ports carry an
array of it: 16 wide on the write port, because the IFU does not
compact (ifu_ibuf_interfaces.md IB-1, IFU-5, IBUF-3), and 8 wide on
the read port into decode, where instr_decoder is [SLOTS-1:0]
(IBUF-9). The ibuf is the width converter. This read "at each of
the 8 decode slots", which attaches decode's width to the type and
puts it against the four documents that carry 16 on the write port.
Session-072.
DCD-2 Position 16, the 17th halfword of IFU-8, has no entry in
either view. It can only be the tail of a straddling
instruction, never a start.
3. Inputs¶
DCD-3 The predecoder takes both the raw halfwords and the
expanded buffer.
IFU-4 expands before predecode, and expansion runs at every halfword position independently, so a position that is not an instruction start still produces an expanded value. That value is meaningless. The raw halfwords are what determine which positions are starts, so both are needed.
4. Instruction starts¶
DCD-4 A position is an instruction start if it is reached by the
walk from the block start PC. At each start, the low two
bits of that position's halfword give the length: not
`2'b11` is a 16-bit instruction and the next start is one
position later, `2'b11` is a 32-bit instruction and the
next start is two positions later.
DCD-5 The walk begins at the block start PC supplied by the FTQ,
which is position 0: positions count from the block start
(ftq_ifu_interfaces.md 3) and the block is unaligned, IFU-6.
When the block starts on the tail of a 32-bit instruction
that began at position 15 of the previous block, the walk
begins at position 1 (IFU-11).
Session-074. This read "not at position 0", from before
positions were counted from the block start, and did not
cover a block that starts on a tail.
DCD-6 The start mask is a parallel prefix over the per-position
lengths, not a sequential walk. Each position independently
yields the length of an instruction starting there, and the
mask is a scan over those lengths.
DCD-6 is stated because the obvious implementation is a loop and the obvious loop does not close timing over 16 positions.
5. Control flow classification¶
DCD-7 Per position the predecoder emits a 2-bit type: `2'b00`
not a control flow instruction, `2'b01` conditional
branch, `2'b10` JAL, `2'b11` JALR. Plus `is_call` and
`is_ret`.
The classification runs on the expanded encodings, so only the base-ISA opcodes are recognised. The compressed forms have already become their 32-bit equivalents and are not separately decoded. That is the reason for IFU-4.
DCD-8 The classification is exact, not a hint. It distinguishes
the three control flow classes and resolves call and
return. There is no conservative case and nothing is
deferred to decode.
6. Targets¶
DCD-9 The predecoder computes a target for conditional branches
and for JAL, as the position's PC plus the sign-extended
immediate of the relevant format.
DCD-10 No target is computed for JALR. The target depends on a
register value the front end does not have. The target
field carries no meaning for a JALR position and the FTQ
does not read it, IFU-17.
7. Call and return¶
The specification's return-address-stack hints are the reference
for which JAL and JALR forms push, pop, or both. x1 and x5 are
the link registers and the behaviour is a function of rd and
rs1.
DCD-11 `is_call` and `is_ret` are independent bits, not a single
encoded class. The specification has one case that both
pops and pushes, a JALR whose `rd` and `rs1` are both link
registers and are not equal. Both bits are set for it.
DCD-11a Downstream, that pair maps to `bp_br_type_e.RETURN_CALL`,
added session-069 (`ras_decisions.md` 2). The predecoder
emits the two bits; the enum is formed from them where a
single classification is required, as on
`ras_br_type_p2`.
TD-DCD-2 CLOSED by BP-119. It asked whether the RAS, built
before DCD-11, accepts both bits set on one instruction
and in which order. It did not: ras.sv treated 3'b111 as
a no-op at p2, in the p3 repair and at commit, and
nothing upstream presented 3'b111 anyway (the cluster
and the uBTB presented RETURN, so the stack was one
short after each switch). BP-119 built RAS-DS1: pop,
then push, at p2, p3 and commit.
8. Validity and range¶
DCD-12 A position's `valid` is set when it is an instruction
start under DCD-4 and it lies within the fetched range.
DCD-13 `pd_range` marks the positions actually fetched. The
range ends at the predicted taken position when the FTQ
supplied one, and at the block end otherwise, and is cut
short at a fault (ftq_ifu_interfaces.md 6). The block end
is `ftq_ifu_next_pc`, the fall-through: the not-taken range
is the positions whose address is below it, all sixteen
when it is not within 32 bytes above the start. Session-074,
as BP-116 built it.
DCD-14 The predecoder does not test the prediction. It reports
what it found. The comparison against the prediction, and
`cfi_val`, `cfi_pos`, `mis_val`, `mis_pos`, are the IFU's,
IFU-15.
9. Faults¶
DCD-15 A faulting position is reported with `fault_val` and
`fault_pos` in the block view, and with the cause, the
faulting virtual address, and on a guest page fault the
faulting guest physical address and its implicit-access
kind, in the bundle view. The kind was added session-077
(mmu_decisions.md MMU-29).
The cause field carries three causes, not two, plus none:
instruction access fault, instruction page fault and instruction
guest-page fault. H is mandatory in RVA23 through Sha.
mmu_decisions.md MMU-16.
The two carry different things on purpose. The FTQ needs only to know the block ended early. The architectural exception travels with the instruction to the backend. This is IFU-2 and the note under IFU-20.
10. The bundle view¶
DCD-16 `ifu_pd_pkt_t` carries, per slot: valid, the expanded
32-bit instruction, the start PC, the position within the
prediction block, the FTQ index, the fault cause, the faulting
virtual address, the faulting guest physical address, the
implicit-access kind of that guest physical address,
`is_rvc`, and the control flow classification of DCD-7.
`is_vsetvl` and `needs_vtype` are REMOVED from it (TD#148):
decode computes its own (DCD-17) and nothing read the IFU's.
RULED session-077 (Jeff), after BP-124; REMOVED by BP-125,
ifu_pd_pkt_t 192 -> 190 bits (T78 checks the width). The two
paragraphs below record why they were carried.
THE FAULTING GPA IS FAULT_GPA_WIDTH = 56 BITS, the widest
guest physical address a walk can form (a 44-bit VS-stage
PPN plus the page offset), so every faulting GPA is carried
whole and none is replaced by a sentinel
(mmu_decisions.md MMU-23, MMU-30 withdrawn). Ruled
session-077 (Jeff); a package change, built by BP-124. For
kind 00 the IFU fills the page offset from the faulting
halfword's virtual address (ifu_decisions.md IFU-2a).
THE IMPLICIT-ACCESS KIND is two bits, valid on a guest page
fault: 2'b00 the fetch's own guest physical address, 2'b01
an implicit read of a VS-stage page table, 2'b10 an
implicit write of one, 2'b11 reserved
(itlb_ifu_interfaces.md IT-6c). The backend needs it to
write htinst (mmu_decisions.md MMU-29). Added session-077
(Jeff); a package change, BUILT by BP-123 as
`logic [1:0] fault_gpa_imp`.
`is_vsetvl` and `needs_vtype` are per-instruction and belong
here by TD-DCD-1; the enumeration did not carry them while
ifu_ibuf_interfaces.md 4 listed them as coming from this
rule. `vtype_hazard` is NOT here, TD-DCD-1. Session-072.
`needs_vtype` is set for every OP-V instruction other than
the vsetvl configuration forms, and for every vector load
and store. It over-marks the whole-register forms, which is
safe for rename. Session-074, as BP-116 built it; recheck
against decode when decode moves to ifu_pd_pkt_t, TD#143.
DCD-16a A SLOT THAT FAULTED AT FETCH carries only `valid`, the
start PC, the FTQ index, the position and the fault fields
(cause, faulting VA, faulting GPA and its kind). Every
other field on it -- the instruction, `is_rvc`, the DCD-7
classification (and, until BP-125, `is_vsetvl` and
`needs_vtype`) -- is
meaningless, and neither decode nor the backend may read
it. The faulting instruction never executes, so nothing
needs its length or class: the trap is taken from the
fault fields. Ruled session-075 (Jeff); the IFU drives
`is_rvc` from the faulting halfword today, which this makes
harmless rather than wrong. Found by BP-118.
The start PC and the position are both present and are not redundant. Expansion breaks the correspondence between them, because a compressed instruction advances the PC by two and fills a whole slot.
is_rvc is present because expansion also erases the length. The
backend needs it for the link address of a compressed JAL or JALR
(rd = pc + 2) and for the fall-through PC of a not-taken
mispredict. Added session-074 (Jeff).
TD-DCD-1 The vtype fields of the old `predecode_pkt_t` are
`is_vsetvl`, `needs_vtype` and `vtype_hazard`. The
first two are per-instruction and belong here. The
third does not. `vtype_hazard` is defined as a vsetvl
preceding a `needs_vtype` in the same bundle, and the
bundle the predecoder sees is a prediction block while
the bundle decode sees is 8 slots from the ibuf head.
The ibuf regroups: one prediction block can split across
two decode bundles and one decode bundle can draw from
two prediction blocks. An intra-bundle property computed before
the ibuf is wrong after it. `vtype_hazard` is computed
in decode, DCD-17.
10a. Decode on the bundle view -- TD#143¶
RULED session-075 (Jeff). BUILT by BP-118. What decode does once it
takes ifu_pd_pkt_t from the ibuf read port (IBUF-9) instead of
predecode_pkt_t. Section 1 keeps the instruction ENCODINGS out of
scope, since they are the specification's; these four rules are its
boundary, which the specification does not decide. This read that
section 1 keeps the instruction decode out of scope, true until
section 10b (session-077).
DCD-17 `vtype_hazard` IS COMPUTED IN DECODE. For each of the 8
decode slots it is set when an earlier valid slot in the
same decode bundle is a vsetvl form and this slot needs
vtype. Decode computes it from its OWN classification of
the instruction, not from the `is_vsetvl` and `needs_vtype`
bits in `ifu_pd_pkt_t`: decode's is exact, and the IFU's
`needs_vtype` over-marks the whole-register forms (DCD-16).
Closes DCD-U1.
The ibuf stays a buffer with no knowledge of instruction
meaning, and the decode bundle is exactly the group the
flag describes.
DCD-18 DECODE PASSES `ifu_pd_pkt_t` THROUGH to rename unchanged,
beside its own decode packet, plus `vtype_hazard` per slot.
The PC, FTQ index, position, fault fields and `is_rvc`
reach the backend this way (ftq_backend_interfaces.md A1).
`predecode_out` and `predecode_pkt_t` are retired.
DCD-19 A SLOT CARRYING A FETCH FAULT IS NOT DECODED AS ILLEGAL.
Its instruction bits are meaningless, and an instruction
fetch fault takes priority over an illegal instruction
exception. Decode passes the fault through and raises no
illegal on that slot.
DCD-20 C AND Zcb ARE ALWAYS ENABLED. After expansion in the IFU
decode cannot tell which compressed extension an
instruction came from: `is_rvc` survives, the Zcb
distinction does not. RVA23 mandates both, so `misa.C` is
read-only 1, and decode's per-extension gating of
compressed encodings is deleted.
TD#148 `is_vsetvl` and `needs_vtype` in `ifu_pd_pkt_t` have no
reader once DCD-17 is built. Left in place so BP-118 needs
no change to `bp_structs_pkg`. Removal ruled session-077
(Jeff). CLOSED by BP-125: removed from the struct,
ifu_predecode, ifu_f3 and every reader.
TD#155 `en_c`, `en_zcb` and `MASK_BITS` in instr_decoder lose
their readers with the gating DCD-20 deletes. They are
declared in decode_pkg.sv (`ext_enable_t`), so removing
them is a package change; it narrows fe_top's ext_enable
input and removes tb_instr_decoder's en_c=0 and en_zcb=0
cases. CLOSED BY BP-120: removed; ext_enable_t and
fe_top's ext_enable are 16 bits; tb_instr_decoder 654 ->
649 checks.
As built by BP-118, a faulting slot's decode packet is valid and
the instruction bits only, no illegal and no vector decode, and it
neither raises nor seeds vtype_hazard. DCD-16a makes the
instruction bits meaningless too; decode reads none of them.
10b. Decode representation and legality -- session-077¶
RULED session-077 (Jeff), from the PA's R1 to R14, after BP-123. The decoder mapped FP, AMO and CSR instructions onto placeholder operations before BP-123, and BP-123 (D4) mapped the SYSTEM fences, HLV/HLVX/HSV, WRS and FLH/FSH onto the representation already used for their class, so a backend could not tell those operations apart. Reading the decoder in session-077 also found reserved encodings in those spaces accepted, which RVA23 recommends raising illegal. BUILT by BP-124 (session-077): alu_op_t 8 bits, values 107 to 185 as DCD-22 lists them, the seven decode_pkt_t fields after is_illegal, Zvbb at 189 to 198; tb_instr_decoder 1323 checks; sim_dec_sweep 458752 encodings.
PA ADDITIONS, drafted session-077 and built by BP-124 as written: DCD-24's vector paragraph and its is_fp, is_load and is_store rule; DCD-25's zero-extended CSR address, the vtype immediates and the vsetivli AVL; DCD-33; the vector part of DCD-34; DCD-35; the operation names and order of DCD-22. Jeff accepted BP-124's decisions D1 to D9 (session-077), recorded in DCD-24, DCD-25, DCD-32 and DCD-36.
The specification references, checked session-077: a reserved encoding's behaviour is UNSPECIFIED and raising illegal-instruction is valid behaviour (unprivileged, RV32I; F chapter); RVA23 strongly recommends illegal-instruction for unimplemented opcodes (rva23-profile.adoc, RVA23U64 and RVA23S64 Recommendations); a reserved FENCE configuration SHALL be treated as FENCE (RV32I), and the unused fields of FENCE.I shall be ignored (Zifencei); Zfhmin is FLH, FSH, FMV.X.H, FMV.H.X, FCVT.S.H, FCVT.H.S, and with D FCVT.D.H and FCVT.H.D (zfhmin.adoc); Zfa's .H forms need Zfh, FMVH.X.D and FMVP.D.X are RV32 only, and Zfa depends on F (zfa.adoc).
DCD-21 THE PRINCIPLE (R1). `alu_op` and the decoded fields of
`decode_pkt_t` fully identify every scalar operation, its
operands' register files and its legality. No downstream
unit re-decodes the instruction word for any of these.
`instr` stays in the packet for traps (stval) and debug, not
as a decode source. For a vector instruction `v_op_class`
identifies the operation and `alu_op` is ALU_VEC.
DCD-22 `alu_op_t` IS 8 BITS (R2). Values 0 to 106 keep their values;
ALU_ILL stays 63. Three are RENAMED to their exact meaning,
values unchanged: ALU_FLD (56) -> ALU_FLOAD, ALU_FSD (57) ->
ALU_FSTORE, ALU_CSR (49) -> ALU_CSRRW. ALU_FMADD (58) keeps
its name and now means FMADD only. The new operations are
appended from 107 in this order:
ALU_VEC
FP ALU_FMSUB ALU_FNMSUB ALU_FNMADD
ALU_FADD ALU_FSUB ALU_FMUL ALU_FDIV ALU_FSQRT
ALU_FSGNJ ALU_FSGNJN ALU_FSGNJX ALU_FMIN ALU_FMAX
ALU_FCVT_W ALU_FCVT_WU ALU_FCVT_L ALU_FCVT_LU
ALU_FCVT_FW ALU_FCVT_FWU ALU_FCVT_FL ALU_FCVT_FLU
ALU_FCVT_FF ALU_FMV_XF ALU_FMV_FX
ALU_FEQ ALU_FLT ALU_FLE ALU_FCLASS
Zfa ALU_FLI ALU_FMINM ALU_FMAXM ALU_FROUND ALU_FROUNDNX
ALU_FCVTMOD_W_D ALU_FLEQ ALU_FLTQ
A ALU_LR_W ALU_LR_D ALU_SC_W ALU_SC_D
ALU_AMOSWAP_W ALU_AMOSWAP_D ALU_AMOADD_W ALU_AMOADD_D
ALU_AMOXOR_W ALU_AMOXOR_D ALU_AMOAND_W ALU_AMOAND_D
ALU_AMOOR_W ALU_AMOOR_D ALU_AMOMIN_W ALU_AMOMIN_D
ALU_AMOMAX_W ALU_AMOMAX_D ALU_AMOMINU_W ALU_AMOMINU_D
ALU_AMOMAXU_W ALU_AMOMAXU_D
fences ALU_FENCE_I ALU_CBO_INVAL ALU_CBO_CLEAN ALU_CBO_FLUSH
ALU_CBO_ZERO ALU_SFENCE_VMA ALU_SINVAL_VMA
ALU_SFENCE_W_INVAL ALU_SFENCE_INVAL_IR ALU_HFENCE_VVMA
ALU_HFENCE_GVMA ALU_HINVAL_VVMA ALU_HINVAL_GVMA
Zawrs ALU_WRS_NTO ALU_WRS_STO
Zicsr ALU_CSRRS ALU_CSRRC ALU_CSRRWI ALU_CSRRSI ALU_CSRRCI
79 operations, 107 to 185. ALU_FENCE (55) is FENCE, with
FENCE.TSO and PAUSE, which are FENCE configurations.
DCD-23 FP PRECISION IS A FIELD (R3). `decode_pkt_t` gains
`fp_fmt [1:0]` and `fp_src_fmt [1:0]`, encoded 2'b00 S,
2'b01 D, 2'b10 H, 2'b11 unused. `fp_fmt` is the instruction's
fmt field (bits 26:25) for OP-FP and the four FMA opcodes, so
for a conversion to or from an integer, a move, a compare or
a classify it is the precision of the FP operand, and for
ALU_FCVT_FF the destination; for an FP load or store it is
the width of the memory datum. `fp_src_fmt` is the source
precision of ALU_FCVT_FF only, from instruction bits 21:20
(rs2[1:0]). Both
are zero for a non-FP operation. The rounding mode stays in
`funct3`. This read "for a conversion, of the destination",
which left FCVT.W.S and FCVT.W.D indistinguishable.
DCD-24 OPERAND REGISTER FILES (R4). `decode_pkt_t` gains `rd_is_fp`,
`rs1_is_fp` and `rs2_is_fp`; rs3 is always an FP register.
`uses_rd`, `uses_rs1`, `uses_rs2` and `uses_rs3` are exact
per operation: a unary FP operation (FSQRT, FCVT_*, FMV_*,
FCLASS, FROUND, FROUNDNX, FCVTMOD_W_D) does not use rs2, and
FLI uses no source register; rs3 is zero for every operation
but the four FMAs. `is_fp` means the operation executes in
the FP unit, so an FP load or store has `is_fp` clear and
names its FP register with `rd_is_fp` or `rs2_is_fp`
(BP-124 D2). LR sets `is_load` only, SC `is_store` only, an
AMO both, a CBO neither (D3). `is_csr` is set for the six
CSR operations and for ECALL, EBREAK, SRET, MRET and WFI,
and clear for the fences, WRS, HLV/HSV and MOP (D6).
Accepted session-077 (Jeff).
FOR A VECTOR INSTRUCTION these fields describe its SCALAR
register operands only; its vector register operands are in
`vec_decode_pkt_t`. OPIVX and OPMVX read GPR rs1; OPFVF reads
FPR rs1; vmv.x.s, vcpop.m, vfirst.m and the vsetvl forms
write GPR rd; vfmv.f.s writes FPR rd; vsetvl reads GPR rs1
and rs2, vsetvli GPR rs1, vsetivli neither; a vector load or
store reads GPR rs1, and GPR rs2 when strided. Every other
vector instruction uses no scalar register. For every vector
instruction `is_fp` is clear (it executes in the vector
unit), `is_load` is set for a vector load and `is_store` for
a vector store, and `is_branch`, `is_jump` and `is_csr` are
clear. Added session-077 by the PA as R4's consequence for
vector instructions, whose scalar packet set uses_rd,
uses_rs1 and uses_rs2 for every instruction; flagged for
Jeff.
DCD-25 IMMEDIATES THAT SIT IN A REGISTER FIELD go in `imm`, because
decode zeroes an unused register field: the CSRRxI zimm in
`imm[16:12]` beside the CSR address in `imm[11:0]`, for all
six CSR operations the address ZERO-extended and `imm[31:17]`
zero, `imm[16:12]` zero for the register forms (the decoder
sign-extended the address as an I-type immediate); the FLI
constant index in `imm[4:0]`; an OPIVI 5-bit immediate in
`imm`, sign- or zero-extended as the specification defines
for that instruction, and vror.vi's 6-bit immediate, whose
bit 5 is instruction bit 26, in `imm[5:0]` zero-extended;
vmv<nr>r.v's register-count field zero-extended (BP-124 D9,
accepted); the
vtype immediate of vsetvli (zimm[10:0]) and vsetivli
(zimm[9:0]) in `imm[10:0]` zero-extended, reserved bits
included, so vill can be formed downstream; and vsetivli's
AVL, uimm[4:0], in `imm[20:16]`. The decoder zeroes rs1 for
CSRRWI, CSRRSI and CSRRCI, losing the zimm, and would lose
vsetivli's AVL once DCD-24 clears its uses_rs1; found
session-077, PA additions.
DCD-26 FP LEGALITY (R5). Legal, each gated by its enable: F (en_f),
D (en_d), Zfhmin as quoted above (en_zfhmin; the D-dependent
pair also en_d), Zfa's .S and .D forms and FCVTMOD.W.D
(en_zfa; the .D forms also en_d). Illegal: every other .H
operation (Zfh is not implemented), Zfa's .H forms,
FMVH.X.D and FMVP.D.X (RV32 only), every Q form, and
FCVTMOD.W.D with an rm other than 001 (RTZ), which zfa.adoc
reserves.
DCD-27 STATIC ROUNDING MODE 101 OR 110 IS ILLEGAL (R6), in every
instruction whose encoding has an rm field. Dynamic rm with
an invalid frm is raised at execute, not here.
DCD-28 AMO LEGALITY (R7). Legal: funct3 010 (W) and 011 (D), with
funct5 LR 00010 (rs2 must be x0), SC 00011, AMOSWAP 00001,
AMOADD 00000, AMOXOR 00100, AMOAND 01100, AMOOR 01000,
AMOMIN 10000, AMOMAX 10100, AMOMINU 11000, AMOMAXU 11100.
Every other width (Zabha) and funct5 (AMOCAS, Zacas) is
illegal. aq and rl travel in `funct7`.
DCD-29 FENCES AND CBO (R8). MISC_MEM funct3 000 is ALU_FENCE for
every fm, pred, succ, rs1 and rd: the specification requires
reserved configurations to be treated as FENCE. fm, pred and
succ travel in imm[11:0] zero-extended, a reserved
configuration's raw fields included; the backend executes
a reserved configuration as FENCE with fm 0000 (RV32I).
BP-124 D4, accepted session-077 (Jeff). funct3 001
is ALU_FENCE_I, its imm, rs1 and rd ignored as Zifencei
requires. funct3 010 is the CBO operation of imm (0, 1, 2,
4), any other imm illegal, and rd not x0 illegal (DCD-31).
funct3 011 to 111 is illegal. The SYSTEM fence forms are the
ALU_SFENCE/SINVAL/HFENCE/HINVAL operations of DCD-22.
DCD-30 WRS, HLV, CSR (R9, R10, R11). WRS.NTO and WRS.STO are their
own operations. HLV, HLVX and HSV keep the width-exact load
and store operations, with `is_load` or `is_store`, and set
new packet bits `is_hlsv` (a virtual-machine access) and,
for HLVX, `is_hlvx` (read with execute permission). The six
CSR instructions are six operations.
DCD-31 SYSTEM RESERVED FIELDS ARE ILLEGAL (R12). rd not x0 in
ECALL, EBREAK, MRET, SRET, WFI, WRS, the SFENCE, SINVAL,
HFENCE and HINVAL forms and CBO; rs1 not x0 in ECALL,
EBREAK, MRET, SRET, WFI, WRS, SFENCE.W.INVAL and
SFENCE.INVAL.IR.
DCD-32 VECTOR RESERVED ENCODINGS ARE ILLEGAL (R13): every encoding
that decodes to VOTHER or to the VMEM default, and any store,
segment or not, with sumop 10000 (built by BP-124).
EVERY OTHER RESERVED VECTOR ENCODING IS ILLEGAL TOO. RULED
session-077 (Jeff), after BP-124, which found 24742 in its
sweep (rule VRSV) and reported them as this rule then said.
The classes, from the V 1.0 text BP-124 cites:
- mew = 1 (EEW 128 and above), every load and store form
- a unit-stride segment load or store whose lumop/sumop is
neither 00000 nor 10000
- a whole-register load or store with vm 0, NFIELDS other
than 1, 2, 4 or 8, mew 1, or (store) width not 000
- vlm.v or vsm.v with vm 0, width not 000, or mew 1
- vsetvl with bits 29:25 not zero (bit 31 set and bit 30
clear is vsetvl; bit 30 set is vsetivli)
- vadc and vsbc with vm 1
- vmv.v.v/x/i and vfmv.v.f with vs2 not v0
- vmv.s.x and vfmv.s.f with vs2 not v0 or vm 0
- vfmv.f.s with vs1 not 0 or vm 0; vmv.x.s with vm 0
- vmv<nr>r.v with vm 0 or a register count other than 1, 2,
4 or 8
- vcompress.vm and the eight mask-logical operations with
vm 0
- vid.v with vs2 not v0
- VFUNARY0 selectors 00100, 00101 and 01101 (the last is
Zvfbfmin's vfwcvtbf16.f.f.v, not implemented)
This read: "Other reserved vector encodings found are
reported for a ruling, not changed." BP-124 D7 classed every
lumop 01000 encoding as whole-register, reserved NFIELDS
included; those fall under the third class. An illegal
vector word carries a zero vector packet (DCD-36).
BUILT by BP-125, TD#175 closed: a reserved memory form
decodes as VMEM and a reserved OP-V form as VOTHER, so the
existing illegal path applies (D3). Counts by class, each
encoding counted under the class of its form (D2; the
classes overlap on mew): mew 15168, segment lumop/sumop 7168,
whole-register 236, vlm/vsm 30, vsetvl 1178, vadc/vsbc 190,
vmv.v/vfmv.v.f 136, vmv.s.x/vfmv.s.f 144, vfmv.f.s/vmv.x.s 76,
vmv<nr>r 66, vcompress and mask-logical 342, vid.v 2,
VFUNARY0 6; total 24742. CORRECTED session-077: the vsetvl
class read "bits 30:25", copied by the PA from BP-124's report
without checking the encoding; bit 30 set is vsetivli, so
that text would have made half the vsetivli encodings
illegal. BP-125 built bits 29:25. Checked against
riscv-opcodes rv_v, every other class matches its fixed
fields.
DCD-33 ZVBB IS DECODED, one v_op_class per instruction, appended
after VOP_VSOXSEG in this order with the values 189 to 198:
VOP_VANDN, VOP_VBREV, VOP_VBREV8, VOP_VREV8, VOP_VCLZ,
VOP_VCTZ, VOP_VCPOP_V (VOP_VCPOP is vcpop.m), VOP_VROL,
VOP_VROR and VOP_VWSLL, gated by en_v, each with is_vector and
needs_vtype set. Zvbb is mandatory in RVA23U64
and the decoder had no entry for it, so DCD-32 would have
made it illegal. Added session-077 by the PA; flagged for
Jeff.
DCD-36 AN ILLEGAL PACKET carries ALU_ILL and nothing else: no
register (uses_* clear, the fields zero), no immediate, no
is_* flag, no FP field, and a zero vector packet, so rename
and dispatch see only the trap. BP-124 D5, accepted
session-077 (Jeff).
DCD-34 VERIFICATION (R14). Legality and classification are checked
against a disassembler oracle, spike-dasm, the disassembler the
decoder work has used, with --isa naming exactly the implemented
extensions (every RVA23U64 and RVA23S64 mandatory extension that
has instructions, H and Svinval among them, and no optional one).
Directed decoder tests take each word from clang -c (RISC-V
target, the same extension set) and confirm it with spike-dasm.
This read "an LLVM disassembler oracle, as BP-117 checked the
expander, with --mattr". spike-dasm and clang replaced it
session-077 (Jeff). BP-124 found LLVM installed off PATH, in the
embecosm toolchain under /usr/local, which the expander oracle
uses (TD#147); this note said the system had no LLVM. BUILT by
BP-124: sim_dec_sweep compares the decoder against
tb/dec_dasm_oracle.txt (458752 encodings, including all eight
LOAD-FP and STORE-FP widths), oracle_dec_sweep regenerates it
with tb/gen_dec_dasm_oracle.py, and asm_dec_words re-checks the
216 directed words with clang and spike-dasm (246 since BP-125).
The out-of-repo tool path is TD#176. Since DCD-32's classes
became illegal (BP-125) the sweep expects 208902 legal and 249850
illegal. BP-124's Results Capture gave its totals as 233504 and
225248; its per-space figures sum to 233644 and 225108. The sweep
covers every funct and selector field of OP_FP, the four FMA
opcodes, AMO, MISC_MEM, SYSTEM, and, because of DCD-32 and
DCD-33, OP_VECTOR and the vector forms of LOAD-FP and STORE-FP.
Each disagreement is resolved against the ratified specification
and listed. The sweep over the vector space was added by the PA
with DCD-33.
DCD-35 THE Zimop COMMENTS are corrected: Zicfiss, an RVA23
expansion option this design does not implement, redefines
some MOP encodings. decode_pkg.sv reads "(no extension
redefines them in RVA23)" and instr_decoder.sv "no RVA23
extension redefines them" (BP-123); both become "no
extension this design implements redefines them; Zicfiss, an
RVA23 option not implemented, redefines some".
11. Open¶
DCD-U1 CLOSED session-075 by DCD-17: decode. It asked where
`vtype_hazard` is computed; TD-DCD-1 had excluded the
predecoder and left the ibuf read port and decode.
DCD-U2 CLOSED session-070 by ras_decisions.md RAS-DS1: the RAS
treats them as two operations and performs the POP FIRST,
then the push. bp_cluster.md and ftq_bpu_interfaces.md 5.4
agree. This asked for the order "if the RAS treats them as
two operations"; it does, and RAS-DS1 says so. What is
then open was TD-DCD-2, whether the BUILT RAS implemented
it; it did not, and BP-119 built it.
12. Bindings¶
IFU-1 Expansion in the IFU. The RVC expander is specified
there, not here.
IFU-3 Puts predecode in the IFU.
IFU-4 Expansion before predecode, the premise of DCD-7.
IFU-6 Unaligned block, the premise of DCD-5.
IFU-8 17 positions, the premise of DCD-2.
IFU-15 The IFU owns the prediction test, not DCD-14.
IFU-16 Satisfied by DCD-7.
IFU-17 Satisfied by DCD-10.
IFU-18 Direction is proven only for an unconditional, which
follows from DCD-7 and is the FTQ's rule.
IBUF-2 Consumes the bundle view of DCD-16.
TD-IFU-1 Closed by DCD-16.
TD-IFU-5 Closed by this document.
IBUF-9 The 8-wide read port that sets the decode bundle of
DCD-17.
TD#143 DCD-17 to DCD-20 built by BP-118; rvc_expander.sv
retires in BP-119.
MMU-29 The implicit-access kind of DCD-16.
MMU-23 FAULT_GPA_WIDTH, DCD-16.
13. Document History¶
2026-10-09 session-077, ruling (Jeff). DCD-15, DCD-16 and DCD-16a
carry the implicit-access kind of a guest physical
address. This document had no history section; its
earlier changes are in PROJECT_STATUS.
2026-10-09 session-077, after BP-123, rulings (Jeff). Section 1:
the representation and legality are in scope. DCD-16:
the GPA is FAULT_GPA_WIDTH = 56; the kind is built.
Section 10b, DCD-21 to DCD-35, from R1 to R14. DCD-24's
vector paragraph, DCD-33 (Zvbb) and the vector part
of DCD-34 were added by the PA and flagged.
2026-10-09 session-077, after review of the BP-124 draft. DCD-23:
fp_fmt is the encoding's fmt field. DCD-24: is_fp,
is_load and is_store for vector instructions. DCD-25:
the vtype immediates and the vsetivli AVL. DCD-26:
FCVTMOD.W.D needs rm 001. DCD-35: the exact comment
text. 10b lists the PA additions pending Jeff. 10a's
scope sentence; DCD-16's "last two".
2026-10-10 session-077, ruling (Jeff). DCD-34: the oracle is
spike-dasm and directed words come from clang -c; the
LLVM oracle is withdrawn, there being no LLVM on the
system.
2026-10-10 session-077, after BP-124, rulings (Jeff). 10b built;
the PA additions accepted as built. BP-124's D2 to D7
and D9 accepted: DCD-24 (FP load/store is_fp, LR/SC/AMO
marking, is_csr, rs3), DCD-29 (the FENCE immediate),
DCD-36 (the illegal packet). DCD-32: every reserved
vector encoding is illegal, the VRSV classes listed;
built by BP-125. DCD-34: built; LLVM is installed off
PATH, so the "no LLVM" note is corrected.
2026-10-10 session-077, ruling (Jeff). DCD-16 and TD#148:
is_vsetvl and needs_vtype leave ifu_pd_pkt_t; removed
by BP-125.
2026-10-10 session-077, after BP-125. DCD-32 built, TD#175
closed, with the per-class counts; its vsetvl class
corrected from bits 30:25 to 29:25 (PA error). DCD-34:
the sweep's totals. DCD-16 and TD#148: the removal
built, 192 -> 190 bits.
ifu_decisions.md
planning/arch/ifu_decisions.md on GitHub
Instruction Fetch Unit Decisions¶
FILE: ifu_decisions.md
SOURCE: session-069
STATUS: DRAFT
UPDATED: 2026-10-09
CONTACT: Jeff Nye
Owns the IFU-N, TD-IFU-N and IFU-UN registries. The numbers are issue order and the sections are topical, so they do not run in numeric order: IFU-5 follows IFU-1 in section 1, IFU-4 follows TD-IFU-5 in section 3, and IFU-23 is in section 7 after IFU-23a to IFU-27 in 5.1. Session-072.
Scope is the IFU. Its boundaries are held elsewhere:
ftq_ifu_interfaces.md upstream, l1i_ifu_interfaces.md for the
instruction side, itlb_ifu_interfaces.md for translation, and
ifu_ibuf_interfaces.md downstream. TD#116 closes on this
document as revised session-074; section 8 records the rulings.
1. Compressed instruction expansion¶
IFU-1 Compressed instructions are expanded to their 32-bit form
in the IFU, before the instruction buffer.
Three consequences follow and are not separate rulings.
The ibuf holds uniform 32-bit slots. It does not pack halfwords, its read and write ports are fixed width, and the only variability on the write side is how many slots are valid in a cycle.
The IFU owns the straddle. A 32-bit instruction can begin in the last halfword of a prediction block. The IFU fetches the 17th halfword (IFU-8), so the instruction completes inside its own block, and the next block, which begins on its tail, walks from position 1 (IFU-11). Nothing downstream sees a partial instruction. This read that the IFU holds the leading halfword across the boundary. Session-074.
The PC is carried per slot. Expansion breaks the correspondence between slot position and address, because a compressed instruction advances the PC by two and occupies a full slot.
IFU-1 matches XiangShan, where RVC expansion sits in the IFU ahead of the IBuffer so the backend decoders see one instruction format.
IFU-5 The IFU presents the ibuf a fixed-width vector of 16 slots
every cycle with one per-slot enable mask. It does not
compact. The ibuf compacts on write.
A 32-byte block holds at most 16 instructions, so 16 slots covers the widest case and the port never changes width. Compaction is a shift by a variable amount, and doing it in the IFU puts that shifter in series with expansion and predecode in the same cycle. Moving it into the ibuf puts it against the write port instead.
One mask, not two. The start-within-range of DCD-12 and the
truncation by the prediction check of IFU-15 are both IFU-internal
and the ibuf needs only the result. ifu_ibuf_interfaces.md IB-2
and IB-3.
The port detail belongs to ifu_ibuf_interfaces.md.
2. Slot payload¶
IFU-2 Each slot delivered to the ibuf is an `ifu_pd_pkt_t`,
whose fields are `dcd_decisions.md` DCD-16 and
`ifu_ibuf_interfaces.md` 4: the expanded instruction, its
start PC, its position within the prediction block, its
FTQ index, its fault cause, faulting VA and faulting GPA
with the GPA's implicit-access kind, is_rvc, and its control
flow classification. Declared in `bp_structs_pkg`, BP-115;
the kind added session-077. is_vsetvl and needs_vtype were
also carried until BP-125 removed them (dcd_decisions.md
TD#148, ruled session-077; ifu_pd_pkt_t 192 -> 190 bits).
This read "its position within the buffer" and "its FTQ pointer", and did not list the faulting VA that IFU-2a refers to. The position is within the prediction block and the index is FTQ_IDX_BITS, the value ftq_resolve_t returns. Session-074.
The start PC and the position are both needed and are not the same thing. Expansion breaks the correspondence between the two, because a compressed instruction advances the PC by two and occupies a full slot.
The fault cause is per slot, not per prediction block. itlb_decisions.md
ITLB-11 returns one of three causes and the exception has to reach
the backend attached to the instruction it belongs to.
IFU-2a A slot whose cause is an instruction guest-page fault, cause
20, also carries the faulting GUEST PHYSICAL address. It
comes back on the translation port, IT-6a, because the IFU
never had it. Shtvala requires `htval` to be written with
it. The virtual address of IFU-2 is still carried for
`stval` and `vstval` under Shvstvala. The GPA's
implicit-access kind comes with it (IT-6c) and is carried
the same way; the backend needs it for htinst
(mmu_decisions.md MMU-29). Session-077.
THE GPA IS FAULT_GPA_WIDTH = 56 BITS (mmu_decisions.md
MMU-23), on IT-6a, in the queue of IFU-25 and in
`ifu_pd_pkt_t.fault_gpa`. For kind 00 the walker returns
the faulting page and the IFU fills `fault_gpa[11:0]` from
the faulting halfword's virtual address, ALWAYS, so the
field is the faulting guest physical address itself; the
trap path forms htval from it (htval holds the GPA shifted
right by 2). For kinds 01 and 10 the field is the VS-stage
PTE's guest physical address, unchanged. Built by BP-123
(D5) with an exception for a GPA of 0, MMU-30's sentinel;
RULED session-077 (Jeff), after BP-123, without the
exception, MMU-30 being withdrawn; the width and the
unconditional fill BUILT by BP-124.
H is mandatory in RVA23 through Sha, so the guest case is not optional and the GPA field is not conditional on a build option.
TD-IFU-1 CLOSED by `dcd_decisions.md` DCD-16 and BUILT by
BP-115. The bundle view is a NEW struct, `ifu_pd_pkt_t`,
in `bp_structs_pkg`; `predecode_pkt_t` in `decode_pkg.sv`
is not changed and is retired with decode's move to the
new struct, TD#143. This read that DCD-16 redefines
`predecode_pkt_t` and that a `decode_pkg.sv` edit
remained. Session-074.
`predecode_pkt_t` in `decode_pkg.sv` carries valid, the
32-bit instruction, three vtype annotations and a branch
hint. It has no PC, no FTQ index, no fault cause and no
faulting VA, and nothing else in the package carries
them. IFU-2 requires all four and they are additions.
3. Predecode¶
The predecode correction is written back to the FTQ from the IFU
and ftq_ifu.sv is Complete including that writeback, so the
boundary this section specifies already exists in RTL.
IFU-3 Predecode is in the IFU and is specified in this document.
Decode has no planning document because it is close to a direct translation of the RISC-V specification. Predecode is not in that specification, so it has no home there and would otherwise have none at all.
TD-IFU-5 CLOSED by `dcd_decisions.md`. The predecoder is written
fresh from that document and neither `predecode.sv` nor
the old `predecode_pkt_t` constrains it. Retained for
the record.
`predecode.sv` as built does not do what IFU-16
requires. Its output struct carries `may_be_branch`,
documented as a conservative hint set on the JAL, JALR
and BRANCH opcodes with full resolution deferred to
decode, and it is 8 slots wide. IFU-16 needs a 2-bit
type separating conditional from JAL from JALR, plus
is_call and is_ret, plus a computed target, across the
16 positions of `ftq_pd_info_t`. The built module is a
decode-side helper and the one specified here is a
different module. Its location under
`rtl/core/frontend/decode/` is a path and not the
issue.
IFU-4 Expansion runs before predecode. Predecode operates on the
expanded buffer and recognises base-ISA branch encodings
only.
Expansion does not need to know where instructions start. At each 2-byte position the four bytes beginning there are taken, and the low bits of that position alone decide whether a compressed instruction is expanded or a 32-bit one passes through. Every position expands independently, so the start mask and the expanders run in parallel.
The gain is in predecode. On the expanded buffer it recognises JAL, JALR, BEQ and BNE and not also C.J, C.JAL, C.JR, C.JALR, C.BEQZ and C.BNEZ.
XiangShan orders these the other way, predecode at F2 and expansion at F3, and its predecode therefore carries both the instruction-start and RVC detection and the branch classification. IFU-4 splits those: the start mask is computed separately and predecode keeps only the classification.
4. Straddle¶
A 32-bit instruction can begin in the last halfword of one prediction block and end in the next. Because RVC makes instructions 2-byte aligned, this also happens at a line boundary and at a page boundary, so the second half can miss, can translate differently, and can fault on its own.
IFU-6 The prediction block is not aligned. It begins at the
predicted target, which is any 2-byte address.
IFU-7 The IFU fetches two cache lines when the block start falls
in the upper half of a line, and one otherwise.
IFU-8 The IFU covers 34 bytes, not 32: the 32-byte block plus
the 2 bytes a straddling 32-bit instruction takes from the
line after it. That is 17 halfword positions. Only the
first 16 can be instruction starts, so IFU-5 stays at 16
slots.
IFU-6 is the XiangShan arrangement and IFU-7 and IFU-8 follow from it rather than being separate choices. An unaligned block starting in the upper half of a line runs past the line end, so the second line is needed for the ordinary case, not the edge case.
The second line is a separate translation. It can be in another page, so it can hit in the ITLB when the first missed, fault when the first did not, and arrive at its own time.
The fault raised on the second half belongs to the instruction that started in the first. XiangShan carries an exception mask on its IFU-to-IBuffer boundary that can mark the first instruction of either prediction block for this reason. XiangShan's "fetch block" is its 32-byte prediction block, not pacino's 64-byte fetch block (fe_decisions.md Conventions). Session-071.
5. Pipeline¶
IFU-9 Five stages: F0, F1, F2, F3 and WB. This is the XiangShan
segmentation.
IFU-10 Stage contents.
F0 Accept the FTQ request. Read the translation queue
head, IFU-25. Issue the L1I request with the physical
address it supplies, two requests under IFU-7, or none
when the block's line matches the previous request
(TD-IFU-8) or the translation faulted (IF-23).
F1 Compute the PC of every 2-byte position in the block.
The cache access is in flight.
F2 L1I data returns. Check it against the request, form
the per-instruction fault information from the line's
fault information, compute the jump and fall-through
ranges, and select the 17 halfword positions of
IFU-8.
F3 Expand, predecode, check the prediction, mask, and
present the slot vector of IFU-5 to the ibuf.
WB Write the predecode correction back to the FTQ.
F0 does NOT start a translation. Translation happens in a separate pipeline that runs ahead of this one, section 5.1. L1I-3 makes the L1I physically indexed with translation complete before the array is indexed, so a request issued in the same cycle the lookup began would carry an address that does not exist yet. IF-8 says the same from the other side. An earlier revision of IFU-10 did exactly that.
IFU-11 A 32-bit instruction starting at position 15 completes in
its own block from the 17th halfword (IFU-8, DCD-2). F3
holds a register with the address of that tail. A block
whose start equals it begins its walk at position 1
(DCD-5). The tail's translation and fault are its own
block's second result when the straddle crosses a page
(IFU-25).
RULED session-074 (Jeff), as BP-116 built it. This read
that the register holds the leading halfword, its PC and
its fault, and that the instruction completes in the next
block. That contradicted IFU-8, and an instruction carried
into the next block would sit at position -1, which
ifu_pd_pkt_t.pos cannot express.
L1iReadLatency is 2, so F1 and F2 are mostly the wait for data.
That is why five stages carry what BOOM does in four: BOOM's
fetchWidth is 4 or 8 instructions and pacino is 16 positions over
a 32-byte block, so its F3 work does not compress the same way.
IFU-12 Expansion stays in F3. F3 holds expansion, predecode, the
prediction check and the mask.
IFU-4 puts expansion ahead of predecode, the reverse of XiangShan, so F2 and F3 do not hold what XiangShan's do. Expansion is a mux per position and predecode on expanded encodings is a narrow decode. The prediction check is a priority encode over the 16 positions to find the earliest control flow instruction, feeding a 40-bit target compare, target[VA_WIDTH-1:1] at VA_WIDTH 41 (fe_decisions.md FE-19, TD-FE-3), and a 4-bit position compare. This read "a 39-bit target compare", the floor computed against the retired 40-bit address. Session-071. F2 keeps the data return, the fault information and the position select.
5.1 The translation pipeline¶
IFU-23a The IFU has two decoupled pipelines. The TRANSLATION
pipeline runs ahead and produces physical addresses. The
FETCH pipeline of IFU-10 consumes them. A queue joins
them.
IFU-24 The translation pipeline is driven by its own pointer
into the FTQ, ahead of the pointer the fetch pipeline
uses. It reads a block's start PC, performs the ITLB
lookup of `itlb_ifu_interfaces.md`, and enqueues the
result.
IFU-25 The translation queue holds, per block: the physical
address, the PMA attributes of IT-10, the fault cause and
status of IT-4, and the guest physical address of IT-6a
with its implicit-access kind of IT-6c when the cause is
20. F0 reads the head. The kind added session-077. The GPA
is FAULT_GPA_WIDTH = 56 bits in both results (IFU-2a);
session-077, after BP-123, BUILT by BP-124.
A BLOCK THAT CROSSES A PAGE HOLDS TWO RESULTS in its one
entry: the second page's physical address, PMA attributes,
fault cause, GPA and its kind, valid only for a crossing
block and filled by a second ITLB lookup in the next cycle.
A fault on the second page belongs to the positions in it
(DCD-15).
Ruled session-074 (Jeff). Ending blocks at page boundaries
instead would change built BPU and FTQ block semantics for
an event on well under 1% of sequential blocks.
IFU-26 A block whose effective type is not both cacheable and
idempotent is marked in the queue and is issued to the L1I
as an UNCACHED request (IFU-21), under the commit gate of
IFU-22. This read "is not issued to the L1I. It takes the
uncached path of IFU-21"; IFU-21 was reversed session-076. MMU-14 and
IT-11; the effective type includes the PTE's PBMT
(mmu_decisions.md MMU-U6). This read "translates to a
non-idempotent region". Session-071.
IFU-27 On a redirect both pipelines are flushed of everything at
or after the flush index (ftq_ifu_interfaces.md 5). The
fetch pipeline then stalls until the translation pipeline
refills the head. How the flush is applied with requests in
flight is IFU-28 to IFU-32, section 6.1, built by BP-118.
This read "the queue is emptied" (session-074), and until
session-075 described the BP-116 stub that cleared all
state, legal only with nothing outstanding.
THE COST DEPENDS ON WHETHER F ALREADY HAS CONTENT. From the
redirect cycle to the first cycle the FTQ presents the
translation request for the flush index F:
p2, p3 1 cycle BP-125, tb_ftq K4, K11
predecode 2 cycles BP-117, tb_ftq G5
backend 2 cycles BP-113, tb_ftq G11, G16
For a backend redirect, and for a predecode redirect since
BP-117 put F at K+1, F is the redirect target block and its
p1 content write lands at the end of the redirect cycle, so
there is nothing to translate until then. A p2 or p3
redirect corrects K, which already has content; BP-125
measured that row at 1 cycle (this read that it is inferred,
since tb_ftq drove no p2 or p3 redirect). ftq_decisions.md
5.1 carries the same table.
This read "front-end (p2, p3, predecode) 1 cycle" from
BP-113, measured while predecode still flushed at K.
Before that, "at least one cycle" for both. Session-075.
This is the XiangShan arrangement with one part left out. XiangShan's IPrefetchPipe queries the MetaArray and the ITLB and writes hit way, ECC and exception information into a WayLookup queue for MainPipe to read, and it documents the same reset and redirect cost: WayLookup is empty, the prefetch and fetch pointers reset together, and MainPipe stalls one extra cycle.
WHAT IS LEFT OUT, AND THIS IS A CHOICE. XiangShan puts the
prefetch pipeline inside the ICache and queues the hit WAY along
with the translation, so its main pipe reads the data array with
the way already resolved. Pacino's L1I is EMITTED by cachegen.
Putting a second pipeline, an ITLB client and a lookup queue
inside it is a cachegen change of the class INFRA-012 sized for
one node: 4 configuration, 5 schema, 8 emitter items. So the
translation pipeline is placed in the IFU instead, the L1I is
unchanged and still receives a physical address on the
l1i_ifu_interfaces.md port, and the queue holds translation
only, not the hit way.
The cost of that choice is that the L1I tag compare stays in the fetch path where L1I-5 puts it, so the way is resolved during F1 and F2 rather than ahead of F0. The benefit is that nothing in the emitted L1I changes.
IFU-U5 CLOSED session-074 (Jeff). The translation queue depth is
a parameter, default 4. An entry frees when its block enters
F1, whether it issued a request, reused the previous line or
faulted; the translation result travels with the block.
Freeing on data return would make the queue cover everything
in flight, up to 32 blocks at a line buffer of 16. Four
covers the one-cycle ITLB hit of ITLB-5 at one block per
cycle. A longer hit would cut throughput whatever the
depth: the one-bit tag of IT-2 allows one block at the ITLB
at a time. Translation stays in order, IT-14. XiangShan
exposes theirs as nWayLookupSize.
The FTQ side is xlate_ptr, ftq_decisions.md 5.1, and the port is
ftq_ifu_interfaces.md 4.1. Both were written session-069 with this
section. FQ-1 becomes commit_ptr <= fetch_ptr <= xlate_ptr <=
alloc_ptr.
6. Prediction check and writeback¶
ftq_ifu.sv is Complete and is the FTQ half of this boundary, so
this section records a contract rather than deciding one. The
port names are its port list.
IFU-13 The IFU reports, it does not redirect. There is no
IFU-to-FTQ redirect port. The FTQ derives the redirect
from the writeback, which keeps one producer for the fact.
IFU-14 The writeback carries, per block: `pdwb_val`, `pdwb_idx`,
`pdwb_gen`, a `ftq_pd_info_t` for each of `FTQ_PD_WIDTH`
positions, `pd_range`, `cfi_val` and `cfi_pos`, `mis_val`
and `mis_pos`, `target`, `fault_val` and `fault_pos`.
IFU-15 `cfi_pos` and `mis_pos` are different facts. `cfi_pos`
names the first control flow instruction predecode found.
`mis_pos` names the position that failed the check. They
coincide in one of the four mispredict cases and not in
the others.
IFU-16 Predecode emits, per position: valid, a 2-bit type where
00 is not a control flow instruction, 01 a conditional
branch, 10 JAL and 11 JALR, plus is_call and is_ret.
IFU-17 Predecode computes a target for direct branches and JAL.
For JALR the target field carries no meaning and the FTQ
does not read it.
IFU-18 Predecode proves a direction only for an unconditional
branch. It cannot know a conditional's direction, TAGE and
SC own that, and the entry's prediction stands.
IFU-19 The generation bit issued with the request is carried
through the IFU and returned with the writeback. A
writeback whose bit does not match is dropped entirely.
IFU-20 On a flush the IFU drops every in-flight fetch whose index
is at or after the flush index and discards everything it
holds for those entries. A request presented in a flush
cycle is ignored (ftq_ifu_interfaces.md 5, TD#138). Both
pipelines of IFU-23a are flushed by the one group. This read
that the flush applies first and that request is the first
fetch of the corrected stream. Session-074.
IFU-20 is load-bearing beyond the IFU. The generation tag is one bit, and one bit is only sufficient because a stale writeback cannot outlive the flush cycle. If the IFU ever holds a writeback longer than that, the tag width has to be revisited.
6.1 How the flush is applied -- TD#134¶
RULED session-075 (Jeff). BUILT by BP-118. IFU-28 to IFU-32 say how IFU-20 is met with requests still in flight. They replace the BP-116 stub, which cleared all IFU state and was legal only with nothing outstanding. Clearing all is wrong because the FTQ does not rewind fetch_ptr or xlate_ptr past an entry older than the flush index F (ftq_decisions.md 5.5 R1), so a block older than F that the IFU drops is never presented again.
IFU-28 SURVIVAL. A block SURVIVES a flush when it is older than F,
measured from the commit pointer: with
age(i) = (i - ftq_ifu_commit_ptr) mod FTQ_DEPTH, a block with
FTQ index i survives when age(i) < age(F). Every block the
IFU holds is at or after commit_ptr, because an entry commits
only after its instructions have left the IFU, so the age is
well defined without a wrap bit. Surviving blocks continue in
every structure: both pipelines, the translation queue and
the line buffer. Non-surviving blocks are dropped from all of
them in the flush cycle. RC_UNSPEC, where F is commit_ptr,
drops everything with no special case.
IFU-29 L1I RESPONSES FOR DROPPED BLOCKS. The L1I has no cancel and
the IFU accepts every response (l1i_ifu_interfaces.md IF-10).
At the flush, every in-flight request identifier whose blocks
all fail IFU-28 is marked KILLED. When a killed identifier's
response arrives its data is discarded, and the identifier
and its line buffer slot are freed as for any response
(IF-11). No generation counter is needed: an identifier
cannot be reissued while it is in flight (IF-6), so a killed
identifier cannot be confused with a later request.
IFU-30 A SHARED LINE BUFFER SLOT. A slot that serves more than one
block (TD-IFU-8, IF-7) survives when any block it serves
survives; the blocks that fail IFU-28 are removed from it.
Blocks are taken in order, so the removal is one cut at the
first non-surviving block.
IFU-28a THE STRADDLE REGISTER (IFU-11) survives a flush only when
the block after the one that set it survives; otherwise it
is cleared, and the corrected block at the same address
walks from position 0. Built by BP-118, accepted session-075
(Jeff).
IFU-29a A REQUEST ALREADY PRESENTED IS NOT WITHDRAWN. When a flush
drops a block whose L1I request is presented and not yet
accepted, the request stays presented, unchanged, until the
L1I accepts it (l1i_ifu_interfaces.md IF-4), and its
response is then discarded by IFU-29. F0 accepts nothing
else meanwhile. Built by BP-118, accepted session-075
(Jeff).
IFU-31 ITLB LOOKUPS IN FLIGHT. ITLB responses have no ready and may
return out of order under a one-bit tag naming the half of a
block (itlb_ifu_interfaces.md IT-2, IT-3, IT-14). When the
block being translated fails IFU-28, its outstanding lookups
are DEAD: their responses are dropped, and translation of a
new block does not start until every dead lookup has
answered, so a tag value is never shared between a dead and
a live lookup. When the block being translated survives,
translation continues. How long the wait lasts is the
ITLB's miss latency, a property of the ITLB and not of the
IFU; a testbench model of the ITLB answers when the
stimulus says and so cannot measure it. What the IFU must
guarantee is that translation of a new block starts the
cycle after the last dead lookup answers, and not before.
This read "BP-118 measures it". Session-075.
IFU-32 THE GENERATION BOUND. After the flush cycle the IFU presents
no writeback (ftq_ifu_interfaces.md 6) for a block that
failed IFU-28. This is what keeps one generation bit
sufficient (IFU-20, ftq_ifu_interfaces.md 6.1), and an
assertion checks it.
TD#135 (uncached) and TD#136 (maintenance) stayed stubbed after BP-118; BP-123 BUILT both (section 7, l1i_ifu_interfaces.md 10 and 11), accepted session-077 (Jeff). A request presented in a flush cycle is still ignored (IFU-20).
The fault takes two paths and they carry different things. The
architectural exception travels with the instruction to the
backend, which is the fault cause and faulting VA of IFU-2. The
FTQ is told only that the block ended early, which is why
fault_pos is declared on the port and not read.
FTB_BLOCK_BYTES is 32, so FTQ_PD_WIDTH is 16 and
FTQ_PD_POS_BITS is 4. The writeback array covers the 16
positions that can be instruction starts. The 17th position of
IFU-8 has no entry and needs none: it can only be the tail of a
straddling instruction, never a start, and it is consumed inside
the IFU.
7. Uncached fetch¶
Fetch from a page whose effective type is non-idempotent or non-cacheable (MMU-14, MMU-U6) cannot use the normal path. MMU-14 forbids speculating into it, and a memory mapped device must not see a read for an instruction that is not on the committed path.
IFU-21 UNCACHED FETCH GOES THROUGH THE L1I, MARKED UNCACHED.
The request carries ifu_l1i_req_uncached
(l1i_ifu_interfaces.md IF-44); the L1I serves it from the L2
whatever its tags hold and does not allocate the line
(icache_decisions.md L1I-24). RULED session-076 (Jeff),
REVERSING the session-069 rule, which read "The IFU has a
second instruction source for uncached fetch, separate from
the L1I. The L1I is not involved." The L1I's miss path
already does what an uncached fetch needs; a second source
would duplicate it as a second memory port, a second response
path and a second L2 client. TD#135.
IFU-22 The FTQ drives its commit pointer to the IFU continuously.
The IFU compares the index of the uncached block against
it and issues the bus transaction only when every earlier
instruction has committed.
IFU-22 and IFU-23 STAND under the new IFU-21 (confirmed session-076, Jeff): the uncached request is presented only when every earlier instruction has committed, and its instructions are delivered one at a time, each after the previous has committed. They are the no-speculation rule MMU-14 requires.
The IFU cannot learn this any other way. Stopping fetch is what allows the pipeline to drain, but the drain takes an unknown number of cycles and the IFU has no way to observe that it has finished. The FTQ already holds the commit pointer, so what is added is its export, not the knowledge.
The FTQ cannot gate the request instead. Whether a block is uncached is learned in the IFU's translation pipeline, from the PMA result, and marked in the queue entry (IFU-25, IFU-26), after the FTQ has handed the translation request over. This read "from the PMA result at F2". Session-074.
IFU-23 Uncached fetch returns one instruction at a time. It is
sent to the ibuf alone, and the IFU waits for it to commit
before issuing the next. Since the request returns a whole
line (IFU-U4), the next instruction may come from the line
the IFU already holds or from a new uncached request; either
meets this rule.
IFU-23b HOW IFU-23 IS MET: EACH UNCACHED INSTRUCTION IS ITS OWN FTQ
ENTRY. F3 delivers an uncached block's first instruction
alone. When the block would deliver more, the writeback
marks that position with `mis_val` and `mis_pos` and sets
`ifu_ftq_uc_end` (ftq_ifu_interfaces.md 6); the FTQ takes
the successor as start + 2 * mis_pos + the instruction's
length, 2 or 4 (ftq_ifu_interfaces.md 7, W3U). The next
instruction is then the next entry, and IFU-22 gates it at
F0 against the commit pointer like any uncached block. A
JALR is delivered alone with no redirect: its target is
unknown to the IFU, so its successor is the backend's.
This is XiangShan's MMIO scheme. The alternative,
per-instruction commit visibility inside the IFU, has no
port. Built by BP-123 (D1), accepted session-077 (Jeff).
TD-IFU-4 CLOSED. `ftq_ifu_commit_ptr` was added to the fetch
request group by BP-114 (TD#142). It is a driven value,
not a query with a response, so it adds no handshake.
This read that ftq_ifu.sv has no commit pointer output.
IFU-U4 CLOSED session-076 (Jeff). An uncached fetch reads a whole
L1I line, because pacino never executes from non-idempotent
physical memory (mmu_decisions.md MMU-15b). The only uncached
fetch is then from main memory whose PTE marks it NC or IO,
where reading the bytes around the instruction has no side
effect. No narrow bus and no split transaction. This read
"Bus width and the split it forces. XiangShan's MMIO bus is
8 bytes ... Pacino's uncached bus width is not set.
Unresolved."
8. The line buffer, issue and reordering¶
Ruled session-074 (Jeff), closing TD#116. These were listed here as unruled.
TD-IFU-7 CLOSED. The line buffer of `icache_decisions.md` L1I-14
has a depth that is a parameter, default 16 =
MAX_OUTSTANDING. One slot is reserved per L1I request
identifier when it is allocated (`l1i_ifu_interfaces.md`
IF-7), because the response carries no ready and must
always have somewhere to land. Size it later with the
TD#128 harness. What a redirect does to it is IFU-29
and IFU-30 (TD#134). A slot's reader count is sized by a
parameter, default the maximum derived from the pipeline,
with an assertion at the limit; it was fixed at 32 against
a possible 33 (TD#153, ruled session-075). BUILT BY
BP-119: parameter LB_RD_MAX, default 2*LB_DEPTH+1 = 33,
the count stored in 6 bits, and assertion U5 firing when a
count exceeds the parameter (the default is reachable and
legal). The 6-bit count never overflowed; the defect was
the fixed bound only.
TD-IFU-8 CLOSED. Issue is in order, oldest first, whenever a
translated block, a free identifier and a free slot all
exist. A block whose line matches the PREVIOUS request
reuses that request's line-buffer slot and makes no
request; it shares no identifier, which may already be
retired. A slot frees when its last block is consumed.
One comparator catches the common case, consecutive
blocks in one line. The previous-request register is
what l1i_ifu_interfaces.md IF-36 clears after a
maintenance operation's done, as BP-123 built it (its
Assumption 2, for Jeff to confirm). So two
sequential blocks make one L1I request, and what merges
in the L1I MSHRs is a redirect back to a line in flight
or a non-consecutive repeat.
TD-IFU-9 CLOSED. The reordering store of TD-IF-5 is the line
buffer itself, consumed in allocation order. A response
lands in the slot its identifier reserved; F2 takes slots
in order. No separate structure, and the identifier free
list bounds it.
TD-IFU-10 MOVED to TD#136. The maintenance path of
`l1i_ifu_interfaces.md` 11; its producer is the backend
commit stage, which has no document. Section 7 here
covers uncached fetch, not this.
9. Open¶
IFU-U4 CLOSED session-076. Section 7, MMU-15b.
IFU-U6 Instruction prefetch. L1I-19 puts the requester in the IFU
and ftq_decisions.md 6.1 defers prefetch. Nothing is built;
ifu_l1i_req_prefetch is driven 0. DEFERRED, session-074.
10. Bindings¶
ITLB-11 Supplies the fault cause and VA of IFU-2.
M1 to M4 The four mispredict tests are the IFU's to make. M4,
a predicted taken position outside the fetched range,
is named explicitly in `ftq_ifu.sv` as the IFU's test.
DCD-* The predecoder of IFU-3 and IFU-16 is specified in
`dcd_decisions.md`. This document states where it sits
and what it must produce; that one states how.
IB-* The ibuf boundary is `ifu_ibuf_interfaces.md`.
IT-* The translation boundary is `itlb_ifu_interfaces.md`.
Its requester is the translation pipeline of IFU-24,
not the fetch pipeline.
L1I-3 PIPT. The reason F0 cannot start a translation.
L1I-5 2-cycle hit, tag compare after the array read. Stays
in the fetch path under the IFU-23a placement.
MMU-14 Requires the uncached path of section 7, which goes
through the L1I since session-076 (IFU-21).
MMU-15b No execution from non-idempotent memory; closes IFU-U4.
IFU-7 Two lines means up to two ITLB lookups per block.
`itlb_ifu_interfaces.md` carries both.
IF-8 NOT amended. It is a gate condition -- issue only on a
valid non-faulting translation -- and stands as written;
the three causes and the VA are behind it at IF-23 and
IF-24 (itlb_decisions.md 5). This read "Amended by
TD-ITLB-1, single non-faulting condition becomes two
causes plus the VA": no TD-ITLB-1 was ever issued in the
registry itlb_decisions.md owns, and two causes is three.
Session-072.
TD#116 Closed by section 8, session-074.
TD#136 Carries TD-IFU-10.
TD#118 The IFU outstanding-request depth has no real target
until the l2 transaction limit is known. Not yet
recorded as a decision.
MMU-29 The implicit-access kind of IFU-2a and IFU-25.
MMU-23 FAULT_GPA_WIDTH, the width of the GPA of IFU-2a and
IFU-25.
11. Document History¶
2026-10-09 session-077, ruling (Jeff). IFU-2, IFU-2a and IFU-25
carry the implicit-access kind of a guest physical
address (MMU-29). This document had no history
section; its earlier changes are in PROJECT_STATUS.
2026-10-09 session-077, after BP-123, rulings (Jeff). IFU-2a:
the GPA is FAULT_GPA_WIDTH = 56 and the kind-00
offset fill is unconditional. IFU-25: the queue's GPA
width. IFU-23b: one uncached instruction per FTQ
entry, as BP-123 built it (D1). TD-IFU-8: the register
IF-36 clears (Assumption 2, for Jeff to confirm).
6.1: TD#135 and TD#136 built.
2026-10-10 session-077, after BP-124. IFU-2a and IFU-25 built:
the 56-bit GPA and the unconditional kind-00 fill.
2026-10-10 session-077, ruling (Jeff). IFU-2: is_vsetvl and
needs_vtype leave ifu_pd_pkt_t (TD#148, BP-125).
2026-10-10 session-077, after BP-125. IFU-27: the p2, p3 row
measured, 1 cycle. IFU-2: the two fields removed.
RVC Expander¶
Status: RTL complete, interim documentation
Expansion of compressed (RVC) instructions, including Zcb, to their 32-bit forms; the expander sits in the IFU.
Specification: ifu_decisions.md (in the Overview above)
Related: IA task: DECODE-003; Frontend demo: fd17_rvc: Compressed and Unaligned Code
Fusion Combiner¶
Status: RTL planned. Documentation planned.
Macro-op fusion, combining adjacent instructions into one operation; no fusion logic is in the current decoder.
Integer Decode¶
Status: RTL complete, interim documentation
Decode of the scalar integer instructions and the RVA23 integer extensions.
Specification: dcd_decisions.md (in the Overview above)
Related: Blog: What RVA23 Actually Asks of a Decoder; Blog: Scalar Foundation to Vector ALU
Float Decode¶
Status: RTL complete, interim documentation
Decode of the scalar floating-point instructions, including the fused multiply-add forms.
Specification: dcd_decisions.md (in the Overview above)
Related: Blog: What RVA23 Actually Asks of a Decoder
Vector Decode¶
Status: RTL complete, interim documentation
Decode of the RVV vector instructions and the vsetvl dependency information passed to rename.
Specification: dcd_decisions.md (in the Overview above)
Related: Blog: Scalar Foundation to Vector ALU