Branch Prediction Unit¶
Overview¶
Status: RTL complete, interim documentation
The branch prediction cluster, its seven predictors, the p1, p2 and p3 override order, and how predictions reach the FTQ.
Related: Blog: Branch Prediction Cluster Organization; Blog: Branch Prediction Cluster Build; Blog: Branch Prediction Cluster Simulation and Mutation-based Verification; IA tasks: BP-084, BP-101, BP-138; Frontend demo: fd02_steady: Steady-State Prediction and Fetch
Working specification
This page shows the planning documents and specifications for RTL tag fe-1.0.0.
bp_cluster.md
planning/arch/bp_cluster.md on GitHub
BP Cluster Micro-Architectural Decisions¶
FILE: bp_cluster.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-08
CONTACT: Jeff Nye
Overview¶
8-issue OoO RISC-V RVA23 branch predictor cluster. Optionally dual prediction (Xiangshan model): two predictions per 32-byte block, one per prediction slot. THE SLOTS ARE THE BLOCK'S TWO BRANCH FIELDS, br0 and br1, NOT TWO NEXT-PC SLOTS: one lookup supplies both, and a taken branch ends the block (fe_decisions.md 10, FE-10, FE-11). See Dual Prediction Mode below. Dual mode is runtime-selectable via a static configuration input. An earlier revision read "two independent next-PC predictions per fetch bundle"; corrected session-070.
Predictors: uBTB, Loop, FTB, TAGE, SC, ITTAGE, RAS.
Override order (conditional branch direction and target):
uBTB (p1) -> FTB, TAGE (p2) -> SC (p3)
ON DIRECTION this IS a ranking: SC > TAGE > FTB, all three produce
that one quantity, with a trusted loop prediction above all three
since BP-122 (fe_decisions.md 3.3), suspended per branch when the
FTB fast path
fires (ftb_confidence_override_rules.md 4.3, 4.2). ON EVERYTHING
ELSE it is stage order, not a ranking: a later stage supersedes an
earlier one (FE-3, fe_decisions.md 12, narrowed session-070), and
targets are selected by branch type.
Loop predictor overrides uBTB at p1 when trusted, that is when
lp_pred_is_loop is set (Loop Predictor above). Since BP-122 its p2
re-read is also the slot's direction at p2 and p3 when trusted.
This read "Loop predictor does not participate after p1".
ITTAGE and RAS are outside this ordering (type-gated, see below).
Block width¶
The successor on a uBTB miss is PC + FTB_BLOCK_BYTES, 32 bytes.
FTB_BLOCK_BYTES is 32, the PREDICTION block. FETCH_BLOCK_BYTES is
64, the FETCH block, a global parameter: the L1I line the IFU reads
(fe_decisions.md Conventions). ftb_decisions.md 2.3
rules that the two are independent and must not be collapsed:
treating the 64-byte fetch as a 64-byte prediction reintroduces a
two-block-per-cycle structure and would demand four
conditional-branch predictions per cycle against a two-prediction
budget.
AN EARLIER REVISION OF THIS DOCUMENT wrote the miss successor as
PC + fetch_width at both sites below. fetch_width here is
FETCH_BLOCK_BYTES, 64, so the successor skipped a whole prediction
block: the 32 bytes between PC+32 and PC+64 went unpredicted and a
branch in them was missed until the p2 redirect corrected it.
Bounded to one cycle, but a wrong successor is written into the FTQ
entry in the meantime. Corrected session-069.
The base is the lookup PC, not the aligned address containing it.
Prediction blocks are unaligned (ftq_decisions.md 4.7,
ifu_decisions.md IFU-6), and a miss does not resync the stream to
a 32-byte boundary.
BUILT by BP-110 (TD#125, closed): bp_cluster.sv no longer forms any in-block address from the aligned base, the miss successor is lookup PC + 32, and the branch PC is block START + (pos << POS_OFFSET_BITS) (ftb_decisions.md 4.6 R-2). This read "AS BUILT, bp_cluster.sv forms both the miss successor and the branch PC from the 32-byte-ALIGNED base", from the session-071 RTL read; stale since BP-110. Session-076.
Predictor Hierarchy and Roles¶
uBTB (micro Branch Target Buffer)¶
- Size: 256 entries, 4-way associative
- Stage: p1 output
- Role: First prediction. Provides next-PC to start speculative fetch.
On miss: no prediction generated. Fetch proceeds
sequentially (PC + FTB_BLOCK_BYTES, 32 bytes) until the
p2 redirect fires. The base is the LOOKUP PC, not the
32-byte-aligned address containing it, so a miss does
not resync the stream to alignment.
uBTB does not generate a redirect signal. It supplies or
withholds an initial prediction only.
Loop Predictor¶
- Size: 256 entries, 4-way associative
LP_N_SETS = LP_TBL_ENTRIES / LP_TBL_WAYS = 64 sets
LP_IDX_BITS = $clog2(64) = 6b
- Stage: p1 output (same timing as uBTB)
- Role: Detects loop branches and predicts exit. Overrides uBTB at
p1 when loop predictor is trusted. THE TRUST TEST IS
INSIDE loop_pred: lp_pred_is_loop is set only on a hit
with cnf == LP_CONF_LEVEL (loop_pred_interfaces.md
Semantics). The cluster's p1 mux then selects on
lp_pred_is_loop alone. This read "Trust decision made by
override control, not internally". Session-072.
- Parameters (all overridable at elaboration):
LP_TBL_ENTRIES = 256
LP_TBL_WAYS = 4
LP_TAG_BITS = 14
LP_ITR_BITS = 14 -- iteration counter width
LP_CNF_BITS = 2 -- confidence counter width
LP_AGE_BITS = 8 -- age/replacement counter width
LP_N_SETS = LP_TBL_ENTRIES / LP_TBL_WAYS
LP_IDX_BITS = $clog2(LP_N_SETS), min 1
- Override: sits alongside uBTB in p1. The p1 mux selects the loop
predictor's DIRECTION over the uBTB's when
lp_pred_is_loop is set; the target comes from the uBTB
entry (ftq_bpu_interfaces.md 4). Does not participate in
the p2/p3 override chain.
- Status: BUILT by BP-122 (TD#169): read before write, the
speculative count advanced at p2 with a per-FTQ-entry
checkpoint, and a trusted p2 direction over TAGE and SC.
Used in lp and loops. loop_pred_interfaces.md.
FTB (Fetch Target Buffer, aka BTB)¶
- Size: 2048 entries, 4-way associative, 512 sets
FTB_WAYS = 4, FTB_ENTRIES = 2048, FTB_SETS = 512.
`ftb_decisions.md` 2.2 and section 8 are the reference;
do not restate the geometry here.
- Stage: p2 output (p0 send, p1 registered, p2 valid)
- Role: Authoritative branch target for direct conditional and
unconditional branches. Identifies branch type per slot,
gating which predictor provides the target at p2:
return -> RAS provides target
indirect -> ITTAGE provides target
conditional -> TAGE provides direction, FTB provides target
direct unc -> FTB provides target
TAGE¶
- Stage: p2 output (p0 index calc, p1 SRAM read + tag match, p2 final)
- Role: Direction prediction for conditional branches. OVERRIDES
THE FTB DIRECTION: the FTB submits its own direction for
every valid conditional (conf MSB on ftb_brI_taken_p2)
and TAGE supersedes it at p2. fe_decisions.md 3.3;
ftb_confidence_override_rules.md 3.1, 4.3 and 8, where
the direction priority is SC > TAGE > FTB.
EXCEPT UNDER THE FAST PATH: when ftb_fastpath_p2[i]
fires -- conf saturated and ftb_fastpath_en set -- the
FTB direction stands for that branch and no TAGE or SC
direction override is applied. TAGE and SC are still
requested and still trained
(ftb_confidence_override_rules.md 4.2, 6).
THE REDIRECT IS A SEPARATE QUESTION. p2_redirect fires
only when the successor the cluster would publish differs
from the one its own p1 stage registers hold, not on the
override itself: an override that does not change the
successor fires nothing (fe_decisions.md FE-4, 2.5).
An earlier revision read "p2_redirect fires on override";
a session-070 revision then over-corrected and denied the
direction override itself. Both corrected session-070.
- Tables:
T0: 2 ways x 2048 entries, base table
Entry layout: 2b CTR (no tag, no valid, no useful)
T1: 2 banks x 2048, FH=8b, FH1=8b, FH2=7b, hist=8b
T2: 2 banks x 2048, FH=11b, FH1=8b, FH2=7b, hist=13b
T3: 2 banks x 2048, FH=11b, FH1=8b, FH2=7b, hist=32b
T4: 2 banks x 2048, FH=11b, FH1=8b, FH2=7b, hist=119b
T1-T4 tagged entry: TAG EPC USE CTR VALID, MSB to LSB. The
field order and widths are owned by
tage_table_entry_formats.md; by default tag 8b, epc 2b,
useful 2b, ctr 3b, valid 1b. This listed valid, tag, ctr
and useful with no EPC. Session-072.
SC (Statistical Corrector)¶
- Stage: p3 output. The SC path STARTS AT p2, not p0: the TAGE p2
result and the p0 inputs staged forward are presented at
p2, the table index hashes are computed at p2, the table
RAM reads issue at p2, and the result is valid at p3. The
update path is u0/u1. sc_decisions.md 2 and 9,
sc_interfaces.md Timing, sc_table_interfaces.md Table
Pipeline, bp_arb_spec.md 6.1. An earlier revision read
"p0 index, p1 counter read, p2 accumulate, p3 final",
which is a four-stage path this design does not have.
Corrected session-070.
- Role: Corrects TAGE when TAGE is systematically biased. Requires
TAGE output to proceed (TAGE must be valid before SC can
finalize). Overrides TAGE direction when combined counter
magnitude exceeds threshold, subject to the FTB fast
path (ftb_confidence_override_rules.md 4.2). The p3
redirect fires only when SC CHANGES WHAT THE CLUSTER
PUBLISHED AT p2, not on the override itself
(fe_decisions.md 3.1, FE-4). An earlier revision read
"p3_redirect fires on override"; corrected session-070.
Threshold: dynamically adapted at runtime (O-GEHL scheme,
TC counter), not a fixed design-time value and not CSR-
configurable. See sc_decisions.md sections 9-10, G7.
- Arbitration: the SC arbiter is in bp_cluster. Since BP-121 a
prediction is never delayed and an SC update is granted
only with no block at p2 that TAGE answers
(bp_arb_spec.md 4.5). The SC request is formed for every
block TAGE answers at p2, squashed or not (r_tv_p2,
BP-121 D13).
- Tables:
ST0: 512 entries, direct mapped, 6b wide, hist=0b
No folded history (hist=0).
ST1: 512 entries, direct mapped, 6b wide, hist=4b
ST2: 512 entries, direct mapped, 6b wide, hist=16b
ST3: 512 entries, direct mapped, 6b wide, hist=64b
ST4: 1024 entries, direct mapped, 6b wide, hist=none
No folded history (BrIMLI index, not a hashed fold).
ITTAGE (Indirect Target TAGE)¶
- Stage: p2 output (p0 index and tag hash, p1 SRAM read + tag
match, p2 final target)
- Role: Target prediction for indirect non-return branches (JALR
non-return). Target stored directly in the ITTAGE tables --
no base+offset secondary LUT. Active only when FTB
identifies branch type as indirect.
- Target: 40b, VA[40:1]. Bit 0 is always zero for instruction
alignment and is not stored. IT_MAX_TGT_WIDTH = 40 and the
reconstruction is {stored, 1'b0}; no target bit is
inferred by extension. Built by BP-111 (TD#132, closed).
This read "38b ... must zero-extend; TD#122", stale since
BP-111. Session-076. See ittage_interfaces.md.
- Tables:
IT1: 2 banks x 256 entries, FH=4b, FH1=4b, FH2=4b, hist=4b
IT2: 2 banks x 256 entries, FH=8b, FH1=8b, FH2=8b, hist=8b
IT3: 2 banks x 512 entries, FH=9b, FH1=9b, FH2=8b, hist=13b
IT4: 2 banks x 512 entries, FH=9b, FH1=9b, FH2=8b, hist=16b
IT5: 2 banks x 512 entries, FH=9b, FH1=9b, FH2=8b, hist=32b
RAS (Return Address Stack)¶
Dual-stack, static partition: 16 speculative + 32 commit entries, pointer-only snapshot recovery. Push and pop at p2, type-gated on the FTB branch type; p3 applies an inverse repair when the p3 view, qualified by p3 reachability, disagrees with p2 (BP-121, TD#166). The pushed return address is the call PC plus 2 or 4 from the FTB jump field's rvc bit (BP-121, TD#164). Outside the conditional override chain: RAS supplies the target for a return, ITTAGE for every other indirect JALR, and the FTB target is the ITTAGE-miss fallback, not a third arm.
ras_decisions.md is the one home for all of it: role and repair table 1, call and return detection with the full JALR hint table 2, the stacks and pointers 3, snapshot and restore 4, the recursion counter 5, dual-slot behaviour 6, return address value 8, parameters 9.
This section restated the whole of that -- structure, pointers, pipeline, the repair table, the hint table and the JALR roles -- under a session-050 decision recording the duplication as intentional. PROJECT_CORE.md places each rule in exactly one document, and this file already says so of 4.3 and 4.4 (Update Policy). The hint table, which ras_decisions.md 2 pointed here for, moved there. Session-071.
Pipeline Staging¶
Cycle N (p0): PC input. Index calculations begin in the
predictors that index at p0.
FTB, TAGE, ITTAGE send address to SRAM.
SC DOES NOT. Its path starts at p2; see the SC
Stage bullet. An earlier revision listed SC here
and at p1; corrected session-070.
Cycle N+1 (p1): uBTB output valid -> first prediction available.
Loop predictor output valid -> overrides uBTB if
lp_pred_is_loop is set.
Fetch begins speculatively on p1 result.
On uBTB miss and lp_pred_is_loop clear: fetch
proceeds PC + FTB_BLOCK_BYTES.
TAGE: SRAM read completes, tag match, slot reorder.
FTB: result registered (arrives too late for p1).
SC: nothing. It has not started.
Cycle N+2 (p2): FTB output valid (registered from p1).
TAGE final result valid.
RAS: push/pop executes, ras_pop_addr_p2 valid.
ITTAGE: final target valid.
SC STARTS HERE: the TAGE p2 result and the staged
p0 inputs are presented, index hashes are
computed, and the table RAM reads issue. Result
at p3. sc_decisions.md 2 and 9,
sc_table_interfaces.md Table Pipeline.
p2_redirect fires if the successor the cluster
would publish at p2, formed from FTB/TAGE/RAS/ITTAGE,
differs from its own p1 stage registers (FE-4).
FTB entry saved for one additional cycle (-> p3).
Cycle N+3 (p3): SC final result valid -> p3_redirect if the p3
successor differs from the cluster's own p2 stage
registers (FE-4). This read "if SC != p2",
predictor against stage. Session-071.
RAS p3 = p2 registered. Stack repair if p3 != p2.
FTB entry from p2 held and available.
Redirect Architecture¶
Two redirect points downstream of p1:
p2_redirect: fires when the successor the cluster would publish at
p2 differs from the one ITS OWN p1 STAGE REGISTERS
HOLD. NOT "disagrees with uBTB p1": the p1 successor
is the uBTB's OR the loop predictor's, whichever the
p1 mux selected (fe_decisions.md 2.5, and the Loop
predictor line in the Overview above). Naming the uBTB
is wrong whenever the LP won the mux. The comparison
is one quantity against the cluster's own staged view,
never predictor against predictor (FE-4). Corrected
session-070.
Target selection at p2 by branch type:
return -> RAS ras_pop_addr_p2
indirect -> ITTAGE (final; FTB target on miss)
conditional -> TAGE direction + FTB target
direct -> FTB target
TAGE overrides FTB direction (conditional only).
RAS and ITTAGE are type-gated, not in the
TAGE/FTB override chain.
The per-slot successor is chained from the highest
slot down, and a slot after a taken slot raises no
redirect (ftq_bpu_interfaces.md 6, BP-121 D5, D15).
p3_redirect: fires when SC CHANGES THE SUCCESSOR the cluster
published at p2 -- not whenever SC overrides the
TAGE direction. An override that leaves the next
fetch address unchanged fires nothing
(fe_decisions.md 3.1, FE-4; SC Role above;
sc_interfaces.md Consumer obligations). This read
"fires when SC overrides TAGE direction from p2".
Session-070.
SC requires TAGE output as input; SC cannot finalize
before TAGE. Target for p3_redirect comes from FTB
(held from p2). Direction comes from SC.
No predictor produces a new target at p3.
Note: uBTB does not generate a redirect. It provides or withholds an initial prediction only. The override chain starts at p2.
Dual Prediction Mode¶
Configuration: static input dual_pred_en (1 = dual, 0 = single).
Mechanism: the two slots are the two BRANCH FIELDS of ONE 32-byte prediction block, br0 and br1, each located by its own pos within the block's 16 two-byte positions, counted from the block start. The FTB and uBTB store positions region-relative and convert at their own boundary (ftb_decisions.md 4.6). One lookup supplies both (fe_decisions.md 10, FE-10). They are not two next-PC slots and not two PC ranges.
A TAKEN BRANCH ENDS THE BLOCK. FE-11: a RAS-operating instruction, and any taken branch, terminates the block, so slot 1 is not reached when slot 0 is taken. An earlier revision said the slots allow "a taken branch in the middle of a bundle to also predict the branch at the predicted target", which describes a second prediction past a taken branch. That cannot happen.
dual_pred_en DOES NOT CHANGE THE STRUCTURE. The slots and the channels exist either way (fe_decisions.md 10). At dual_pred_en=0 only br0 is reported and only upd_ch[0] carries traffic; nothing is removed. An earlier revision read "One update channel: upd_ch[0] only", which reads as a structural difference. Corrected session-070.
THE p1 SLOTS ARE IN POSITION ORDER. The uBTB does not reorder its slots, so bp_cluster swaps a uBTB slot 1 that lies below slot 0 (fe_decisions.md FE-10, BP-121 D12).
When dual_pred_en=1:
- Both br0 and br1 reported per block.
- Both update channels carry traffic: upd_ch[0] and upd_ch[1].
- Each channel handles both conditional and indirect resolution.
When dual_pred_en=0:
- Only br0 reported.
- Only upd_ch[0] carries traffic. upd_ch[1] still exists.
History Module¶
Centralized ownership of all branch history state. Owned by BPC, not rename/dispatch. No SRAM -- purely registered state.
Registers¶
GHR (Global History Register):
Width: GHR_WIDTH = 256b circular buffer
Pointer: ghist_ptr (GHIST_PTR_BITS = 8b), OWNED BY bp_history
Update: speculative on each prediction. Write pred_taken into
buffer at ghist_ptr position, one write per active
prediction slot in priority order, stopping at the
first taken slot (BP-121 D16).
Restore: on redirect, bp_history restores its own pointer from
the checkpoint the rollback INDEX names. No pointer
value is supplied from outside. bp_history_decisions.md
2 and 10, bp_history_interfaces.md Pointer Ownership.
This read "driven externally" and "accept new ghist_ptr
from external logic". Session-070.
Since BP-121 the rollback also carries a correction:
bp_history restores to the bundle's first bit, writes
the corrected bits and rewrites the checkpoint
(bp_history_decisions.md 3.5).
Recompute all folded histories from buffer contents.
PHR (Path History Register):
Width: PHR_WIDTH = 32b circular buffer
Pointer: phist_ptr (PHIST_PTR_BITS = 5b), OWNED BY bp_history
Update: speculative on each prediction:
PHR[phist_ptr] = pred_pc[2] ^ pred_pc[3]
One write per active prediction slot in priority order.
Bit selection (pc[2] ^ pc[3]) is subject to tuning.
Restore: as ghist_ptr above -- bp_history restores from the
checkpoint index, not from a supplied pointer value.
Same policy as GHR.
PHR folding is deferred. bp_history.sv maintains phr_mem and exposes phr_buf, but PHR does not contribute to any fold in bp_folded_hist_t. All current folds are GHR-derived only. PHR contribution to index and tag hashing is TBD, tracked by bp_history_decisions.md HI2 and tage_interfaces.md TI1. It is NOT resolved: an earlier revision said "resolved at TAGE and ITTAGE implementation sessions", and both units are now Complete and green with the question still open under HI2. Corrected session-070. The same statement appears under Folded Histories below; this is the one question, not two.
Folded Histories¶
All folded histories maintained incrementally inside this module. Consumers (TAGE, ITTAGE, SC) read folded outputs directly. Exposed via bp_folded_hist_t packed struct output port.
One set of three folds per tagged TAGE table (T1-T4):
tage_t<N>_idx_fh -- index fold, width = FH for T<N>
tage_t<N>_tag_fh1 -- tag fold 1, width = FH1 for T<N>
tage_t<N>_tag_fh2 -- tag fold 2, width = FH2 for T<N>
One set of three folds per ITTAGE table (IT1-IT5):
it_t<N>_idx_fh -- index fold, width = FH for IT<N>
it_t<N>_tag_fh1 -- tag fold 1, width = FH1 for IT<N>
it_t<N>_tag_fh2 -- tag fold 2, width = FH2 for IT<N>
One index fold per SC table with history (ST1-ST3):
sc_t1_idx_fh -- width = SC_TBL_HIST[1] = 4b
sc_t2_idx_fh -- width = SC_TBL_HIST[2] = 16b
sc_t3_idx_fh -- width = SC_TBL_HIST[3] = 64b
Incremental fold update rule for fold of width W, history H:
bit_out = ghr_mem[(ghist_ptr + H) % GHR_WIDTH]
new_fold = (fold << 1) | new_bit ^ fold[W-1] ^ bit_out
where new_bit is the incoming pred_taken.
On redirect: recompute all folds from circular buffer contents at the restored pointer position (combinational, G15).
PHR/GHR mixing for index and tag hashing is the same open question as the one under History Module above: HI2 and TI1. Not resolved at the TAGE and ITTAGE sessions, which have happened. Corrected session-070.
Checkpoints¶
One checkpoint slot per FTQ entry (FTQ_DEPTH = 64 slots). Each slot stores: ghist_ptr (8b) and phist_ptr (5b) only. Folded histories are NOT checkpointed -- recomputed on rollback. Implemented as register arrays indexed by FTQ_IDX_BITS. Checkpoint written with post-update pointer values.
Update Policy¶
Update trigger: post-execute resolution. No wait for retire. Both update channels exist in either mode. At dual_pred_en=0 only upd_ch[0] carries traffic; upd_ch[1] is still there (Dual Prediction Mode above, fe_decisions.md 10). This read "Two update channels when dual_pred_en=1, one when dual_pred_en=0", a structural difference there is not. Session-070. Each channel carries both conditional and indirect branch resolution (they are one combined channel, not split by type).
RAS update: speculative at p2 (separate from main update channels). Checkpoint/restore: the RAS snapshot (tosr, tosw, bos) is written into the FTQ entry at prediction and restored from it on redirect. Pointer-only; the circular data is not cleared. A flush is a redirect (FE-14), so there is no separate flush protocol. The mechanism is ras_restore_val / ras_restore_snapshot, built in ras.sv and driven by tb_ras. Nothing here is deferred to rename/dispatch. ras_decisions.md 4.3 and 4.4 are the single source; do not restate or re-derive the protocol here.
Prediction phase pre-computes meta-data needed for updates and stores it alongside the prediction result. Update path reads this stored meta-data rather than recomputing on resolution.
FTQ Entry Split¶
MOVED 2026-08-19. This section carried a copy of the FTQ entry layout. The sole prose home is now planning/arch/ftq_entry_formats.md; bp_structs_pkg.sv remains the reference declaration.
The FTQ entry is two structures in two SRAMs, both indexed by the FTQ entry index: bp_ftq_entry_t on the fast path, read every cycle, and bp_ftq_meta_t on the slow path, carried per prediction slot and read only at post-execute update. What the cluster contributes to each is ftq_bpu_interfaces.md sections 4, 4a, 7.1 and 7.2.
Known Gaps and TBDs¶
Open items and TBDs for this document are tracked in PROJECT_STATUS.md -- BP Cluster Open TBDs section.
Settled Implementation Details¶
Parameter values derived in bp_defines_pkg.sv:
TAGE_MAX_AWIDTH = $clog2(2048) = 11 (max table depth)
TAGE_TBL_SEL_WIDTH = $clog2(5) = 3 (5 tables T0-T4)
TAGE_MAX_DWIDTH = TAGE_TAG_BITS = 8 (tag is widest alloc field)
TAGE_CTR_BITS = 3 (max: T0=2b, T1-T4=3b)
SC_NUM_TABLES = 5 (ST0-ST4)
FTQ_CONF_BITS = 4 (confidence placeholder)
SC table roles are prose, not parameters: ST0-ST3 hold the confidence counters and ST4 is the BrIMLI table. See sc_decisions.md 6.
SC index array (superseded session-056; sc_imli_idx split retired):
sc_upd_idx [0:SC_NUM_TABLES-1][SC_MAX_IDX_WIDTH-1:0]
sc_upd_ctr [0:SC_NUM_TABLES-1][SC_MAX_CTR_WIDTH-1:0]
Uniform 5-entry arrays (ST0-ST4). The original BP-001 rationale
(ST4 index width differs, cannot form a uniform array) no longer
applies -- indices/counters are packed 2D arrays sized to the max
width across tables (session-058), zero-extended per table as
needed. See sc_decisions.md section 9, bp_structs_pkg.sv.
RAS snapshot bundled as bp_ras_snapshot_t sub-struct within bp_ftq_entry_t. Access pattern: entry.ras.tosr, .tosw, .bos. Pointer width: RAS_PTR_BITS = $clog2(16) = 4b each field. See planning/arch/ras_decisions.md section 4.
FTQ entry history checkpoint (BP-002):
ghr_snapshot (256b) removed from bp_ftq_entry_t.
Replaced with ghist_ptr (8b) and phist_ptr (5b).
Folded histories recomputed on rollback, not stored per slot.
Implemented in bp_structs_pkg.sv.
Timing Methodology Gap¶
Verilator does not provide timing data. Stage notation in struct comments expresses intent to Claude Code but is not verified by any automated tool. Jeff reviews RTL directly for timing correctness. This is documented as a known methodology gap.
Timing intent for BP cluster structs uses the prediction pipeline
stages, not the decoder's P-stages:
p0.comb = combinational in p0
p1.clk = registered at end of p1 (available start of p2)
etc.
The decoder's P0/P1 and the prediction pipeline's p0/p1 are now distinguished by case alone. bp_structs_pkg.sv CARRIES NO s2 OR s3 LABEL: the conversion was applied and verified session-070 (ftq_bpu_interfaces.md section 10, PROJECT_STATUS.md). This read that the struct comments were not inspected and might still carry them. Session-072.
Methodology Notes¶
This is the second case study for the AI-assisted co-design methodology
writeup. Complexity drivers vs. the decoder track:
- Micro-architectural decisions were open (not spec-driven)
- Interfaces not predetermined by any external spec
- Multi-module consistency is a real challenge (7 predictor
modules plus bp_history and the cluster top, all sharing
bp_defines_pkg.sv and bp_structs_pkg.sv)
- Timing budget spans 3 cycles with conditional redirect paths
Raw observations to be captured in docs/observations/ during BP work.
Document History¶
2026-05-18 Session-025 baseline.
2026-06-23 Session-050. RAS section updated: static partition
decision recorded (16 spec + 32 commit). Linked-list
structure retained in section for reference alongside
new decisions; full rationale in ras_decisions.md.
ftq_entry_t ras field comment corrected: 6b -> 4b
(RAS_PTR_BITS = $clog2(16) = 4b). Settled
implementation details: RAS snapshot pointer width
noted.
2026-08-19 FTQ Entry Split rewritten to match bp_structs_pkg.sv.
The rev 1.0 entry was pre-dual-slot: target, br_type,
taken, pred_src and confidence were block-scalar and
there was no pos field. They are now per slot in
bp_ftq_slot_t [NUM_PRED_SLOTS-1:0], declared inside
bp_ftq_entry_t, and pos is added. Type names corrected
to bp_ftq_entry_t / bp_ftq_meta_t. branch_id restated
as the FTQ ENTRY index (TD-FE-5). Slow path restated
as five nested predictor metadata types rather than a
flattened field list; the lp member is lp_pred_t and
the retired bp_loop_meta_t spellings lp_pst_itr and
lp_cur_itr are gone (TD#106, BP-092); ftb_pred_meta_t
added (IC-FTB-10). Per-slot carry of bp_ftq_meta_t and
the disjoint p2/p3 write groups recorded. Widths
stated: slot 55b, entry 182b at NUM_PRED_SLOTS = 2.
2026-08-19 bp_ftq_entry_t gains pft_addr, the block fall-through,
VA_WIDTH wide and block scalar. Successor selection is
re-evaluated on every redirect (fe_decisions.md 2.4)
and the not-taken arm is bpu_pred_pft_p1, which arrives
only at p1, so the value must be stored. Entry width
182b -> 222b, block-scalar subtotal 72b -> 112b.
Applied to bp_structs_pkg.sv and checked in
tb_bp_pkg.sv (ENTRY_BITS, a field width check and the
block-scalar preservation check). All 47 bpu targets
green.
2026-08-19 Slow path restated as the TD-FE-2 overload scheme: a
two-arm packed union, u.cond {tage, sc, lp} against
u.ind {ittage}, with ftb outside it. 420b -> 277b per
slot. Defined and deferred: a storage optimization
only. The arm is decoded from the fast-path
bp_ftq_slot_t.br_type, which carries the FTB
classification once the slot correction group of
fe_decisions.md 2.5 writes it (TD-FE-6). Definition
and the write/read rules are ftq_entry_formats.md 3.1;
this section carries the layout and the widths only.
2026-08-19 FTQ Entry Split reduced to a pointer. The layout it
carried moved to planning/arch/ftq_entry_formats.md,
which is now the only prose copy. This document had
held a third copy alongside fe_decisions.md and the
package, and all three were being edited in lockstep.
2026-09-15 session-069. The uBTB-miss successor is PC +
FTB_BLOCK_BYTES (32), not PC + fetch_width (64).
fetch_width is FETCH_BLOCK_BYTES and collapsing the
two is banned by ftb_decisions.md 2.3. Corrected at
both sites; new Block width section states the base
is the lookup PC, not the aligned address.
2026-09-17 FTB associativity corrected from 8-way to 4-way,
512 sets. This was the last surviving copy of the
"FTB_WAYS currently 8" draft annotation that
ftb_decisions.md struck in session-053 when BP-065
confirmed the package at 4; this document was not
swept at the time. 4-way is what is built:
bp_defines_pkg.sv FTB_WAYS = 4, and ftb_cntrl.sv
plru_victim / plru_touch implement a 3-bit four-way
tree-PLRU. The geometry now cites ftb_decisions.md
rather than restating it, since restating it is how
the stale copy survived.
Three unrelated repairs in the same pass. The SC
heading read "#design## SC" and rendered as body
text, not a heading. Methodology Notes cited
bp_pkg.sv, deleted at the session-008 package split;
it is bp_defines_pkg.sv and bp_structs_pkg.sv. The
same line said 6 predictor modules; there are seven,
plus bp_history and the cluster top, which is what
bp_cluster.sv instantiates. Document History was not
in date order -- the session-069 entry sat above four
older ones -- and is now sorted.
2026-09-17 ITTAGE corrected to p2. The Stage bullet, the Pipeline
Staging block and Redirect Architecture all carried a
raw-at-p2 / final-at-p3 split with a p3 refinement of
the indirect target. That split was removed from
fe_decisions.md on 2026-07-23 as an artifact of the
base+offset LUT scheme, which Pacino does not use; this
document was not swept. p2 is confirmed by
fe_decisions.md 1, ittage_interfaces.md (p0 hash, p1
SRAM read and tag match, p2 final target) and the RTL:
ittage.sv and ittage_cntrl.sv declare only
ittage_pred_rdy_p2 and ittage_pred_meta_p2, and contain
no p3 signal. Closes TD#42.
ITTAGE target width corrected. It read "stored directly
as VA_WIDTH bits" with VA_WIDTH 40b. It is 38b, the
upper 38 bits of a Sv39 VA with bit 0 not stored
(ittage_interfaces.md; IT_MAX_TGT_WIDTH = 38). The
scheme -- target held in the ITTAGE tables, no
base+offset LUT -- was already correct here.
Stage labels converted from s0-s3 to p0-p3 throughout,
50 sites including p2_redirect and p3_redirect and the
RAS repair table. The stages are identical; only the
label changes (sc_decisions.md 3). Timing Methodology
Gap reworded to match.
Overview override chain annotated with stages:
uBTB (p1) -> FTB, TAGE (p2) -> SC (p3). The bare
"SC > TAGE > FTB > uBTB" was stage order written
without the labels, which fe_decisions.md 12 reads as a
contention ranking and rejects. With the labels it is
FE-3 supersession. The one real intra-stage rule, TAGE
over FTB direction within p2, is stated.
SC_NUM_MAIN_TBLS and SC_NUM_ALL_TBLS replaced by
SC_NUM_TABLES = 5. Neither name appears in
sc_decisions.md or sc_table_interfaces.md, and this
section already used SC_NUM_TABLES four lines below in
the sc_upd_idx / sc_upd_ctr declarations. The ST0-ST3
versus ST4 split that SC_NUM_MAIN_TBLS encoded is real
but is prose in sc_decisions.md 6, not a parameter, and
is restated as such here.
RAS checkpoint/restore "Policy TBD at rename/dispatch"
replaced by a pointer to ras_decisions.md 4.3 and 4.4.
The protocol is decided and built: pointer-only restore
of tosr/tosw/bos from the FTQ snapshot, no separate
flush path because a flush is a redirect (FE-14),
implemented as ras_restore_val /
ras_restore_snapshot in ras.sv with tb_ras coverage.
RAS-3 closed 2026-08-20. ras_decisions.md 4.4.2 lists
the stale OPEN markers that caused that item to be
re-raised repeatedly; this line was one more, and it
also named the wrong owner -- the History Module
section of this document already states that
speculative predictor state is owned by the BPC, not
rename/dispatch.
2026-09-19 session-071. Block width: the FETCH block is the L1I
line; the as-built aligned-base successor and branch PC
recorded against TD#125. Dual Prediction Mode: pos is
start-relative. Pipeline timeline: p2 and p3 redirects
restated as the published successor against the
cluster's own stage registers (FE-4).
2026-09-19 session-071. RAS section reduced to a summary and a
pointer; ras_decisions.md is its only home, and the
JALR hint table moved there.
2026-09-20 session-072. TAGE T1-T4 entry listed without EPC; now
cites tage_table_entry_formats.md. Loop Predictor: the
trust test is inside loop_pred (lp_pred_is_loop), not
in override control; the LP supplies direction only.
2026-09-20 session-072, second pass. the two remaining "override control"
statements on loop-predictor trust swept to
lp_pred_is_loop; spec_pop_addr swept to
ras_pop_addr_p2.
2026-09-20 session-072. D28: bp_structs_pkg.sv carries no s2 or s3
label; the conversion was verified session-070.
2026-10-08 session-076, PA-direct correction recording BP-121.
Block width: the aligned-base note brought to BP-110
(TD#125). Loop Predictor: status and TD#169. SC:
arbitration (D6, D13). ITTAGE: target 40b, VA[40:1]
(BP-111, TD#132). RAS: p3 reachability, push address.
Redirect Architecture: chained successors (D5, D15).
Dual Prediction Mode: p1 slots in position order
(D12). History Module: first taken slot (D16) and the
correction on rollback (D14).
fe_decisions.md
planning/arch/fe_decisions.md on GitHub
FILE: fe_decisions.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-15
CONTACT: Jeff Nye
Overview¶
This document holds front end decisions. It carries two kinds of content and they have different scopes.
The prose sections are the paths between the branch prediction cluster and the fetch target queue, sections 1 to 3 and 7 to 10, and the front end top, section 15.
The registries are front end wide and are not split: invariants in section 11 and, for the front-end top, section 15; technical debt in section 13, unresolved items in section 14. FE-15 to FE-18 are issued in section 15, beside the top they describe, and FE-13 follows FE-14 in section 11: the numbers are issue order, not document order. This read that the invariants are in section 11. Session-072. An FE, TD-FE or FE-U number may be issued for any front end subject, not only for the BPU and the FTQ.
The two paths¶
BPU to FTQ carries predictions. The FTQ allocates an entry on the initial prediction and issues a fetch from it. Later predictors correct that entry by redirect.
Correction and redirect are the same thing. A predictor at p2 or p3 may override the p1 prediction held in the entry, replacing the corrected slot's target and redirecting fetch to the new address. A redirect names one FTQ entry index and carries a corrected target per slot. Redirects supersede by stage order. The mechanism is section 3.
FTQ to BPU carries updates. On post-execute resolution the FTQ reads the metadata captured at prediction time and forms an update for each predictor named by the resolved branch type. Updates reach the predictors through per-predictor update queues.
Predictor internals are out of scope here, as is the RAM arbitration model. These sections state what each predictor contributes to the FTQ, when, and the handshakes that carry it.
Conventions¶
Stage labeling is p0 through p3 for prediction and u0/u1 for update.
One FTQ entry holds one PREDICTION block: FTB_BLOCK_BYTES, 32 bytes, beginning at any 2-byte address (ftq_decisions.md 4.7). A prediction block carries NUM_PRED_SLOTS predictions, one per prediction slot. The slots are the branch fields of one FTB block; see section 10.
A FETCH block is a different thing: FETCH_BLOCK_BYTES, 64 bytes, the unit the IFU reads from the L1I, which is one cache line held in the IFU line buffer (ifu_decisions.md TD-IFU-7). The IFU takes one prediction block per request and extracts it from the line it read (IFU-7, IFU-8). No RTL reads FETCH_BLOCK_BYTES; it is the L1I line size under a second name. The front end DELIVERS one prediction block per cycle (TD#133, ftq_ifu_interfaces.md 8 item 2); two per cycle would not be IFU-internal. The two sizes must not be collapsed, and "fetch block" is not a name for the 32-byte unit.
RULED session-071 (Jeff). This read "One FTQ entry holds one fetch block", and section 10 defined a fetch block as one 32-byte FTB block. The misuse had spread to most of the front-end documents and to RTL comments.
The rest of the front end¶
Each unit owns its own document and issues its own numbers. This document does not restate them.
IFU ifu_decisions.md
predecode dcd_decisions.md
instruction buffer ibuf_decisions.md
instruction TLB itlb_decisions.md
page table walker mmu_decisions.md (no L2 TLB now)
FTQ internals ftq_decisions.md, ftq_entry_formats.md
predictors one document per predictor
The L1I is specified in icache_decisions.md. Its RTL is the pacino copy of the cachegen emission at rtl/core/frontend/icache (cachegen_decisions.md CG-D1, built by BP-123); this read that it "is emitted by cachegen rather than written". FE-16 keeps it inside the front end top as a sibling of the IFU, per L1I-2.
1. Stages¶
p0 Indices and addresses presented to the RAMs. PC hash and
folded history available. RAS top of stack read.
p1 RAM outputs available. The initial prediction is formed. The
FTQ allocates an entry and issues a fetch.
p2 FTB result valid; branch type available. TAGE final. ITTAGE.
RAS push or pop executes.
p3 SC final.
u0 Update address and write data presented to the RAMs.
u1 RAM write completes.
Predictor stage assignments:
p0 RAS top of stack read
p1 uBTB, LP
p2 FTB, TAGE, ITTAGE, RAS push/pop
p3 SC
The FTQ never stalls waiting for a predictor later than p1. Every stage after p1 is a redirect source.
2. BPU to FTQ: The Initial Prediction¶
2.1 Selection at p1¶
The LP and uBTB are one-cycle predictors. NEITHER HAS AN SRAM. The
uBTB is combinational from pred_pc_p0: ubtb.sv derives index and
tag by continuous assign and produces every output field in one
always_comb reading a flop array, with no register in the path, so
the result is valid within the p0 cycle and the cluster registers it
(bp_arb_spec.md 7.1, ftq_bpu_interfaces.md 4). The loop predictor
is a registered counter array (sram_init.md). An earlier revision
said both used "two single port RAMs in each predictor"; that is
wrong for both, and section 7.3 of this document already said the
uBTB is combinational. Corrected session-070.
Both LP and uBTB support dual prediction, they will present two
predictions per cycle when requested. THE TWO PREDICTORS DIFFER IN
HOW. The uBTB's slots SHARE ONE LOOKUP: one lookup returns one entry
describing one 32-byte block, and the slots are that entry's br0 and
br1 fields (section 10, FE-10, ubtb_interfaces.md). The loop
predictor's slots ARE independent: its table is replicated as one
bank per slot (TI6) and a write to one bank cannot change another
(loop_pred_interfaces.md), as the next paragraph says.
An earlier revision said of both that the slots "share no resources and operate fully independently", which is the retired two-PC-range model and wrong for the uBTB. A session-070 revision then over- corrected to "THE SLOTS ARE NOT INDEPENDENT AND SHARE THE LOOKUP" for both, which is wrong for the LP and contradicted the paragraph below it. Corrected session-070.
The loop predictor was retrofitted to NUM_PRED_SLOTS in BP-091: every
prediction and update port carries a slot dimension and the internal
tables are per-slot banks (TI6). Its prediction output is named
pred_p1.
The remaining discussion focuses on a single slot for clarity, the decisions and operation of the 2nd slot are identical.
Both LP and uBTB outputs are valid at p1. There is a selection mux which choses the prediction to present.
lp_pred_is_loop set -> the LP supplies the direction
else ubtb slot valid -> the uBTB supplies the slot
else -> this slot carries no prediction
The LP has no valid output. lp_pred_is_loop is set only on a hit at confidence cnf == LP_CONF_LEVEL, tested inside loop_pred (loop_pred_interfaces.md Semantics); lp_hit alone does not qualify. The LP supplies a direction only, and the target comes from the uBTB entry (ftq_bpu_interfaces.md 4, which owns this mux). The uBTB slot valid is pred_p1[s].valid. This keyed the mux on an "LP output valid" and said both predictors assert a valid. Session-072.
The LP or uBTB p1 predictions are not sources for redirects since they both are the 1st prediction in the pipeline. Since BP-122 the LP also re-reads at p2, and that p2 direction can raise a p2 redirect (3.2, 3.3); the p1 LP direction is an early guess that p2 corrects.
When neither the LP nor the uBTB hits, the slot carries no prediction. The successor PC for that case is defined in section 2.4.
2.2 Returns¶
RAS SUPPLIES A TARGET only for return branch types; it is also
PUSHED by calls, which is an update rather than a prediction
(section 7.2, FE-U9, ras_decisions.md 2). This read "RAS is only
active for return branch types". Corrected session-070.
The RAS presents its
top-of-stack entry as the predicted target. THE TOP OF STACK IS READ
AT p0: ras.sv declares ras_tos_addr_p0 and ras_tos_valid_p0. The
cluster registers that value and applies it when the p1 selection mux
forms a RETURN slot.
The RAS does not participate in the uBTB/LP selection. It supplies the target for one branch type, the return, taken from its stack rather than from a prediction table.
The return branch type is available at p1 from the uBTB entry (ubtb_entry_t.br_type), so the RAS is engaged without waiting for the FTB branch-type classification at p2.
2.3 Allocation¶
The FTQ allocates an entry at p1, when the initial prediction is formed, and issues the fetch from it. Allocation is unconditional: an entry is allocated for every prediction block, including a block the p1 predictors miss. The p1 predictors are early in the pipeline; FTB, TAGE, ITTAGE, and RAS can each find or correct a branch at p2 or p3, and a redirect names an FTQ entry index, so the FTQ entry is allocated in p1 for a later stage to correct it. A p1 miss allocates an entry whose slots carry no taken prediction and whose successor is the fall-through address.
The FTQ entry index is the 6-bit index into the 64-entry FTQ. It
identifies one prediction block and is the value carried in branch_id. All
NUM_PRED_SLOTS predictions for that block occupy the one entry.
The entry written at p1 records the prediction and the architectural state it was made against (ftq_entry_formats.md 2), so the block can be restored on a later redirect (ftq_decisions.md 3).
The IFU-FTQ interface carries fetch requests and a predecode writeback. It is specified in ftq_ifu_interfaces.md.
2.4 Successor PC¶
The successor PC is the start PC of the next prediction block: the address fetched after this block. It is selected across the block's slots, priority-ordered top to bottom:
slot 0 valid and taken -> slot 0 target
slot 1 valid and taken -> slot 1 target
otherwise -> fall-through address
The fall-through address for the not-taken case arrives on the p1
output group as bpu_pred_pft_p1, one value per prediction, qualified
by bpu_pred_val_p1 (TD#108, BP-092). Before that port existed the
block end stayed inside the cluster and the FTQ had no source for it
on a not-taken block.
The FTQ writes that value into the allocated entry as
bp_ftq_entry_t.pft_addr (ftq_entry_formats.md 2). bpu_pred_pft_p1
is present only in the p1 cycle, and the selection above is
re-evaluated on every redirect, so the not-taken arm has to be read
back from the entry rather than resampled from the cluster.
Both slots are predicted at p1. The selection chooses which slot's target is the successor; it does not gate whether a slot is predicted.
The per-slot successor the redirect comparison uses follows the same order: chained from the highest slot down, and a slot after a taken slot is unreachable and raises no redirect (ftq_bpu_interfaces.md 6, BUILT by BP-121, D5 and D15).
The selection is re-evaluated whenever a redirect rewrites a slot.
2.5 Slot correction at p2 and p3¶
The p1 prediction is the uBTB and loop-predictor view. The FTB classifies the block at p2 and supplies the in-block position of each branch field. Those are corrections to the RECORD, and they are needed whether or not fetch has to be resteered.
The cluster therefore publishes its view of every slot again at p2, and once more at p3 with the SC direction applied:
bpu_slot_val_p2 bpu_slot_idx_p2 bpu_slot_p2 [0:NUM_PRED_SLOTS-1]
bpu_slot_val_p3 bpu_slot_idx_p3 bpu_slot_p3 [0:NUM_PRED_SLOTS-1]
Each group carries one bp_ftq_slot_t per slot, the same type the p1
group delivers. The FTQ overwrites the slot description of the named
entry with the latest group it has received.
THE GROUP IS NOT GATED ON A REDIRECT (FE-13). A redirect fires only
when the p2 successor differs from the p1 successor, and the case
that matters most does not qualify: a conditional branch the uBTB
missed and the FTB found, predicted not taken. Both views end the
block at the same address, no redirect fires, and without this group
the entry would keep br_type NO_BRANCH and pos zero for its whole
life -- so section 7.2 would form no update for it and no predictor
would ever be trained on that branch. See TD-FE-6.
A slot holding the block's jump field takes the jump field's own position, not a conditional field's, matching the lowest-free-slot placement rule of section 10.
p3 changes only taken, and pred_src when SC actually moved the
direction. SC corrects direction, not branch type, so br_type,
pos and target are carried through the p2 to p3 register
unchanged.
The port specification is ftq_bpu_interfaces.md section 4a.
3. BPU to FTQ: Redirects¶
Correction and redirect are synonymous terms. A later-stage predictor may change -- correct -- the prediction currently held in the FTQ entry. Every correction after p1 is a redirect. A redirect identifies one FTQ entry index and carries a corrected target per slot.
3.1 Interface¶
NO PREDICTOR DECLARES A REDIRECT PORT. INFRA-011 confirmed this across
all 140 ports of the eight top-level BPU modules, and the inventory
now stands at 141: session-071 added ubtb's blk_p1, making ubtb 6
(bpu_port_inventory.md Coverage). Session-072. A prior revision of
this section named <pred>_redir_val_<pN>, <pred>_redir_tgt_<pN> and
<pred>_redir_ftq_idx_<pN> as a per-predictor port group. No such
ports exist and none is planned.
The redirect is DERIVED at the bp_cluster boundary. The cluster compares a predictor's stage output against the prediction it formed at p1 and carried forward in its own stage registers (FE-4). bp_cluster does not read the FTQ.
The groups are named by STAGE, not by predictor:
bpu_redir_p2 bp_redirect_t [0:NUM_PRED_SLOTS-1]
bpu_redir_idx_p2 [FTQ_IDX_BITS-1:0]
bpu_redir_p3 bp_redirect_t [0:NUM_PRED_SLOTS-1]
bpu_redir_idx_p3 [FTQ_IDX_BITS-1:0]
bp_redirect_t is the per-slot payload and carries target_pc and
valid. The array is per slot; the index is scalar alongside it,
because both slots occupy one prediction block, which is one FTQ entry.
p2 carries the FTB, TAGE, ITTAGE and RAS corrections. p3 carries the SC correction.
The comparison reduces both views of a slot to ONE quantity, the address fetched after that slot. Two not-taken views therefore compare equal and raise no redirect. The p1 operand is formed at p1 from the p1 view only: the slot target when taken, the uBTB fall-through on a hit, the LOOKUP PC plus FTB_BLOCK_BYTES on a miss.
Not the block-aligned PC. Prediction blocks are unaligned: a block begins at the lookup PC, which is a taken branch target and so any 2-byte address (ftq_decisions.md 4.7, ifu_decisions.md IFU-6). A miss does not resync the stream to a 32-byte boundary (bp_cluster.md, Block width). An earlier revision said block-aligned and predates the session-069 ruling.
The p3 comparison is against the p2-corrected value, not the raw p1 prediction, so a p3 redirect fires only when SC changes what the cluster published at p2.
Every p2 and p3 comparison is qualified by branch_id equal to the FTQ
index held in the matching stage register, so a queued or
back-pressured response cannot be compared against the wrong entry. The
redirect logic assumes no fixed predictor latency.
The port specification is ftq_bpu_interfaces.md section 6.
3.2 Sources¶
p2 FTB, TAGE, ITTAGE, RAS, LP (its p2 re-read, BP-122)
p3 SC
The uBTB is not a redirect source since it forms the initial prediction. THE LP IS ONE SINCE BP-122: its p2 re-read (pred_p2) supplies a trusted direction at p2, which can change the successor and so raise a p2 redirect (3.3). This read "The uBTB and the LP are not redirect sources".
3.3 Direction and target¶
A redirect's payload is always a target (section 3). The FTB, RAS, and ITTAGE produce a target directly; TAGE and SC produce a direction, which then selects a target.
The FTB identifies the branch type of each slot at p2. That type selects the target source for the slot:
return RAS ras_pop_addr_p2
indirect ITTAGE
conditional direction from TAGE, then SC (see below)
direct unc. FTB branch target
Return and indirect are different branch types. The RAS and ITTAGE are never both consulted for the same branch.
For a conditional branch, TAGE (p2) then SC (p3) supplies the direction, which selects the target:
taken -> FTB branch target
not taken -> fallthrough address
The branch target and the fallthrough address both derive from the FTB result. The derivation is an FTB-internal operation with a description found in the FTB documentation. The contents of this documentation is not necessary to follow the remaining discussion.
TAGE overrides the FTB direction on conditional branches only. At p3 the SC may override the TAGE direction; the FTB result is still available, so both target candidates are present when the SC direction selects between them.
A TRUSTED LOOP PREDICTION OUTRANKS ALL THREE. RULED session-076 (Jeff, BP-122 decision 2), BUILT by BP-122: a trusted p2 loop direction is the slot's direction at p2, over TAGE, and SC does not override it at p3. The direction ranking is LP (trusted) > SC > TAGE
FTB. Before this ruling TAGE and SC overrode the LP's p1 direction, so a correct loop exit could never remove the mispredict. As built, the trusted LP direction also stands over an FTB fast-path direction (ftb_confidence_override_rules.md 4.3).
A redirect rewrites its slot. The block's successor PC is then re-derived across all slots per section 2.4.
3.4 Supersession¶
A redirect from a later stage supersedes any earlier redirect for the same FTQ entry index and the same slot. The FTQ tracks which redirects are stale and discards them.
Redirects do not cross slots. A p3 redirect on slot 1 does not discard a p2 redirect on slot 0 of the same entry; the two correct different branches.
A p2 redirect and a p3 redirect for one entry index and slot can be in flight in consecutive cycles, and the fetch stream started by the p2 redirect is already speculative when the p3 redirect arrives. The FTQ does not compare targets to settle this. The later stage wins for the entry index and slot it names.
4, 5, 6. MOVED¶
The FTQ entry formats, the entry lifetime, and the checkpoint and restore behaviour left this document on 2026-08-19. They are FTQ internals; this document is the BPU <-> FTQ boundary.
was 4.1 fast path bp_ftq_entry_t -> ftq_entry_formats.md 2
was 4.2 slow path bp_ftq_meta_t -> ftq_entry_formats.md 3
was 4.2.1 overload scheme -> ftq_entry_formats.md 3.1
was 4.3 read rates -> ftq_decisions.md 1
was 5 entry lifetime -> ftq_decisions.md 2
was 6 checkpoint and restore -> ftq_decisions.md 3
Section numbers 4, 5 and 6 are retired rather than reused, so every "section 7.2" and "section 2.4" reference in this document and in ftq_bpu_interfaces.md still resolves.
The registries stay here, as the Overview says: invariants in section 11 and, for the front-end top, section 15; technical debt in section 13, unresolved items in section 14. They cover the front end as a whole and are not split. This read that the invariants are in section 11 alone, against FE-15 to FE-18 in section 15. Session-072.
7. FTQ to BPU: Updates¶
7.1 Trigger¶
Updates are triggered at post-execute resolution. Updates do not wait for retirement.
There is one update channel per prediction slot, upd_ch[0] through upd_ch[NUM_PRED_SLOTS-1]. Each channel carries both conditional and indirect resolution.
7.2 Formation¶
On resolution of a branch at FTQ entry index k, slot s, the FTQ
reads slot s of bp_ftq_meta_t[k] from the slow-path SRAM, and reads
pc and slot s br_type from the fast-path entry.
The slot's br_type determines the set of predictors updated. It is
the FTB classification, placed in the entry by the p2 slot correction
group (section 2.5), not the p1 uBTB view (TD-FE-6):
conditional uBTB, LP, FTB, TAGE, SC
indirect uBTB, FTB, ITTAGE
return uBTB, FTB, RAS
direct unc. uBTB, FTB
direct call uBTB, FTB, RAS
indirect call uBTB, FTB, ITTAGE, RAS
return-call uBTB, FTB, RAS (pop, then push)
no branch none
The last four rows close FE-U9, session-075 (Jeff). RETURN_CALL does not train ITTAGE: its target comes from the RAS pop, and ITTAGE is never consulted for a RAS-predicted branch (section 3.3), so training it would fill an entry nothing reads.
Every row is built, BP-119. The return-call row was not met before it (found by BP-118, TD#152), and before it only the FTB and RAS rows trained in the front-end top, because no unit formed the per-predictor payloads (TD#151; now ftq_upd_conv, ftq_bpu_interfaces.md 8).
A BRANCH ITS FTQ ENTRY DOES NOT HOLD. On its first execution a conditional branch or a JALR the FTB does not hold has no slot in its FTQ entry: the p2 slot correction carries only what the FTB returned, and predecode writes a slot only on a structural mispredict. RULED session-075 (Jeff), built by BP-119: its resolution is placed in a slot of its entry in program order (the ftq_ifu W1 rule) and trains every predictor of its row from that slot's prediction-time metadata, the FTB allocating on a miss. Before this ruling such a resolution formed no update, so the FTB never learned the branch and TAGE, SC, LP and ITTAGE never trained (ftq_entry_formats.md 3.1).
ITEM C (Jeff, 2026-10-18; built by BP-139). A placed resolution whose slot holds another valid branch trains the uBTB and the FTB only: the slot's prediction-time metadata is the other branch's (TAGE is indexed by block start per slot), so TAGE, SC, LP and ITTAGE are suppressed, as R2 does for a type disagreement (ftq_entry_formats.md 3.1). It replaces the paragraph above for that case only. fd09 at one slot: the back edge trained into B's TAGE entries on 101 of 256 iterations before BP-139, 0 after.
TAGE and SC predict direction and are updated only for conditional branches. ITTAGE is updated only for indirect branches. RAS IS UPDATED BY BOTH: a return pops it and a call pushes it, and INDIRECT_CALL updates ITTAGE for the target and the RAS for the return address (FE-U9, session-061 ruling). This read "RAS is updated only for returns". Corrected session-070. The SC is excluded when disabled by its CSR bit (FE-U6).
A predictor that missed at prediction time is still updated. Each
predictor derives allocate-versus-train from its own bp_ftq_meta_t
slice and the resolved outcome; that decision is predictor-internal.
The update path uses the metadata captured at predict. It does not recompute predictor state from the PC or the history.
EXCEPT THE LOOP PREDICTOR. RULED session-075 (Jeff), after BP-121, reversing BP-121 decision 6: the loop predictor's update reads the entry before writing it, which its table allows because it is flops, not RAM. BUILT by BP-122 (TD#169). loop_pred_interfaces.md is the home of the rule.
A slot off the executed path never resolves and forms no update.
7.3 Enqueue¶
Each RAM-based predictor EXCEPT THE FTB has an update queue in front of it. The queue is a FIFO with two write ports, so up to two updates may be enqueued per cycle. Two write ports serve NUM_PRED_SLOTS = 2 update channels.
THE FTB HAS NO QUEUE AND NO READY. It has a single update port, scheduled by ftq_ftb_sched outside the predictor: ftq_decisions.md 5.7, ftb_interfaces.md 2.5, ftq_bpu_interfaces.md 8. This paragraph said "each RAM-based predictor" without the exception. Corrected session-070.
Updates reach a predictor in resolution order. This is an out-of-order machine and resolution order is not program order. The FIFO is not reordered.
The uBTB is combinational and has no queue; it updates immediately. The RAS is register-file based and has no queue; its update is snapshot-based, described in section 9.
8. Handshakes¶
The RAM arbitration model is specified in bp_arb_spec.md and is out
of scope here. Three handshakes cross the BPU/FTQ boundary.
Prediction issue. The FTQ can be back-pressured. A prediction request is stalled. When the FTQ cannot accept the uBTB output, the uBTB holds its output stable.
Update enqueue. The FTQ presents upd_val and upd_inp per
channel. The update queue asserts upd_rdy when it accepts. When the
queue is full, upd_rdy deasserts and the FTQ holds valid until
accepted.
Prediction delivery. The predictor presents pred_rdy when its
result is valid. The TAGE result is consumed by both the FTQ and the
SC.
consumer_ready IS SC's, NOT THE FTQ's. It is an input port on
tage.sv and is driven in bp_cluster.sv from SC state alone,
~sc_enable | (sc_ready & ~w_sc_grant_upd): it says whether SC can
take the TAGE p2 result this cycle. The cluster drives it rather
than sc.sv because deriving it from tage_pred_rdy_p2 would close a
combinational loop. An earlier revision of this paragraph named the
FTQ, and bp_arb_spec.md 4.7 named either. Both corrected
session-070 against the RTL.
A prediction may be granted ahead of a pending update to the same RAM entry, and reads pre-update state. The potential accuracy loss from the stale prediction state is accepted.
9. RAS¶
Only the FTQ-facing RAS behavior is stated here. RAS internals are in
ras_decisions.md.
The RAS is register-file based. It has no prediction queue, no update queue, and no arbiter.
p0 top-of-stack read. ras.sv declares ras_tos_addr_p0 and
ras_tos_valid_p0. The cluster registers the value and applies
it at p1 as the predicted target for a return (section 2.2).
It is NOT the section 3.3 entry: that table selects at p2,
where the return target is ras_pop_addr_p2.
p2 push or pop executes once the FTB branch type confirms a call
or a return. Participates in the p2 redirect.
bp_ras_snapshot_t is written into the FTQ entry at p2 for EVERY
valid block, whether or not the block operated on the RAS: the state
after both slots' operations, carried on ftq_bpu_interfaces.md 4c
(ras_decisions.md 4.2). A block with no call or return records the
unchanged state. On a misprediction or flush the RAS is restored from
the snapshot in the entry the redirect names (ftq_backend_interfaces.md
5 D2). This read "checkpointed into the FTQ entry at the time of the
call or return that updated the RAS". Session-071.
One snapshot per FTQ entry is sufficient under dual slot. A RAS operation is a call or a return, both taken branches, so one in slot 0 ends the block before slot 1 is reached. At most one RAS-operating INSTRUCTION therefore occurs per block, and one snapshot covers it -- including the DCD-11 JALR that pops and then pushes, since both happen at one position. The cluster enforces this by gating p2 RAS operations on reachability across slots (FE-11).
RAS flush behavior is CLOSED: a flush restores the RAS by the same pointer restore as any redirect (ras_decisions.md 4.4). There is no flush event at all -- FE-14. TD #96, G24 and IC-FTB-07 are closed.
10. Prediction Slots¶
NUM_PRED_SLOTS parameterizes the number of prediction slots and the
number of update channels, upd_ch[0] through upd_ch[NUM_PRED_SLOTS-1].
One FTQ entry holds all NUM_PRED_SLOTS predictions for one prediction block.
A prediction block is one 32-byte FTB block (FTB_BLOCK_BYTES). It is not the fetch block; see Conventions. This read "A fetch block is one 32-byte FTB block". Session-071. Both slots are predicted from one FTB lookup: slot 0 is the block's first branch field, slot 1 the second. The slots are not two PC ranges; they are the two branch fields of one block (ftb_decisions.md 2.1, 2.3).
The uBTB follows the same model. BP-086 rewrote ubtb.sv to a single
lookup returning one entry that describes one block and supplies both
slots; the pred_pc_p0 + 32 slot-1 lookup is retired.
dual_pred_en, when clear, gates the second prediction slot off at
runtime. It does not change the structure: the slots and the channels
exist either way.
A BRANCH NO SLOT CARRIES (BP-139, option A, ruled by Jeff 2026-10-18; BP-138 D1 option b was the jump case). Slot 0 carries the FTB's br0, a higher slot br1, and the jump the lowest slot with no conditional. When the FTB reports a branch that no slot carries, the block ends at the PC of the first such branch: the p2 fall-through, bpu_blk_pft_p2, is that PC (w_cut_p2, w_cut_pos_p2). The next block starts there and places the branch in slot 0. At one slot this is br1, or the jump behind br0 when there is no br1; at two slots, a jump behind two conditionals. Every branch the FTB reports is predicted at every slot count.
A BACKSTOP SINCE BP-140. The FTB stores at most NUM_PRED_SLOTS branches per entry and ends the entry at the first branch it does not keep (the split at update, ftb_decisions.md 3), so from an entry it wrote it never reports a branch no slot carries, and the block ends at that PC by the stored end. The cut stays, unchanged, for an entry that reports more (none in tb_fe_top: 0 cut groups at both slot counts, 280 / 2409 before). FD-23 of examples/fe_demo, written for the cut, was re-pointed at the split by DOC-007; it reports the cut count, 0. w_jmp_cut_p2 is now read by nothing.
11. Invariants¶
Proposed numbering. Stated here for the first time; not carried from
bp_cluster.md or bp_arb_spec.md.
FE-1 The FTQ allocates an entry and issues a fetch from the p1
prediction. It never waits for a predictor later than p1.
FE-2 The initial prediction is formed by selection at p1 between
the LP and the uBTB, per slot. Every correction after p1 is
a redirect naming an FTQ entry index and a slot.
FE-3 A redirect from a later stage supersedes an earlier redirect
for the same FTQ entry index and slot. The later stage wins
by stage order. The FTQ does not compare targets to settle
it. Supersession does not cross slots.
FE-4 The redirect comparison is made at the cluster boundary,
between a predictor's stage output and the prediction the
cluster formed at p1 and holds in its own stage registers.
No predictor is compared against another predictor, and the
cluster does not read the FTQ.
FE-5 No prediction is dropped, and no update is dropped except
as FE-5a permits. A full prediction path stalls fetch. A
full update queue stalls the update path.
FE-5a AMENDMENT 2026-08-19. An FTB update may be dropped on
collision, and ONLY when it is low value: the FTB hit at
predict and the branch was predicted correctly, so the
update is a routine conf step on a counter already in the
right direction. An update that allocates an entry or
corrects a mispredict is never dropped; where dropping one
would otherwise be required the FTQ backpressures
resolution instead. The FTB update port is scalar and the
8-issue target resolves more than one branch per cycle, so
without this the FTB training rate would stall the backend.
Applies to the FTB path alone. Every other predictor takes
one update per slot per cycle and keeps FE-5 unqualified.
ftq_decisions.md 5.7, IC-FTB-09.
FE-6 Updates reach a predictor in resolution order. The update
queue is a FIFO and is not reordered.
FE-7 The FTQ history checkpoints are pointer-only and block
granular, one per FTQ entry.
FE-8 The update path uses metadata generated during predict. The
set of predictors updated is determined by the slot's
br_type.
FE-9 A prediction granted ahead of a pending update to the same
RAM entry reads pre-update state. The prediction accuracy
loss from the stale read is accepted.
FE-10 One FTQ entry holds one prediction block and all NUM_PRED_SLOTS
predictions for it. The slots are the branch fields of one
FTB block. The slot is the array index; no slot identifier
field is carried. The index is ORDERED as of IC-FTB-16:
slot 0 is the block's first branch in program order.
THAT HOLDS AT p1 AS WELL. The uBTB does not reorder its
slots (ruled session-073, ubtb_interfaces.md), so a uBTB
slot 1 can lie below slot 0. bp_cluster swaps the two p1
slots into position order. BUILT by BP-121 (D12); before
it such a block was sent to the later branch's target.
FE-11 At most one RAS-OPERATING INSTRUCTION occurs per block. A
RAS operation is a taken branch, so one in slot 0 ends the
block before slot 1 is reached. One RAS snapshot per FTQ
entry is therefore sufficient.
THAT INSTRUCTION MAY PERFORM TWO OPERATIONS. A JALR whose
rd and rs1 are both link registers and are not equal is a
pop followed by a push (dcd_decisions.md DCD-11). The
snapshot conclusion is unaffected: two operations at one
position need no second recovery point. An earlier
revision said at most one RAS OPERATION per block, which
excluded that case. Corrected session-069;
ras_decisions.md 6.2 RAS-DS1.
FE-12 No predictor declares a redirect port. Redirects exist only
as cluster-derived, stage-named groups (section 3.1).
FE-14 A FLUSH IS A REDIRECT. The front end has no flush event
distinct from a redirect and no flush protocol. Clearing a
predictor is done by WITHHOLDING ITS STAGE VALID, not by
asserting a flush: a stage whose valid is low does not
advance, so nothing downstream of it acts. bp_cluster
already works this way -- w_any_redir_p2 / w_any_redir_p3
and the FTQ arm of BP-102 clear the stage valids, and no
predictor is told anything.
Corroborated by XiangShan, which has NO flush port on ANY
predictor: BasePredictorIO carries s0_fire..s3_fire,
s2_redirect, s3_redirect, update and redirect, and nothing
else. BPU.scala 383 derives its stage flushes from
redirect_req.valid and they never leave the BPU.
CONSEQUENCE. ftb_flush_px and ras_flush_val/_snapshot are
redundant. They are LEFT IN PLACE, unread or nearly so,
and are not evidence of unfinished work. See
ras_decisions.md 4.4.2 for the RAS half and
ftb_interfaces.md 2.6 for the FTB half.
AS BUILT by BP-121 (D8, D9), which found the squash was
not applied: blocks younger than a redirect still
performed RAS operations. The block at p1 is squashed by
any rollback. The block at p2 survives only its own p2
redirect; a squashed block at p2 performs no RAS
operation (ras_p2_keep). The RAS restore is not applied
when the rollback is the cluster's own p2 or p3 redirect,
because the redirecting block's own operation stands
(ras_decisions.md 4.3).
FE-13 The cluster publishes its view of every slot on every
prediction, at p2 and again at p3, not only when a redirect
fires. A redirect says fetch must be resteered; the slot
correction group says what the entry must record. The two
are different questions and fire at different rates.
FE-19 A FETCH ADDRESS IS 41 BITS AND ITS HIGH BITS ARE CHECKED
BEFORE IT NARROWS. VA_WIDTH is 41 because H is mandatory
through Sha, MMU-20 makes the G-stage Sv39x4, and Shvsatpa
requires vsatp to support Bare. With V=1 and
vsatp.MODE=Bare the fetch PC is a guest physical address of
up to 41 bits. Sv39x4 requires bits 63:41 to be zero or the
access guest-page faults.
The backend computes a JALR target with 64-bit arithmetic
and may produce a PC with bits 63:41 set. That must fault.
Narrowing it to VA_WIDTH discards the evidence, so
bkend_ftq_redir_pc is checked WHERE IT IS FORMED, in the
backend, before it narrows. The front end does not
re-derive this and has no means to.
HOW A REJECTED ADDRESS IS SIGNALLED IS NOT DECIDED, FE-U11.
An earlier draft of this invariant said the FTQ receives a
redirect "already marked malformed". No such marking
exists: the redirect group of ftq_backend_interfaces.md 5
carries four cause values, MISPREDICT, TRAP, REPLAY and
UNSPEC, and none of them means this. Either the backend
traps before forming the redirect at all, or a fifth cause
is added. FE-U11.
This is not new with 41 bits. The same hole exists at 40
today; two-stage translation moves the boundary from 39 to
41 and makes it visible.
WITHIN 41 BITS, LEGALITY IS THE ITLB'S. THREE REGIMES, not
two:
- translation on, V=0 with satp.MODE=Sv39 or V=1 with
vsatp.MODE=Sv39: a legal address has bits 40:39 equal to
bit 38.
- V=1 with vsatp.MODE=Bare: the fetch PC is a guest
physical address and all 2^41 patterns are legal, which
is why VA_WIDTH is 41.
- V=0 with satp.MODE=Bare: THE FETCH ADDRESS IS PHYSICAL.
Svbare is mandatory (rva23-profile.adoc), so this regime
is reachable, and it is the one the machine resets into.
No sign-extension rule applies and nothing translates;
the address is bounded by pa_bits = 36
(icache_decisions.md L1I-20), and an address above that
is out of implemented physical space, which the PMP and
PMA checks answer with cause 1 rather than a page fault
(MMU-10, MMU-12). V=1 with both vsatp.MODE and
hgatp.MODE Bare reaches physical space the same way.
The same value is legal in one regime and a fault in
another, and only the ITLB holds V, satp.MODE and
vsatp.MODE. MMU-16 has cause 12 and cause 20 for the
translating regimes and cause 1 for the third. No predictor
and no FTQ stage evaluates this.
This enumeration carried two regimes and attributed the
sign-extension rule to the whole of V=0, which is wrong
wherever satp.MODE is Bare. Session-072.
CONSEQUENCE FOR PREDICTORS. Predictor storage need not
represent every address exactly. An FTB tag that does not
cover bit 40 aliases, and is caught by predecode at the
block end. MMU-14 already keeps speculation out of
non-idempotent regions. Architectural addresses -- pc,
pft_addr, target_pc, ftq_resolve_t.target,
bkend_ftq_redir_pc, RESET_VECTOR -- may not truncate.
FTB_TAG_BITS is pinned at 26 on that basis, TD#122.
THE ITTAGE STORES THE WHOLE TARGET. Since BP-111 (TD#132)
its target field is VA[40:1], IT_MAX_TGT_WIDTH is 40, and
no site infers a target bit. This read that
IT_MAX_TGT_WIDTH was pinned at 38 and that the ITTAGE
reconstruction zero-extended bits 40:39, which no
extension rule could get right for both a V=1 guest
physical address and a V=0 Sv39 kernel address.
Session-074.
NOT FE-13. FE-13 republishes the cluster's own view of the
block, which on an alias is the aliased one, so it cannot
detect its own error. Predecode reads the fetched bytes and
is the independent check: ftq_ifu_interfaces.md 6 and 7.
POINTER MASKING DOES NOT REACH THIS INVARIANT. Ssnpm is
mandatory in RVA23S64, so it is fair to ask whether bits
40:39 are masked. They are not. The ratified Pointer
Masking specification v1.0 applies the ignore
transformation to explicit memory accesses only -- loads,
stores, atomics, FP loads and stores -- and states it does
NOT apply to implicit accesses such as page-table walks or
instruction fetches. Every address this invariant covers is
a fetch address, so Ssnpm has no front-end consequence.
RECORDED SO IT IS NOT RE-RAISED. A session-070 draft of
this invariant claimed the opposite, sourced to the J
extension working draft, whose discussion of masking the
two extra Sv39x4 GPA bits under vsatp.MODE=Bare concerns
DATA accesses. It was applied to the fetch path in error.
12. Source Document Conflicts¶
There is a known difference in pipe stage labeling. RESOLUTION: all documents will transition to the p0/p1/p2/p3 labeling. This document uses it.
bp_arb_spec.md contains errors. Where this document departs from it,
it does so deliberately:
2, 7.1 uFTB output presented at p0 -- AS A PORT NAME AND AN
ALLOCATION POINT, which is the error. The uBTB result
IS combinationally valid within the p0 cycle (7.1 is
cited for exactly that in section 2.1 of this document
and in ubtb_interfaces.md Timing); what is wrong is
treating p0 as the stage at which the prediction is
FORMED and the FTQ allocates. Session-070: the two
readings were being confused, this entry being read as
rejecting 7.1 outright.
RESOLUTION: the initial prediction is formed at p1 and the
FTQ allocates there. This entry said bp_arb_spec.md 7.2
refers to "the uBTB p1 prediction"; 7.2 contains no such
text. Session-071.
2, 7.2 The RAS top-of-stack read at p0 called "the initial p0
prediction", and in section 2 the RAS said to drive the
FTQ directly at p0.
RESOLUTION: the p0 TOS read is an INPUT to the p1
prediction. The cluster registers it and applies it when
the p1 selection mux forms a RETURN slot (section 2.2).
The RAS drives no FTQ port at p0 and forms no prediction
of its own. Session-071.
2, 5.2 LP listed as RAM-based, with a prediction queue, update
queue and credit arbitration.
RESOLUTION: the LP has no SRAM; loop_pred.sv is a
registered counter array (sram_init.md) and declares no
PQ, UQ or arbiter. bp_arb_spec.md section 2 marks the
column NO* and 5.2 is retained only in case the LP is
given a RAM. Added session-072; bp_arb_spec.md 5.2 had
flagged the omission since session-070.
2, 3.4 LP listed as a redirect source (lp_redir_val_p2).
RESOLUTION: the LP is not a redirect source. It is selected
against the uBTB by mux at p1. lp_redir_val_p2 does not
exist. No predictor declares any redirect port (FE-12).
3.3 "SC > TAGE > FTB/LP > uFTB/RAS" presented as an override
priority.
RESOLUTION, NARROWED session-070. The chain as written
mixes two quantities and only one of them is ranked.
DIRECTION IS ONE QUANTITY and IS ranked. The FTB submits a
direction for every valid conditional (conf MSB on
ftb_brI_taken_p2), TAGE supersedes it at p2, SC supersedes
TAGE at p3: SC > TAGE > FTB on direction. Section 3.3 of
this document says so, and
ftb_confidence_override_rules.md 4.3 and 8 are the owning
rules. Suspended per branch when ftb_fastpath_p2 fires,
where the FTB direction stands and neither TAGE nor SC
overrides it, though both are still requested and trained.
EVERYTHING ELSE IS NOT RANKED. Targets are selected by
branch type -- RAS for a return, ITTAGE for an indirect
with the FTB target on an ITTAGE miss, FTB otherwise --
and the uBTB and LP at p1 produce a whole prediction that
a later stage supersedes. Those do not contend and there
is no ordering among them beyond stage order, FE-3.
AN EARLIER REVISION of this resolution read "there is no
priority chain. These predictors do not produce the same
quantity and do not contend." That reason is true of LP,
uFTB and RAS and false of SC, TAGE and FTB, which all
produce a direction, so the resolution contradicted
section 3.3 of this same document. Narrowed rather than
withdrawn: the wider chain is still rejected.
3.3 "ITTAGE (p2) > RAS (p0)" presented as an override chain.
RESOLUTION: there is no chain. br_type selects the RAS for
a return and the ITTAGE for an indirect. The two are never
both consulted for one branch.
4.4, 6.2 The update queue producer described as commit. 6.2 was
added session-071; it carried the same statement with no
annotation.
RESOLUTION: the producer is post-execute resolution. The
two write ports and the backpressure behavior are retained
as written.
4.4 Updates described as program-order.
RESOLUTION: this is an out-of-order machine. Updates are
enqueued and delivered in resolution order (FE-6).
naming uFTB.
RESOLUTION: the predictor is the uBTB. This document uses
uBTB throughout.
Prior revisions of this document assigned the two prediction slots to fixed PC ranges (slot 0 pred_pc+0:31, slot 1 pred_pc+32:63), citing G8 and G17. That split does not apply to the FTB. NOR DOES IT APPLY TO TAGE OR ITTAGE ANY MORE: tage_interfaces.md TI3 has slot 1's PC supplied on tage_pred_inp_p0[1].pc and records pred_pc+32 as an error that was removed. This paragraph called it "the TAGE/ITTAGE bundle split", which sent the reader to a convention TAGE disowns. There is no pred_pc+32 split anywhere. Corrected session-070; the FTB conclusion below is unchanged.
The FTB prediction block is one 32-byte block and one FTB lookup supplies both predictions (ftb_decisions.md 2.1, 2.3); the two slots are the block's two branch fields, not two PC ranges. Section 10 now follows ftb_decisions.md, and BP-086 removed the retired model from ubtb.sv.
13. Technical Debt¶
TD-FE-1 CLOSED 2026-08-19. The IFU interface is specified in
planning/interfaces/ftq_ifu_interfaces.md. Section 2.3 of
this document referenced the gap and now names the file.
The predecode writeback forms NO predictor update: FE-8
keeps update formation post-execute, and a second
producer in a different order would break FE-6. The
writeback is the third correction of a slot, after the p2
and p3 slot correction groups.
The three entry fields it left open are now decided:
ftq_entry_formats.md 4 adds wb_rcvd and fault as flop
vectors outside both SRAMs, and rejects request-issued
as a second encoding of fetch_ptr. Nothing of TD-FE-1
remains.
TD-FE-8 CLOSED. A predecode writeback in flight when its entry
is squashed and its index reallocated arrived after the
new allocation cleared the status bits, and set them on
the WRONG use of that index.
ftq_decisions.md 5.6 solves the same problem for cluster
responses with a four-deep in-flight shadow, and that
mechanism does not transfer: it works because the
cluster's stage registers advance unconditionally, so
the shadow shifts in lockstep. IFU latency is neither
fixed nor bounded -- an ICache miss makes it arbitrary
-- so there is no stage count to shadow.
ftq_ifu_interfaces.md 5 has the IFU discard what it
holds for flushed entries, which covers everything
except a writeback already presented in the flush cycle.
Whether that race is real depends on the IFU's flush
timing, which is not specified.
THE FIX, as taken: one generation bit, ftq_ifu_gen out
with the request and ifu_ftq_pdwb_gen back on the
writeback, TOGGLED on each allocation, held in a third
flop vector beside wb_rcvd and fault. A writeback whose
tag does not match is dropped entirely.
A toggle rather than the pointer's wrap bit: a rewind can
reallocate an index within one wrap, where a wrap-derived
value does not discriminate. ONE bit is sufficient
because the IFU flush BOUNDS the stale writebacks in
flight to one per flush, not because of the encoding --
if that contract changes the width must be revisited.
The 5.6 rejection of carried wrap bits does not apply --
it was rejected for widening FTQ_IDX_BITS at every
bp_cluster port and in three predictor metadata structs,
and the IFU path touches none of those.
ftq_entry_formats.md 4.4, ftq_ifu_interfaces.md 6.1.
TD-FE-2 CLOSED. bp_ftq_meta_t field overloading. Resolved in
ftq_entry_formats.md 3.1: a two-arm packed union, u.cond
holding
tage, sc and lp, u.ind holding ittage, with ftb outside
the union. The member is chosen by
bp_ftq_slot_t.br_type; there is NO wr_br_type
discriminant -- it was dropped 2026-08-19 as redundant.
421b -> 278b per slot. The slot dimension is unaffected:
the union is inside bp_ftq_meta_t and the array is still
declared at instantiation.
IT IS DEFINED AND DEFERRED, NOT APPLIED. Section 16 of
this document, ftq_entry_formats.md 3.1, ftq_decisions.md
6 and the PROJECT_STATUS ftq_meta.sv row all say so, and
G10 still lists the overload as outstanding. "CLOSED"
here means the SCHEME is decided.
This entry read "420b -> 280b per slot" with a
wr_br_type discriminant. Both were superseded on
2026-08-19; ftq_bpu_interfaces.md 10 item 17 carried a
third pair, 420b -> 277b. ftq_entry_formats.md 3.1 is
the owner and gives 421b -> 278b. Corrected
session-070.
TD-FE-3 bp_ftq_entry_t.pc and per-slot target are VA_WIDTH bits.
REVERSED session-070, TD#122. This entry read that 39
bits suffice because RVA23 mandates C so bit 0 of an
instruction address is always zero, and that 39 was the
floor. That was computed against a 40-bit sign-extended
Sv39 address. VA_WIDTH is 41: the fetch PC may be a
41-bit guest physical address under V=1 with
vsatp.MODE=Bare, FE-19. The floor is therefore 40, as
addr[40:1], not 39.
The reduction to 35 remains unavailable for the reason
recorded in session-069: it assumed a prediction block always
begins on an FTB_BLOCK_BYTES boundary, and blocks are
unaligned (ftq_decisions.md 4.7, ifu_decisions.md IFU-6).
Any move to 40 is an ENCODING change, from addr[40:0] to
addr[40:1], not a width trim, and every producer and
consumer changes with it. Held at 41 until the design is
working; revisit at the optimization step, together with
the width of bp_redirect_t.target_pc, which carries the
same quantity. The per-slot target is replicated
NUM_PRED_SLOTS times, so the saving scales with the slot
count.
To be merged into the project tech debt list.
TD-FE-4 bp_ftq_slot_t.pred_src has no functional consumer. Update
fan-out is determined by br_type (section 7.2); redirect
supersession is by stage and slot (section 3.4); each
predictor derives its own training decision from its
bp_ftq_meta_t slice. The field is retained for diagnostic
attribution of which predictor supplied the fetched
prediction, and for performance counters. Nothing
functional reads it. It is now replicated per slot.
Removal requires cleanup outside this document:
ftq_entry_formats.md section 2 lists pred_src as the
predictor that won, with no consumer; bp_structs_pkg.sv
carries
the field and its encoding. Remove the field and its enum
when both are updated.
To be merged into the project tech debt list.
TD-FE-7 CLOSED by BP-102. bp_cluster derived its bp_history
rollback entirely from its own p2 and p3 redirects and
declared no input by which the FTQ could request one. The
RAS could be restored on a backend mispredict, because
ras_restore_val is an input, but the history rollback
could not be triggered at all.
THE STATE WAS NOT MISSING. bp_history.sv holds the full
checkpoint array, ckpt_gptr and ckpt_pptr of FTQ_DEPTH
entries indexed by FTQ index, and rolls back by reading
it. Every checkpoint the machine needs was already inside
the cluster. What was missing was the TRIGGER: for a p2
or p3 redirect the cluster knows the index from its own
stage registers, but for a backend redirect the index is
known only to the FTQ and no port carried it in.
The fix, as built: two input ports, ftq_rollback_val and
ftq_rollback_idx -- a valid and an FTQ_IDX_BITS index, no
history data -- ORed into the existing rollback with
priority over the cluster's own, since an architectural
correction outranks a speculative one. bp_history is
unchanged.
THE INDEX FORM WAS TAKEN, and the alternative is now
closed. The two copies of a checkpoint -- the array
inside bp_history and the field in the FTQ entry -- are
written from the same p1 allocation and are one to one
against an FTQ_IDX_BITS index, so presenting the index
selects the same pointer pair the values would have, at
FTQ_IDX_BITS = 6 bits rather than 13, and leaves
bp_history untouched. SEVEN IS FTQ_PTR_BITS, the pointer
with its wrap bit, which this port does not carry: the
port is [FTQ_IDX_BITS-1:0] (ftq_backend_interfaces.md,
ftq_bpu_interfaces.md) and FTQ_IDX_BITS is 6. This read
seven in both places. Session-072.
(13, not 14: ghist_ptr is 8 and phist_ptr is 5,
ftq_decisions.md 3.1, ftq_entry_formats.md 2,
bp_history_decisions.md 7. Session-070.)
ftq_decisions.md 3.2 was worded for the value form and
was corrected to match.
The FTQ arm is a flat override, NOT a new level in the
FE-3 stage order. FE-3 orders speculative corrections
among themselves; an architectural correction is not a
later stage, it is a different kind of thing. FE-3 still
orders p3 over p2 between themselves.
Unblocks ftq_backend_interfaces.md section 5 D1. Same
class as TD-FE-6 and found the same way, by writing down
what the FTQ would have to drive.
TD-FE-6 CLOSED. bp_ftq_slot_t.br_type and .pos held the p1 uBTB
values for the entry's whole life. bp_cluster formed the
FTB classification in w_br_type_p2 and the FTB positions
in w_ftb_br0_pos_p2 / w_ftb_br1_pos_p2, but no port
carried any of them out: bp_redirect_t holds target_pc
and valid only. Section 7.2 keys update fan-out off
br_type, so a block the uBTB missed and the FTB hit read
NO_BRANCH at resolution and formed NO update at all --
the case where training matters most. Section 7.4 of
ftq_bpu_interfaces.md claimed pos came from the FTB,
which no port made possible.
Carrying the type on bp_redirect_t does NOT fix it: a
redirect fires only when the p1 and p2 successors differ,
and the defining case is a not-taken conditional the uBTB
missed, where both views end the block at the same
address and no redirect fires. The classification is
needed on every prediction, the redirect is an exception
path.
Fixed by the section 2.5 slot correction group, valid on
every prediction the FTB answers. tb_bp_cluster group I,
24 checks; sim_bp_cluster 973 -> 997. Proven by mutation:
gating bpu_slot_val_p2 on w_any_redir_p2 reproduces the
defect and I1 catches it.
TD-FE-5 CLOSED, verified session-070. It read:
bp_structs_pkg.sv comments branch_id as "FTQ slot index"
in bp_ftq_entry_t, tage_pred_meta_t, sc_pred_meta_t, and
ittage_pred_meta_t; the field is the FTQ entry index.
The package contains no "FTQ slot index" string; every
branch_id comment reads "FTQ entry index". PROJECT_STATUS
recorded it done at session-063 and this entry and
ftq_bpu_interfaces.md 10 item 3 both stayed open.
14. Unresolved¶
FE-U1 CLOSED session-075 (Jeff). Return identification before
p1. The RAS presents its top-of-stack as the initial
predicted target for a return, but the FTB branch type
does not exist until p2. The uBTB entry's br_type is what
identifies the return at p1 (section 2.2); the residual
question was what happens when the uBTB misses and the
block contains a return. Nothing at p1: the FTB
identifies the return at p2 and the p2 redirect corrects
the successor from ras_pop_addr_p2 (section 3.3). The
cost is the p2 redirect latency on a uBTB miss, which
every other branch type the uBTB misses already pays.
FE-U2 CLOSED for the FTQ side, 2026-08-19. A backend mispredict
flush reaches the FTQ on the redirect group of
ftq_backend_interfaces.md section 5, which serves
mispredict, trap and replay from one port set.
The RAS behaviour behind D3 is CLOSED TOO, 2026-08-20, and
was answered by ras_decisions.md 4.4 long before that: a
flush restores the RAS by the same pointer restore as any
redirect, which is D2 and is built. The unread
ras_flush_* ports are redundant, not unfinished (4.4.2).
NOTHING REMAINS. BP-105 closed the flush EVENT and the
FTB half by decision: there is no flush event, a flush is
a redirect, FE-14. TD #96, G24 and IC-FTB-07 all closed.
FE-U3 bp_ftq_slot_t.confidence, 4 bits. bp_cluster.md marks the
purpose TBD and FTQ_CONF_BITS a placeholder. Nothing in
either path reads it; the cluster drives it to zero.
FE-U4 PHR contribution to index and tag hashing. OPEN, and not
deferred to anything: the TAGE and ITTAGE implementation
sessions it was deferred to are done, both units are
Complete, and every fold is still GHR-derived
(bp_cluster.md History Module, bp_history_decisions.md HI2). This
read that bp_cluster.md defers it to those sessions, a
deferral bp_cluster.md retired session-070. Session-072.
FE-U5 Indirect chain update and correction semantics.
bp_arb_spec.md defers RAS and ITTAGE to a later spec.
FE-U6 SC CSR enable. bp_arb_spec.md 0 states that when the SC is
disabled the control logic issues no SC updates, does not
process the SC response queue, and does not wait on it,
while SC-related buffering and storage continue as normal.
The phrasing is not yet placed in the specification.
FE-U7 CLOSED 2026-08-19. FTQ allocation and deallocation policy
is ftq_decisions.md 5. FOUR pointers with a wrap bit --
xlate_ptr was added session-069 and this read "Three":
alloc advances at p0 when the request is accepted, since
ftq_pred_idx_p0 leaves with it; fetch advances on the IFU
handshake; one commit pointer both issues the RAS commit
and frees, walking at one entry per cycle because
ras_commit_* is scalar. Full is alloc catching commit and
is the only condition that stops the FTQ predicting.
Redirect rewinds alloc and fetch, never commit.
FE-U8 CLOSED. Prediction block to FTQ entry mapping. bp_ftq_entry_t now
carries a per-slot array of target, taken, and br_type, so
one entry represents one prediction block with NUM_PRED_SLOTS
predicted branches. See ftq_entry_formats.md 2, where the
fast path moved, and section 10, FE-10. This read
"sections 4.1 and 10"; 4.1 is retired (section 6, MOVED).
Session-072.
FE-U9 CLOSED session-075 (Jeff) by the section 7.2 table:
RETURN_CALL trains uBTB, FTB and RAS, not ITTAGE. The
item as raised: br_type update fan-out covers four of the EIGHT
bp_br_type_e encodings. The section 7.2 table has rows for
conditional, indirect, return, and direct unconditional.
FOUR have no row: DIRECT_CALL, INDIRECT_CALL, NO_BRANCH and
RETURN_CALL. Both call encodings push the RAS, and per the
session-061 ruling INDIRECT_CALL updates ITTAGE for the
target and RAS for the return address. NO_BRANCH forms no
update. Independent of the slot count.
RETURN_CALL AT 3'b111 IS THE FOURTH AND ITS FAN-OUT IS NOT
DETERMINED. It was added session-069 (ras_decisions.md 2,
dcd_decisions.md DCD-11a) for the JALR that pops then
pushes, which made the enum eight encodings, not seven.
That it drives the RAS twice is settled. Whether it also
trains ITTAGE for its target, as INDIRECT_CALL does, is
not: it is an indirect JALR whose predicted target comes
from the pop. Resolve with the 7.2 table. An earlier
revision of this item read "four of the seven" and named
three unlisted encodings. Corrected session-070.
FE-U11 How a backend redirect PC with bits 63:41 set is signalled.
FE-19 requires the check where the redirect is formed and
does not say what the backend does with the result. The
ftq_backend_interfaces.md 5 cause field has no value for
it. Two candidates: the backend traps on the JALR and forms
no redirect, which needs nothing here; or a fifth cause is
added, which changes that port. The first is likely right
and is not this document's to rule -- no backend document
exists. TD#122 carried it until that TD closed,
session-074; it now waits on the backend document.
15. Front End Top¶
TD#117 records that there is no front-end top and that ftq.sv
deliberately does not instantiate bp_cluster. This section is
the level above both. It closes TD#117.
15.1 Contents¶
FE-15 The front end top is structural. It instantiates
bp_cluster, ftq, the IFU, the L1I, THE ITLB, the ibuf and
decode, and wires them. It holds no state and makes no
decision. The ITLB is inside by FE-U10 and was missing
from this list; session-070. THE L1I INSTANCE IS THE PACINO
COPY at rtl/core/frontend/icache (FE-21, CG-D1). Built by
BP-123, accepted session-077 (Jeff).
The same rule ftq_decisions.md 7 applies to ftq.sv
applies here.
ftq.sv is a structural top over the FTQ modules and bp_cluster
is a structural top over the predictors. The front end top is the
third of these and the last; nothing above it is front end.
15.2 The L1I¶
FE-16 The L1I is INSIDE the front end top and is instantiated
there, as a SIBLING of the IFU. It is not inside the IFU.
The IFU exposes the interface to it. This is
icache_decisions.md L1I-2 and this section does not
restate that document.
The point of L1I-2 is that the cache is SELF CONTAINED, not that it is elsewhere. Keeping it a sibling rather than a child of the IFU is what lets physical design treat it in isolation, and that purpose is met wherever the instantiation sits.
An earlier revision of FE-16 put the L1I outside the front end altogether. It was written session-069 and contradicted L1I-2, which predates it. L1I-2 is the ruling.
The L1I's source is the pacino copy of the cachegen emission, in
the front end tree at rtl/core/frontend/icache, since BP-123
(FE-21). This read that its source "is the emitter and the
configuration, not a file in the front end tree". Either is a build
fact and does not move the module. Its port into the l2, named
mem (FE-21; this read up_i), is a topology edge and is not a
front end connection.
15.3 The boundary¶
FE-17 TWO groups cross the front end boundary, and one listed
here does not. This read THREE until session-076, when the
uncached group ceased to exist (IFU-21 reversed). This read "Four groups cross",
counting a row it then calls not a boundary group, and
placed the IFU-to-ITLB path on the boundary when FE-U10
puts the ITLB inside the top. Corrected session-070.
instruction NOT a boundary group. The IFU to L1I
path, l1i_ifu_interfaces.md, is INTERNAL
to the top under FE-16. What crosses is
the L1I's l2-side port, `mem` (FE-21;
this read `up_i`), a topology edge.
translation the ITLB to the page table walker, and
that alone (itlb_l2tlb_interfaces.md).
There is no L2 TLB now and the walker
is outside the top (mmu_decisions.md
MMU-1, MMU-1a, session-077); this read
"the ITLB to the shared L2 TLB". The
IFU to the ITLB, itlb_ifu_interfaces.md,
is INTERNAL: FE-U10 puts the ITLB inside
the top, a sibling of the IFU.
itlb_decisions.md and mmu_decisions.md.
uncached NO LONGER A GROUP. Uncached fetch goes
through the L1I marked uncached
(ifu_decisions.md IFU-21, reversed
session-076), so it leaves by the L1I's
`mem` port like any fetch. This row read "the IFU's
second instruction source, IFU-21. It
does not pass through the L1I."
backend decode to rename and dispatch; the FTQ
to the backend for resolution, redirect
and commit (ftq_backend_interfaces.md);
and the commit stage to the IFU for
FENCE.I and cbo.inval
(l1i_ifu_interfaces.md 11, built by
BP-123, accepted session-077).
fe_top has outputs that no group above names: ftq_full and ftq_empty, and decode_bundle, vec_decode_bundle and pd_out. They are listed in examples/fe_demo/docs/fe_top_connectivity.md (DOC-002, D5 and D6). Which group each belongs to is open. Session-080.
The backend group is two unrelated paths that happen to share a direction. Decode hands instructions forward. The FTQ exchanges control with the backend and is not in the instruction path at all.
15.4 Reset and redirect¶
FE-18 The top introduces no redirect source and no flush
mechanism. FE-14 holds across it: a flush is a redirect,
and a redirect reaches each unit by the path that unit
already declares.
bp_cluster clears its stage valids from its own p2 and p3 arms
and from the FTQ arm of BP-102. The FTQ drives the IFU flush of
ftq_ifu_interfaces.md 5. The ibuf clears on a BACKEND redirect
only, IBUF-8, 8a and 8b, ifu_ibuf_interfaces.md IB-12. This read
"clears on redirect", which would include the p2 and p3 cluster
redirects; those do not clear it. Corrected session-070.
There is no front-end-wide flush signal and the top does not
create one.
15.4a Inputs the top takes because their producers do not exist¶
FE-20 Ruled session-075 (Jeff). Three groups cross the boundary
INWARD in addition to FE-17's, each standing in for a
unit that does not exist yet. The top passes them through
and decides none of them.
csr V, the current privilege, satp, vsatp and
hgatp ASID, VMID and MODE fields, and the
pmpcfg and pmpaddr registers. ITLB-17 and
MMU-11a. The CSR file does not exist. The
walker is outside the top and takes its own
CSR group (mmu_decisions.md MMU-24a); this
group does not carry the roots or the
envcfg bits. Session-077.
config the cluster configuration: sc_enable,
ftb_fastpath_en (G25), tage_enable_aging,
tage_aging_interval, ittage_enable_aging and
ittage_aging_interval, and decode's
ext_enable. What eventually drives them is
the CSR file's question, not the top's. This
listed dual_pred_en, which no module has
(section 10 describes it), and omitted the
aging inputs and ext_enable; found by BP-118.
Session-075. sc_enable goes to the cluster
and the FTQ (the converter applies the
SC-disabled rule), BP-119.
maintenance the ITLB invalidate port of ITLB-14. Its
producer is the backend.
And one OUTWARD dependency: decode's output to rename is
qualified by the ibuf read ready of IBUF-12, which comes
in on the backend group until rename exists.
FE-21 The L1I is the cachegen emission under
tools/cachegen/output/l1i, instantiated from that path,
as rtl/core/frontend/l1i_param_chk already compiles
against it. Its l2-side port leaves the top as a
boundary edge; a testbench answers it. The emission names
that port `mem` (link tl_l1i_l2), and its core port
`core_*`, not the `ifu_l1i_*` and `l1i_ifu_*` of
l1i_ifu_interfaces.md; widths agree and fe_top maps them
one to one. This read `up_i`. BUILT by BP-118 as
rtl/core/frontend/fe_top. Session-075.
SUPERSEDED by cachegen_decisions.md CG-D1. Since BP-123
fe_top and rtl/core/frontend/l1i_param_chk instantiate the
pacino copy at rtl/core/frontend/icache, and nothing in
rtl/ compiles the emission under tools/. The copy keeps the
emission's names: `mem` for the l2-side port and `core_*`
for the core port, including core_uncached and the
core_inv_* group, which fe_top maps one to one to
l1i_ifu_interfaces.md (10.1). Its l2-side port still leaves
the top, and tb_fe_top's memory model answers it from the
image that also answers the walker (ptw_mem_interfaces.md
WM-10). Built by BP-123, accepted session-077 (Jeff).
15.5 Unresolved¶
FE-U10 CLOSED by the FE-16 ruling. The ITLB is inside the front
end top, a sibling of the IFU on the same reasoning:
written RTL, serving the IFU alone, self contained. The
boundary falls between the ITLB and the shared translation
level, which serves the data side and is outside: the
page table walker, with no L2 TLB now (mmu_decisions.md
MMU-1, session-077; this named the L2 TLB). FE-17 is
written for that reading.
16. Document History¶
2026-07-09 tmp_004. Written from bp_cluster.md rev 1.0,
bp_arb_spec.md rev 1.0, and bp_structs_pkg.sv. Covers
the BPU to FTQ prediction and redirect path and the FTQ
to BPU update path. Predictor internals and the RAM
arbitration model are out of scope. Departures from
bp_arb_spec.md are recorded in section 12.
2026-07-23 fe_decisions.md. Renamed from tmp_004.md. Dual-slot FTQ
entry applied, closing FE-U8. bp_ftq_entry_t split into
block-scalar fields and a per-slot bp_ftq_slot_t array;
bp_ftq_meta_t carried per slot. Redirect val and tgt
became per-slot arrays with a scalar ftq_idx; the slot
is the array index. Supersession restated per entry and
slot. Section 2.4 successor PC selection added. History
checkpoint and RAS snapshot confirmed block granular,
with the one-RAS-operation-per-block argument recorded
in section 9. FE-10, FE-11, TD-FE-5, and FE-U9 added.
ITTAGE raw/final split removed (single-stage target at
p2; the p2/p3 split was a conventional LUT-plus-offset
artifact not present in Pacino). Section 10 slot model
corrected: the two slots are the branch fields of one
32-byte FTB block, not two fixed PC ranges; G8/G17 is
the TAGE/ITTAGE bundle split and does not govern the
FTB (ftb_decisions.md 2.1, 2.3). Intro line, FE-10, and
FE-11 propagated to the branch-field model; FE-11
restated to the RAS-operation basis.
2026-08-09 PA-direct correction, session-064. Three corrections
carried from
ftq_bpu_interfaces.md section 10.
Section 2.2 and section 9: the RAS top of stack is read
at p0, not p1. ras.sv declares ras_tos_addr_p0 and
ras_tos_valid_p0; the cluster registers the value and
applies it at p1. Section 1 stage list updated to match.
Section 3.1: the per-predictor redirect port group was
removed. No predictor declares a redirect port
(INFRA-011, all 140 ports). Rewritten to the
cluster-derived, stage-named groups bpu_redir_p2 and
bpu_redir_p3, with the one-quantity comparison, the p1
operand definition, the p3 comparison basis and the
branch_id qualification. FE-4 restated and FE-12 added.
Section 4.2: bp_loop_meta_t replaced by lp_pred_t
(TD#106, BP-092); ftb_pred_meta_t added to the nested
member list. TD-FE-3 reference to <pred>_redir_tgt_<pN>
retargeted to bp_redirect_t.target_pc.
Also updated: section 2.1 for the BP-091 loop_pred
dual-slot retrofit; section 2.4 and 4.1 for
bpu_pred_pft_p1 and bp_ftq_slot_t.pos; section 10 for
the BP-086 uBTB block model; FE-U1, FE-U3 and FE-U9
sharpened.
2026-08-19 Section 4.3 corrected. It stated that the fast-path
entry is read by "every redirecting predictor's
cluster-boundary comparison", contradicting FE-4 and
section 3.1 of this document and section 6 of
ftq_bpu_interfaces.md, all three of which state that
bp_cluster does not read the FTQ. The sentence
predates the session-064 FE-4 rewrite and was the only
statement bearing on fast-path read-port count.
Rewritten to the three real readers, all of them the
FTQ itself: fetch every cycle, the redirect apply
path, and resolution.
2026-08-19 bp_ftq_entry_t gains pft_addr, the block fall-through,
VA_WIDTH and block scalar. Sections 2.4 and 4.1
updated. The successor selection of 2.4 is re-evaluated
on every redirect and its not-taken arm is
bpu_pred_pft_p1, which is present only in the p1 cycle,
so the value must be held in the entry. Applied to
bp_structs_pkg.sv and checked in tb_bp_pkg.sv. Entry
width 182b -> 222b. All 47 bpu targets green.
2026-08-19 TD-FE-2 RESOLVED. Section 4.2.1 added: the
bp_ftq_meta_t overload scheme. Two-arm packed union,
u.cond {tage, sc, lp} against u.ind {ittage}, with ftb
and a wr_br_type discriminant held outside it. Arm
selection, four write rules and three read rules
stated; the p3 SC write must be suppressed on the
indirect arm or it corrupts ITTAGE state. 420b -> 280b
per slot, slow path 53,760b -> 35,840b. Section 7.2
fan-out re-keyed from bp_ftq_slot_t.br_type to
bp_ftq_meta_t.wr_br_type, and the stale sentence in
4.1 corrected. TD-FE-6 opened: the p2 FTB
classification reaches no FTQ-facing port, which is
both a prerequisite for this scheme and a pre-existing
defect in the 7.2 fan-out. FE-13 added.
2026-08-19 TD-FE-6 CLOSED, and the TD-FE-2 record restaged around
it. Section 2.5 added: the p2 and p3 slot correction
groups, delivered in bp_cluster.sv, which carry the FTB
classification and the in-block positions into the
fast-path entry on EVERY prediction rather than only on
a redirect. Section 4.1 and section 7.2 returned to
keying update fan-out on bp_ftq_slot_t.br_type, which
is now correct. FE-13 restated to the slot correction
group. Section 4.2.1 restaged: the union is DEFINED AND
DEFERRED, a storage optimization with no other
dependency, and its wr_br_type discriminant is dropped
-- it was proposed while the fast-path br_type was
stale and is redundant now. 280b -> 277b per slot,
slow path 35,456b, FTQ 49,664b. tb_bp_cluster group I,
24 checks, sim_bp_cluster 973 -> 997, all 47 targets
green in this session.
2026-08-19 ftq_backend_interfaces.md written: resolution,
redirect and commit. FE-U2 closed for the FTQ side.
TD-FE-7 opened -- bp_cluster has no history-rollback
input, so a backend mispredict cannot restore the GHR
and PHR pointers. Third of the four FTQ interfaces;
only ftq_icache remains, and it is a decision rather
than a specification.
2026-08-20 TD-FE-8 CLOSED, one generation bit on the IFU path,
toggled per allocation. FTQ module decomposition
recorded in ftq_decisions.md 7: several modules, a
purely structural ftq.sv top, partitioned by the rule
that every piece of state has exactly one owner.
2026-08-20 TD-FE-1 closed in full: its three deferred entry
fields decided in ftq_entry_formats.md 4, two added
as flop vectors and one rejected. TD-FE-8 opened for
the in-flight predecode writeback race.
2026-08-20 TD-FE-7 CLOSED by BP-102. bp_cluster gains
ftq_rollback_val and ftq_rollback_idx with priority
over its own p2/p3 arms; bp_history unchanged. The
index form was taken over the pointer-value form and
ftq_decisions.md 3.2, which was written for the value
form, was corrected. tb_bp_cluster group J, 30 checks,
sim_bp_cluster 1765 -> 1795, all 47 targets green in
that session.
2026-09-15 session-069. FE-16 CORRECTED. Its first revision put
the L1I outside the front end, contradicting
icache_decisions.md L1I-2, which predates it. L1I-2
is the ruling: the L1I is inside the front end top,
a sibling of the IFU, not inside the IFU. The point
is that the cache is SELF CONTAINED, which physical
design needs, not that it sits elsewhere. FE-15 and
FE-17 follow; FE-U10 closes on the same reasoning,
putting the ITLB inside and the shared L2 TLB out.
2026-09-17 session-070. FE-19 added: VA_WIDTH is 41 and the high
bits of a backend-formed redirect PC are checked before
the address narrows. H is mandatory through Sha, MMU-20
makes the G-stage Sv39x4, and Shvsatpa requires vsatp
to support Bare because Svbare requires it of satp, so
a V=1 vsatp.MODE=Bare fetch PC is a 41-bit guest
physical address. Legality within 41 bits stays with
the ITLB, which holds V and vsatp.MODE; the front end
does not evaluate it.
TD-FE-3 reversed. It called 39 the floor, computed
against a 40-bit sign-extended Sv39 address. The floor
is 40 as addr[40:1], and reaching it is an encoding
change rather than a width trim. TD#122.
2026-09-19 session-071. Conventions and section 10 define the
PREDICTION block (32 bytes, one FTQ entry) and the
FETCH block (64 bytes, the L1I line the IFU reads) as
separate things; "fetch block" had been used for the
32-byte unit throughout, including FE-10 and FE-U8.
Section 9: the RAS snapshot is written at p2 for every
valid block (ftq_bpu_interfaces.md 4c). Section 12:
the "2, 7.1" entry no longer quotes text bp_arb_spec
does not contain; "2, 7.2" added for the RAS p0 read;
the 4.4 producer entry now covers 6.2. The 2026-08-09
history entry was labelled INFRA-012, a task that did
not exist then; it was a PA-direct correction.
2026-09-20 session-072. 2.1: the p1 mux keys on lp_pred_is_loop,
not an LP valid, which does not exist; the LP supplies
direction only. 12: the LP no-SRAM departure from
bp_arb_spec.md 2 and 5.2 added. FE-U4 no longer
deferred to the completed TAGE/ITTAGE sessions.
2026-09-20 session-072, second pass. 3.3 and 9: spec_pop_addr swept to
ras_pop_addr_p2, and 9 no longer identifies the p0
TOS read with the 3.3 entry.
2026-09-20 session-072, third pass. FE-19: the legality
enumeration carried two regimes and attributed the
sign-extension rule to all of V=0; V=0 with
satp.MODE=Bare is physical and bounded by pa_bits.
The ITTAGE zero-extend is stated as binding
predictions, not architectural addresses.
2026-09-20 session-072. D18: the rollback index is FTQ_IDX_BITS = 6,
not 7; 7 is FTQ_PTR_BITS.
2026-09-20 session-072. E5: the registry pointer names section 15 and
the issue-order numbering. E9: the zero-extension
paragraph moved clear of the "Both are caught"
clause. E11: SPDX header added. E12: the history
section's split fences merged.
2026-09-20 session-072. D16: FE-U8 cites ftq_entry_formats.md 2
instead of the retired section 4.1. E17: section 6's
registry sentence matches the Overview. E18: the
pft_addr sentence has its verb back.
2026-09-20 session-072. E22: Document History sorted into date order;
newer entries had been appended at the wrong end.
2026-10-01 session-074. Conventions: one prediction block per
cycle, TD#133. FE-19: the ITTAGE stores VA[40:1]
since BP-111 (TD#132); the 38-bit pin and the
zero-extension paragraph are retired. FE-U11 no
longer names TD#122 as its carrier.
2026-10-07 session-075, rulings (Jeff). 7.2: rows for
direct call, indirect call, return-call and no
branch; RETURN_CALL does not train ITTAGE, closing
FE-U9. FE-U1 closed: a return the uBTB misses is
corrected at p2. 15.4a: FE-20, the csr, config and
maintenance input groups; FE-21, the L1I from its
emitted path.
2026-10-07 session-075, after BP-118. 7.2: as built the
return-call row is not met (TD#152) and only the FTB
and RAS train in the top (TD#151). FE-20: the config
group as the RTL has it. FE-21: the emitted port names
and fe_top built.
2026-10-07 session-075, after BP-119. 7.2: every row built;
the ruling that a branch its FTQ entry does not hold
is placed at resolution and trains every predictor of
its row. FE-20: sc_enable also goes to the FTQ.
2026-10-08 session-076, PA-direct correction recording BP-121.
2.4: per-slot successors chained (D5, D15). 7.2: the
loop predictor reads before it writes (ruled after
BP-121, TD#169). FE-10: p1 slots in position order
(D12). FE-14: the squash as built (D8, D9).
2026-10-09 session-076, recording BP-122. 3.2: the LP's p2
re-read is a direction source at p2. 3.3: a trusted
LP outranks SC, TAGE and FTB (ruled). 7.2: built.
2.1: the p1 LP direction is an early guess.
2026-10-09 session-076, ruling (Jeff). FE-17: the uncached group
is gone (IFU-21 reversed); the maintenance path from
commit is part of the backend group.
2026-10-09 session-077, rulings (Jeff). FE-17 and FE-U10: the
translation group goes to the page table walker,
outside the top; there is no L2 TLB (MMU-1 reversed).
FE-20: the walker's CSRs are its own group.
2026-10-09 session-077, after BP-123, rulings (Jeff). FE-15 and
15.2: the L1I instance is the pacino copy. FE-17: the
commit-to-IFU maintenance path built. FE-21 superseded
by CG-D1. The front-end units list no longer calls the
L1I emitted rather than written. 15.2 and FE-17 name
the L1I's l2-side port `mem` (FE-21), not up_i.
2026-10-15 session-080, after DOC-002. FE-17: the fe_top outputs
no group names.
2026-10-17 session-081, after BP-138. 10: a jump no slot carries
ends the block at the jump PC (D1, provisional).
2026-10-19 session-081, after BP-139. 10: a branch no slot carries
ends the block at its PC (option A). 7.2: item C.
2026-10-19 session-081, after BP-140. 10: the cut is a backstop.
2026-10-19 session-081, after DOC-007. 10: FD-23 re-pointed at the
split; w_jmp_cut_p2 is read by nothing.
bp_arb_spec.md
planning/arch/bp_arb_spec.md on GitHub
Branch Predictor Arbitration and Prediction Pipeline Specification¶
FILE: bp_arb_spec.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-29
CONTACT: Jeff Nye
0. Caveat¶
-
There is a plan for a SC csr bit which enables the SC. PA will help insert the right phrasing in the right locations. When the SC is disabled the FTB/control logic does not issue updates to the SC, it does not process the SC prediction response queue and otherwise does not wait for any responses from the SC. The FTB buffers and storage of SC related signals continues as normal.
-
Redirect naming. Sections 3.3, 3.4 and 5.x below use a
<pred>_redir_*per-predictor naming that does not exist in any RTL. No predictor declares a redirect port; INFRA-011 confirmed this across all 140 ports of the eight top-level modules, 141 since session-071 added ubtb's blk_p1 (bpu_port_inventory.md Coverage). Session-072. The redirect is derived at the bp_cluster boundary and the groups are named by STAGE:bpu_redir_p2andbpu_redir_p3. The port specification is ftq_bpu_interfaces.md section 6, and the theory of operation is fe_decisions.md section 3.1. Read every<pred>_redir_*name below as "that predictor's contribution to the stage group", not as a port.
1. Problem Statement¶
The branch predictor cluster contains multiple synchronous RAM-based predictors. Each predictor has a prediction path (read) and an update path (write) that compete for the same RAM access stage. No protocol exists in the current design to manage that competition or to define how multiple predictors interact to produce a final prediction.
This spec defines:
a. The per-predictor buffering and arbitration mechanism that
allows prediction and update requests to overlap safely.
b. The pipeline stage model for all predictors and how later
stages override earlier ones via a redirect mechanism.
c. The RAS snapshot model, which does not fit the RAM
arbitration pattern.
2. Predictor Inventory¶
| Predictor | RAM-based | Pred stage | Override stage | Update timing |
|---|---|---|---|---|
| uFTB | No | p0 | p0 | Immediate |
| RAS | No | p0/p2 | p2 | Speculative push/snapshot restore. p0: TOS read, an input to the p1 prediction (fe_decisions.md 12, session-071). p2: push/pop executes, redirect participation. See section 7.2 and ras_decisions.md 1 and 1.2. |
| FTB | Yes | p1/p2 | p1/p2 | u0/u1 |
| LP | NO* | p1 | NONE** | u0/u1 |
| TAGE | Yes | p2 | p2 | u0/u1 |
| SC | Yes | p3 | p3 | u0/u1 (separate UQ) |
| ITTAGE | Yes | p2 | p2 | u0/u1 |
- LP: NO SRAM. loop_pred.sv is a pure registered counter array (sram_init.md, fe_decisions.md 2.1). This column read Yes. Session-070; see 5.2. ** LP: completes at p1 and is selected against the uFTB by the p1 mux; it is not a redirect source (5.2, open item F, fe_decisions.md 3.2 and 12). These columns read p1/p2 and p1/p2. Session-072.
The indirect predictor chain (RAS + ITTAGE) shares the stage timing of its direct counterparts but has different update and correction semantics. It is deferred to a later spec. Placeholders are included here where the indirect chain interacts with the direct chain.
Note: fe_decisions.md section 12 records the departures from this table that the front-end specification takes deliberately. The LP is not a redirect source; the initial prediction is formed at p1.
3. Pipeline Stage Model and Override Chain¶
3.1 Stage definitions¶
p0 Inputs presented to RAMs (flopped). PC hash, folded
history available.
p1 RAM outputs available. Tag match, hit processing.
p2 Result formation. Provider selection, meta capture.
p3 Statistical corrector threshold decision.
u0 Update address and write data presented to RAMs.
u1 RAM write completes.
3.2 Predictor stage assignments¶
p0: uFTB, RAS (TOS read only)
p1: LP, selected against the uFTB by mux (not an override)
p1/p2: FTB
p2: TAGE, ITTAGE, RAS (push/pop, redirect participation)
p3: SC (chained from TAGE p2 output)
3.3 Override chain¶
A later stage overrides a previous stage if its prediction differs. Override is implemented as a redirect: the cluster compares the predictor's result against the prediction it formed at p1 and holds in its own stage registers. If they differ it asserts a redirect with the corrected target PC and the FTQ index of the fetch being corrected.
The FTQ acts on the earliest available prediction (uFTB/RAS at p0) and issues a fetch immediately. It does not wait for later predictors. Later predictors issue redirects independently when their results are ready.
Override priority (highest to lowest):
SC (p3) > TAGE (p2) > FTB/LP (p1/p2) > uFTB/RAS (p0)
For indirect branches:
ITTAGE (p2) > RAS (p0) [indirect chain, deferred]
Note: fe_decisions.md section 12, narrowed session-070, rejects the chains as written but NOT the direction ranking inside the first one. ON DIRECTION, SC > TAGE > FTB is real: all three produce that one quantity, a trusted loop prediction ranks above all three since BP-122 (fe_decisions.md 3.3), and the ranking is suspended per branch when the FTB fast path fires (ftb_confidence_override_rules.md 4.3, 4.2). The rest is not ranked: br_type selects the RAS for a return and the ITTAGE for an indirect, so the two are never both consulted for one branch, and redirects supersede by stage order (FE-3). The rows are retained here as the original text; fe_decisions.md governs.
A redirect from a later stage supersedes any earlier redirect for the same FTQ entry. The FTQ must track which redirects are stale.
3.4 Redirect interface (per predictor, per stage)¶
HISTORICAL. The signal names in this section were never implemented and will not be. See the Caveat in section 0 and ftq_bpu_interfaces.md section 6 for the real interface.
The original text described each RAM-based predictor that can redirect as exposing:
output logic <pred>_redir_val_<pN>
output logic [VA_WIDTH-1:0] <pred>_redir_tgt_<pN>
output logic [FTQ_IDX_BITS-1:0] <pred>_redir_ftq_idx_<pN>
uFTB and RAS drive the FTQ directly at p0 without a redirect interface. They are the initial prediction. RAS push/pop and redirect participation occurs at p2; the p0 output is a TOS read only.
Note: fe_decisions.md 12 departs from this paragraph. Neither drives the FTQ at p0. The cluster registers the uBTB output and the RAS TOS read and forms the initial prediction at p1, where the FTQ allocates (FE-2). Session-071.
Redirect signal naming examples:
ftb_redir_val_p2
lp_redir_val_p2
tage_redir_val_p2
itage_redir_val_p2
sc_redir_val_p3
Status: NO SUCH PORT EXISTS, on any predictor or at the cluster boundary. The session-060 audit (INFRA-009) found none on the unit-level RTL, and INFRA-011 confirmed the same across all 140 ports of all eight modules once bp_cluster was built; the inventory is 141 since session-071 added ubtb's blk_p1. Session-072. The redirect is cluster-derived logic, and the delivered groups are named by stage rather than by predictor:
bpu_redir_p2 bp_redirect_t [0:NUM_PRED_SLOTS-1]
bpu_redir_idx_p2 [FTQ_IDX_BITS-1:0]
bpu_redir_p3 bp_redirect_t [0:NUM_PRED_SLOTS-1]
bpu_redir_idx_p3 [FTQ_IDX_BITS-1:0]
The comparison reduces both views of a slot to one quantity, the address fetched after that slot, and every comparison is qualified by branch_id equal to the FTQ index in the matching stage register. The LP is not a redirect source at all: it is selected against the uBTB by mux at p1.
4. RAM Arbitration Model¶
4.1 Competing stage¶
Each RAM-based predictor has one cycle in which prediction and update compete for the RAM inputs. This is the competing stage:
Prediction: p0 presents RAM read address (flopped input).
Update: u0 presents RAM write address and data (flopped).
Only one transaction may own the competing stage per cycle. An arbiter selects from a Prediction Queue (PQ) and an Update Queue (UQ) placed in front of each predictor. It was credit-based until BP-121 (section 4.5).
4.2 Common arbitration parameters (per predictor)¶
Each RAM-based predictor has its own parameter set. Names are prefixed with the predictor identifier. TAGE is shown as the reference instance.
// Queue depths
localparam int TAGE_PQ_DEPTH = 8;
localparam int TAGE_UQ_DEPTH = 8;
// UQ write port width
// 4-at-once commit causes 2-cycle backpressure to commit.
localparam int TAGE_UQ_WR_PORTS = 2;
// Response buffer depth
localparam int TAGE_RESP_BUF_DEPTH = 2;
// Credit arbiter (no counter uses the credits since BP-121, 4.5)
localparam int TAGE_PRED_CREDITS = 4;
localparam int TAGE_UPD_CREDITS = 1;
localparam int TAGE_STARVE_THRESH = 8;
FTB, LP, and ITTAGE have analogous parameter sets with their own prefix and independently chosen values.
The credit parameters (<PRED>_PRED_CREDITS, <PRED>_UPD_CREDITS) no longer drive any counter: BP-121 removed the credit counters (section 4.5). <PRED>_STARVE_THRESH still sets the starvation hold.
Note, TD#39, MOOT since BP-121: PRED_CREDITS = 4 was less than STARVE_THRESH = 8, so the old rule 2 starvation override was unreachable in ordinary traffic. The rules it concerned are replaced (4.5). This read as an open parameter question. Session-076.
4.3 Prediction Queue (PQ)¶
Structure:
- FIFO. Depth <PRED>_PQ_DEPTH.
- Entry type: prediction input struct for that predictor.
- Binary counter head/tail, registered full/empty flags.
- Bypass: if PQ is empty and arbiter grants prediction this
cycle, incoming request bypasses FIFO and drives the
competing stage directly.
Handshake (producer side):
- Producer presents val and inp signals.
- PQ asserts not_full.
- Producer may issue only when not_full.
- Full: backpressure to fetch. No drop.
Handshake (arbiter side):
- Arbiter asserts pq_rd_en on grant.
- PQ presents head entry.
- PQ advances pointers on pq_rd_en.
4.4 Update Queue (UQ)¶
Structure:
- FIFO. Depth <PRED>_UQ_DEPTH.
- Entry type: update input struct for that predictor.
- Two write ports (<PRED>_UQ_WR_PORTS=2). Up to 2 updates
may be enqueued per cycle.
- Bypass: if UQ empty and arbiter grants update, incoming
entry bypasses FIFO.
Handshake (producer side):
- Commit presents upd_val[s] and upd_inp[s] per slot.
- UQ asserts <pred>_uq_not_full[s] per slot when accepted
(tage_uq_not_full, ittage_uq_not_full; this read upd_rdy,
the names before BP-132, TD#49).
- When UQ full, <pred>_uq_not_full deasserts. Commit holds
valid until accepted.
Handshake (arbiter side):
- Arbiter asserts uq_rd_en on grant.
- UQ presents head entry.
Updates are program-order. FIFO must not be reordered.
Note: fe_decisions.md section 12 corrects both statements above. The producer is post-execute resolution, not commit, and this is an out-of-order machine, so updates are enqueued and delivered in resolution order (FE-6). The two write ports and the backpressure behaviour are retained as written.
4.5 Arbiter: a prediction is never delayed¶
RULED session-075 (Jeff, BP-121 decision 5), BUILT by BP-121 (D6) for TAGE and ITTAGE in their units and for SC in bp_cluster. RULES 2 TO 4 ARE REPLACED. They were a credit scheme in which an update could be granted ahead of a waiting prediction. In the integrated front end that delayed the TAGE, ITTAGE and SC responses for 70 to 90 percent of p2 blocks; a late response is discarded by branch_id, so those blocks lost the prediction. The credit counters are removed.
The rule, in one line: a prediction is never delayed; an update is granted only in a cycle with no prediction presented; and after <PRED>_STARVE_THRESH cycles of a waiting update, the predictor's queue-ready drops for one cycle so that such a cycle occurs.
Initialization:
starve_ctr = 0
Per-cycle grant logic (priority order):
1. resp_buf_full asserted: no grant. Prediction path
blocked; do not issue a new prediction.
Note: rule 1 does not block update grants.
2. Starvation hold: UQ non-empty AND starve_ctr reaches
<PRED>_STARVE_THRESH: the queue-ready drops for one
cycle -- tage_pq_not_full or ittage_pq_not_full, and
sc_uq_not_full for SC -- so no prediction is presented
in a following cycle and rule 6 grants the update.
starve_ctr resets when the update is granted. The exact
cycle on which the ready drops is as built (tb_tage
TC-54 checks it at STARVE_THRESH - 1).
3. Both a prediction and an update present: grant the
prediction. The waiting update counts toward the
starvation hold; how starve_ctr counts is as built.
4. RETIRED by BP-121 (the credit-exhausted update grant).
5. PQ non-empty only:
Grant prediction unconditionally.
(This read "Do not consume prediction credits"; there
are no credits since BP-121.)
6. UQ non-empty only:
Grant update unconditionally.
7. Both empty: no grant.
FOR SC the arbiter is in bp_cluster. A prediction presented means a block at p2 that TAGE answers, squashed or not (r_tv_p2, BP-121 D13), so an SC update is never granted under a live TAGE result. An SC update grant had dropped consumer_ready under a live TAGE result (4.7) before BP-121.
SINCE BP-126 (TD#123, P-3, confirmed session-077) the SC update request is the SC UQ non-empty or an update presented to it (sc_uq_has_data), and the grant drains the UQ (sc_uq_rd_en). The cluster's sc_uq_not_full drops when the UQ is full as well as for the one-cycle starvation hold of rule 2. The cluster's sc_upd_rdy is the UQ's room (and sc_enable), not the grant. The rules above are unchanged.
TESTED as replaced: tb_tage TC-54 (arb_starve_tst) and the concurrent tests, and tb_bp_cluster group H rewritten (H1 no grant, H2 prediction granted, H2b sc_ready guard, H3 update alone granted, H4 prediction wins every cycle and the update is granted after the one-cycle hold). sim_bp_cluster_init reaches H2b from the ports, with no fast-init strap; sim_bp_cluster reaches it by clearing the strap (BP-135). The concurrent pred+upd residual of TD#73 is covered for TAGE by tb_tage's concurrent tests; BP-121 does not say whether ITTAGE has its own.
This section read "Credit Arbiter" with the seven credit rules, IMPLEMENTED for SC in bp_cluster (session-063) and tested by BP-094 group H (TD#73). Replaced session-076.
4.6 Competing stage register¶
The arbiter output is captured in a transaction register that travels with the pipeline from p0/u0 to p1/u1:
typedef struct packed {
logic trx_type; // 0=PRED 1=UPD
logic [$clog2(NUM_PRED_SLOTS)-1:0] trx_slot;
} bp_arb_trx_t;
The full input data (<PRED>_pred_inp or <PRED>_upd_inp) is held stable at the queue head until the grant is de-asserted. The transaction register carries only type and slot. This avoids a wide registered copy of the full input struct.
At p1/u1:
- trx_type==PRED: RAM read result flows to result formation.
- trx_type==UPD: RAM write completes. No result routing.
4.7 Prediction Response Buffer¶
Structure:
- <PRED>_RESP_BUF_DEPTH entries (default 2).
- Bypass when empty and consumer ready.
- Entry: prediction metadata struct + valid flag.
Handshake:
- p2 result formation asserts p2_valid. Result enters buffer.
- Consumer presents consumer_ready. FOR TAGE THAT CONSUMER IS
SC, and consumer_ready is driven in bp_cluster.sv from SC
state alone: ~sc_enable | (sc_ready & ~w_sc_grant_upd). The
FTQ is not in that path. "FTQ or SC for TAGE" read as though
either could drive it; corrected session-070 against the RTL.
- Buffer asserts pred_rdy when head is valid.
- When buffer full and consumer not ready, resp_buf_full
asserted to arbiter (blocks new prediction grants, rule 1).
4.8 Same-entry conflict resolution¶
When a prediction and an update targeting the same RAM entry are both pending, prediction is granted first (section 4.5, rule 3). The prediction reads pre-update state. The update is granted in a subsequent cycle.
5. Per-Predictor Arbitration Instances¶
5.1 FTB¶
Parameters: FTB_PQ_DEPTH, FTB_UQ_DEPTH, FTB_UQ_WR_PORTS,
FTB_RESP_BUF_DEPTH, FTB_PRED_CREDITS,
FTB_UPD_CREDITS, FTB_STARVE_THRESH.
Values: TBD. Independent of TAGE sizing.
Pred input: ftb_pred_inp_t (PC + branch_id + prediction block
boundary fields -- wider than tage_pred_inp_t)
Upd input: ftb_upd_inp_t (resolved prediction block metadata)
Pred output: ftb_pred_meta_t (branch targets, block end PC,
taken map)
Override: p2, via the cluster-derived bpu_redir_p2 group.
No ftb_redir_val_p2 port exists.
Notes: FTB updates on every resolved prediction block, not
only on mispredictions. UQ drain rate may be
higher than TAGE. Size UQ_DEPTH accordingly.
As shipped, ftb.sv declares 42 flat ports
(before BP-121 added ftb_jmp_rvc_p2 and
ftb_upd_jmp_rvc_u0) and no
PQ, UQ or arbiter; the parameters above are not
instantiated.
5.2 Loop Predictor (LP)¶
THE LP HAS NO SRAM. loop_pred.sv is a pure registered counter
array (sram_init.md; fe_decisions.md 2.1), so the queue and
credit machinery below describes a contention that does not
exist -- there is no single RAM port for prediction and update
to compete for. The section 2 table read "RAM-based: Yes" and is
now NO*. Retained rather than deleted because the LP may yet be
given a RAM; if it is not, 5.2 should be withdrawn.
fe_decisions.md 12 lists this departure as of session-072;
flagged session-070.
Parameters: LP_PQ_DEPTH, LP_UQ_DEPTH, LP_UQ_WR_PORTS,
LP_RESP_BUF_DEPTH, LP_PRED_CREDITS,
LP_UPD_CREDITS, LP_STARVE_THRESH.
Values: TBD. LP metadata is small; shallower queues
may be sufficient.
Pred input: lp_pred_inp_t (PC + branch_id -- narrow)
Upd input: lp_upd_inp_t
Pred output: lp_pred_t
Override: NONE. The LP is not a redirect source. It is
selected against the uBTB by mux at p1
(fe_decisions.md 2.1). lp_redir_val_p2 does not
exist.
Request: Fetch presents prediction request to LP PQ
independently (Option B). Same PC as TAGE
but separate queue instance. No shared
upstream PQ at this time.
Notes: LP completes at p1, not p2. Its prediction output
is pred_p1 and it is per-slot as of BP-091. As
shipped it declares no PQ, UQ or arbiter.
5.3 TAGE¶
Parameters: TAGE_PQ_DEPTH=8, TAGE_UQ_DEPTH=8,
TAGE_UQ_WR_PORTS=2, TAGE_RESP_BUF_DEPTH=2,
TAGE_PRED_CREDITS=4, TAGE_UPD_CREDITS=1,
TAGE_STARVE_THRESH=8.
Pred input: tage_pred_inp_t
Upd input: tage_upd_inp_t
Pred output: tage_pred_meta_t
Override: p2, via the cluster-derived bpu_redir_p2 group.
No tage_redir_val_p2 port exists.
Notes: TAGE response buffer holds tage_pred_meta_t.
SC prediction chains from that buffer (section 6).
BUILT in tage_arb.sv, a submodule of tage.sv:
PQ, UQ, arbiter, starvation count, competing-stage
mux, bp_arb_trx_t register and response buffer
(BP-132, TD#52). Its status outputs are
tage_pq_not_full and tage_uq_not_full (TD#49).
TAGE and SC have separate UQ buffers. This is a change
from the previous where the UQ entry was shared.
5.4 ITTAGE¶
Parameters: ITTAGE_PQ_DEPTH=4, ITTAGE_UQ_DEPTH=2,
ITTAGE_UQ_WR_PORTS=2, ITTAGE_RESP_BUF_DEPTH=2,
ITTAGE_PRED_CREDITS=2, ITTAGE_UPD_CREDITS=1,
ITTAGE_STARVE_THRESH=2.
Note: ITTAGE_RESP_BUF_DEPTH is vestigial -- the response buffer
was removed (BP-038b, ittage.sv). ITTAGE has no independent
prediction response FIFO at the unit level.
BUILT in ittage_arb.sv, a submodule of ittage.sv: PQ, UQ,
arbiter and starvation count (BP-132, TD#52). Its status
outputs are ittage_pq_not_full and ittage_uq_not_full (TD#49).
Pred input: ittage_pred_inp_t
Upd input: ittage_upd_inp_t
Pred output: ittage_pred_meta_t
Override: p2, via the cluster-derived bpu_redir_p2 group. No
dedicated redirect port on ittage.sv; the cluster derives the
redirect by comparing ittage_pred_meta_p2 against the prediction
it formed at p1, per section 3.4. Indirect chain only.
5.5 SC¶
Parameters: SC_UQ_DEPTH=8, SC_UQ_WR_PORTS=2,
SC_RESP_BUF_DEPTH=2, SC_PRED_CREDITS=4,
SC_UPD_CREDITS=1, SC_STARVE_THRESH=8.
Pred input: tage_pred_meta_t
staged p0->p2 prediction inputs, see section 6.1
Upd input: sc_upd_inp_t
Pred output: sc_pred_meta_t
Override: p3, via the cluster-derived bpu_redir_p3 group.
No sc_redir_val_p3 port exists.
Notes: SC has no SC_PQ_DEPTH. SC does not instantiate its
own prediction FIFO; the TAGE response buffer
(TAGE_RESP_BUF_DEPTH) is the prediction-side storage
and acts as SC's PQ for arbitration (section 6.1).
SC response buffer holds sc_pred_meta_t.
TAGE and SC have separate update queues and
prediction response queues. This is a change
from the previous version.
The SC arbiter is IMPLEMENTED in bp_cluster
(session-063), and its rules were replaced by
BP-121 (section 4.5).
THE SC UQ IS BUILT in sc.sv by BP-126 (TD#123):
SC_UQ_DEPTH entries, each one update cycle of both
slots (SC_UQ_WR_PORTS slot writes). sc_upd_rdy and
sc_uq_not_full are its room, and sc_upd_rdy is also
low before sc_ready. sc_uq_has_data and sc_uq_rd_en
connect it to the bp_cluster arbiter. An empty UQ
passes a granted update through (4.4 bypass). This
read that sc.sv stubbed the arbitration-layer ports
(sc_uq_not_full = 1'b1, sc_upd_rdy = all-ones) and
built no SC UQ, so the values above described the
target model only. Session-077.
6. Statistical Corrector (SC) -- Chained Predictor¶
SC is a Seznec-style statistical corrector. It has its own RAM tables of signed counters and a thresholding process. It adds one pipeline stage (p3) after TAGE p2.
SC tables are single-port RAMs. SC prediction (read, p2->p3) and SC update (write, u0/u1) compete for the one RAM port. The section 4.5 arbiter governs that contention unchanged. SC's prediction transactions are drawn from the TAGE response buffer (acting as SC's PQ); SC's update transactions are drawn from the SC UQ. SC does not instantiate an independent prediction FIFO.
6.1 TAGE/SC Prediction Request Communication¶
TAGE prediction response meta data is used by the SC. The SC accepts the tage_pred_meta_t and a staged version of the tage_pred_inp structures as prediction request inputs but SC only queues a sub-set of the information provided.
tage_pred_inp is staged from p0 to p2. P2 is the start of the SC prediction pipeline.
The SC has discrete ports for the p2 versions of the prediction pc, a snapshot of the lower 10 bits of the PHR, AND THE THREE SC INDEX FOLDS.
These signals are captured at p0/p1
tage_pred_inp_p0[slot].pc[VA_WIDTH-1:1]
folded_hist.tage_phr[9:0]
folded_hist.sc_t1_idx_fh
folded_hist.sc_t2_idx_fh
folded_hist.sc_t3_idx_fh
They are staged to p2 and applied as inputs to SC
logic [VA_WIDTH-1:1] inp_pc_p2[0:NUM_PRED_SLOTS-1]; //tage_pred_inp_p0[s].pc
logic [9:0] sc_phr_p2; // folded_hist.tage_phr[9:0]
logic [SC_MAX_FH-1:0] sc_t1_idx_fh_p2; // folded_hist.sc_t1_idx_fh
logic [SC_MAX_FH-1:0] sc_t2_idx_fh_p2; // folded_hist.sc_t2_idx_fh
logic [SC_MAX_FH-1:0] sc_t3_idx_fh_p2; // folded_hist.sc_t3_idx_fh
ALL FIVE ARE STAGED. The three index folds were connected live to bp_history until BP-090. bp_history advances whenever a branch is predicted, so at p2 the live folds described a block LATER than the one SC was indexing -- the same defect the PC and the phr staging exists to prevent. They are the same class of signal and take the same staging. TD#92; ftq_bpu_interfaces.md section 10 item 8 records the closure.
TAGE and ITTAGE do not appear here because they take bp_folded_hist_t whole at their own p0 request and stage internally. SC is the only consumer that takes sliced folds.
The TAGE prediction response is a port on the SC along with the ready signal indicating the prediction response is valid.
tage_pred_meta_p2[0:NUM_PRED_SLOTS-1];
tage_pred_rdy_p2
Of the tage_pred_meta_p2, these signals are used. These ports hold the signals for the two prediction slots, indicated by (s).
tage_pred_meta_p2[s].tage_pred_strong
tage_pred_meta_p2[s].tage_pred_medium
tage_pred_meta_p2[s].tage_pred_tkn
tage_pred_meta_p2[s].tage_extd_ctr
These are p2 signals and do not require staging.
The SC prediction-side arbiter draws its prediction transactions from the TAGE response buffer (which acts as SC's PQ) and its update transactions from the SC UQ. Section 4.5 arbitration applies unchanged. When the arbiter grants an SC update and stalls an SC prediction, the TAGE response buffer head is held, which backpressures TAGE (see section 11 item C). SINCE BP-121 THAT CASE DOES NOT ARISE: an SC update is granted only when no prediction is presented (4.5).
6.2 SC Update Request Communication¶
SC has a separate UQ. The UQ entry type is sc_upd_inp_t.
Note: A single conditional branch commit event must enqueue one entry in the TAGE UQ and one in the SC UQ. Each of these entries can contain two branches, since Pacino BPC is dual prediction capable.
Note: fe_decisions.md 12 corrects "commit" above, as it does for 4.4. The producer is post-execute resolution (FE-6): one resolved conditional branch enqueues one TAGE UQ entry and one SC UQ entry. Session-071.
The SC and TAGE UQ's are separate.
The cluster's SC update request into the arbiter is AN SC UPDATE PRESENTED (sc_upd_val_u0), not an update on a conditional channel. The SC ready returned to the FTQ is the arbiter's grant, so it depends on the SC valid, and the FTQ presents the SC valid before it sees the ready (ftq_bpu_interfaces.md 8). Changed by BP-119: the request was formed from the conditional-channel valid, which made a combinational loop once the FTQ gated its valids on the readies.
SUPERSEDED by BP-126 (TD#123, P-3): the request is sc_uq_has_data, the UQ non-empty or an update presented to it, and the SC ready returned to the FTQ is the UQ's room, which does not depend on the SC valid. The paragraph above is the BP-119 to BP-125 state. Session-077.
7. Non-RAM Predictors¶
7.1 uFTB¶
uFTB is fully combinational. No internal SRAMs. No PQ, UQ, or arbiter required. Output is presented directly to the FTQ at p0. uFTB result is the initial prediction that fetch acts on; it is not a redirect.
If the FTQ cannot accept the uFTB output (FTQ full), uFTB holds its output stable. No response buffer needed.
Note: fe_decisions.md places the initial prediction at p1, where the FTQ allocates. The uBTB output is combinational from pred_pc_p0 and the cluster registers it once so the p1 selection mux reads it alongside the loop predictor's registered output. The predictor name is uBTB; uFTB is retained here as the original text only.
7.2 RAS¶
RAS is a register-file-based stack. It does not have synchronous SRAMs in the TAGE sense. No PQ, UQ, or credit arbiter required.
Prediction¶
RAS prediction is a read of the top-of-stack (TOS) register, which is combinational. A return instruction detected at p0 causes the RAS to present the TOS value as the predicted target. This is the initial p0 prediction, not a redirect. ras.sv declares ras_tos_addr_p0 and ras_tos_valid_p0.
Note: fe_decisions.md 12 (entry "2, 7.2") departs from the sentence above. The TOS read is an input to the p1 prediction: the cluster registers it and the p1 mux applies it to a RETURN slot. It is not a prediction and reaches no FTQ port at p0. Session-071.
Push (call)¶
A call instruction is detected via FTB structural prediction at p2. The return address is pushed onto the RAS speculatively at p2. Because the prediction is speculative, the push may be on a mispredicted path.
Snapshot and restore¶
RAS state (TOSR, TOSW, BOS -- defined in bp_ras_snapshot_t in bp_structs_pkg.sv, each RAS_PTR_BITS=4b wide) is checkpointed into the FTQ entry of every valid p2 block, from the state after both slots (this read "at the time of the prediction that consumed or produced the RAS state"; DOC-011). On a redirect the RAS is restored from the FTQ snapshot of THE ENTRY THE REDIRECT NAMES BY ITS INDEX, including when _self marks that entry squashed (ftq_backend_interfaces.md 5 D2, ras_decisions.md 3.2, 4.3 and 4.4). A flush IS a redirect (FE-14). This read "the last known-good entry", which ras_decisions.md 3.2 records replacing. Session-070.
The snapshot is written at p2 for every valid block, from the state after both slots, on ftq_bpu_interfaces.md 4c (ras_decisions.md 4.2, session-071), not only for a block that operated on the RAS.
The bp_ftq_entry_t struct includes a bp_ras_snapshot_t field. This is the RAS update mechanism -- not a RAM write but snapshot retirement. See ras_decisions.md section 4.
Commit¶
On commit the RAS commit stack is updated: a register-file write at CSP for a call, and CSP moves. BOS moves to the committing entry's snapshot TOSR, except a RETURN whose snapshot is an empty stack (ras_decisions.md 3.3, 4.5). This read "the FTQ snapshot for the retiring entry is released. No RAM write occurs" (DOC-011; ras.sv:833-848).
Open items¶
Flush behavior: the RAS half is CLOSED, ras_decisions.md 4.4.
The flush EVENT is CLOSED too, BP-105: there is none. A flush is
a redirect, fe_decisions.md FE-14. TD #96 is closed.
8. Prediction Request Distribution¶
8.1 Current approach¶
Fetch presents prediction requests independently to each predictor's PQ. The same PC fans out to FTB PQ, LP PQ, and TAGE PQ simultaneously. Each predictor has a separate not_full backpressure signal to fetch. Fetch stalls if any predictor's PQ is full.
This is simpler than a shared upstream PQ and is appropriate given the small metadata size of LP and the independent sizing of each predictor.
8.2 Shared upstream PQ: not built¶
A single queue in front of every predictor's PQ is not built and not needed: each request goes straight to each predictor's own queue (8.1). TD #97 CLOSED, session-078 (Jeff).
9. RTL changes¶
Section removed.
10. Testbench Requirements¶
Section removed. Testbench requirements derive from the section 4.5 arbitration rules, section 4.8 same-entry ordering, and the section 11 item C backpressure chain. They are enumerated in the implementing task file, not here.
11. Open Items¶
B. bp_arb_trx_t width.
The transaction register carries only trx_type and
trx_slot (section 4.6). Queue head data held stable.
Evaluate whether hold-stable is synthesizable cleanly
in the target flow before committing to RTL.
C. CLOSED. SC response buffer is a separate queue with
it's own back pressure chain eventually tied into the TAGE
p2 inputs, and ties into TAGE's response back pressure.
OLD: SC response buffer placement and backpressure chain.
SC response buffer sits after p3. SC backpressures
TAGE response buffer consumer_ready when full. The
TAGE response buffer then backpressures the TAGE
arbiter (resp_buf_full, rule 1). This is a two-deep
stall chain. Confirm worst-case SC drain rate does not
create unacceptable prediction stalls.
D. Shared upstream PQ.
CLOSED, session-078 (Jeff). Not built and not needed (8.2).
This was TD #97.
OLD: Deferred. Option B (independent PQs) used initially.
Revisit before LP integration if timing or fan-out
is a problem.
E. Flush protocol interaction.
CLOSED, BP-105. There is no flush event to interact with: a
flush is a redirect (fe_decisions.md FE-14). The queues need
no flush behaviour, and the OLD analysis below is CORRECT and
is already how the design works without one -- a redirect
clears stage valids, so PQ entries are naturally discarded,
while the update path is not gated by the redirect at all and
UQ entries simply proceed.
Corroborated by XiangShan: its predictors take `update`
independently of the redirect path and no queue is flushed,
because nothing flushes them.
OLD: _px signals not yet defined. On flush:
PQ entries: discardable (speculative).
UQ entries: must not be discarded (post-commit).
In-flight competing-stage transaction: if PRED,
discard result. If UPD, must complete.
F. LP response stage.
CLOSED. The LP completes at p1. Its output is pred_p1 and it
is selected against the uBTB by mux at p1, so it is not a
redirect source at any stage.
G. RAS open items RAS-1, RAS-2, RAS-3.
See section 7.2 and planning/arch/ras_decisions.md section 10.
RAS-2 (stack depth): CLOSED session-050.
16 speculative + 32 commit, static partition.
See ras_decisions.md section 3.
RAS-1 (push timing): PARTIALLY RESOLVED session-050.
Push at p2 gated on FTB branch type.
See ras_decisions.md section 7.
RAS-3 (flush recovery): CLOSED 2026-08-20, and answered by
ras_decisions.md 4.4 well before that date -- only the
label said otherwise. The RAS response to a flush is the
pointer restore of 4.3, built and tested as
ras_restore_val. BP-105 then closed the flush EVENT as
well: there is none (fe_decisions.md FE-14). Do not re-raise from the
unread ras_flush_* ports (4.4.2).
H. FTB and LP parameter values. Marked TBD; assign before each
module's arbitration RTL is written. SC AND ITTAGE ARE NOT
TBD -- 5.4 and 5.5 give their values (SC_UQ_DEPTH = 8,
SC_UQ_WR_PORTS = 2, and the ITTAGE set). This read "FTB, LP,
SC, ITTAGE ... All marked TBD". Session-070.
I. ITTAGE arbitration spec.
CLOSED. Confirm with PA.
OLD:
Deferred until TAGE is fully validated.
Placeholder in section 5.4.6
J. MOOT, BP-121 (session-076): the credit rules are replaced
(4.5), so the parameter relationship below no longer exists.
TD#39. PRED_CREDITS < STARVE_THRESH, so the section 4.5
rule 2 starvation override is unreachable in ordinary traffic
at the current parameter values. IT IS NOT UNTESTABLE AND THE
TESTS ARE WRITTEN: TD#73 closed by BP-094 group H, which
covers all seven grant rules, and test H6 SEEDS the starve
counter to reach the override (PROJECT_STATUS TD#39, TD#73).
What remains is only whether the parameter relationship is
intentional. This read "may be unreachable ... and therefore
untestable ... before the arbiter tests are written", which
contradicts 4.5's "All seven are TESTED". Session-070.
12. Document History¶
2026-04-09 Session-025. Initial draft. Supersedes
tage_pred_upd_arb_spec.md. Resolves debt #33.
Open item A closed same session.
Rev 2 same session: SC/TAGE merged metadata
structs (cond_pred_meta_t, cond_pred_upd_inp_t).
SC lockstep constraint eliminated by design.
Covers all predictors: uFTB, RAS, FTB, LP,
TAGE, SC, ITTAGE.
Status: draft, open items B-I remain.
TAGE section ready for RTL planning.
Other predictors: architecture settled,
parameters TBD.
2026-06-23 Session-050. Consistency pass.
Section 2 predictor inventory: RAS row updated
to clarify p0=TOS read only, p2=push/pop and
redirect participation. Override stage column
updated to p2.
Section 3.2 stage assignments: RAS entry
expanded to note both p0 and p2 roles.
Section 3.4: note added clarifying RAS p0
output is TOS read; push/pop at p2.
Section 7.2: push timing updated to p2 gated
on FTB branch type (RAS-1 partially resolved).
Snapshot field widths corrected to RAS_PTR_BITS
= 4b (was unstated; old linked-array reference
removed from struct comment in bp_structs_pkg).
Open item G: RAS-1/RAS-2/RAS-3 status updated.
References to ras_decisions.md added throughout.
2026-06-28 Session-057. Manual edits
SC semantics defined.
PA consistency pass: section 2 SC update timing
"lockstep w/ TAGE" replaced with "separate UQ";
section 5.5 SC params reconciled (SC_PQ_DEPTH
removed; TAGE response buffer is SC's PQ; six
arbiter params retained for single-port RAM
predict-vs-update contention); section 6 lead-in
and 6.1 closing added to state the SC arbiter
draws predictions from the TAGE response buffer
and updates from the SC UQ. Typo fixes (responses,
prediction, These signals). Section 6.1 cross-ref
"section 61" corrected to 6.1.
2026-08-09 PA-direct correction, session-064. Section 6.1 now
names the
three SC index folds among the p0-to-p2 staged
inputs, alongside the prediction PC and the phr
(TD#92, staged by BP-090), with the reason recorded:
bp_history advances whenever a branch is predicted,
so the live folds at p2 belonged to a later block.
Redirect naming: a caveat added at section 0 and the
status note in section 3.4 rewritten -- no predictor
declares a redirect port and none is planned; the
delivered groups are bpu_redir_p2 and bpu_redir_p3,
derived at the cluster boundary and named by stage.
The Override lines in 5.1 through 5.5 retargeted to
those groups, and the LP's marked NONE since it is
selected by mux at p1 rather than redirecting. Open
item F closed on the same basis, open item J added
for TD#39, and the TD#39 note added at section 4.2.
Notes added where fe_decisions.md section 12 already
records a deliberate departure (sections 2, 3.3, 4.4,
7.1). Section 4.5 marked implemented-for-SC and
untested (TD#73). RAS p0 port names stated.
2026-09-17 Session-070 audit. Section 4.5 and 5.5 both read
"untested; TD#73". TD#73 closed by BP-094 group H,
whose closure covers exactly the seven 4.5 grant
rules plus tage consumer_ready, hierarchically. Both
corrected to TESTED. The TD#39 precondition in 4.5
is also overtaken: TD#39 was folded into the TD#73
closure and its residual is a parameter decision.
Section 5.5 read "not stubbed at the unit level".
That is wrong. sc.sv assigns sc_uq_not_full = 1'b1
and sc_upd_rdy = all-ones under a comment naming
them arbitration-layer stubs, and builds no SC UQ.
Both statements are true together: the arbiter is in
bp_cluster, and the unit-level ports are stubbed.
5.5 now says so, and marks SC_UQ_DEPTH and
SC_UQ_WR_PORTS as target-model values.
The SC UQ gap itself is now untracked. TD#73 and
TD#94 are closed and neither was about building the
queue, yet this document, sc_interfaces.md and
sc.sv (lines 30-32 and 148) all name them as the
deferral. Raised as TD#123.
2026-09-19 session-071. Notes added at section 3 (after the
redirect interface listing), 6.2 and 7.2 recording
fe_decisions.md 12's departures: neither the uBTB nor
the RAS drives the FTQ at p0, the RAS TOS read is an
input to the p1 prediction, and the 6.2 producer is
resolution, not commit. The inventory row's RAS p0
cell restated. 7.2: the snapshot is written at p2 for
every valid block. 5.1: prediction block, not fetch
block. The 2026-08-09 entry was labelled INFRA-012,
which did not exist then.
2026-09-20 session-072. 2 and 3.2: the LP row's stage columns read p1/p2 and
p1/p2; now p1 and NONE, matching 5.2, open item F and
fe_decisions.md 3.2. 5.2 notes that fe_decisions.md 12
now lists the no-SRAM departure.
2026-10-07 session-075, after BP-119. 6.2: the SC update request
is an SC update presented; the SC ready is a grant
that depends on it.
2026-10-08 session-076, PA-direct correction recording BP-121.
4.5: rules 2-4 replaced; a prediction is never
delayed, an update is granted with no prediction
presented, and a starvation hold drops the
queue-ready for one cycle (decision 5, D6, D13). The
credit counters are removed. 4.1, 4.2, 4.8, 5.5, 6,
6.1: credit wording. TD#39 and item J moot.
2026-10-10 session-077, after BP-126. 4.5: the SC request,
grant and readies with the SC UQ (TD#123, P-3). 5.5:
the SC UQ built. 6.2: the BP-119 request and ready
superseded.
2026-10-12 session-078, after BP-132. 4.4: the UQ ready is
<pred>_uq_not_full (TD#49). 5.3, 5.4: the TAGE and
ITTAGE arbitration is in tage_arb.sv and ittage_arb.sv
(TD#52).
2026-10-12 session-078, TD#97 closed (Jeff). 8.2 and 11.D: the
shared upstream PQ is not built and not needed.
2026-10-14 session-080, after BP-135. 4.5: sim_bp_cluster_init
reaches H2b from the ports.
2026-10-29 session-082, after DOC-011. 7.2: the snapshot is
written for every valid p2 block; the commit updates the
commit stack and BOS.
bpu_port_inventory.md
planning/interfaces/bpu_port_inventory.md on GitHub
BPU Top-Level Port Inventory¶
FILE: bpu_port_inventory.md
SOURCE: INFRA-011
STATUS: DRAFT
UPDATED: 2026-10-10
CONTACT: Jeff Nye
STATUS, session-071. This is the INFRA-011 read of the RTL port blocks, 2026-08-02. Sections 1 and 2 have been brought up to date from the task records since, NOT re-read from the RTL: ubtb gained blk_p1 (session-063) and ubtb_interfaces.md now uses the suffixed names, and BP-091 made loop_pred per-slot and renamed pred_p0 to pred_p1 (TD#105). Sections 3 to 8 are as read by INFRA-011 and have not been re-verified. A fresh read is the only way to make this file an RTL fact again.
Session-077, from BP-126's Results Capture, not re-read from the RTL: ras lost ras_pc_p2 (TD#101) and sc gained sc_uq_has_data and sc_uq_rd_en (TD#123). Sections 6 and 7 and Coverage are updated.
Legend¶
Stage is the pipestage suffix carried by the port name as declared. NONE means the name carries no suffix. Slot is ARRAY for a declared slot dimension, SCALAR for a single non-slotted signal, PACKED when the slot dimension is inside the struct, NAMED when the slot appears in the port name. Doc is OK when the interface document lists the port with matching direction and type, MISMATCH when listed differently, MISSING when not listed.
1. ubtb¶
RTL: rtl/core/frontend/bpu/rtl/ubtb.sv Doc: planning/interfaces/ubtb_interfaces.md
| Port | Dir | Type / Width | Stage | Slot | Doc |
|---|---|---|---|---|---|
| clk | in | logic | NONE | SCALAR | OK |
| rstn | in | logic | NONE | SCALAR | OK |
| pred_pc_p0 | in | [VA_WIDTH-1:0] | p0 | SCALAR | OK |
| pred_p1 | out | ubtb_pred_t | p1 | ARRAY | OK |
| blk_p1 | out | ubtb_blk_t | p1 | SCALAR | OK |
| upd_u0 | in | ubtb_upd_t | u0 | ARRAY | OK |
Notes:
- pred_p1 declared with packed slot dimension on the type:
`ubtb_pred_t [NUM_PRED_SLOTS-1:0] pred_p1` (ubtb.sv:37 at
INFRA-011).
- upd_u0 declared with packed slot dimension on the type:
`ubtb_upd_t [NUM_PRED_SLOTS-1:0] upd_u0` (ubtb.sv:38 at
INFRA-011).
- blk_p1 added session-071 from the records: ubtb.sv has it
(PROJECT_STATUS.md Module Status) and ubtb_interfaces.md lists it.
Its line is not recorded here.
- Findings 1 to 3 are resolved: ubtb_interfaces.md names the ports
pred_pc_p0, pred_p1, blk_p1 and upd_u0. This table read five
ports, no blk_p1, and three MISMATCH rows. Session-071.
EXTRA: none
2. loop_pred¶
RTL: rtl/core/frontend/bpu/rtl/loop_pred.sv Doc: planning/interfaces/loop_pred_interfaces.md
| Port | Dir | Type / Width | Stage | Slot | Doc |
|---|---|---|---|---|---|
| clk | in | logic | NONE | SCALAR | OK |
| rstn | in | logic | NONE | SCALAR | OK |
| pred_pc_p0 | in | [VA_WIDTH-1:0] | p0 | ARRAY | OK |
| pred_valid_p0 | in | [NUM_PRED_SLOTS-1:0] | p0 | ARRAY | OK |
| pred_p1 | out | lp_pred_t | p1 | ARRAY | OK |
| upd_p0 | in | lp_upd_t | p0 | ARRAY | OK |
| upd_valid_p0 | in | [NUM_PRED_SLOTS-1:0] | p0 | ARRAY | OK |
Notes:
- Brought up to date session-071 from BP-091 (TD#105) and
loop_pred_interfaces.md, not re-read from the RTL. The payload
and address ports are unpacked [0:NUM_PRED_SLOTS-1] after the
name, the valid bits a packed vector. This table read every port
SCALAR and the prediction output as pred_p0, the pre-BP-091 RTL.
EXTRA: none
3. ftb¶
RTL: rtl/core/frontend/bpu/rtl/ftb.sv Doc: planning/interfaces/ftb_interfaces.md
| Port | Dir | Type / Width | Stage | Slot | Doc |
|---|---|---|---|---|---|
| clk | in | logic | NONE | SCALAR | OK |
| rstn | in | logic | NONE | SCALAR | OK |
| pred_valid_p0 | in | logic | p0 | SCALAR | OK |
| pred_pc_p0 | in | [VA_WIDTH-1:0] | p0 | SCALAR | OK |
| ftb_valid_p2 | out | logic | p2 | SCALAR | OK |
| ftb_hit_p2 | out | logic | p2 | SCALAR | OK |
| ftb_way_p2 | out | [FTB_WAY_BITS-1:0] | p2 | SCALAR | OK |
| ftb_br0_valid_p2 | out | logic | p2 | SCALAR | OK |
| ftb_br0_pos_p2 | out | [FTB_BR_POS_BITS-1:0] | p2 | SCALAR | OK |
| ftb_br0_taken_p2 | out | logic | p2 | SCALAR | OK |
| ftb_br0_conf_p2 | out | [FTB_CONF_WIDTH-1:0] | p2 | SCALAR | OK |
| ftb_br0_target_p2 | out | [VA_WIDTH-1:0] | p2 | SCALAR | OK |
| ftb_br1_valid_p2 | out | logic | p2 | SCALAR | OK |
| ftb_br1_pos_p2 | out | [FTB_BR_POS_BITS-1:0] | p2 | SCALAR | OK |
| ftb_br1_taken_p2 | out | logic | p2 | SCALAR | OK |
| ftb_br1_conf_p2 | out | [FTB_CONF_WIDTH-1:0] | p2 | SCALAR | OK |
| ftb_br1_target_p2 | out | [VA_WIDTH-1:0] | p2 | SCALAR | OK |
| ftb_jmp_valid_p2 | out | logic | p2 | SCALAR | OK |
| ftb_jmp_pos_p2 | out | [FTB_BR_POS_BITS-1:0] | p2 | SCALAR | OK |
| ftb_jmp_target_p2 | out | [VA_WIDTH-1:0] | p2 | SCALAR | OK |
| ftb_is_call_p2 | out | logic | p2 | SCALAR | OK |
| ftb_is_ret_p2 | out | logic | p2 | SCALAR | OK |
| ftb_is_jalr_p2 | out | logic | p2 | SCALAR | OK |
| ftb_pft_addr_p2 | out | [VA_WIDTH-1:0] | p2 | SCALAR | OK |
| ftb_fastpath_p2 | out | [1:0] | p2 | SCALAR | OK |
| ftb_fastpath_en | in | logic | NONE | SCALAR | OK |
| ftb_upd_valid_u0 | in | logic | u0 | SCALAR | OK |
| ftb_upd_pc_u0 | in | [VA_WIDTH-1:0] | u0 | SCALAR | OK |
| ftb_upd_hit_u0 | in | logic | u0 | SCALAR | OK |
| ftb_upd_way_u0 | in | [FTB_WAY_BITS-1:0] | u0 | SCALAR | OK |
| ftb_upd_is_br_u0 | in | logic | u0 | SCALAR | OK |
| ftb_upd_br_idx_u0 | in | logic | u0 | SCALAR | OK |
| ftb_upd_taken_u0 | in | logic | u0 | SCALAR | OK |
| ftb_upd_target_u0 | in | [VA_WIDTH-1:0] | u0 | SCALAR | OK |
| ftb_upd_pos_u0 | in | [FTB_BR_POS_BITS-1:0] | u0 | SCALAR | OK |
| ftb_upd_is_jmp_u0 | in | logic | u0 | SCALAR | OK |
| ftb_upd_jmp_target_u0 | in | [VA_WIDTH-1:0] | u0 | SCALAR | OK |
| ftb_upd_is_call_u0 | in | logic | u0 | SCALAR | OK |
| ftb_upd_is_ret_u0 | in | logic | u0 | SCALAR | OK |
| ftb_upd_is_jalr_u0 | in | logic | u0 | SCALAR | OK |
| ftb_upd_pft_addr_u0 | in | [VA_WIDTH-1:0] | u0 | SCALAR | OK |
| ftb_flush_px | in | logic | px | SCALAR | OK |
Notes:
- br0 / br1 / jmp in the port names are the conditional and jump
fields of one indexed entry, not prediction slots
(ftb_interfaces.md:77-78). Slot is SCALAR on those rows.
- ftb_fastpath_p2 [1:0] is bit 0 = br0, bit 1 = br1
(ftb_interfaces.md:171), not a slot dimension.
EXTRA: none
4. tage¶
RTL: rtl/core/frontend/bpu/rtl/tage.sv Doc: planning/interfaces/tage_interfaces.md
| Port | Dir | Type / Width | Stage | Slot | Doc |
|---|---|---|---|---|---|
| clk | in | logic | NONE | SCALAR | OK |
| rstn | in | logic | NONE | SCALAR | OK |
| tage_pred_val_p0 | in | [NUM_PRED_SLOTS-1:0] | p0 | ARRAY | OK |
| tage_pred_inp_p0 | in | tage_pred_inp_t | p0 | ARRAY | OK |
| tage_pred_rdy_p2 | out | [NUM_PRED_SLOTS-1:0] | p2 | ARRAY | OK |
| tage_pred_meta_p2 | out | tage_pred_meta_t | p2 | ARRAY | OK |
| tage_upd_val_u0 | in | [NUM_PRED_SLOTS-1:0] | u0 | ARRAY | OK |
| tage_upd_inp_u0 | in | tage_upd_inp_t | u0 | ARRAY | OK |
| tage_upd_rdy_u1 | out | [NUM_PRED_SLOTS-1:0] | u1 | ARRAY | OK |
| pq_not_full | out | logic | NONE | SCALAR | OK |
| upd_rdy | out | [NUM_PRED_SLOTS-1:0] | NONE | ARRAY | OK |
| tage_enable_aging | in | logic | NONE | SCALAR | OK |
| tage_aging_interval | in | [31:0] | NONE | SCALAR | OK |
| consumer_ready | in | logic | NONE | SCALAR | OK |
| folded_hist | in | bp_folded_hist_t | NONE | SCALAR | OK |
| tage_rdy | out | logic | NONE | SCALAR | OK |
Notes:
- tage_pred_inp_p0, tage_pred_meta_p2, tage_upd_inp_u0 declared with
unpacked slot dimension [0:NUM_PRED_SLOTS-1] after the port name
(tage.sv:39, 41, 44).
- The _val / _rdy ports carry the slot dimension as a packed vector
[NUM_PRED_SLOTS-1:0], one bit per slot.
EXTRA: none
5. ittage¶
RTL: rtl/core/frontend/bpu/rtl/ittage.sv Doc: planning/interfaces/ittage_interfaces.md
| Port | Dir | Type / Width | Stage | Slot | Doc |
|---|---|---|---|---|---|
| clk | in | logic | NONE | SCALAR | OK |
| rstn | in | logic | NONE | SCALAR | OK |
| ittage_pred_val_p0 | in | [NUM_PRED_SLOTS-1:0] | p0 | ARRAY | OK |
| ittage_pred_inp_p0 | in | ittage_pred_inp_t | p0 | ARRAY | OK |
| ittage_pred_rdy_p2 | out | [NUM_PRED_SLOTS-1:0] | p2 | ARRAY | OK |
| ittage_pred_meta_p2 | out | ittage_pred_meta_t | p2 | ARRAY | OK |
| ittage_upd_val_u0 | in | [NUM_PRED_SLOTS-1:0] | u0 | ARRAY | OK |
| ittage_upd_inp_u0 | in | ittage_upd_inp_t | u0 | ARRAY | OK |
| ittage_upd_rdy_u1 | out | [NUM_PRED_SLOTS-1:0] | u1 | ARRAY | OK |
| pq_not_full | out | logic | NONE | SCALAR | OK |
| upd_rdy | out | [NUM_PRED_SLOTS-1:0] | NONE | ARRAY | OK |
| ittage_enable_aging | in | logic | NONE | SCALAR | OK |
| ittage_aging_interval | in | [31:0] | NONE | SCALAR | OK |
| folded_hist | in | bp_folded_hist_t | NONE | SCALAR | OK |
| ittage_rdy | out | logic | NONE | SCALAR | OK |
Notes:
- ittage_pred_inp_p0, ittage_pred_meta_p2, ittage_upd_inp_u0
declared with unpacked slot dimension [0:NUM_PRED_SLOTS-1] after
the port name (ittage.sv:33, 35, 39).
EXTRA: none
6. sc¶
RTL: rtl/core/frontend/bpu/rtl/sc.sv Doc: planning/interfaces/sc_interfaces.md
| Port | Dir | Type / Width | Stage | Slot | Doc |
|---|---|---|---|---|---|
| clk | in | logic | NONE | SCALAR | OK |
| rstn | in | logic | NONE | SCALAR | OK |
| tage_pred_rdy_p2 | in | [NUM_PRED_SLOTS-1:0] | p2 | ARRAY | OK |
| tage_pred_meta_p2 | in | tage_pred_meta_t | p2 | ARRAY | OK |
| inp_pc_p2 | in | [VA_WIDTH-1:1] | p2 | ARRAY | OK |
| sc_phr_p2 | in | [9:0] | p2 | SCALAR | OK |
| sc_t1_idx_fh_p2 | in | [SC_MAX_FH-1:0] | p2 | SCALAR | OK |
| sc_t2_idx_fh_p2 | in | [SC_MAX_FH-1:0] | p2 | SCALAR | OK |
| sc_t3_idx_fh_p2 | in | [SC_MAX_FH-1:0] | p2 | SCALAR | OK |
| sc_pred_rdy_p3 | out | [NUM_PRED_SLOTS-1:0] | p3 | ARRAY | OK |
| sc_pred_meta_p3 | out | sc_pred_meta_t | p3 | ARRAY | OK |
| sc_upd_val_u0 | in | [NUM_PRED_SLOTS-1:0] | u0 | ARRAY | OK |
| sc_upd_inp_u0 | in | sc_upd_inp_t | u0 | ARRAY | OK |
| sc_upd_rdy_u1 | out | [NUM_PRED_SLOTS-1:0] | u1 | ARRAY | OK |
| sc_uq_not_full | out | logic | NONE | SCALAR | OK |
| sc_upd_rdy | out | [NUM_PRED_SLOTS-1:0] | NONE | ARRAY | OK |
| sc_uq_has_data | out | logic | NONE | SCALAR | OK |
| sc_uq_rd_en | in | logic | NONE | SCALAR | OK |
| sc_enable | in | logic | NONE | SCALAR | OK |
| sc_ready | out | logic | NONE | SCALAR | OK |
Notes:
- tage_pred_meta_p2, inp_pc_p2, sc_pred_meta_p3, sc_upd_inp_u0
declared with unpacked slot dimension [0:NUM_PRED_SLOTS-1] after
the port name (sc.sv:60, 63, 71, 75).
- inp_pc_p2 is declared [VA_WIDTH-1:1], not [VA_WIDTH-1:0]
(sc.sv:63). Transcribed as declared.
- sc_uq_has_data and sc_uq_rd_en added by BP-126 (TD#123): the SC
update queue's request and the arbiter's drain grant
(sc_interfaces.md). Their positions in the port block are not
recorded. sc_uq_not_full and sc_upd_rdy are now the queue's room.
EXTRA: none
7. ras¶
RTL: rtl/core/frontend/bpu/rtl/ras.sv Doc: planning/interfaces/ras_interfaces.md
| Port | Dir | Type / Width | Stage | Slot | Doc |
|---|---|---|---|---|---|
| clk | in | logic | NONE | SCALAR | OK |
| rstn | in | logic | NONE | SCALAR | OK |
| ras_tos_addr_p0 | out | [VA_WIDTH-1:0] | p0 | ARRAY | OK |
| ras_tos_valid_p0 | out | logic | p0 | ARRAY | OK |
| ras_pred_val_p2 | in | logic | p2 | ARRAY | OK |
| ras_br_type_p2 | in | bp_br_type_e | p2 | ARRAY | OK |
| ras_fall_through_p2 | in | [VA_WIDTH-1:0] | p2 | ARRAY | OK |
| ras_pop_addr_p2 | out | [VA_WIDTH-1:0] | p2 | ARRAY | OK |
| ras_pop_valid_p2 | out | logic | p2 | ARRAY | OK |
| ras_snapshot_p2 | out | bp_ras_snapshot_t | p2 | ARRAY | OK |
| ras_pred_val_p3 | in | logic | p3 | ARRAY | OK |
| ras_br_type_p3 | in | bp_br_type_e | p3 | ARRAY | OK |
| ras_restore_val | in | logic | NONE | SCALAR | OK |
| ras_restore_snapshot | in | bp_ras_snapshot_t | NONE | SCALAR | OK |
| ras_commit_val | in | logic | NONE | SCALAR | OK |
| ras_commit_br_type | in | bp_br_type_e | NONE | SCALAR | OK |
| ras_commit_ret_addr | in | [VA_WIDTH-1:0] | NONE | SCALAR | OK |
| ras_commit_snapshot | in | bp_ras_snapshot_t | NONE | SCALAR | OK |
| ras_flush_val | in | logic | NONE | SCALAR | OK |
| ras_flush_snapshot | in | bp_ras_snapshot_t | NONE | SCALAR | OK |
Notes:
- All ARRAY rows use the unpacked slot dimension
[0:NUM_PRED_SLOTS-1] after the port name (ras.sv:38-55).
- ras_pc_p2, declared and unread, was removed by BP-126 (TD#101),
from ras.sv and ras_interfaces.md. The line numbers above predate
the removal.
EXTRA: none
8. bp_history¶
RTL: rtl/core/frontend/bpu/rtl/bp_history.sv Doc: planning/interfaces/bp_history_interfaces.md
| Port | Dir | Type / Width | Stage | Slot | Doc |
|---|---|---|---|---|---|
| clk | in | logic | NONE | SCALAR | OK |
| rstn | in | logic | NONE | SCALAR | OK |
| pred_taken | in | [1:0] | NONE | ARRAY | OK |
| pred_pc | in | [VA_WIDTH-1:0] | NONE | ARRAY | MISMATCH |
| num_branches | in | [1:0] | NONE | SCALAR | OK |
| ckpt_wr_en | in | logic | NONE | SCALAR | OK |
| ckpt_wr_idx | in | [FTQ_IDX_BITS-1:0] | NONE | SCALAR | OK |
| rollback_valid | in | logic | NONE | SCALAR | OK |
| rollback_ckpt_idx | in | [FTQ_IDX_BITS-1:0] | NONE | SCALAR | OK |
| ghist_ptr | out | [GHIST_PTR_BITS-1:0] | NONE | SCALAR | OK |
| phist_ptr | out | [PHIST_PTR_BITS-1:0] | NONE | SCALAR | OK |
| ckpt_ghist_ptr | out | [GHIST_PTR_BITS-1:0] | NONE | SCALAR | OK |
| ckpt_phist_ptr | out | [PHIST_PTR_BITS-1:0] | NONE | SCALAR | OK |
| ghr_buf | out | [GHR_WIDTH-1:0] | NONE | SCALAR | OK |
| phr_buf | out | [PHR_WIDTH-1:0] | NONE | SCALAR | OK |
| folded | out | bp_folded_hist_t | NONE | SCALAR | OK |
Notes:
- pred_taken is one bit per slot: bit 0 = slot 0, bit 1 = slot 1
(bp_history.sv:33-34). The dimension is the literal [1:0], not
NUM_PRED_SLOTS.
- pred_pc is declared with the unpacked dimension as the literal
[2] after the port name (bp_history.sv:36), not
[0:NUM_PRED_SLOTS-1].
- num_branches [1:0] is a count with values 0, 1, 2
(bp_history.sv:37), not a slot dimension.
- pred_pc MISMATCH: see finding 4.
EXTRA: none
Findings¶
Findings 1 to 3 RESOLVED session-071: ubtb_interfaces.md now uses the suffixed names. Finding 4 is unchanged in the document (bp_history_interfaces.md still gives pred_pc the packed form) and has not been re-checked against the RTL. Finding 4 cited line 58, which is the clk port; the pred_pc line is cited by name instead, since line numbers move. Session-072.
1 to 3. RESOLVED session-071, recorded as they were written at
INFRA-011. ubtb_interfaces.md listed pred_pc_p0, pred_p1 and
upd_u0 without their stage suffixes, as pred_pc, pred and upd,
while ubtb.sv carried them; the document now names all four
ports, blk_p1 included, so all three MISMATCH rows are gone.
The lines cited then, :45 to :47, are the Port List heading and
its first rows today. Session-072.
- planning/interfaces/bp_history_interfaces.md, Port List, the
pred_pc line -- port pred_pc is listed as
input logic [VA_WIDTH-1:0] [2], both dimensions before the name (packed form). bp_history.sv:36 declaresinput logic [VA_WIDTH-1:0] pred_pc [2], the [2] dimension unpacked after the name. Direction agrees; the dimension placement differs.
Coverage¶
Eight modules, 140 ports read from the RTL port declaration blocks at INFRA-011: ubtb 5, loop_pred 7, ftb 42, tage 16, ittage 15, sc 18, ras 21, bp_history 16. With blk_p1, ubtb is 6 and the total 141 (session-071, from the records). After BP-126, sc is 20 and ras 20, total 142 (session-077, from the records). Ports added since INFRA-011 and not listed here: ftb_jmp_rvc_p2 and ftb_upd_jmp_rvc_u0 (BP-121), ras_p2_keep (BP-121), and bp_history's rollback_corr, rollback_n, rollback_tkn and rollback_pbit (BP-121, BP-122); the counts above exclude them. All eighteen Context Loaded paths were present on disk. No port row required UNKNOWN.
ubtb_interfaces.md
planning/interfaces/ubtb_interfaces.md on GitHub
uBTB Interface Specification¶
FILE: ubtb_interfaces.md
SOURCE: various; session-063 rewrite
STATUS: DRAFT
UPDATED: 2026-10-12
CONTACT: Jeff Nye
Overview¶
The uBTB (micro Branch Target Buffer) is a 256-entry 4-way associative predictor. It fires at p1 and provides the first next-PC prediction to the BP cluster. It does not generate redirect signals. It provides or withholds a prediction only.
One uBTB lookup returns ONE entry describing ONE 32-byte block. That entry holds two conditional branch fields and one jump field, the same shape as an FTB entry (ftb_decisions.md 4). The cluster's two prediction slots are br0 and br1 of that one entry.
Types are defined in bp_structs_pkg.sv. This document describes port semantics, timing contracts, and consumer/producer obligations. It does not restate struct field layouts.
Module Parameters¶
NUM_PRED_SLOTS : int -- elaboration-time only. 1 or 2.
Value 3+ is undefined.
NUM_PRED_SLOTS sizes the prediction output array and the update input array. It does NOT change the number of lookups: one lookup per cycle in either case. At NUM_PRED_SLOTS=1 only the br0 field is reported.
Port List¶
clk : input logic -- rising edge
rstn : input logic -- active low
pred_pc_p0 : input logic [VA_WIDTH-1:0] -- p0 input
pred_p1 : output ubtb_pred_t [NUM_PRED_SLOTS-1:0] -- p1 output
blk_p1 : output ubtb_blk_t -- p1 output
upd_u0 : input ubtb_upd_t [NUM_PRED_SLOTS-1:0] -- post-execute
Prediction Interface¶
Producer: uBTB¶
Consumer: BP cluster (p1 selection mux, FTQ write)¶
Timing¶
pred_pc_p0 is presented at p0 (combinational input).
pred_p1 and blk_p1 are combinational from pred_pc_p0. There is
NO REGISTER IN THE PATH: ubtb.sv derives index and tag by
continuous assign and produces every output field in one
always_comb reading mem, which is a flop array but is read
combinationally. Both outputs are therefore valid WITHIN THE p0
CYCLE, and the BP cluster registers them; the _p1 suffix names
where the consumer sees them, not where this module produces
them. bp_arb_spec.md 7.1 and ftq_bpu_interfaces.md 4.
Both are held stable until the next pred_pc_p0 is presented.
AN EARLIER REVISION said the outputs were "combinational from
registered mem" and "valid at the start of p1, one cycle after
pred_pc_p0". That conflates mem being state with the read being
registered, and claims a cycle of latency the module does not
have. ubtb.sv's header comment carried the same error; its
timing paragraph was right before BP-134, and BP-134 corrected
its opening lines.
Corrected session-070 against the RTL.
Lookup¶
One index and one tag are derived from pred_pc_p0. One way search over UBTB_WAYS. The matched entry supplies every slot.
index : pred_pc_p0[10:5] XOR (pred_pc_p0[4:1] << UBTB_SOFF_SHIFT)
tag : {pred_pc_p0[30:11], pred_pc_p0[4:1]}, UBTB_TAG_BITS = 24
ONE ENTRY PER START PC (BP-140, ruled by Jeff 2026-10-18; PROVISIONAL
index fold), within the partial tag: aliasing above pc[30] is
allowed, as before.
Slot 0 is built from the entry's br0 field. Slot 1 from br1. A slot carrying the block-terminating jump reports the jump field's type and target.
Since BP-140 the entry is one start's block, stored start-relative and in ascending position (br0 below br1, the jump after both), so there is no read window and nothing to compact or reorder; slot 0 is br0 and the first branch. The divergences of session-073 (mask without compaction, br_idx naming a storage field, a hidden field refilled) are gone with the region entry. The bp_cluster p1 swap (FE-10, BP-121 D12) stays and no longer fires for a uBTB entry. REMAINING DIVERGENCES FROM THE FTB: targets are displacements from the block start, not from the branch and jump PCs; the jump field has no rvc bit (a jump's end comes from the update's pft_addr); the fall-through is not bounds checked at the read (blk_p1 below); the tag is partial; replacement is round-robin.
Semantics¶
blk_p1.hit = 1 -- entry valid and tag matched. blk_p1.pft_addr
is valid. Each pred_p1[s] is valid or not per
its own valid bit.
blk_p1.hit = 0 -- uBTB miss. Every pred_p1[s].valid is 0 and all
other fields are driven 0. No prediction for
this block.
pred_p1[s].valid = 1 -- slot s of the matched entry carries a
branch. All other fields in pred_p1[s]
are valid and must be consumed.
pred_p1[s].valid = 0 -- slot s carries no branch. All other
fields are driven 0 and must be ignored.
A hit with no valid slot is a legal state: the block is known and contains no branch the uBTB has recorded. The successor is the fallthrough.
On miss the BP cluster proceeds with fetch at the fallthrough. The uBTB asserts no redirect and no stall.
THE MISS FALLTHROUGH IS NOT FROM THIS MODULE. blk_p1.pft_addr is
driven 0 on a miss like every other field, so the cluster computes
the successor itself: lookup PC + FTB_BLOCK_BYTES, 32 bytes
(bp_cluster.md, Block width). The base is the lookup PC, not the
32-byte-aligned address containing it, so a miss does not resync
the stream to alignment.
pred_p1[s] field semantics¶
target : predicted target for this slot, reconstructed to full
width by ubtb.sv from the stored displacement. Valid
when pred_p1[s].valid=1. Ignored by fetch when
br_type==RETURN; RAS provides the target at p2.
br_type : bp_br_type_e. Valid when pred_p1[s].valid=1. The
conditional fields always report COND. The slot
carrying the jump field reports DIRECT_CALL,
INDIRECT_CALL, RETURN, RETURN_CALL, INDIRECT_NONRET,
or DIRECT_UNC per the stored is_call / is_ret /
is_jalr bits.
RETURN_CALL is is_call AND is_ret AND is_jalr, added
session-069 for the JALR that pops then pushes
(ras_decisions.md 2). The stored bits already express
it; only the enum mapping was missing.
br_taken : predicted direction, the conf MSB. Meaningful only when
br_type==COND. Present in the struct for all types but
the consumer must ignore it for non-COND.
pos : in-block instruction position, 0..15, of this branch,
counted from the BLOCK START, stored in the same form
(UBTB_BR_POS_BITS; region-relative and windowed from
session-071 to BP-140).
The cluster uses it to locate the branch in the fetch
bundle. NOT to order br0 against br1: br0 is always
the earlier branch by fill order
(ftb_decisions.md 4, IC-FTB-16). This read "to order
br0 against br1". Session-070. It is used to
locate the taken branch in the fetch bundle.
conf : the bimodal direction counter value. MSB is the
direction.
carry : DELETED by BP-110 (session-073). It was the ENTRY
fall-through carry, the block-scoped overflow bit of
the stored pftAddr, and it had no consumer anywhere in
rtl/. Nothing replaces it: at six bits pftAddr reaches
past the block boundary on its own, so a consumer
derives the crossing from blk_p1.pft_addr itself.
G18 and UI2 close as "field removed".
It read at one point as "1 when THIS SLOT'S TARGET
lies outside this block" and "NOT the carry used to
reconstruct blk_p1.pft_addr" (session-069), which
session-070's package-comment correction reversed.
Session-071.
blk_p1 field semantics¶
hit : entry valid and tag matched.
pft_addr : the block end, reconstructed to full width from the
stored partial pftAddr: five bits measured from the
BLOCK START (BP-140; six from the aligned region base
before it), no carry bit. ftb_decisions.md 5.5, 8.1.
Authoritative for the cluster when no slot is taken.
IT IS NOT BOUNDS CHECKED. Ruled session-073 (Jeff).
This entry previously required the FTB-G1 rule of
ftb_decisions.md 4.5, and the RTL has never had it.
The uBTB index drops UBTB_OFFSET_BITS and blocks are
unaligned, so two lookup PCs in one 32-byte region do
share an entry and an aliased end can be reported.
That is accepted for the same reason as the slot
divergence above: the p1 prediction is superseded at
p2, where the FTB result IS bounds checked (FTB-G1 and
FTB-G3).
Consumer obligations¶
- Must not use pred_p1[s] when blk_p1.hit=0.
- Must not use pred_p1[s].target when pred_p1[s].valid=0.
- Must not use pred_p1[s].br_taken when br_type != COND.
- Must write the selected slot into the FTQ fast path
(bp_ftq_slot_t) with pred_src set to PRED_UBTB.
The uBTB takes no part in the redirect comparison. The cluster compares the successor it would publish at p2 against its own p1 stage registers (fe_decisions.md FE-4); no predictor is compared against another, and the uBTB is not a redirect source. This list carried "Must compare pred_p1[s] against the p2 FTB result and derive a redirect if they disagree". Session-071.
Update Interface¶
Producer: post-execute resolution path (BP cluster)¶
Consumer: uBTB¶
Timing¶
upd_u0 is a synchronous input, sampled on the rising clk edge.
upd_u0[u].valid may be asserted in any cycle.
Both channels are processed in the same cycle. Both may target the same entry; they write different fields of it.
Semantics¶
upd_u0[u].valid = 0 -- channel u carries no update this cycle.
upd_u0[u].valid = 1 -- channel u carries a resolved update. All
other fields are valid and are written to
the uBTB entry.
upd_u0[u] field semantics¶
pc : block start PC of the entry being updated. Derives
the set index and tag for the write.
is_br : this resolve is a conditional branch.
br_idx : NOT READ since BP-140. A conditional's field is named
by its position (Allocation and field writes); the
member stays in ubtb_upd_t (ports unchanged).
RESERVED (Jeff, session-081).
br_taken : resolved direction. Drives the bimodal conf step, and
at fill the weak conf init direction.
target : resolved taken target, full width. ubtb.sv converts
to the stored displacement form.
pos : in-block position of the resolving branch, 0..15,
START-relative, stored as given (BP-140). Names the
field: the same position is the same branch.
is_jmp : this resolve is a jump.
jmp_target : resolved jump target, full width. Written on every
jump resolve.
is_call : jump type.
is_ret : jump type.
is_jalr : jump type.
pft_addr : resolved block end, full width. Written only for a
jump (the FTQ's resolved end of the taken jump,
TD#164), reduced to five bits from the block start;
for a conditional it is the block's predicted end and
is not written (BP-140, PROVISIONAL, as the FTB).
Allocation and field writes¶
The uBTB applies the FTB's update rule (ftb_decisions.md 3 and 5.5
as restated by BP-140; ubtb.sv apply_upd):
same position, same kind : a conditional trains conf toward
the outcome and rewrites its target;
a jump rewrites the jump field.
same position, other kind : replaces that field.
at or after the end, or after
the stored jump : no change (a stale resolution).
new branch : joins the held ones in position
order, weak conf; a new jump removes
the conditionals after it.
more than N_SLOTS branches : THE SPLIT. The lowest N_SLOTS kept;
the end is the PC of the first not
kept; a jump not kept is cleared.
Tag miss : allocate, end start + 32. The
evicted way is the round-robin
write pointer.
A branch cannot fill both conditional fields (BP-131 measured 82 at
two slots before BP-140; the position now names the field). Two
channels landing on one entry in one cycle are applied in order and
give the same entry in either order (tb_ubtb TC21). The jump target
is rewritten on every resolve of that jump.
Read-during-write contract¶
If an update and pred_pc_p0 index the same set in the same cycle, pred_p1 reflects the pre-update state. The new entry is visible on the following cycle. The producer must not depend on same-cycle readback.
Producer obligations¶
- Must provide resolved values, not speculative ones.
- Must compute pft_addr correctly before asserting valid (and,
in the built form, carry; TD#124 deletes it).
- Both channels may target one entry in the same cycle. They must
not target the same FIELD of that entry.
Miss Signaling Contract¶
The uBTB has no miss output port. Miss is blk_p1.hit=0. The BP
cluster detects the miss and continues fetch at the fallthrough it
computes itself, lookup PC + FTB_BLOCK_BYTES; see the Semantics
section above and bp_cluster.md.
The uBTB does not stall, does not generate a redirect, and does not communicate miss reason or miss type externally.
Known Gaps and Deferred Items¶
| ID | Item | Status |
|---|---|---|
| UI2 | CLOSED session-073, BP-110. The carry | Field removed. |
| field is deleted; it never had a | ||
| consumer. G18 closes with it. | ||
| UI3 | Both update channels targeting one entry | Confirm at |
| in the same cycle. Same-field collision | bp_cluster | |
| is a producer error. |
Document History¶
2026-10-19 session-081, after BP-140. Per-start entries and the
split at update, the rule the FTB uses; the region
window, the masking and the field named by br_idx are
gone. One branch can no longer fill both conditional
fields. br_idx is no longer read and is kept reserved
(Jeff).
2026-10-12 session-079, after BP-134. Timing: the ubtb.sv header
comment corrected.
2026-10-12 session-078, after BP-131. Allocation and field writes:
one branch can fill both conditional fields, measured
82 times at two slots; the block split is not built.
Both deferred to TD#179.
2026-10-08 session-076, PA-direct correction recording BP-121.
Lookup: the p1 slot-order inversion was not harmless;
bp_cluster swaps the p1 slots (D12).
2026-10-08 session-075, after BP-120. The position rule built;
only the field br_idx names is compared.
2026-10-07 session-075, after BP-119. Allocation and field
writes: a filled field keeps pos only for the same
position; otherwise the jump field is rewritten or
the conditional filled as new (ruled, Jeff), TD#156.
pft_addr text brought to the BP-110 build (no carry).
The cluster now meets the obligation not to use
br_taken when br_type is not COND (BP-119).
2026-09-22 session-073, after BP-110. The uBTB divergence from
the FTB is ruled and stated at the head of the
prediction section: mask only, no compaction, no
reorder, br_idx names a storage field, and a hidden
field is refilled. pft_addr is six bits with no carry
and is ruled NOT bounds checked. carry deleted; G18
and UI2 closed.
2026-09-20 session-072. The Update Interface pft_addr field, the
pftAddr/carry recompute and the producer obligation
annotated as the built form against the TD#124
ruling.
2026-09-19 session-071. pos is start-relative at both ports and
stored region-relative, one bit wider, with a read
window, as the FTB (ftb_decisions.md 4.6, TD#125). The
consumer obligation to compare pred_p1 against the p2
FTB result is removed: FE-4. carry is the entry
fall-through carry, as G18 and the package say, not
a slot-target bit; TD#124 removes its source. "Fetch
block" replaced by
"prediction block" where the 32-byte unit was meant.
2026-09-15 session-069. The miss fallthrough is stated: the
cluster computes lookup PC + FTB_BLOCK_BYTES, this
module drives 0. Previously the fallthrough was
named twice and defined nowhere.
2026-09-15 session-069. pft_addr reconstruction is bounds
checked, matching ftb_decisions.md 4.5 FTB-G1. The
two meanings of "carry", per-slot target-outside-block
and per-block fall-through overflow, are distinguished
in the field semantics. G18 / UI2.
2026-08-02 session-063. Single-lookup block descriptor model.
One lookup returns one entry describing one 32-byte
block; the two prediction slots are br0 and br1 of
that entry. ubtb_entry_t reshaped to the FTB entry
format. ubtb_pred_t gains pos and conf. ubtb_upd_t
reshaped to mirror the FTB update port. ubtb_blk_t
added for the entry-scoped hit and fallthrough.
UI1 and UI4 closed.
tage_cntrl_decisions.md
planning/arch/tage_cntrl_decisions.md on GitHub
tage_cntrl Design Decisions¶
FILE: tage_cntrl_decisions.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-12
CONTACT: Jeff Nye
Manual Changes Already Applied¶
The following changes have been applied manually to bp_structs_pkg.sv before the BP-008 prompt is executed. Claude Code must not re-apply or modify these.
tage_pred_meta_t field renames:
tage_pred_idx -> tage_prm_idx
tage_pred_comp -> tage_prm_comp
tage_pred_useful -> tage_prm_useful
tage_pred_ctr -> tage_prm_ctr
tage_pred_meta_t fields added:
tage_prm_tkn -- direction from primary component CTR MSB
tage_alt_tkn -- direction from alternate component CTR MSB
Scope¶
This document captures settled design decisions for tage_cntrl.sv (BP-008). It is a companion to tage_interfaces.md and tage_table_interfaces.md. It does not restate information already in those documents unless a decision modifies or extends them.
Dual Prediction Support¶
tage_cntrl supports two simultaneous prediction requests via vector-indexed ports sized to NUM_PRED_SLOTS. Slot 0 and slot 1 operate identically and independently -- there is no cross-slot interaction in prediction logic, update logic, or UAON counter state. Both slots may have tage_pred_val_p0 asserted in the same cycle. Each slot has its own uaon counter (uaon[0], uaon[1]) and aging interval counter (lcl_aging_interval[0], lcl_aging_interval[1]). Provider selection, alternate provider selection, UAON mux, and tage_pred_meta population are replicated per slot. Slot 1 PC is supplied by the fetch unit via tage_pred_inp_p0[1].pc. No offset derivation is performed in tage_cntrl. tage_cntrl consumes tage_pred_inp_p0[slot].pc[12:2] as the T0 RAM index for each slot directly.
T0 Behavior¶
T0 is the base table. It has no valid bit, no tag, no useful bit. tage_cntrl treats T0 output as always-hit. T0 taken_p1 is unconditionally valid as the fallback direction.
T0 uses a 2b saturating counter. Weak states are 01 and 10. T0 initializes to 10 (weakly taken), TAGE_T0_SRAM_INIT_VALUE = 2 in bp_defines_pkg.sv; the tagged tables T1-T4 initialize to 0 (TAGE_SRAM_INIT_VALUE). BP-126, TD#103. This read "T0 initializes to 00 (strongly not taken), per TAGE_SRAM_INIT_VALUE=0", which recorded the RTL before BP-126, not the intent (PROJECT_STATUS.md, session-061 CONFLICT TO RESOLVE note, resolved). Session-077.
T0 is the provider when no tagged table hits (ADR-001, tage_cntrl_ctr_update_rules.md), and use_alt_on_na does not apply then. T0 IS the alternate when the primary is T1, or when only one tagged table hits (Alternate provider, below; rows 14-17 of the CTR update table). This read "T0 is never the alternate provider", which the next paragraph, the Alternate provider section and the CTR table all contradict. Session-072.
When use_alt_on_na fires and the alternate is T0, the direction comes from T0 CTR MSB (bit 1). T0 is then the provider; it steps toward the outcome and is written through tage_bim's alt update bus (tage_cntrl_ctr_update_rules.md rows 19.1-19.8, BP-133, TD#18).
T0 direction is always taken from the taken_p1[s] port output of the T0 tage_bim instance (tage_table_interfaces.md, T0 Port List), seen inside tage_cntrl as t_taken_p1[0][s], not from the padded CTR field in tage_pred_meta_t. t_taken_p1 is defined in tage_table_interfaces.md as the MSB of the T0 entry, which is CTR[1]. tage_prm_ctr stores the T0 2b CTR zero-padded to 3b when T0 is provider. tage_prm_ctr[2] is always zero for T0 and must never be used as the direction signal.
The confidence decode (tage_pred_strong, tage_pred_medium, tage_pred_weak) and tage_extd_ctr do not read this padded form. For a T0 provider they read the equivalent 3b value {ctr[1], ctr[0], ctr[0]}: 00 -> 000, 01 -> 011, 10 -> 100, 11 -> 111 (TD#182, BP-134, ruled session-079). The stored tage_prm_ctr and tage_alt_ctr keep the zero-padded form, which the update path reads. tage_prm_tkn captures the correct direction from t_taken_p1[0][s] at predict time and is the authoritative direction field for both prediction output and update-time interpretation.
T0 is its own module, tage_bim.sv, not a tage_table instance (tage_table_interfaces.md Table description, sram_init.md, tage_interfaces.md). This read "the T0 tage_table instance". Session-072.
CTR Encoding (T1-T4, 3b)¶
000 sn not taken strongly not taken
001 wn2 not taken weakly not taken (less weak)
010 wn1 not taken weakly not taken (just flipped)
011 wn0 not taken weakest not taken
100 wt0 taken weakest taken
101 wt1 taken weakly taken
110 wt2 taken weakly taken (less weak)
111 wt3 taken strongly taken
Direction = CTR[2] (MSB).
Strong states: 000 (strongly NT), 111 (strongly T). Weak states: 011 and 100 only -- the most uncertain, and the use_alt_on_na trigger points. Medium states: 001, 010 (NT) and 101, 110 (T). This is the one-hot decode of tage_pred_strong, tage_pred_weak and tage_pred_medium (TD#87, below and tage_interfaces.md). This read "Weak states: 001, 010, 011 ... 100, 101, 110" with 011 and 100 as separate "boundary" states; TD#87 moved 001, 010, 101 and 110 to medium and the list was not updated. The wn/wt mnemonics in the table above are names, not the class. Session-071.
Newly allocated entries initialize to 100 (weakest taken).
use_alt_on_na Counters¶
Two 4b saturating counters, one per prediction slot. Both owned by tage_cntrl. Both operate independently. No cross-slot interaction in prediction or update.
Trigger condition: provider CTR is 3'b011 or 3'b100 only.
Expressed as: (ctr == 3'b011) || (ctr == 3'b100)
When triggered and counter MSB is set: use alternate direction. tage_using_primary reflects the final mux select. tage_use_alt_on_na captures the trigger decision into meta.
Counter state at predict time is not stored in meta. Only the single-bit trigger decision (tage_use_alt_on_na) is captured.
Derived Signal¶
pred_diff = tage_prm_tkn != tage_alt_tkn
pred_diff is not stored in meta. It is recomputed at update time from tage_prm_tkn and tage_alt_tkn stored in meta.
tage_pred_tkn remains the final output direction after use_alt_on_na mux. It reflects tage_using_primary selection.
Prediction Phase -- tage_cntrl Responsibilities¶
Provider selection (p1, combinational)¶
Scan T4 down to T1 for hit_p1[slot] asserted. Longest history hit wins -- this is the primary provider. T0 is unconditional fallback if no tagged table hits.
Captures into meta:
tage_prm_idx -- already-hashed RAM index of primary hit
tage_prm_comp -- table index of primary provider
tage_prm_useful -- useful field of primary provider entry
tage_prm_ctr -- CTR field of primary provider entry
tage_prm_tkn -- CTR MSB of primary provider
Alternate provider (p1, combinational)¶
Continue scan below primary hit for next longest hit. If primary is T1 or T0 is provider, alternate is T0.
Captures into meta:
tage_alt_idx -- already-hashed RAM index of alternate hit
tage_alt_comp -- table index of alternate provider
tage_alt_useful -- useful field of alternate provider entry
tage_alt_ctr -- CTR field of alternate provider entry
tage_alt_tkn -- CTR MSB of alternate provider
Allocation candidate (p1, combinational)¶
See tage_cntrl_alloc_rules.md for full rules.
tage_cntrl generates tage_alloc_idx directly (pre-hashed). It is not run through tage_hash. Source is the idx_hash_p0 that was used to access the candidate table during prediction. Written into meta as-is. Update path uses it as a direct RAM address with no rehashing.
Captures into meta:
tage_alloc_comp -- table index of allocation candidate
tage_alloc_idx -- pre-hashed RAM index of candidate
tage_alloc_tag -- tag captured at predict time
Decoration flags (p1, combinational)¶
tage_pred_strong; -- post-mux provider ctr in {3'b000, 3'b111}
tage_pred_medium; -- post-mux provider ctr in {001,010,101,110}
tage_pred_weak; -- post-mux provider ctr in {3'b011, 3'b100}
tage_extd_ctr; -- signed extended-range provider ctr, SC sum
tage_use_alt_on_na; -- use_alt_on_na was used to select provider
tage_using_primary; -- provider was primary component, else alternative
branch_id -- copied from tage_pred_inp_t
Final direction (p1, combinational)¶
Normally: tage_prm_tkn. When use_alt_on_na fires (trigger condition met and counter MSB set): tage_alt_tkn. When alternate is T0: T0 CTR MSB (2b counter, bit 1). Result -> tage_pred_tkn.
p2 flop¶
All meta fields flopped at p2. These are packed into the tage_pred_meta_t structs
tage_pred_rdy flopped alongside, gated on tage_pred_val_p0 delayed one cycle.
CTR Update Rules¶
See tage_cntrl_ctr_update_rules.md for the full table.
resolved_taken is supplied at update time via tage_upd_inp_t. pred_diff is recomputed at update from tage_prm_tkn and tage_alt_tkn stored in meta.
Every tagged CTR step moves the counter toward the resolved direction: INC on taken, DEC on not-taken, saturating. That is the table read with its legend (INC strengthens, DEC weakens, in the entry's current direction). Before BP-126 tage_cntrl stepped the tagged counters numerically by correctness, so a correct not-taken entry moved toward taken (011 became 100). Fixed by BP-126 (D-1), confirmed session-077 (Jeff). Which counter steps is unchanged.
Summary:
- prm_comp > 0 and alt_comp > 0: both providers are tagged
tables. CTR actions per rows 1-12.
- prm_comp == 0 and alt_comp == 0: both are T0. T0 CTR
updated per rows 13a-13d.
- prm_comp > 0 and alt_comp == 0: primary is tagged, alt
is T0. With tage_using_primary 1, only the primary CTR is
updated (rows 14-17); T0 is not. With tage_using_primary 0
(use_alt_on_na chose T0), T0 steps toward the outcome and the
primary steps if pred_diff and it was right (rows 19.1-19.8,
BP-133, TD#18, ruled session-079).
- prm_comp == 0 and alt_comp > 0: architecturally impossible
(T0 as primary is the unconditional fallback; row 18 in
tage_cntrl_ctr_update_rules.md is an ASSERT/invalid case,
not a live update path). T0 not updated.
Useful Counter and Aging Rules¶
See tage_cntrl_use_update_rules.md for full rules including UAON, Table 7, aging interval and epoch operation, and u_eff computation.
Allocation Rules¶
See tage_cntrl_alloc_rules.md for full rules.
Concurrent CTR and USE Writes¶
When the CTR update rules and the useful update rules both target the same table and same index in the same cycle, the two writes are performed as a single RAM write.
tage_cntrl must combine the active write enables and align both the CTR write data and the USE write data into a single ram_din word. The bweb_n mask must have bits cleared for both the CTR field range and the USE field range simultaneously.
This is structurally supported by bw_ram and the existing bweb_n logic in tage_table.sv. tage_cntrl is responsible for asserting both strobes in the same cycle with correctly aligned data. tage_table performs the merged write.
Open Items Before BP-008 Prompt¶
- CLOSED. tage_interfaces.md port list uses old field names, to be updated for the tage_prm_* renames before or alongside BP-008. BP-008 has run and tage_cntrl.sv is Complete; tage_interfaces.md now restates no meta field names and points at bp_structs_pkg.sv, and its TI7 records the migration closed and verified. This stood open as a BP-008 prerequisite. Session-072.
tage_cntrl_alloc_rules.md
planning/arch/tage_cntrl_alloc_rules.md on GitHub
tage_cntrl Allocation Rules¶
FILE: tage_cntrl_alloc_rules.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-09-20
CONTACT: Jeff Nye
Scope¶
This document covers allocation candidate selection at predict time and the allocation write at update time. It is a companion to tage_cntrl_decisions.md and tage_table_interfaces.md.
Trigger¶
Allocation fires during update when:
cond_mispredict == 1
AND tage_prm_comp < M (provider is not the longest table)
Where M is the index of T4 (the longest history table).
If provider is T4 and mispredicts: update CTR only, no allocation.
Count¶
One entry allocated per misprediction event.
Candidate Selection at Predict Time (p1, combinational)¶
Scan tables T(provider+1) through T4 for u_eff == 0. u_eff is used for the useful == 0 test, not raw USEFUL. No allocation in consecutive tables -- if Tj is selected, Tj+1 is skipped even if u_eff == 0. Select the shortest-history qualifying table.
If provider table is the last table, no allocation should occur tage_alloc_comp should be set to zero.
tage_cntrl generates tage_alloc_idx directly (pre-hashed). Source is the idx_hash_p0 that drove the candidate table during prediction. No rehashing at update time.
Captures into meta:
tage_alloc_comp -- table index of selected candidate.
Set to 0 (T0) when no candidate found.
tage_alloc_idx -- pre-hashed RAM index of candidate
tage_alloc_tag -- tag for the new entry, captured at
predict time
No-candidate sentinel¶
tage_alloc_comp == 0 (T0) indicates no allocation candidate was found. T0 is never a valid allocation target -- allocation only targets tables longer than the provider. This sentinel is unambiguous and consistent with the use of comp == 0 as the tagged-table-miss indicator in the CTR update rules.
When tage_alloc_comp == 0 arrives at update time, alc_wr_u0 is suppressed for all tables. No allocation write is issued.
Epoch aging (EPC field) handles starvation prevention. Useful bit decrement on failed allocation is not implemented.
Initialization of Allocated Entry¶
CTR = 3'b100 (weakest taken) USE = 2'b00 (null useful) EPC = current lcl_epoch value for the slot TAG = tage_alloc_tag from meta VALID = 1'b1
Allocation Write Data Assembly¶
The allocation write data is constructed per the entry layout in tage_table_entry_formats.md, which owns it; this cited tage_table_interfaces.md, whose Entry Formats section points there and carries no layout. Session-072. TAG bits are the MSBs:
[TAG, EPC, USE, CTR, VALID]
This maps directly to alc_wd_u0[ALLOC_DATA_WIDTH-1:0].
Write Strobe Generation¶
alc_wr_u0[slot] is asserted at update time when:
cond_mispredict == 1
AND tage_prm_comp < M
AND tage_alloc_comp != 0 (valid candidate was found)
The no-consecutive-table constraint is enforced at predict time during candidate selection. The write strobe at update time does not re-evaluate adjacency.
alc_wr_u0 is gated per table inside tage_table by comparing THIS_TABLE to tage_alloc_comp, presented as alc_tbl_sel_u0 (tage_table_interfaces.md). Only the selected candidate table performs the write. This read "via prm_tbl_sel_u0", the provider's selector, which names the wrong table. Session-071.
EPC Field¶
The current lcl_epoch value for the slot is written to the EPC field of the allocated entry at update time. See tage_cntrl_use_update_rules.md for aging rules. This named tage_cntrl_useful_update_rules.md, which does not exist. Session-072.
tage_cntrl_ctr_update_rules.md
planning/arch/tage_cntrl_ctr_update_rules.md on GitHub
tage_cntrl CTR Update Rules¶
FILE: tage_cntrl_ctr_update_rules.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-14
CONTACT: Jeff Nye
Notes¶
- prm_comp > 0 : primary provider is a tagged table (T1-T4)
- alt_comp > 0 : alternate provider is a tagged table (T1-T4)
- comp == 0 : T0 (BIM fallback)
- pred_diff : tage_prm_tkn != tage_alt_tkn
- resolved_taken: supplied at update time via tage_upd_inp_t
- X : don't care
- -- : no action
- n/a : not applicable (one provider is T0)
These two markers were an EM DASH and a HYPHEN, which no plain-ASCII grep separates and the eye does not either. Session-072.
CTR Update Table¶
Legend:
UP = tage_using_primary
PT = tage_pred_tkn
RT = resolved_taken
pT = tage_prm_tkn
aT = tage_alt_tkn
pCMP = tage_prm_comp
aCMP = tage_alt_comp
pACT = action for primary CTR
aACT = action for alternative CTR
t0ACT = action for T0 (bim) CTR
INC AND DEC MEAN DIFFERENT THINGS IN THE TWO GROUPS OF COLUMNS.
pACT, aACT : INC = strengthen, a step AWAY from the direction
boundary in the entry's current direction; DEC =
weaken, a step TOWARD it. INC on a not-taken entry
lowers its value (row 2.1).
t0ACT : INC = numeric increment, a step toward taken; DEC =
numeric decrement, a step toward not-taken. DEC on a
correct not-taken prediction is a strengthen (row 13a).
Both groups move the counter toward the resolved direction; only the
label differs. So 13a and 17.1, and 13b and 15.1, describe the same
movement under different labels. The values are unchanged; this
note was added session-072 because the legend defined both groups
only as "action for" a counter.
BP-126 (session-077) found tage_cntrl stepping the tagged counters numerically by correctness: INC when correct, DEC when wrong. Under direction = CTR[2] a correct not-taken entry then moved toward taken (011 became 100). Fixed to step toward the resolved direction (D-1, confirmed by Jeff). That is what this table says under the legend above, so no row changes. BP-126 read the copy of the table in tb_tage_manual_tasks.svh, which carries no legend, took pACT and aACT INC as a numeric increment, and reported the two documents in conflict (its PD-16). They agree.
diff = `tage_prm_tkn` != `tage_alt_tkn`
diff is for reference, diff is not a signal
in the prediction meta data
The meta fields are tage_prm_tkn and tage_alt_tkn
(tage_cntrl_decisions.md, Manual Changes Already
Applied). This document read tage_prm_taken and
tage_alt_taken in the legend and here; no such fields
exist. Session-072.
| # | UP | PT | RT | diff | pT | aT | pCMP | aCMP | pACT | aACT | t0ACT | Explanation |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1.1 | 1 | 1 | 1 | 1 | 1 | 0 | >0 | >0 | INC | -- | -- | Provider = primary, predicted taken correctly |
| 1.2 | 1 | 1 | 1 | 0 | 1 | 1 | >0 | >0 | INC | -- | -- | Provider = primary, predicted taken correctly |
| 2.1 | 1 | 0 | 0 | 0 | 0 | 0 | >0 | >0 | INC | -- | -- | Provider = primary, predicted not-taken correctly |
| 2.2 | 1 | 0 | 0 | 1 | 0 | 1 | >0 | >0 | INC | -- | -- | Provider = primary, predicted not-taken correctly |
| 3 | 1 | 1 | 0 | 1 | 1 | 0 | >0 | >0 | DEC | INC | -- | Provider = primary wrong, alt opposite prediction |
| 4 | 1 | 0 | 1 | 1 | 0 | 1 | >0 | >0 | DEC | INC | -- | Provider = primary wrong, alt opposite prediction |
| 5 | 1 | 1 | 0 | 0 | 1 | 1 | >0 | >0 | DEC | -- | -- | Provider = primary wrong, alt same or ignored |
| 6 | 1 | 0 | 1 | 0 | 0 | 0 | >0 | >0 | DEC | -- | -- | Provider = primary wrong, alt same or ignored |
| 7.1 | 0 | 1 | 1 | 1 | 0 | 1 | >0 | >0 | -- | INC | -- | Provider = alt, predicted taken correctly |
| 7.2 | 0 | 1 | 1 | 0 | 1 | 1 | >0 | >0 | -- | INC | -- | Provider = alt, predicted taken correctly |
| 8.1 | 0 | 0 | 0 | 0 | 0 | 0 | >0 | >0 | -- | INC | -- | Provider = alt, predicted not-taken correctly |
| 8.2 | 0 | 0 | 0 | 1 | 1 | 0 | >0 | >0 | -- | INC | -- | Provider = alt, predicted not-taken correctly |
| 9 | 0 | 1 | 0 | 1 | 0 | 1 | >0 | >0 | INC | DEC | -- | Provider = alt wrong, primary opposite prediction |
| 10 | 0 | 0 | 1 | 1 | 1 | 0 | >0 | >0 | INC | DEC | -- | Provider = alt wrong, primary opposite prediction |
| 11 | 0 | 1 | 0 | 0 | 1 | 1 | >0 | >0 | -- | DEC | -- | Provider = alt wrong, pred_diff ignored |
| 12 | 0 | 0 | 1 | 0 | 0 | 0 | >0 | >0 | -- | DEC | -- | Provider = alt wrong, pred_diff ignored |
| 13a | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | -- | -- | DEC | BIM predicted NT, resolved NT, correct |
| 13b | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | -- | -- | INC | BIM predicted NT, resolved T, wrong |
| 13c | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | -- | -- | DEC | BIM predicted T, resolved NT, wrong |
| 13d | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | -- | -- | INC | BIM predicted T, resolved T, correct |
| 13e | 0 | x | x | x | x | x | 0 | 0 | ASSERT | ASSERT | ASSERT | Invalid: UP=0 when pCMP=aCMP=0. ADR-001 violation. tage_assert.sv fires. No RTL action. |
| 14.1 | 1 | 1 | 0 | 0 | 1 | 1 | >0 | 0 | DEC | -- | n/a | Alt=BIM, primary wrong, alt same |
| 14.2 | 1 | 1 | 0 | 1 | 1 | 0 | >0 | 0 | DEC | -- | n/a | Alt=BIM, primary wrong, alt opposite |
| 15.1 | 1 | 0 | 1 | 0 | 0 | 0 | >0 | 0 | DEC | -- | n/a | Alt=BIM, primary predicted NT, resolved T, wrong |
| 15.2 | 1 | 0 | 1 | 1 | 0 | 1 | >0 | 0 | DEC | -- | n/a | Alt=BIM, primary predicted NT, resolved T, wrong, alt opposite |
| 16.1 | 1 | 1 | 1 | 0 | 1 | 1 | >0 | 0 | INC | -- | n/a | Alt=BIM, primary predicted T, resolved T, correct, alt same |
| 16.2 | 1 | 1 | 1 | 1 | 1 | 0 | >0 | 0 | INC | -- | n/a | Alt=BIM, primary predicted T, resolved T, correct, alt opposite |
| 17.1 | 1 | 0 | 0 | 0 | 0 | 0 | >0 | 0 | INC | -- | n/a | Alt=BIM, primary predicted NT, resolved NT, correct, alt same |
| 17.2 | 1 | 0 | 0 | 1 | 0 | 1 | >0 | 0 | INC | -- | n/a | Alt=BIM, primary predicted NT, resolved NT, correct, alt opposite |
| 18 | x | x | x | x | x | x | 0 | >0 | ASSERT | ASSERT | ASSERT | invalid condition pCMP=0 aCMP>0, handled by assert |
| 19.1 | 0 | 1 | 1 | 1 | 0 | 1 | >0 | 0 | -- | n/a | INC | Alt=BIM chosen by UAON, BIM right, primary wrong |
| 19.2 | 0 | 1 | 1 | 0 | 1 | 1 | >0 | 0 | -- | n/a | INC | Alt=BIM chosen by UAON, BIM right, primary same |
| 19.3 | 0 | 0 | 0 | 0 | 0 | 0 | >0 | 0 | -- | n/a | DEC | Alt=BIM chosen by UAON, BIM right, primary same |
| 19.4 | 0 | 0 | 0 | 1 | 1 | 0 | >0 | 0 | -- | n/a | DEC | Alt=BIM chosen by UAON, BIM right, primary wrong |
| 19.5 | 0 | 1 | 0 | 1 | 0 | 1 | >0 | 0 | INC | n/a | DEC | Alt=BIM chosen by UAON, BIM wrong, primary right |
| 19.6 | 0 | 0 | 1 | 1 | 1 | 0 | >0 | 0 | INC | n/a | INC | Alt=BIM chosen by UAON, BIM wrong, primary right |
| 19.7 | 0 | 1 | 0 | 0 | 1 | 1 | >0 | 0 | -- | n/a | DEC | Alt=BIM chosen by UAON, BIM wrong, primary same |
| 19.8 | 0 | 0 | 1 | 0 | 0 | 0 | >0 | 0 | -- | n/a | INC | Alt=BIM chosen by UAON, BIM wrong, primary same |
Rows 19.1-19.8 were added by BP-133 (TD#18), ruled session-079 (Jeff). The primary is tagged, the alternate is T0 and use_alt_on_na chose it (UP=0), so T0 is the provider and steps toward RT (t0ACT, numeric, as in rows 13a-13d). The primary steps per rows 9 and 10: only when pred_diff is set and the primary was right (pACT, under its legend). No USE update; T0 has none. T0 is written through tage_bim's alt update bus. Before BP-133 no row covered this case and the RTL left T0 untouched.
The tb_tage_manual tests of rows 19.x seed a state a prediction produces: primary CTR 011 or 100, T0 direction aT, use_alt_on_na set. tb_fe_top program t0_uaon reaches the rows end to end (BP-135).
ADR¶
ADR-001¶
ADR: tage_using_primary when BIM is sole provider
When tage_prm_comp=0 and tage_alt_comp=0 at prediction time, tage_using_primary shall be 1.
Rationale: when no tagged table hits, BIM is the sole provider. The concept of primary vs alternate does not apply. BIM is defined as the primary provider in this case. using_primary=0 would be architecturally meaningless and is disallowed.
RTL: tage_cntrl.sv pred_logic block sets using_prm_p1 to 1'b1 by default. The UAON override that sets it to 0 is gated on prm_comp != 0 and therefore cannot fire in the BIM case.
Enforcement: tage_assert.sv assertion on tage_pred_rdy_p2 and tage_upd_val_u0.
Status: ACTIVE. RTL verified. Assertion implemented.
tage_cntrl_uaon_update_rules.md
planning/arch/tage_cntrl_uaon_update_rules.md on GitHub
tage_cntrl UAON Update Rules¶
FILE: tage_cntrl_uaon_update_rules.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-14
CONTACT: Jeff Nye
Changelog:
- 2026-10-14 (session-080, BP-136, Jeff): uaon_N is updated only when
the alternative is a tagged table; with T0 as the alternative it is
unchanged, as tage_cntrl.sv uaon_upd_ff is built.
- 2026-09-20 (session-072): the alternative component definition
admitted only tagged tables, so it excluded T0, which
tage_cntrl_decisions.md and tage_cntrl_ctr_update_rules.md rows
14-17 make a legal alternate. The FILE field read
tage_tmp_uaon_update_rules.md.
- 2026-07-02 (TD#87): the UAON update gate now keys on tage_pred_weak,
not tage_pred_strong. TD#87 redefined tage_pred_strong to mean
STRICTLY strong (3'b000/3'b111), which is narrower than the prior
"NOT WEAK" set. Gating on the new tage_pred_strong would wrongly act
on medium CTRs. Behavior of the rule is unchanged from the original
intent (act only on a weak/boundary prediction); only the gating
signal and the doc terminology are corrected.
USE_ALT_ON_NA (UAON) Background¶
Two USE_ALT_ON_NA (UAON) registers heuristically qualify the selection of primary or alternative components during prediction. During update the UAON registers are conditionally modified based on the correctness of the predictions.
UAON has no impact when both the primary and alternative components are tagged table misses (tage_prm_comp == 0 and tage_alt_comp == 0). If TTM is asserted this section does not apply.
UAON Implementation¶
Two registers: uaon_0 and uaon_1, one per prediction slot. Both are unsigned 4b saturating counters owned by tage_cntrl. Both operate independently. No cross-slot interaction.
Parameter: TAGE_UAON_THRES = 8, defined in bp_defines_pkg.sv.
Terminology¶
Primary component: the table with a tag hit and the longest history length. tage_prm_comp holds its table index.
Alternative component: the provider below the primary -- the tagged table with the next lower history length and a tag hit, or T0 when the primary is T1 or no lower tagged table hits. T0 has no tag and is always available, so a tag hit is not what qualifies it (tage_cntrl_decisions.md Alternate provider; tage_cntrl_ctr_update_rules.md rows 14-17, alt = BIM). tage_alt_comp holds the table index, 0 for T0.
When NO tagged table hits, T0 is the PRIMARY (ADR-001), both comps are 0, and this section does not apply -- see TTM above.
NOT WEAK: with a 3b CTR, weak states are 3'b011 and 3'b100 only. All other CTR values are NOT WEAK.
tage_pred_weak: set from the final provider CTR after the UAON mux has selected primary or alternative. Asserted when that CTR is 3'b011 or 3'b100. This is the UAON update gate.
tage_pred_strong: per TD#87, asserted only when the final provider CTR is 3'b000 or 3'b111. NOTE: this is STRICTLY strong, NOT the "NOT WEAK" set -- medium CTRs (001/010/101/110) have tage_pred_strong=0 AND tage_pred_weak=0. Do not use tage_pred_strong as the UAON gate; use tage_pred_weak. See bp_structs_pkg.sv for field definitions.
Component Selection During Prediction¶
Primary component CTR is available in tage_prm_ctr.
if (tage_prm_ctr is NOT WEAK)
select primary component
else
if (uaon_N >= TAGE_UAON_THRES)
select alternative component
else
select primary component
NOT WEAK condition:
not_weak = (tage_prm_ctr != 3'b011) && (tage_prm_ctr != 3'b100)
tage_using_primary reflects the result of this selection. tage_pred_weak reflects the weak (boundary) condition on the final provider CTR; tage_pred_strong reflects strictly {3'b000, 3'b111} per TD#87.
UAON Modification During Update¶
These rules apply independently to uaon_0 and uaon_1.
They apply only when the primary and the alternative are both tagged tables (tage_prm_comp != 0 and tage_alt_comp != 0). With T0 as the alternative, uaon_N is unchanged.
Signal names¶
Full signal paths for reference:
tage_pred_weak = tage_upd_inp_u0[s].tage_pred_meta.tage_pred_weak
cond_mispredict = tage_upd_inp_u0[s].cond_mispredict
tage_prm_tkn = tage_upd_inp_u0[s].tage_pred_meta.tage_prm_tkn
tage_alt_tkn = tage_upd_inp_u0[s].tage_pred_meta.tage_alt_tkn
Correctness definitions¶
TAGE predicts direction. Correctness is taken/not-taken match.
prm_correct = (resolved_taken == tage_prm_tkn)
prm_wrong = (resolved_taken != tage_prm_tkn)
alt_correct = (resolved_taken == tage_alt_tkn)
alt_wrong = (resolved_taken != tage_alt_tkn)
Update rules¶
if (!tage_pred_weak)
-> do nothing // provider was strong or medium
else if (prm_wrong && alt_correct)
-> increment uaon_N (saturate at 4b max)
else if (prm_correct && alt_wrong)
-> decrement uaon_N (saturate at 0)
else
-> do nothing // weak but both-wrong or both-right
Truth table¶
| tage_pred_weak | prm_wrong | alt_correct | prm_correct | alt_wrong | Action |
|---|---|---|---|---|---|
| 0 | X | X | X | X | none (not weak) |
| 1 | 1 | 1 | 0 | 0 | INC uaon_N |
| 1 | 0 | 0 | 1 | 1 | DEC uaon_N |
| 1 | 1 | 0 | 0 | 1 | none (both wrong) |
| 1 | 0 | 1 | 1 | 0 | none (both right) |
tage_cntrl_use_update_rules.md
planning/arch/tage_cntrl_use_update_rules.md on GitHub
tage_cntrl USEFUL Update Rules¶
FILE: tage_cntrl_use_update_rules.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-14
CONTACT: Jeff Nye
Background¶
Each tagged TAGE table entry (T1-T4) contains a 2-bit USEFUL counter field. The USEFUL field records whether an entry has recently provided a correct prediction that disagreed with the alternative provider. An entry with a non-zero USEFUL value has demonstrated recent predictive value and is protected from eviction during allocation. An entry whose USEFUL value has decayed to zero is a candidate for replacement. The epoch-based aging mechanism described below allows this protection to decay over time without requiring explicit per-entry writes: as the lcl_epoch counter advances, the effective USEFUL value (u_eff) seen by the allocation logic decreases for entries that have not been recently updated, making them eligible for eviction even if their raw USEFUL field is non-zero. USEFUL is updated only when the primary and alternate providers disagree -- when they agree, no information about relative provider quality is available and no update is performed.
TAGE USEFUL Counter Aging¶
The TAGE predictor periodically ages the USEFUL counters in table entries. Useful aging gradually removes replacement protection from predictor entries that have not recently demonstrated value, allowing stale entries to be evicted (allocated) in favor of new ones without explicitly clearing the tables.
Aging is a two-phase process that fits within the existing prediction request/update request process. During prediction requests, the EFFECTIVE useful bits are used to determine which entry across the tables is the target for replacement/allocation. The "EFFECTIVE useful bits" are the aged view of the USEFUL bits across the entries.
The EFFECTIVE USEFUL values are returned in the prediction response and used in the subsequent update phase.
There is an enable bit, tage_enable_aging, as a primary input to tage and tage_cntrl.
There is a 32b bus that supplies the aging interval as a primary input to tage and tage_cntrl, called tage_aging_interval.
There are two local 32b registers in tage_cntrl that hold the running interval count called lcl_aging_interval_0 and lcl_aging_interval_1. Each register serves one of the two prediction requests.
There are local 2b registers in tage_cntrl that hold the running epoch count called lcl_epoch_0 and lcl_epoch_1. Each register serves one of the two prediction requests.
TAGE Aging Epoch and Interval Operation¶
With TAGE aging enabled:
On the rising edge of reset lcl_aging_interval_0 and lcl_aging_interval_1 are loaded with the current value of tage_aging_interval.
lcl_aging_interval_0 is a down counter which decrements for each assertion of tage_pred_rdy_p2[0].
lcl_aging_interval_1 is a down counter which decrements for each assertion of tage_pred_rdy_p2[1].
tage_pred_rdy_p2 is one port carrying the slot as a packed vector (tage_interfaces.md Port List). This section read tage_pred_rdy_0_p2 and tage_pred_rdy_1_p2, which do not exist. Session-072.
When lcl_aging_interval_0 reaches zero, lcl_epoch_0 is incremented and lcl_aging_interval_0 is reloaded with the current value of tage_aging_interval.
When lcl_aging_interval_1 reaches zero, lcl_epoch_1 is incremented and lcl_aging_interval_1 is reloaded with the current value of tage_aging_interval.
The value of the respective lcl_epoch_0/1 determines how a given entry's USEFUL counter is interpreted during prediction, allocation, and updates. USEFUL counter updates are described in the next section.
Aging Disabled¶
When tage_enable_aging=0 the epoch mechanism is inactive. The effective USEFUL value is always equal to the raw USEFUL field:
u_eff = USEFUL (aging disabled, equivalent to age==0 path)
Manual tests are expected to run with tage_enable_aging=0. A test failure under this condition indicates a table rule violation, not an aging interaction.
Epoch Advance Timing:¶
lcl_epoch_0 increments one clock after tage_pred_rdy_p2[0] first
asserts (N+1). The aging_ff and the valid pipeline register
are separate always_ff blocks; the aging_ff samples the
previous value of pred_rdy_p2 on the boundary posedge and
fires on the next. The new epoch value is visible to
prediction logic starting at posedge N+1.
TAGE USEFUL Counter Updates¶
Signals¶
The signals are found in the tage_pred_meta entry within tage_upd_inp_t, with the exception of cond_mispredict which is found in tage_upd_inp_t.
The truth table for USEFUL counter updates is shown in Table 7.
Columns¶
The signals referenced are presumed to have tage_upd_inp_u0[s].tage_pred_meta prefixed (the declared port, tage_interfaces.md; this read tage_upd_inp. Session-072). The prefix was removed in the column header to limit table column width.
-
Preds differed (tage_prm_tkn != tage_alt_tkn)
- primary and alternative predictions differed
-
TTM (tagged table miss) (tage_prm_comp == 0 and tage_alt_comp == 0)
- Both the primary component and the alternative component were 0
-
Using primary (tage_using_primary)
- Primary component supplied the prediction, else alternative
-
Mispredict (cond_mispredict)
- The provider's prediction was not correct
-
Useful WR, output
- The useful write signal to RAM
- This is an output of the table
-
Useful SEL, output
- The component selected for useful update
- Select either tage_prm_comp or tage_alt_comp
- This is an output of the table
-
Useful IDX, output
- The index into the component for useful update
- Select either tage_prm_idx or tage_alt_idx
- This is an output of the table
-
Useful WD, output
- Source provided to the saturating counter for increment or decrement
- Select either tage_prm_useful or tage_alt_useful
- This is an output of the table
-
Useful Action, output
- Increment or decrement of the effective useful value
- Control flag to the effective useful add/sub
- See epoch aging description above
Legend¶
DIFF = preds differed (tage_prm_tkn != tage_alt_tkn)
TTM = tagged table miss (tage_prm_comp==0 & tage_alt_comp==0)
UP = tage_using_primary
MISP = cond_mispredict
uWR = useful write enable
uACT = useful action (Inc/Dec u_eff)
uSEL = useful component select
PRM = tage_prm_comp
ALT = tage_alt_comp
uIDX = useful index select
PRM = tage_prm_idx
ALT = tage_alt_idx
uWD = useful write data select
PRM = tage_prm_useful
ALT = tage_alt_useful
x = don't care
- = not applicable
Table 7 - USEFUL modification truth table¶
| # | DIFF | TTM | UP | MISP | uWR | uACT | uSEL | uIDX | uWD |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0 | x | x | x | 0 | - | x | x | x |
| 2 | x | 1 | x | x | 0 | - | x | x | x |
| 3 | 1 | 0 | 1 | 0 | 1 | INC | PRM | PRM | PRM |
| 4 | 1 | 0 | 1 | 1 | 1 | DEC | PRM | PRM | PRM |
| 5 | 1 | 0 | 0 | 0 | 1 | INC | ALT | ALT | ALT |
| 6 | 1 | 0 | 0 | 1 | 1 | DEC | ALT | ALT | ALT |
Row priority note¶
Rows 1 and 2 both independently suppress the useful write (uWR=0). They have no priority relationship between them. If both conditions are true simultaneously (DIFF=0 and TTM=1) the outcome is the same: uWR=0. No ordering is required and no priority encoding should be inferred. Rows 3-6 are only reachable when both row 1 and row 2 conditions are false (DIFF=1 and TTM=0).
Row 2 is structurally an invalid case: with a tagged table miss, a difference in primary and alternative predictions is architecturally impossible. DIFF=x in row 2 reflects this -- the signal value is irrelevant because the condition cannot arise in practice.
Effective USEFUL Calculation¶
The formula below uses these terms:
- u_eff -- calculated effective USEFUL value
- USEFUL -- current raw value of the entry's useful field
- EPOCH -- value in the entry's epoch field
- TG_AGE_EPOCH -- value of lcl_epoch_0 or lcl_epoch_1
age = (TG_AGE_EPOCH - EPOCH) mod 4
if (age == 0) u_eff = USEFUL;
else if (age == 1) u_eff = USEFUL >> 1;
else u_eff = 0;
On a prediction request the u_eff values for the primary and alternative components are calculated. The provider component's MODIFIED u_eff is returned in the prediction response. On the subsequent update these values are written to either the primary or alternative entries depending on the state of tage_upd_inp_t.tage_pred_meta.tage_using_primary (Table 7, UP). This read bpc_upd_data_t.common.using_primary, a type no document declares. Session-072. The current value of lcl_epoch_0/lcl_epoch_1 is written to the EPC field of the entry as well.
Theory:
Since the lcl_epoch_0/1 register is used to form the EFFECTIVE USEFUL value, the simple action of incrementing TG_AGE_EPOCH effectively ages all entries in all tables without the need to update each entry individually.
tb_tage_manual checks the EPC write on each slot with lcl_epoch set to a value different from the seed and from the other slot's epoch (BP-136).
tage_table_entry_formats.md
planning/arch/tage_table_entry_formats.md on GitHub
TAGE table entry formats¶
FILE: tage_table_entry_formats.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-09-20
CONTACT: Jeff Nye
Scope¶
This describes the field ordering for tables in TAGE.
Entry Format¶
T0 Table Entry¶
The T0 table contains a single CTR field. The field width is specifed
by an arrayed parameter TAGE_TBL_CTR[0]
T1-T4 Table Entry¶
The ordering of the fields in the tagged TAGE tables is shown:
MSB LSB
TAG EPC USE CTR VALID
Field widths for EPC, USE, and CTR are defined by parameters
found in bp_defines_pkg.sv
The VALID bit is always 1 bit.
The remaining fields have table specific parameters selected from the named parameter array. [t] indicates the table, T0-T4.
The fields are listed from LSB to MSB
VALID : 1 bit
CTR : `TAGE_TBL_CTR[t]`
USE : `TAGE_TBL_USE[t]`
EPC : `TAGE_TBL_EPC[t]`
TAG : `TAGE_TBL_TAG[t]`
CTR field usage in TAGE¶
CTR is a 3-bit direction counter; its MSB is the predicted direction (tage_cntrl_decisions.md, CTR Encoding). It steps toward the resolved direction. It has no null state and plays no part in choosing an allocation candidate, which is chosen by u_eff == 0 (tage_cntrl_alloc_rules.md). This read that CTR "encodes confidence" and that an entry whose CTR "reaches null on misprediction" becomes a re-allocation candidate, which is the ITTAGE target rule, not TAGE's. Session-071.
Maximum field widths¶
The maximum range for each field is stored in a parameter. These parameters
are found in bp_defines_pkg.sv
TAGE_MAX_TAG_WIDTH
TAGE_MAX_EPC_WIDTH
TAGE_MAX_USE_WIDTH
TAGE_MAX_CTR_WIDTH
TAGE_MAX_VAL_WIDTH
tage_table_hash_rules.md
planning/arch/tage_table_hash_rules.md on GitHub
tage_table Hash Rules¶
FILE: tage_table_hash_rules.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-09-20
CONTACT: Jeff Nye
Scope¶
Define the hash functions used locally within each tage_table instance to derive idx_hash_p0 and tag_hash_p0 for T1-T4, replacing the removed inputs that were previously sourced from tage_cntrl. T0 is excluded -- it uses direct PC bits, no hash.
Input ports associated with hashing functions for T1-TN¶
Each tage_table generates four hashed values. A index hash for prediction slot 0 and slot 1, and a tag hash for prediction slot 0 and slot 1.
There are two PCs supplied by the tage_pred_inp_p0. These are tage_pred_inp_p0[0].pc or tage_pred_inp_p0[1].pc these are inputs to the index and tag hash functions.
The primary input struct bp_folded_hist_t folded_hist provides the folded history buses used for both the index and tag hashes.
Each table, indicated by the module parameter THIS_TABLE selects one of the four groups in folded_hist. There are 3 buses in each of the groups. The fh bus is used for index hashing function. The fh1 and fh2 buses are used by the tag hashing function.
The buses are named as tage_tN_idx_fh,tage_tN_tag_fh1,tage_tN_tag_fh2, where tN is either t1, t2, t3, t4.
The width parameters for these buses are similarly named TAGE_TBL_FH[N] TAGE_TBL_FH1[N] TAGE_TBL_FH2[N], where N is the value of THIS_TABLE, 1 to 4. These read TAGE_TN_FH / _FH1 / _FH2, which no package declares; the parameters are the arrays (tage_table_interfaces.md, bp_history_decisions.md). ITTAGE and SC use the array form. Session-072.
Relevant parameters¶
PC_HASH_SHIFT is a global parameter which defines the RIGHT shift of the pc address, this shift is 2 at present, as the index hash below applies it (PC >> PC_HASH_SHIFT). This read "left shift". Session-071.
THIS_INDEX_BITS is a module level parameter that defines the table specific width of the index
THIS_TAG_BITS is a module level parameter that defines the table specific width of the tag field
THIS_TABLE is a module level parameter that defines the table component id, at present 1,2,3,4.
VA_WIDTH is a global parameter that sets the MSB of the PC. The PC is zero indexed.
Hashing functions for T1-TN¶
Index hash function¶
Then index hash functions take the PC and the idx folded hash as inputs, the outputs are the slot 0 and slot 1 index hashes.
The width of the output is set by module parameter THIS_INDEX_BITS.
The width of the PC input global parameter VA_WIDTH The width of the fh input is set by the table specific parameter TAGE_TBL_FH[N], where N is determined by the value of module parameter THIS_TABLE
The hashing operation is
tmpA = (PC >> PC_HASH_SHIFT) ^ fh output = tmpA[THIS_INDEX_BITS-1:0]
There are two instances of this function, creating two indexes, one for slot 0 and one for slot 1.
Tag hash function¶
Then tag hash functions take the PC and the tag folded hashes as inputs, the outputs are the slot 0 and slot 1 tag hashes. There are two folded hash inputs fh1 fh2.
The width of the output is set by module parameter THIS_TAG_BITS.
The width of the PC input global parameter VA_WIDTH
The width of the fh1 input is set by the table specific parameter TAGE_TBL_FH1[N], where N is determined by the value of module parameter THIS_TABLE
The width of the fh2 input is set by the table specific parameter TAGE_TBL_FH2[N], where N is determined by the value of module parameter THIS_TABLE
The hashing operation is
tmpA = PC >> THIS_INDEX_BITS tmpB = tmpA ^ fh1 ^ (fh2 << 1) output = tmpB[THIS_TAG_BITS-1:0]
There are two instances of this function, creating two tags, one for slot 0 and one for slot 1.
Hashing functions for T0¶
There are no hashing operations for T0. The indexes for T0 are derived from the PC inputs,
tage_pred_inp_p0[0].pc[12:2] tage_pred_inp_p0[1].pc[12:2]
There is no tag in T0 and so no tag hash operation.
tage_interfaces.md
planning/interfaces/tage_interfaces.md on GitHub
TAGE Interface Specification¶
FILE: tage_interfaces.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-15
CONTACT: Jeff Nye
Overview¶
TAGE is a tagged geometric history length branch predictor providing direction prediction for conditional branches. It fires at p2 alongside FTB and OVERRIDES THE FTB DIRECTION. The FTB submits its own direction for every valid conditional (conf MSB on ftb_brI_taken_p2) and TAGE supersedes it at p2, unless the FTB fast path fires for that branch. fe_decisions.md 3.3; ftb_confidence_override_rules.md 3.1, 4.2, 4.3 and 8.
THE p2 REDIRECT IS A SEPARATE QUESTION. It fires only when the successor the cluster would publish differs from the one its own p1 stage registers hold -- an override that does not change the successor fires nothing (fe_decisions.md FE-4 and 2.5, ftq_bpu_interfaces.md 6). An earlier revision said "s2_redirect fires on override"; a session-070 revision then over-corrected and denied the direction override itself. Both corrected session-070.
Five tables: T0 is the base table (no tag, no useful bit, 2b CTR). T1-T4 are tagged tables, each with 2 banks x 2048 entries and increasing history lengths (8b, 13b, 32b, 119b). The entry is TAG EPC USE CTR VALID; tage_table_entry_formats.md owns the layout and widths. This listed valid, tag, ctr and useful with no EPC. Session-072.
Pipeline: p0 index calculation, p1 SRAM read and tag match, p2 final prediction output.
All types defined in bp_defines_pkg.sv and bp_structs_pkg.sv. This document describes port semantics, timing contracts, and consumer/producer obligations. It does not restate struct field layouts -- see bp_structs_pkg.sv.
Port Naming Convention¶
Signal names follow the pattern:
<signal>_<pipestage>
- `pipestage` : p0, p1, p2 for prediction path.
u0, u1 for update path.
There is no px stage. No flush event exists; a
flush is a redirect (fe_decisions.md FE-14,
BP-105). See TI8.
Slot dimension uses vector index [0:NUM_PRED_SLOTS-1]. clk and rstn carry no pipe stage suffix.
Module Parameters¶
Paramters for TAGE are found in section :TAGE parameters: of rtl/core/frontend/bpu/rtl/bp_defines_pkg.sv
Port List¶
// clock and reset
input logic clk
input logic rstn
// prediction interface
input logic [NUM_PRED_SLOTS-1:0] tage_pred_val_p0
input tage_pred_inp_t tage_pred_inp_p0[0:NUM_PRED_SLOTS-1]
output logic [NUM_PRED_SLOTS-1:0] tage_pred_rdy_p2
output tage_pred_meta_t tage_pred_meta_p2[0:NUM_PRED_SLOTS-1]
// update interface
input logic [NUM_PRED_SLOTS-1:0] tage_upd_val_u0
input tage_upd_inp_t tage_upd_inp_u0[0:NUM_PRED_SLOTS-1]
output logic [NUM_PRED_SLOTS-1:0] tage_upd_rdy_u1
// arbitration status outputs, driven by tage_arb (BP-132)
// renamed by BP-132 (TD#49): were pq_not_full and upd_rdy
output logic tage_pq_not_full
output logic [NUM_PRED_SLOTS-1:0] tage_uq_not_full
// aging control -- shared across both slots
input logic tage_enable_aging
input logic [31:0] tage_aging_interval
//SC is able to accept tage pred data
input logic consumer_ready
input bp_folded_hist_t folded_hist
// ram init interface
output logic tage_rdy
Struct Definitions¶
All structs defined in bp_structs_pkg.sv.
tage_pred_inp_t¶
Input bundle presented with each prediction request. Carries branch PC and branch_id for the slot. See bp_structs_pkg.sv for the authoritative definition.
tage_pred_meta_t¶
Prediction output and metadata. Carries primary and alternate component indices, confidence counters, useful bits, allocation target, predicted results for primary and alternative, UAON flag, hit status, and branch_id. See bp_structs_pkg.sv for the authoritative definition.
tage_upd_inp_t¶
Update input bundle. Contains the prediction metadata captured at predict time plus resolution fields supplied by the top level. See bp_structs_pkg.sv for the authoritative definition.
Prediction Interface¶
Producer: tage¶
Consumer: BP cluster (override control, p2 mux, FTQ write)¶
Timing¶
tage_pred_inp_p0[s] is presented at p0. folded_hist
(bp_folded_hist_t from bp_history) is also presented at p0.
Index and tag hash logic is combinational within each
tage_table instance at p0.
p1: SRAM read completes. Tag match and hit processing
execute in p1.
p2: Final prediction flopped out. tage_pred_meta_p2[s]
and tage_pred_rdy_p2[s] are valid at p2.
Metadata timing (BP-094)¶
Every member of tage_pred_meta_t, branch_id INCLUDED, describes the request that produced it, and the whole struct is staged to p2 together. No member is read live from the p0 input at p1.
branch_id is called out because it was the exception. Until BP-094 tage_cntrl built meta_p1 at p1 but read branch_id straight off tage_pred_inp_p0, so the branch_id arriving at p2 named the request presented one cycle LATER than the one the rest of the metadata described. The consequences at the BP cluster boundary were that the branch_id qualification never matched in an unstalled request stream, so the TAGE direction never reached the FTQ, and that in a stalled stream it matched for the WRONG entry. See prompts/BP-093.md tests C0 and D2 for the evidence and prompts/BP-094.md for the fix.
Consumers may rely on this: tage_pred_meta_p2[s].branch_id is the FTQ index a consumer must compare its own stage index against, and a mismatch means the response is stale or delayed, never merely skewed.
Folded History Input¶
folded_hist is the bp_folded_hist_t output of
bp_history. It is shared across both prediction slots
and passed directly to each tage_table instance.
Each tage_table instance selects its table-specific
fields and derives idx_hash_p0 and tag_hash_p0 locally.
TAGE consumes the following fields for index and tag
computation:
tage_t1_idx_fh, tage_t1_tag_fh1, tage_t1_tag_fh2
tage_t2_idx_fh, tage_t2_tag_fh1, tage_t2_tag_fh2
tage_t3_idx_fh, tage_t3_tag_fh1, tage_t3_tag_fh2
tage_t4_idx_fh, tage_t4_tag_fh1, tage_t4_tag_fh2
PHR contribution to index and tag hashing is TBD. All current folds are GHR-derived only.
Semantics¶
tage_pred_val_p0[s] = 1 -- valid prediction request for
slot s. TAGE will process and
produce tage_pred_meta_p2[s]
two cycles later.
tage_pred_val_p0[s] = 0 -- no request for slot s.
tage_pred_rdy_p2[s] will be
0 at p2.
tage_pred_rdy_p2[s] = 1 -- tage_pred_meta_p2[s] is valid.
Both slots may have tage_pred_val_p0 asserted in the same cycle. Slots operate independently with no cross-slot interaction.
T0 always produces a prediction. T1-T4 produce a prediction only on tag match. tage_pred_rdy_p2[s] is asserted on completion of the prediction indicating the predict meta data should be sampled by the consumer.
Selection of primary or alternative:¶
tage_pred_meta_p2[s].tage_pred_tkn carries the predicted direction.
The provider is either a) primary component b) alternative component c) or table 0, T0, aka BIM
All tables are accessed in parallel. Each table returns a hit value, if those hit values are organized as a vector with the table with the longest history in the MSB then the primary and alternative components are the left most hit (primary) and next left most hit (alternative).
In tage there is always at least 1 hit. When there are no hits in the tagged tables the provider component is 0 (T0).
Normally the primary component is selected since by design it has the longest history length, but this selection is modified by the primary component's CTR and the current value of the UAON for that prediction slot.
When the primary component is T0 there is no modification. Otherwise when the primary component's CTR is weak (3'b011 or 3'b100) and the UAON counter is >= TAGE_UAON_THRES the alternative component becomes the provider.
Operation of the UAON is described in tage_cntrl_uaon_update_rules.md.
TAGE processes up to two conditional branches, one for each prediction slot.
Hash Functions¶
Each tage_table instance generates idx_hash_p0 and tag_hash_p0 locally. These hashes are used to access the RAMS in p0.
The hash operations are defined in tage_table_hash_rules.md
Consumer obligations¶
- Must not consume tage_pred_tkn when tage_pred_rdy_p2[s]=0.
- Must write tage_pred_meta_p2[s] into FTQ meta path when tage_pred_val_p0[s] was asserted, regardless of tage_pred_rdy_p2[s]. The update path requires these fields unconditionally.
- Must set pred_src in bp_ftq_entry_t to PRED_TAGE when the cluster takes the TAGE direction for the slot.
- Must apply the TAGE direction over the FTB's for a COND branch, unless ftb_fastpath_p2 is asserted for that branch, in which case the FTB direction stands and no TAGE override is applied (ftb_confidence_override_rules.md 4.2).
- Must assert p2 redirect when tage_pred_rdy_p2[s]=1 and the resulting successor differs from the one the cluster's own p1 stage registers hold. THE REDIRECT CONDITION IS NOT THE OVERRIDE: an override that does not change the successor fires nothing, and the comparison is one quantity against the cluster's own staged view, never predictor against predictor, and never against the FTQ (fe_decisions.md FE-4 and 2.5, ftq_bpu_interfaces.md 6). An earlier revision gave the condition as "disagrees with FTB direction". Corrected session-070.
- Must gate TAGE override on br_type==COND only.
TAGE simulation support¶
- TAGE_FAST_INIT: runtime plusarg (+TAGE_FAST_INIT=1). Read in tage.sv, tage_bim.sv, tage_table.sv. When set: tage_bim and tage_table initial blocks write bw_ram mem arrays via hierarchical reference at time zero. tage.sv straps all tbl_ri_* to zero and drives tage_rdy=1 immediately. sram_init elaborates but is fully bypassed. When not set: sram_init sequences all entries, tage_rdy follows tbl_ri_rdy from sram_init. Simulation-only mechanism. No synthesis impact. bw_ram.sv is not modified.
- TAGE_SRAM_INIT_VALUE: localparam int in bp_defines_pkg.sv, default 0. Used by sram_init (.INIT_VAL) and tage_bim/tage_table initial blocks.
Update Interface¶
Producer: post-execute resolution path (BP cluster)¶
Consumer: tage¶
Timing¶
tage_upd_inp_u0[s] is presented at u0. Sampled on rising clk edge. tage_upd_rdy_u1[s] is asserted at u1 when the update has been applied. Update completes in one cycle. tage_upd_val_u0[s] may be asserted in any cycle. No ordering constraint between update channels when NUM_PRED_SLOTS=2. Both channels processed independently in the same cycle.
RAM Init Interface¶
Output tage_rdy indicates that the RAM initialization cycles have completed. It ties to the ready output of the sram_init module.
No prediction or update cycles begin before tage_rdy has been asserted. TAGE does not gate requests on tage_rdy; the upstream logic does. The upstream logic is the FTQ: ftq_npc holds ftq_pred_val_p0 low until tage_rdy, ittage_rdy and sc_ready are all high (ftq_decisions.md 4.5 H5; ruled session-080, built by BP-137). No FTQ entry, so no update, exists before the first request. This read that TAGE ignores prediction and update requests before tage_rdy; it does not. Session-080.
Semantics¶
tage_upd_val_u0[s] = 0 -- no update this cycle for slot s.
tage_upd_inp_u0[s] ignored.
tage_upd_val_u0[s] = 1 -- resolved update for slot s.
All tage_upd_inp_u0[s] fields
valid.
tage_upd_rdy_u1[s] = 1 -- update applied for slot s.
tage_upd_rdy_u1[s] -- flopped version of tage_upd_val_u0[s].
All updates complete in one cycle.
No backpressure is currently required.
Consumer may ignore this signal.
Retained as placeholder for future
backpressure if required.
tage_pq_not_full -- asserted when the prediction queue has
room to accept a new prediction request.
Consumer must gate tage_pred_val_p0
on this signal. Since BP-121 it also
drops for one cycle as the starvation
hold, so that a waiting update finds a
cycle with no prediction
(bp_arb_spec.md 4.5). A prediction is
never delayed by an update. Was
pq_not_full; renamed by BP-132 (TD#49).
tage_uq_not_full -- asserted when the update queue is not
full. Consumer must gate
tage_upd_val_u0 on this signal. Was
upd_rdy; renamed by BP-132 (TD#49).
bp_cluster connects it to its own port
tage_upd_rdy, which keeps that name
(ruled, Jeff, session-078).
Both are driven by tage_arb.sv, the
TAGE arbitration (PQ, UQ, arbiter,
response buffer), a submodule of
tage.sv since BP-132 (TD#52); tage.sv
is structural apart from the fast-init
muxes and the per-table index select.
Update behavior¶
CTR is a direction strength counter. It tracks the confidence in the prediction for the provider entry.
tage_pred_strong, tage_pred_medium, and tage_pred_weak are a
one-hot decode of the final provider CTR (post-UAON-mux
selection), per TD#87 (BP-081, session-060):
tage_pred_strong = 1 when ctr is 3'b000 or 3'b111
tage_pred_weak = 1 when ctr is 3'b011 or 3'b100
tage_pred_medium = 1 otherwise (001, 010, 101, 110)
tage_extd_ctr (TD#88) is a signed extended-range version of
the same post-mux provider CTR, consumed by SC. See
tage_pred_meta_t in bp_structs_pkg.sv.
When T0 is the post-mux provider (prm_comp 0 with using_primary 1, or alt_comp 0 with using_primary 0), the decode and tage_extd_ctr read the T0 2b counter in its equivalent 3b form {ctr[1], ctr[0], ctr[0]}: 00 -> 000, 01 -> 011, 10 -> 100, 11 -> 111 (TD#182, BP-134, ruled session-079). A T0 provider is therefore strong (00, 11) or weak (01, 10), never medium, and tage_extd_ctr is -7, -1, +1 or +7. tage_prm_ctr and tage_alt_ctr keep the zero-padded T0 form (tage_cntrl_decisions.md, T0 Behavior); only the decode reads the 3b form. Before BP-134 the decode read the zero-padded form, so a T0 predicting taken gave SC a not-taken term.
The definitive operation of CTR updates is found in tage_cntrl_ctr_update_rules.md.
The definitive operation of update time allocations is found in tage_cntrl_alloc_rules.md.
Read-during-write contract¶
Prediction and update paths are mutually exclusive by design. The prediction path is read-only. The update path is write-only. No read-modify-write cycles are required or permitted.
Producer obligations¶
- Must provide resolved_taken from execute, not speculative.
- Must pass tage_pred_meta_p2[s] captured at predict time unmodified into tage_upd_inp_u0[s]. No recomputation at update.
- Must not assert upd_val on the same branch_id via both channels in the same cycle (undefined update order).
SC Consumer Contract¶
The SC = Statistical Corrector.
SC takes tage_pred_rdy_p2 and tage_pred_meta_p2 directly from tage at p2 and consumes tage_pred_strong, tage_pred_medium, tage_pred_tkn and tage_extd_ctr from the meta (sc_interfaces.md, bp_arb_spec.md 6.1, ftq_bpu_interfaces.md 5). TAGE must be valid before SC can finalize. This read that SC reads tage_prm_ctr from the FTQ meta path and "does not read TAGE ports directly at runtime". Session-071.
The SC is only mentioned here for reference in the override chain position.
Override Chain Position¶
ON DIRECTION there IS a priority chain, because the FTB, TAGE and SC all produce that one quantity:
LP (p2, trusted) > SC (p3) > TAGE (p2) > FTB (p2)
The LP term was added by BP-122 (ruled session-076, fe_decisions.md 3.3): a trusted p2 loop direction is the slot's direction, over TAGE.
ftb_confidence_override_rules.md 4.3 states it in those terms, and its section 8 table is explicit that the FTB always SUBMITS a direction and the question is whose is USED. fe_decisions.md 3.3 agrees.
THE EXCEPTION IS THE FTB FAST PATH. When ftb_fastpath_p2[i] fires, conf saturated and ftb_fastpath_en set, the FTB direction stands for that branch and neither TAGE nor SC overrides it. TAGE and SC are still requested and still trained (ftb_confidence_override_rules.md 4.2 and 6).
WHAT IS NOT RANKED is everything else. The uBTB and LP at p1 produce a whole prediction that a later stage supersedes (the LP's p2 direction, above, is ranked); targets come from RAS for a return, ITTAGE for an indirect with the FTB target on an ITTAGE miss, FTB otherwise, selected by branch type and hit. There is no ordering among those beyond stage order, FE-3. fe_decisions.md 12 rejects the wider "SC > TAGE > FTB > uBTB" on that basis and was NARROWED session-070 so its rejection no longer covers the direction ranking above, which its own section 3.3 asserts. An earlier session-070 revision of this paragraph drew that scope on its own authority; the narrowing is now recorded in fe_decisions.md 12.
p1: uBTB + Loop
p2: FTB + TAGE + ITTAGE + RAS
p3: SC
TAGE does not participate in target selection; for a conditional the FTB supplies the target.
Known Gaps and Deferred Items¶
| ID | Item | Status |
|---|---|---|
| TI1 | PHR contribution to index/tag hashing | TBD at impl. |
| All current folds are GHR-derived only | ||
| TI2 | USE_ALT_ON_NA counter width and | Closed |
| update policy | ||
| TI3 | Slot 1 PC derivation. pred_pc+32 was | Closed -- retracted |
| in error and has been removed. Slot 1 | ||
| PC is supplied by fetch unit via | ||
| tage_pred_inp_p0[1].pc. No offset | ||
| derivation in tage_cntrl. | ||
| TI4 | Update channel arbitration when both | G9 in |
| channels write same entry same cycle | bp_cluster.md | |
| TI5 | TAGE/ITTAGE ftq_meta_t overload scheme | G10 in |
| for shared index fields at update | bp_cluster.md | |
| TI6 | Bank selection policy within each | Closed |
| table. Banks are per-slot RAMs, not | ||
| address-banked. Slot 0 uses RAM0, | ||
| slot 1 uses RAM1. Selection is | ||
| structural, not runtime. Unrelated to | ||
| sram_init/bw_ram bank scheme. | ||
| TI7 | bp_tage_meta_t migration to | CLOSED, verified |
| tage_pred_meta_t. bp_tage_meta_t no | session-070. | |
| longer exists in bp_structs_pkg.sv. | PROJECT_STATUS | |
| Nothing is retained in transition. | Open Items 4. | |
| TI8 | Flush port definitions (_px signals). | CLOSED BP-105. |
| NO FLUSH EVENT EXISTS: a flush is a | fe_decisions | |
| redirect. tage needs no flush port and | FE-14. | |
| none is added. |
tage_table_interfaces.md
planning/interfaces/tage_table_interfaces.md on GitHub
TAGE Table Interface Specification¶
FILE: tage_table_interfaces.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-14
CONTACT: Jeff Nye
Overview¶
TAGE is a tagged geometric history length branch predictor providing direction prediction for conditional branches. It fires at p2 alongside FTB and OVERRIDES THE FTB DIRECTION. The FTB submits its own direction for every valid conditional and TAGE supersedes it at p2, unless the FTB fast path fires for that branch, in which case the FTB direction stands and TAGE is still requested and trained (fe_decisions.md 3.3; ftb_confidence_override_rules.md 3.1, 4.2, 4.3, 6, 8).
THE p2 REDIRECT IS A SEPARATE QUESTION: it fires only when the successor the cluster would publish differs from the one its own p1 stage registers hold, so an override that does not change the successor fires nothing (fe_decisions.md FE-4 and 2.5). An earlier revision said "s2_redirect fires on override"; a session-070 revision then over-corrected and denied the direction override itself. Both corrected session-070. tage_interfaces.md Overview carries the same text.
There are two phases in a TAGE design, prediction request and update request. The phase do not overlap.
TAGE supports dual prediction. Each table type contains two rams one for each prediction request/update request. The dual nature is also described as dual slots.
Each prediction slot operates independently. All signals indexed [s] target RAMs exclusively. Slot 0 and slot 1 may perform any combination of read, write, or allocation simultaneously without interference.
TAGE is comprised of tagged and untagged components, also know as tables.
Upto 2 components can be updated in a single update cycle, in the literature these are called the primary and alternative components. This means there can be 4 total writes during an update. This is true only for the ctr field. Only the ctr field can be updated in two components.
Table description¶
There are a parameterized number of tables. Current working version has 5 tables.
Tables are also known as components (unrelated to this projects library of components). The term components is often used in the literature.
There are two table types, tagged and untagged.
There are four tagged tables, T1-T4. There is one untagged table, T0.
There are separate verilog modules for the table types.
Tagged tages use tage_table,
the file is rtl/core/frontend/bpu/rtl/tage_table.sv
Untagged tages use tage_bim,
the file is rtl/core/frontend/bpu/rtl/tage_bim.sv
These read frontend/branch_predictor/rtl/, which is not the tree (PROJECT_CORE.md, package paths). Session-072.
The untagged table, T0, is known as the base table. This is also known as the bimodal table or bim. An entry in T0 is a 2b CTR. T0 has two internal banks using the bit write SRAM module, rtl/lib/rtl/bw_ram.sv (this read common/rtl/bw_ram.sv; PROJECT_CORE.md lists ./rtl/lib/Makefile among the RTL makefiles and no common/ track exists anywhere in PROJECT_CORE.md or PROJECT_STATUS.md. Session-072.)
The tagged tables are T1-T4, and entry in a tagged table include a tag field of table specific width, an EPC field of parameterized width, a USE field of parameterized width, a CTR field of parameterized width and a 1b VALID bit. By default the EPC field is 2b, the USE field is 2b, the CTR field is 3b. The tagged tables have an associated history length of (8b, 13b, 32b, 119b) respectively.
The definitive specification of the field widths is found in
bp_defines_pkg.sv
Bank Address Assignment¶
Each tage_table and tage_bim instance contains two bw_ram instances, one per prediction slot (RAM0 for slot 0, RAM1 for slot 1). Each bw_ram is instantiated with BANKS=2.
The bank_addr port of each bw_ram is derived from the MSB of the index. The row address is the remaining lower bits. For a THIS_INDEX_BITS-wide index:
bank_addr = index[THIS_INDEX_BITS-1]
row_addr = index[THIS_INDEX_BITS-2:0]
This decomposition applies to prediction reads, normal update writes, and the tbl_ri initialization path. It is identical for tage_bim and tage_table.
Table Pipeline¶
The prediction phase uses pipestages p0, p1, p2. Table inputs are presented on p0, SRAM read/compare/tag match occurs on p1. P2 is not used by tables.
The update phase uses pipestages u0, u1. Table inputs are presented on u0, SRAM write occurs in u1.
Port Naming Convention¶
Signal names follow the pattern:
<signal>_<pipestage>
- `pipestage` : p0, p1, p2 for prediction path.
u0, u1 for update path.
There is no px stage. No flush event exists; a
flush is a redirect (fe_decisions.md FE-14,
BP-105). tage_interfaces.md TI8. Corrected
session-070.
Slot dimension uses vector index [0:NUM_PRED_SLOTS-1]. clk and rstn carry no pipe stage suffix.
The ports are not identical between the two table types. They are listed below.
Parameters Types and Structs¶
All types defined in bp_defines_pkg.sv and bp_structs_pkg.sv. This document describes port semantics, timing contracts, and consumer/producer obligations. It does not restate struct field layouts -- see bp_structs_pkg.sv.
Top Level Parameters¶
These parameters are defined in bp_defines_pkg.sv (this read br_defines_pkg.sv, session-072). These parameters define the limits, they are not table specific.
NUM_PRED_SLOTS : int TAGE_MAX_IDX_WIDTH : int TAGE_MAX_TAG_WIDTH : int TAGE_MAX_EPC_WIDTH : int TAGE_MAX_USE_WIDTH : int TAGE_MAX_CTR_WIDTH : int TAGE_MAX_VAL_WIDTH : int
These carried no prefix here while tage_table_entry_formats.md gives TAGE_MAX_*, and the sibling predictors prefix uniformly (IT_MAX_*, SC_MAX_*). Session-072.
Top level module parameters are vectored, the vector positions are aligned with the assumption that tables will be instantiated in a generate loop and the loop index will select the proper parameter for that table.
These are the table specific vectored parameters. These values are for explanation the values to use during design are found in bp_defines_pkg.sv.
TAGE_TBL_BANKS[0:4] : int this parameter is not currently used
TAGE_TBL_ENTRIES[0:4] : int this describes the number of entries in ech
bw_ram instance.
TAGE_TBL_FH[0:4] : int this is the width of the index folded history (fh)
for tables T1-T4, this is not used by T0.
TAGE_TBL_FH1[0:4] : int this is the width of the 1st tag folded history (fh1)
for tables T1-T4, this is not used by T0.
TAGE_TBL_FH2[0:4] : int this is the width of the 2nd tag folded history (fh2)
for tables T1-T4, this is not used by T0.
TAGE_TBL_HIST[0:4] : int this is the number of history bits for tables T1-T4
this is not used by T0.
TAGE_TBL_TAG[0:4] : int this is the width of the tag in tables T1-T4
this is not used by T0.
TAGE_TBL_CTR[0:4] : int this is the width of the CTR field in tables T0-T4
TAGE_TBL_USE[0:4] : int this is the width of the USE field in tables T1-T4
this is not used by T0.
TAGE_TBL_EPC[0:4] : int this is the width of the EPC field in tables T1-T4
this is not used by T0.
TAGE_TBL_IDX[0:4] : int this is the width of the index bus for tables T0-T4
Derived Parameters¶
T1-TN¶
CNTRL_BITS_WIDTH = TAGE_MAX_EPC_WIDTH+TAGE_MAX_USE_WIDTH
+ TAGE_MAX_CTR_WIDTH+TAGE_MAX_VAL_WIDTH;
the width of the control bits in tables T1-T4.
ALLOC_DATA_WIDTH = CNTRL_BITS_WIDTH+THIS_TAG_BITS
T0¶
CNTRL_BITS_WIDTH = 2 the width of the control bits in tables T0. ALLOC_DATA_WIDTH = CNTRL_BITS_WIDTH
Internal Module Parameters¶
Internally a table uses the THIS_ nomenclature to specialized the top level module level parameters for use in the module. These are set by the table specific assignments that occur above this level at module instantiation.
Common internal module parameters¶
THIS_TABLE : int this indicates which table T0-T4
TBL_SEL_WIDTH : int this is the width of the table select bus, typically
tbl_sel or alc_set buses
THIS_VAL_WIDTH : int = 1 this is a static value, the parameter is only
used for documentation
Internal module parameters¶
These are assigned during instantiation.
THIS_INDEX_BITS : int this is the local width of the index bus
THIS_TAG_BITS : int this is the local width of the TAG field
this is not used by T0
THIS_EPC_WIDTH : int this is the local width of the EPC field
this is not used by T0
THIS_USE_WIDTH : int this is the local width of the USE field
this is not used by T0
THIS_CTR_WIDTH : int this is the local width of the CTR field
Port Lists¶
There are two prediction slots, 0 and 1, these are referenced by a vector index 0/1. These are two independent prediction slots.
T0 Port List, tage_bim¶
T0 prediction ports¶
output [NUM_PRED_SLOTS-1:0] taken_p1 // this is bit [1] of the entry.
output [THIS_CTR_WIDTH-1:0] cntrl_bits_p1[0:NUM_PRED_SLOTS-1]
input [NUM_PRED_SLOTS-1:0] tage_pred_val_p0
input tage_pred_inp_t tage_pred_inp_p0[0:NUM_PRED_SLOTS-1]
T0 update ports¶
input [NUM_PRED_SLOTS-1:0] tage_upd_val_u0
input [THIS_CTR_WIDTH-1:0] prm_ctr_wd_u0[0:NUM_PRED_SLOTS-1]
input [NUM_PRED_SLOTS-1:0] prm_ctr_wr_u0
input [TBL_SEL_WIDTH-1:0] prm_tbl_sel_u0[0:NUM_PRED_SLOTS-1]
input [THIS_INDEX_BITS-1:0] upd_index_u0[0:NUM_PRED_SLOTS-1]
T0 misc ports¶
input tbl_ri_active
input tbl_ri_wr
input [THIS_INDEX_BITS-1:0] tbl_ri_wa
input [ALLOC_DATA_WIDTH-1:0] tbl_ri_wd
input rstn
input clk
T1-TN Port List, tage_table¶
T1-TN prediction ports¶
output [NUM_PRED_SLOTS-1:0] hit_p1
output [NUM_PRED_SLOTS-1:0] taken_p1
output [CNTRL_BITS_WIDTH-1:0] cntrl_bits_p1[0:NUM_PRED_SLOTS-1]
output logic [THIS_INDEX_BITS-1:0]
idx_hash_p0[0:NUM_PRED_SLOTS-1]
output logic [TAGE_MAX_TAG_WIDTH-1:0]
tag_hash_p0[0:NUM_PRED_SLOTS-1]
input [NUM_PRED_SLOTS-1:0] tage_pred_val_p0
input tage_pred_inp_t tage_pred_inp_p0[0:NUM_PRED_SLOTS-1]
T1-TN update ports¶
input [NUM_PRED_SLOTS-1:0] tage_upd_val_u0
input [THIS_CTR_WIDTH-1:0] prm_ctr_wd_u0[0:NUM_PRED_SLOTS-1]
input [THIS_CTR_WIDTH-1:0] alt_ctr_wd_u0[0:NUM_PRED_SLOTS-1]
input [THIS_USE_WIDTH-1:0] use_wd_u0[0:NUM_PRED_SLOTS-1]
input [THIS_EPC_WIDTH-1:0] epc_wd_u0[0:NUM_PRED_SLOTS-1]
input [ALLOC_DATA_WIDTH-1:0] alc_wd_u0[0:NUM_PRED_SLOTS-1]
input [NUM_PRED_SLOTS-1:0] prm_ctr_wr_u0
input [NUM_PRED_SLOTS-1:0] alt_ctr_wr_u0
input [NUM_PRED_SLOTS-1:0] use_wr_u0
input [NUM_PRED_SLOTS-1:0] epc_wr_u0
input [NUM_PRED_SLOTS-1:0] alc_wr_u0
input [TBL_SEL_WIDTH-1:0] prm_tbl_sel_u0[0:NUM_PRED_SLOTS-1]
input [TBL_SEL_WIDTH-1:0] alt_tbl_sel_u0[0:NUM_PRED_SLOTS-1]
input [THIS_INDEX_BITS-1:0] upd_index_u0[0:NUM_PRED_SLOTS-1]
input [TBL_SEL_WIDTH-1:0] alc_tbl_sel_u0[0:NUM_PRED_SLOTS-1]
input [THIS_INDEX_BITS-1:0] alc_index_u0[0:NUM_PRED_SLOTS-1]
T1-TN misc ports¶
input tbl_ri_active
input tbl_ri_wr
input [THIS_INDEX_BITS-1:0] tbl_ri_wa
input [ALLOC_DATA_WIDTH-1:0] tbl_ri_wd
input bp_folded_hist_t folded_hist
input rstn
input clk
Misc Interface¶
Semantics:¶
The tbl_ri ports are not driven by tage_cntrl. They are driven by an SRAM initialization module instantiated in tage.sv. The init module is found rtl/lib/rtl/sram_init.sv
tbl_ri_active ram initialization is active
tbl_ri_wr ram write signal, this needs to be converted to an active low
bit write and a global select. When tbl_ri_active is
asserted, tbl_ri_wr overrides all other write signals. But there
is no case where tbl_ri_wr and the other write signals are
asserted.
tbl_ri_wa ram address signal. When tbl_ri_active is asserted, tbl_ri_wa
overrides all other ram address signals. Sized to
THIS_INDEX_BITS.
tbl_ri_wd ram write data signal When tbl_ri_active is asserted, tbl_ri_wd
overrides all other ram data input signals.
Prediction Interface¶
T0 Semantics:¶
There are two effective copies of these signals for each prediction slot.
The unused signals are not documented here.
taken_p1 this is the MSB of the T0 entry
cntrl_bits_p1 this is a THIS_CTR_WIDTH (default 2b) wide bus that
is the contents of the T0 entry.
tage_pred_val_p0 is the trigger that enable SRAM read
produced by tage top top level for prediction slot 0/1
The T0 index is tage_pred_inp_p0[s].pc[12:2], used inside tage_bim to address the RAM for slot s. It is not hashed and not routed through tage_hash, and T0 exposes no index port: the T0 port list above declares no index_hash or idx_hash output, unlike T1-TN.
This paragraph named a T0 signal "index_hash_p0" and spelled the request port tage_pred_inp_0/1_p0; neither exists. The T1-TN sections use idx_hash_p0 and tage_pred_inp_p0[s]. Session-072.
T1-TN Semantics:¶
tage_pred_val_p0[s] is the trigger that enables the SRAM read.
Produced by tage top level.
tage_pred_inp_p0[s] carries the branch PC and branch_id for
prediction slot s. The pc field is used
locally within tage_table to derive the
index hash and tag hash via the functions
defined in tage_table_hash_rules.md.
Produced by tage top level.
folded_hist the bp_folded_hist_t output of bp_history,
shared across both prediction slots. Each
tage_table instance selects the three fields
corresponding to its THIS_TABLE value
(tage_tN_idx_fh, tage_tN_tag_fh1,
tage_tN_tag_fh2) and uses them locally to
compute the index and tag hashes. idx_hash_p0
and tag_hash_p0 are no longer sourced
externally.
Produced by bp_history.
hit_p1[s] is the result of a tag compare. Gated with valid.
taken_p1[s] is the MSB of the entry CTR field. Can be asserted
without hit; ignored when hit is 0.
cntrl_bits_p1[s] is the control bit portion of the entry, used by
tage_cntrl to form the response data.
idx_hash_p0[s] combinational index hash computed from pc and
folded_hist at p0. One value per prediction slot.
Used by tage_cntrl to populate tage_prm_idx,
tage_alt_idx, and tage_alloc_idx in prediction
meta.
The rules for idx_hash_p0 generation are found
in tage_table_hash_rules.md
tag_hash_p0[s] combinational tag hash computed from pc and
folded_hist at p0. One value per prediction slot.
Used by tage_cntrl to populate tage_alloc_tag in
prediction meta.
The rules for tag_hash_p0 generation are found
in tage_table_hash_rules.md
These read tage_alc_idx and tage_alc_tag, the
ITTAGE spelling; the TAGE meta fields are
tage_alloc_* (tage_cntrl_decisions.md,
tage_cntrl_alloc_rules.md). The tag_hash_p0 entry
cited the rules for idx_hash_p0. Session-072.
Update Interface¶
T0 Semantics:¶
tage_upd_val_u0 is the trigger that enables SRAM writes
this is produced by tage top level
prm_ctr_wd_u0 this is the ctr field write data for T0
this is produced by tage_cntrl.
prm_ctr_wr_u0 this is the write signal for the T0 entry. This is
gated by THIS_TABLE compared to prm_tbl_sel_u0.
this is produced by tage_cntrl.
prm_tbl_sel_u0 this is the component index used to select a TAGE table
this is produced by tage_cntrl.
upd_index_u0 this is used to access the ram entry
this is produced by tage_cntrl.
T1-TN Semantics:¶
tage_upd_val_u0[s] is the trigger that enables SRAM writes
this is produced by tage top level
prm_ctr_wd_u0[s] this is the ctr field write data for the
primary component. See above about multiple ctr writes.
this is produced by tage_cntrl.
alt_ctr_wd_u0[s] this is the ctr field write data for the
alternative component. See above about multiple ctr writes.
this is produced by tage_cntrl.
use_wd_u0[s] this is the use field write data.
this is produced by tage_cntrl.
epc_wd_u0[s] this is the epc field write data.
this is produced by tage_cntrl.
alc_wd_u0[s] this is the allocation field write data. This field
writes all control and tag bits.
this is produced by tage_cntrl.
prm_ctr_wr_u0[s] this is the write signal for the primary ctr. This is
gated by THIS_TABLE compared to prm_tbl_sel_u0.
this is produced by tage_cntrl.
alt_ctr_wr_u0[s] this is the write signal for the alternative ctr. This is
gated by THIS_TABLE compared to alt_tbl_sel_u0.
this is produced by tage_cntrl.
use_wr_u0[s] this is the write signal for the use field. This is
gated by THIS_TABLE compared to prm_tbl_sel_u0 OR
alt_tbl_sel_u0. tage_cntrl raises it only for the
table Table 7 selects (see below).
this is produced by tage_cntrl.
epc_wr_u0[s] this is the write signal for the epc field. It is
gated as use_wr_u0 is.
this is produced by tage_cntrl.
THE USEFUL AND EPOCH WRITE GOES TO ONE COMPONENT, the one tage_cntrl_use_update_rules.md Table 7 selects: the primary when tage_using_primary is 1, the alternate when it is 0. tage_cntrl raises use_wr_u0 and epc_wr_u0 only for that table, and tage_table opens the write on a match against either selector, prm_tbl_sel_u0 or alt_tbl_sel_u0. The address is upd_index_u0, which tage.sv selects per table instance (upd_index_u0 below). The alternate is always a lower table than the primary, so a table named as the alternate never matches prm_tbl_sel_u0 and receives the alternate index. The CTR strobes need two selectors because TAGE may write both components' CTRs in one update, in two different tables; the useful write is always one component.
This note read that prm_tbl_sel_u0 and upd_index_u0 carry the component Table 7 selects, and use_wr_u0 and epc_wr_u0 above read as gated on prm_tbl_sel_u0 alone. tage_cntrl drives prm_tbl_sel_u0 and its index bus from the primary in every case. Corrected against tage_cntrl.sv, tage.sv and tage_table.sv, session-078. ittage_table_interfaces.md states the ITTAGE rule: there the useful write opens with the provider's CTR strobe, not on either selector alone.
alc_wr_u0[s] this is the write signal for an entry allocation. This is
gated by THIS_TABLE compared to alc_tbl_sel_u0.
this is produced by tage_cntrl.
prm_tbl_sel_u0[s] this is the primary component index used to select
a TAGE table this is produced by tage_cntrl.
alt_tbl_sel_u0[s] this is the alternative component index used to
select a TAGE table this is produced by tage_cntrl.
upd_index_u0[s] this is the index of the ctr, use and epc writes.
tage_cntrl produces the primary index and the
alternate index on separate buses; tage.sv
selects one for each table instance: the primary
when THIS_TABLE equals prm_tbl_sel_u0[s], the
alternate otherwise. This read "produced by
tage_cntrl". Session-078.
alc_tbl_sel_u0[s] this is the component index used to select a TAGE table
for allocation this is produced by tage_cntrl.
alc_index_u0[s] this is allocation index used to access the ram entry for
allocation this is produced by tage_cntrl
Entry Formats¶
The table entry formats for TAGE are found in
planning/arch/tage_table_entry_formats.md
sc_decisions.md
planning/arch/sc_decisions.md on GitHub
Statistical Corrector (SC) Micro-Architectural Decisions¶
FILE: sc_decisions.md
SOURCE: manual and PA sessions
STATUS: DRAFT
UPDATED: 2026-10-12
CONTACT: Jeff Nye
1. Context¶
Not all of this context will be necessary for all tasks.
SC Planning context:¶
-
SC top level decisions (this document)
planning/arch/sc_decisions.md
-
SC table index creation [written session-058]
planning/arch/sc_table_hash_rules.md
-
SC confidence counter operation [NOT A SEPARATE DOCUMENT]
- the counter step is section 10 of this document;
sc_cntrl_ctr_update_rules.mdis not in the PROJECT_CORE.md inventory and was not written
- the counter step is section 10 of this document;
-
SC table entry format reference [DROPPED]
- the entry is one signed counter of SC_TBL_CTR bits,
sc_table_interfaces.mdEntry Formats; nosc_table_entry_formats.md
- the entry is one signed counter of SC_TBL_CTR bits,
-
SC line coverage plan [NOT WRITTEN]
verification/sc_coverage_plan.md
-
SC table module IO ports and semantics [written session-058]
planning/interfaces/sc_table_interfaces.md
-
SC top level IO ports and semantics [written session-058]
planning/interfaces/sc_interfaces.md
-
SC testbench requirements [written session-058]
planning/testbenches/sc_tb_decisions.md
This list marked all but this document and sram_init.md "[NOT WRITTEN]"; four were written session-058 (PROJECT_STATUS.md Module Status). Session-071.
- SC SRAM reset triggered initialization semantics
planning/arch/sram_init.md
BPU Planning context:¶
- Decisions related to the branch prediction unit
- `planning/arch/bp_cluster.md` (this read bp_decisions.md,
which does not exist; session-072)
- Decisions related to the load balanced prediction/update interface
- `planning/arch/bp_arb_spec.md`
SC RTL configuration context:¶
- Structures and meta data used to communicate in the BPU
- `rtl/core/frontend/bpu/rtl/bp_structs_pkg.sv`
- RTL design parameters for configuration of units in the BPU
- `rtl/core/frontend/bpu/rtl/bp_defines_pkg.sv`
RTL library components:¶
There is a library of common/shared modules.
- Banked RAM module
- `rtl/lib/rtl/bw_ram.sv`
- This is the basis of the SC tables
- RAM init module
- `rtl/lib/rtl/sram_init.sv`
- This is the module that performs post reset table initization.
2. Overview and Scope¶
The Statistical Corrector (SC) is used to improve the accuracy of the TAGE predictor by detecting branches which have shown little correlation to the TAGE mechanism. The SC uses the TAGE output and the SC internal counters to determine whether to reverse the TAGE prediction.
The SC is table based. The tables contain the confidence counters. The tables are indexed through a hashing scheme based on the PC. The tables are read in parallel, their outputs are summed. The magnitude of this sum, compared against a dynamically adapted threshold, decides whether the SC inverts the TAGE prediction. The threshold mechanism and the override-corner logic are specified in sections 9 (prediction) and 10 (update); the SC does not use a fixed LO/HI threshold pair.
The TAGE p2 output is supplied to the SC, the SC operation is one cycle and the SC outputs its results in p3.
Like TAGE, the SC supports dual predictions. The two slots have separate table RAMs (section 6) and predict in parallel. They are NOT wholly independent: the threshold, TC and the two chooser counters (section 8) and the BrIMLI counter are single registers in sc_cntrl, and under a dual-slot update the lowest-indexed valid update slot drives their adaptation (TD#98, temporary, BP-077). This read that the two predictions "do not share resources or conflict in operation". Session-071.
SC predictions require TAGE output. SC updates can proceed without input from TAGE.
3. Pipeline Notation¶
Stage notation is p0/p1/p2/p3 for prediction and u0/u1 for update, in every document and in the RTL (PROJECT_CORE.md, Interface specification approach; fe_decisions.md 12).
The SC begins prediction operation using p2 signals.
This section read that planning documents use s0/s1/s2/s3 and that this document would keep the s-labels until every document could be updated. PROJECT_CORE supersedes that local rule: s0=p0, s1=p1, s2=p2, s3=p3, and a document carrying the old labels is stale. Session-072.
4. Operation Phases¶
There are two non-overlapping phases for the SC operation. There is the prediction phase and the update phase.
SC's own prediction and update phases do not overlap: each table RAM is either read or written. TAGE and SC are NOT in lock step. SC has its own update queue and its own arbitration (bp_arb_spec.md 4.5 and 6), so TAGE may be in one phase while SC is in the other. This read "TAGE and SC are in lock step ... There is never a case there one is in the opposite phase"; bp_arb_spec.md records the lockstep constraint as eliminated by design. Session-071.
There are dedicating module IOs for each phase. The module IO list and naming
convention are found in sc_interfaces.md.
These phases are defined to eliminate the need for read/modify/write to any of the SC tables. Prediction is a RAM read process. Update is a RAM write process. Data and meta data needed for update is generated during the prediction phase and returned along with the prediction.
5. SC IO structures¶
In the prediction phase the SC is supplied with the TAGE prediction output,
tage_pred_meta_t, and the TAGE prediction request input, tage_pred_inp_t.
The input contains the PC for the prediction request and the branch id.
NOTE: this is somewhat redundant in that the branch_id is also available in
the TAGE prediction output. We will accept the redundancy for now. See TD #85
for cleanup task.
Prediction Phase SC structure inputs:¶
(tage_pred_meta_t) tage_pred_meta -> to SC
(tage_pred_inp_t) tage_pred_inp -> to SC
Prediction Phase SC structure outputs:¶
SC -> (sc_pred_meta_t) sc_pred_meta to TOP
Update Phase SC structure inputs:¶
(sc_upd_inp_t) sc_upd_inp -> to SC
There is no update-phase SC structure output. The only update-phase output is sc_upd_rdy_u1 (sc_interfaces.md, Update Interface); sc_pred_meta is a PREDICTION-phase structure. A block giving sc_pred_meta as an update-phase output stood here under its own FIXME saying it was wrong and kept for communication with the PA. Session-072.
The details of the SC top level ports and the SC table ports are found in
sc_interfaces.md and sc_table_interfaces.md.
6. Table Structure¶
The SC contains 5 tables. Each table contains two RAMs, one for each prediction slot. These RAMs operate in parallel, there is no conflict or shared information between these RAMs.
The number of tables is a parameter in bp_defines_pkg.sv, SC_NUM_TABLES.
Therefore there are 2 x SC_NUM_TABLES RAM instances in the tables.
The number of tables may change in the future. This requires the instantiation of the SC tables to use a generate for-loop.
There are 4+1 tables by default. The default table naming is ST0-ST4.
Tables ST0-ST3 contain confidence counters. Table ST4 is the BrIMLI table. BrIMLI is described later.
ST1-ST3 are indexed using the PC hashed with the history inputs. The history
inputs are SC top level ports, sc_t1_idx_fh_p2, sc_t2_idx_fh_p2,
sc_t3_idx_fh_p2. These ports are extract from the primary bp_folded_hist_t
input and staged two cycles.
ST0 uss a portion of the PC directly without a hash.
ST4 is indexed by the BrIMLI counter.
Each table ST1-ST3 has a different history length. History length determines how many bits of history are XOR's with the PC to form the index.
The table geometry are controlled by parameter arrays. These parameters are
found in bp_defines_pkg.sv.
NOTE: SC_TBL_BANKS[0:4] this parameter is not currently used.
The RAM library component, bw_ram includes a BANK module parameter, this is
not related to prediction slots. This is a placeholder for eventual mapping
of bw_ram to a physical RAM model. The bw_ram models in sc_table always
use BANK(2) for their module parameter. This is also their default.
7. SC Table Parameters and Structures¶
The SC and sc_table parameters are defined in bp_defines_pkg.sv and the SC
enums/structs in bp_structs_pkg.sv. THOSE FILES ARE AUTHORITATIVE. This
section gives only the meaning of each parameter array; it does not restate
values. Read the package for current values -- do not copy numbers from this
document.
Parameter meaning¶
The values are declared in bp_defines_pkg.sv. That file is the reference;
this info is provided to assist the discussion. The two spellings here read
bp_defined_pkg.sv and bp_defines_pkg.sv1. Session-072.
SC_TBL_BANKS[n] : this parameter is not currently used.
SC_TBL_ENTRIES[n]: table N entry count, e.g. rows
SC_TBL_FH[n] : table N history length
SC_TBL_HIST[n] : table N history length, duplicate of SC_TBL_FH
SC_TBL_TAG[n] : table N tag width, SC table entries do not have tags
SC_TBL_CTR[n] : table N confidence counter width
SC_TBL_USE[n] : table N useful field width, SC entries do not have USE field
SC_TBL_EPC[n] : table N epoch field width, SC entries do not have EPC field
SC_TBL_IDX[n] : table N number of bits in the index.
A number of MAX width parameters define common signal widths for port:
SC_MAX_IDX_WIDTH
SC_MAX_CTR_WIDTH,
SC_MAX_DATA_WIDTH
SC_MAX_FH
etc.
The dynamic-threshold, TC-counter, sum, and chooser widths are likewise in the package.
SC_THRSH_*
SC_TC_BITS
SC_LSUM_BITS
SC_CHOOSER_*
SC Enum Structures Reference¶
SC enums and structures are defined in bp_structs_pkg.sv. That file
is the refernce, this info is provided to assist the discussion.
typedef enum logic [1:0] {
CHOOSE_NONE = 2'b00,
CHOOSE_MED = 2'b01,
CHOOSE_HIGH = 2'b10,
CHOOSE_RSRVD = 2'b11
} bp_sc_chooser_e;
8. SC Control Local State and Controls¶
There are local registers in sc_cntrl.sv. They are defined here:
//Unsigned dynamic threshold
logic [SC_THRSH_BITS-1:0] threshold,threshold_d; //was threshhold_d
//Threshold adaption counter, includes declaration of temporaries
logic signed [SC_TC_BITS-1:0] TC,TC_d,TC_inc;
//There are two corners for the thresholding
// corner 1: TAGE-hi & SC-very-low
logic signed [SC_CHOOSER_BITS-1:0] choose_hi_vlo;
// corner 2: TAGE-med & SC-very-very-low
logic signed [SC_CHOOSER_BITS-1:0] choose_med_vvlo;
// These are locally declared in the module
localparam signed [SC_TC_BITS-1:0] LCL_TC_MAX
= {1'b0,{(SC_TC_BITS-1){1'b1}}}; // 0111..1
localparam signed [SC_TC_BITS-1:0] LCL_TC_MIN
= {1'b1,{(SC_TC_BITS-1){1'b0}}}; // 1000..0
// Registers used by br_imli index generation
`br_imli` is the backwards branch counter, cleared on reset
`bb_hist` is the backwards branch path register, cleared on reset
`last_back_pc` stores the pc range of the previous backwards branch
logic [9:0] br_imli;
logic [10:0] last_back_pc; //bit [10] is the valid bit;
logic [9:0] bb_hist;
Persistent state reset¶
Abstracted - verilog reset is assumed, reset is active low, rstn
if(!rstn) {
TC = 0;
threshold = SC_THRSH_MID;
choose_hi_vlo = 0;
choose_med_vvlo = 0;
br_imli = 0;
bb_hist = 0;
last_back_pc = 0;
}
9. SC Prediction Phase Operation¶
The inputs to the prediction phase are the PC, table histories, tage
results. The outputs populate an sc_pred_meta_t structure.
// Read the SC tables
// inp_pc_p2 is an SC input port, one for each prediction slot, it is
// staged from the tage input
// sc_phr_p2 is an SC input port, it is staged from the p0 version of the
// folded_history.phr[9:0] input of tage and staged to p2.
// the sc_tX_idx_fh_p2 signals are SC input ports, they are staged
// from the p0 version of bp_history.
logic [SC_MAX_IDX_WIDTH-1:0] st0_index
= sc_idx_hash(inp_pc_p2,SC_TBL_FH[0],0);
logic [SC_MAX_IDX_WIDTH-1:0] st1_index
= sc_idx_hash(inp_pc_p2,SC_TBL_FH[1],sc_t1_idx_fh_p2);
logic [SC_MAX_IDX_WIDTH-1:0] st2_index
= sc_idx_hash(inp_pc_p2,SC_TBL_FH[2],sc_t2_idx_fh_p2);
logic [SC_MAX_IDX_WIDTH-1:0] st3_index
= sc_idx_hash(inp_pc_p2,SC_TBL_FH[3],sc_t3_idx_fh_p2);
// The get_br_imli_idx mode argument is the sc_brimli BR_IMLI_MODE
// compile-time parameter (section 12), not a port. The call below
// takes the parameter default.
logic [SC_MAX_IDX_WIDTH-1:0] st4_index
= get_br_imli_idx(inp_pc_p2[15:6],sc_phr_p2,br_imli);
// The pc argument is [9:0], PC[15:6] (section 12). This call passed the
// whole inp_pc_p2. Session-071.
// IA NOTE: ctr\* are read SIGNED. The raw ctr is what is captured into
// sc_upd_ctr below (the update path saturate-steps the raw counter).
// value\* is the 2\*ctr+1 perceptron contribution and is LOCAL TO THE SUM
// ONLY -- do not capture value\* into the meta.
logic signed [SC_MAX_CTR_WIDTH-1:0] ctr0 = signed'(ST0[st0_index].ctr);
logic signed [SC_MAX_CTR_WIDTH-1:0] ctr1 = signed'(ST1[st1_index].ctr);
logic signed [SC_MAX_CTR_WIDTH-1:0] ctr2 = signed'(ST2[st2_index].ctr);
logic signed [SC_MAX_CTR_WIDTH-1:0] ctr3 = signed'(ST3[st3_index].ctr);
logic signed [SC_MAX_CTR_WIDTH-1:0] ctr4 = signed'(ST4[st4_index].ctr);
logic signed [SC_MAX_CTR_WIDTH+1:0] value0 = (ctr0 <<< 1) + 1;
logic signed [SC_MAX_CTR_WIDTH+1:0] value1 = (ctr1 <<< 1) + 1;
logic signed [SC_MAX_CTR_WIDTH+1:0] value2 = (ctr2 <<< 1) + 1;
logic signed [SC_MAX_CTR_WIDTH+1:0] value3 = (ctr3 <<< 1) + 1;
logic signed [SC_MAX_CTR_WIDTH+1:0] value4 = (ctr4 <<< 1) + 1;
// IA NOTE: sum width is deliberate. Five value\* terms (each +/-63) plus
// tage_extd_ctr (+/-7) bound |sc_sum| at ~322, which fits signed
// SC_LSUM_BITS (10b, +/-511). Do NOT widen SC_LSUM_BITS to "fix" a
// perceived overflow -- there is none at the declared geometry.
//
// Calculate the local sum, include the TAGE contribution
logic signed [SC_LSUM_BITS-1:0] sc_sum = value0
+ value1
+ value2
+ value3
+ value4
+ tage_pred_meta.tage_extd_ctr;
// Create the local SC prediction
logic lcl_sc_pred_tkn = sc_sum >= 0;
// Create confidence bands
// SC confidence magnitude
logic [SC_LSUM_BITS-1:0] abs_sum;
abs_sum = sc_sum[SC_LSUM_BITS-1] ? (~sc_sum + 1'b1) : sc_sum;
// IA NOTE: the vlo/vvlo band construction (threshold>>1, threshold>>2)
// is a LOCAL design choice, not from O-GEHL (single threshold there).
// Band geometry and the threshold seed/bounds are tuning-deferred --
// see TD#93. Implement as written; do not re-derive the band split.
logic sc_vlo = (abs_sum < (threshold >> 1)); // "very low"
logic sc_vvlo = (abs_sum < (threshold >> 2)); // "very very low"
// TAGE confidence: storage-free estimation, Seznec HPCA-2011
logic tage_hi = tage_pred_meta.tage_pred_strong
logic tage_med = tage_pred_meta.tage_pred_medium
// Final selection: SC wins except in two corners
logic final_pred;
bp_sc_chooser_e use_chooser;
logic sc_override;
logic preds_differ = lcl_sc_pred_tkn != tage_pred_meta.tage_pred_tkn
if (!preds_differ) {
final_pred = lcl_sc_pred_tkn; // agree
sc_override = 1'b0;
use_chooser = CHOOSE_NONE;
} else if (tage_hi && sc_vlo) { // corner 1
final_pred = (choose_hi_vlo >= 0) ? lcl_sc_pred_tkn
: tage_pred_meta.tage_pred_tkn;
sc_override = (choose_hi_vlo >= 0 & preds_differ) ? 1'b1 : 1'b0;
use_chooser = CHOOSE_HIGH;
} else if (tage_med && sc_vvlo) { // corner 2
final_pred = (choose_med_vvlo >= 0) ? lcl_sc_pred_tkn
: tage_pred_meta.tage_pred_tkn;
sc_override = (choose_med_vvlo >= 0 & preds_differ) ? 1'b1 : 1'b0;
use_chooser = CHOOSE_MED;
} else {
final_pred = lcl_sc_pred_tkn; // general case: SC
sc_override = (preds_differ) ? 1'b1 : 1'b0;
use_chooser = CHOOSE_NONE;
}
// Capture what is needed for Update
sc_pred_meta.sc_sum = sc_sum;
sc_pred_meta.sc_abs_sum = abs_sum;
sc_pred_meta.sc_pred_tkn = final_pred;
sc_pred_meta.sc_lcl_pred_tkn = lcl_sc_pred_tkn;
sc_pred_meta.sc_tage_pred_tkn = tage_pred_meta.tage_pred_tkn;
sc_pred_meta.sc_override = sc_override;
sc_pred_meta.sc_chooser = use_chooser;
sc_pred_meta.sc_upd_idx[0] = st0_index;
sc_pred_meta.sc_upd_idx[1] = st1_index;
sc_pred_meta.sc_upd_idx[2] = st2_index;
sc_pred_meta.sc_upd_idx[3] = st3_index;
sc_pred_meta.sc_upd_idx[4] = st4_index;
sc_pred_meta.sc_upd_ctr[0] = ctr0;
sc_pred_meta.sc_upd_ctr[1] = ctr1;
sc_pred_meta.sc_upd_ctr[2] = ctr2;
sc_pred_meta.sc_upd_ctr[3] = ctr3;
sc_pred_meta.sc_upd_ctr[4] = ctr4;
10. SC Update Phase Operation¶
Inputs to the update phase are taken from sc_upd_inp and the local
dynamic registers.
// Was the non-override SC prediction correct ?
logic sc_wrong = (sc_upd_inp.sc_pred_meta.sc_lcl_pred_tkn
!= sc_upd_inp.resolved_taken);
// Is the threshold in the weak range
logic sc_lo_upd = (sc_upd_inp.sc_pred_meta.sc_abs_sum) < threshold;
// Use these signals to decide to update the CTRs and other state
logic do_update = sc_wrong || sc_lo_upd;
// Threshold-adaptation counter, compute next, then test it
if (sc_wrong) TC_inc = sat_tc(TC, +1);
else if (sc_lo_upd) TC_inc = sat_tc(TC, -1);
else TC_inc = TC;
if(TC_inc == LCL_TC_MAX) {
TC_d = 0;
threshold_d = sat_thr(threshold, +1);
}
else if (TC_inc == LCL_TC_MIN) {
TC_d = 0;
threshold_d = sat_thr(threshold, -1);
}
else {
TC_d = TC_inc;
threshold_d = threshold;
}
posedge clk {
TC = TC_d;
threshold = threshold_d;
}
// If an update is enabled move the CTR's toward resolved direction
if (do_update) {
incr = resolved_taken ? +1 : -1;
ST0[sc_upd_inp.sc_pred_meta.sc_upd_idx[0]]
= sat_sc(sc_upd_inp.sc_pred_meta.sc_upd_ctr[0],incr);
ST1[sc_upd_inp.sc_pred_meta.sc_upd_idx[1]]
= sat_sc(sc_upd_inp.sc_pred_meta.sc_upd_ctr[1],incr);
ST2[sc_upd_inp.sc_pred_meta.sc_upd_idx[2]]
= sat_sc(sc_upd_inp.sc_pred_meta.sc_upd_ctr[2],incr);
ST3[sc_upd_inp.sc_pred_meta.sc_upd_idx[3]]
= sat_sc(sc_upd_inp.sc_pred_meta.sc_upd_ctr[3],incr);
ST4[sc_upd_inp.sc_pred_meta.sc_upd_idx[4]]
= sat_sc(sc_upd_inp.sc_pred_meta.sc_upd_ctr[4],incr);
}
// Train the chooser: only the counter that was consulted
logic sc_pred_match = sc_upd_inp.sc_pred_meta.sc_pred_tkn
== sc_upd_inp.resolved_taken;
logic tg_pred_match = sc_upd_inp.sc_pred_meta.sc_tage_pred_tkn
== sc_upd_inp.resolved_taken;
if(sc_upd_inp.sc_pred_meta.sc_chooser == CHOOSE_HIGH) {
if(sc_pred_match) choose_hi_vlo = sat_ch(choose_hi_vlo,+1);
else if(tg_pred_match) choose_hi_vlo = sat_ch(choose_hi_vlo,-1);
} else if(sc_upd_inp.sc_pred_meta.sc_chooser == CHOOSE_MED) {
if(sc_pred_match) choose_med_vvlo = sat_ch(choose_med_vvlo, +1);
else if(tg_pred_match) choose_med_vvlo = sat_ch(choose_med_vvlo, -1);
}
11. SC Helper Functions¶
Documenting the helper functions used above.
signed [SC_TC_BITS-1:0] sat_tc(signed [SC_TC_BITS-1:0] curr_TC,int delta)
{
if(delta == 0) return curr_TC;
if(curr_TC == LCL_TC_MIN & delta < 0) return curr_TC;
if(curr_TC == LCL_TC_MAX & delta > 0) return curr_TC;
return curr_TC + delta;
}
unsigned [SC_THRSH_BITS-1:0] sat_thr(unsigned [SC_THRSH_BITS-1:0] curr_THR,
int delta)
{
if(delta == 0) return curr_THR;
if(curr_THR == SC_THRSH_MIN & delta < 0) return curr_THR;
if(curr_THR == SC_THRSH_MAX & delta > 0) return curr_THR;
return curr_THR + delta;
}
signed [SC_MAX_CTR_WIDTH-1:0] sat_sc(signed [SC_MAX_CTR_WIDTH-1:0] curr_CTR,
int delta)
{
if(delta == 0) return curr_CTR;
if(curr_CTR == SC_CTR_MIN & delta < 0) return curr_CTR;
if(curr_CTR == SC_CTR_MAX & delta > 0) return curr_CTR;
return curr_CTR + delta;
}
signed [SC_CHOOSER_BITS-1:0] sat_ch(signed [SC_CHOOSER_BITS-1:0] curr_CH,
int delta)
{
if(delta == 0) return curr_CH;
if(curr_CH == SC_CHOOSER_MIN & delta < 0) return curr_CH;
if(curr_CH == SC_CHOOSER_MAX & delta > 0) return curr_CH;
return curr_CH + delta;
}
12. BrIMLI Register and Semantics¶
BrIMLI Update¶
last_back_pc is a register, cleared on reset, that holds PC[15:6] of the
last backward conditional branch seen by the SC.
br_imli is the backwards branch counter, cleared on reset
bb_hist is the backwards branch path register, cleared on reset
sc_upd_inp.branch_range[9:0] is PC[15:6] of the branch being predicted/updated. It is formed by ftq_upd_conv at the update from the FTQ entry: the block PC plus the slot's position (BP-119; TD#89 closed without FTB storage, BP-133). This read "populated by the FTB or other external logic".
sc_upd_inp.branch_range is the BrIMLI region of the predicted branch.
sc_upd_inp.backwards_branch is a flag formed by ftq_upd_conv indicating the resolved taken target of this branch is less than the PC of the branch, i.e. it is a backward branch. The backend carries the taken target of a conditional whatever its direction (ftb_decisions.md 5.5), and the flag is read only on a taken resolution (TD#90 closed without FTB storage, BP-133).
logic [9:0] br_imli;
logic [10:0] last_back_pc; //bit [10] is the valid bit;
logic [9:0] bb_hist;
logic [9:0] branch_range = sc_upd_inp.branch_range;
logic is_backwards = sc_upd_inp.backwards_branch
// conditional branch is implied, sc only sees conditional branches
// and only receives updates for conditional branches
if (conditional branch)
{
if (sc_upd_inp.resolved_taken)
{
if (is_backwards) // backward branch
{
if (last_back_pc[10] && branch_range == last_back_pc[9:0] )
{
br_imli++; //this is a saturating add
}
else
{
bb_hist = (bb_hist << 1) ^ last_back_pc ^ branch_range;
br_imli = 0;
}
last_back_pc = {1'b1,branch_range};
}
}
}
BrIMLI index mode -- compile-time parameter¶
The BrIMLI index mode (type br_imli_mode_e) is a COMPILE-TIME MODULE
PARAMETER, not a runtime port. It selects the get_br_imli_idx fold
source -- IMLI-with-PHR-fallback, PHR-only, or IMLI-only -- for
performance evaluation. The mode is fixed for a run; there is no
runtime br_imli_mode signal anywhere in the SC.
-
The parameter is declared on
sc_brimli(ST4), the only module that consumes the mode.get_br_imli_idxreads it directly:parameter br_imli_mode_e BR_IMLI_MODE = IDX_IMLI_PHR
Default is `IDX_IMLI_PHR` (current behavior).
-
sc.svexposes a matching parameter and passes it to the ST4 instance so the mode can be set at elaboration from above without editingsc.sv:parameter br_imli_mode_e SC_BR_IMLI_MODE = IDX_IMLI_PHR ... sc_brimli #(.BR_IMLI_MODE(SC_BR_IMLI_MODE)) u_st4 ( ... );
`bp_cluster` sets `SC_BR_IMLI_MODE` at the `sc.sv` instantiation when a
non-default mode is wanted for a perf run.
-
sc_cntrldoes NOT carry the mode. It neither consumes nor routes it. The earlierbr_imli_modeinput andt_br_imli_modepassthrough ports onsc_cntrlare removed; likewise thebr_imli_modeport onsc_brimliand the top-levelbr_imli_modeport onsc.sv. -
The default is
IDX_IMLI_PHR, set on the module and propagated by parameter fromsc.svdown.
BrIMLI index calculation¶
// The mode argument below is bound to the sc_brimli BR_IMLI_MODE
// compile-time parameter (see "BrIMLI index mode" above); it is not a
// port. It is shown as a function argument here only for readability.
logic [9:0] get_br_imli_idx (input [9:0] pc,
input [9:0] phr,
input [9:0] br_imli,
input br_imli_mode_e mode = IDX_IMLI_PHR)
{
logic [9:0] f_idx;
case (mode)
// Case 1 - current behavior. IMLI when active, PHR when cold.
IDX_IMLI_PHR: f_idx = (br_imli == 0) ? phr : br_imli;
// Case 2 - PHR-only baseline. Same table, IMLI never used.
// This is the control: whatever this scores is the
// "free" PHR contribution with no IMLI involved.
IDX_PHR_ONLY: f_idx = phr;
// Case 3 - IMLI-only. No PHR substitution. When the counter is
// cold (0), f_idx contributes nothing and the index is a
// pure PC hash; only real IMLI streaks stir the index.
IDX_IMLI_ONLY: f_idx = br_imli;
default: f_idx = (br_imli == 0) ? phr : br_imli;
endcase
return pc ^ f_idx ^ (pc >> 4); // mask to table depth if < 1024 entries
}
<!--
This was the simple solution. I added the alternatives above. Pick the mode that supplies the best performance during perf eval
logic [9:0] get_br_imli_idx (input [9:0] pc,
input [9:0] phr,
input [9:0] br_imli)
{
logic [9:0] f_br_imli = br_imli == 0 ? phr : br_imli;
logic [9:0] br_imli_idx_hash = pc ^ f_br_imli ^ (pc >> 4);
return br_imli_idx_hash;
}
-->
13. Reset initialization¶
Details of the operation of the sram_init module are found in planning/arch/sram_init.md. What follows is discussion of its operation in the SC context.
Entries in the SC tables do not require a valid bit.
The entries in the RAMs are initialized on the rising edge of the active low
reset. On detection of this edge the sram_init module walks each entry in
the RAMs writing value SC_SRAM_INIT_VALUE to the entry. Note all RAMs are
accessed in parallel during this process. The sram_init module is
parameterized with the maximum number of entries across ST0-ST4 and the maximum
data width across each table.
This initialization process requires an control signal override scheme where,
when in ram initialization all table share the same address, input data and
write enable. When the sram_init module completes the RAM initialzation is
asserts the SC primary output sc_ready.
The SC control logic of the SC can assume that it will see no transactions
(other than RAM init transactions) until sc_ready is asserted.
For simulation purposes there is a fast initialization mode that uses an
initial statement and for loop to directly initialize each RAM entry
in zero time. Fast initialization is triggered through a command line
parameter. Each predictor has it's own fast init CLI parameters. For the
SC this is SC_FAST_INIT. The fast init block is placed in sc_table.sv.
This shows common semantics:
// Fast init: write bw_ram mem arrays at time zero via
// hierarchical reference. Active only when +SC_FAST_INIT=1.
// bw_ram mem is 2D: mem[BANKS][ENTRIES]. Loop covers both banks.
initial begin
int fast_init;
fast_init = 0;
void'($value$plusargs("SC_FAST_INIT=%d", fast_init));
if (fast_init != 0) begin
for (int b = 0; b < 2; b++) begin
for (int i = 0; i < RAM_ENTRIES; i++) begin
u_ram_s0.mem[b][i] =
ALLOC_DATA_WIDTH'(SC_SRAM_INIT_VALUE);
u_ram_s1.mem[b][i] =
ALLOC_DATA_WIDTH'(SC_SRAM_INIT_VALUE);
end
end
end
end
RAM_ENTRIES is a table instance specific module parameter derived from
the number of index bits or number of entries in this table instance.
14. Document History¶
2026-06-26 Session-056. Initial draft. Manually created then refined.
2026-06-28 Session-056. Completed draft, manually edited
2026-06-28 Session-057. PA edits: section renumber settled, manual edits
2026-07-01 Session-059. br_imli_mode specified as a compile-time module
parameter (sc_brimli BR_IMLI_MODE, propagated from sc.sv
SC_BR_IMLI_MODE); no runtime br_imli_mode port on sc_brimli,
sc_cntrl, or sc.sv. Section 12 subsection added; section 9
st4_index note added. Implemented by BP-079a.
2026-09-19 Session-071. Section 2: the slots share the threshold, TC,
chooser and BrIMLI registers (TD#98). Section 4: TAGE and
SC are not in lock step. Section 9: st4_index passes
inp_pc_p2[15:6]. Section 1: the document list records
the four SC documents written session-058, the entry
format document as dropped and the counter rules as
section 10.
2026-09-20 session-072. D5: the TAGE/SC stage text swept to
p-notation. D3: sram_init.sv path normalised;
bw_ram.sv marked unconfirmed.
2026-09-20 session-072. D3: bw_ram.sv path confirmed as
rtl/lib/rtl/bw_ram.sv.
2026-09-20 session-072. E13: the FIXME block giving sc_pred_meta as
an update-phase output removed; sc_upd_rdy_u1 is the
only update-phase output.
2026-09-20 session-072. D34: sram_init.sv is rtl/lib/rtl/, reverting
this pass's components/rtl/ change.
2026-10-12 session-079, recording BP-133. 12: branch_range and
backwards_branch are formed by ftq_upd_conv, not the FTB
(TD#89, TD#90 closed).
sc_table_hash_rules.md
planning/arch/sc_table_hash_rules.md on GitHub
SC Table Hash Rules¶
FILE: sc_table_hash_rules.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-10
CONTACT: Jeff Nye
Overview¶
This document defines the index hashing for the SC tables. There are two functions. sc_idx_hash indexes ST0-ST3 (sc_table). get_br_imli_idx indexes ST4 (sc_brimli).
SC tables have no tags. There is no tag hash.
The functions are prediction-path only. The update path uses the index captured at predict time in sc_pred_meta.sc_upd_idx, carried through sc_upd_inp, presented on upd_index_u0. No re-hash occurs on the update path (sc_decisions.md section 10).
All widths are in bp_defines_pkg.sv. That file is authoritative.
Parameter references¶
VA_WIDTH = 41 (bp_defines_pkg.sv; fe_decisions.md FE-19,
TD#122. This read 40. Session-071)
SC_TBL_IDX[0:4] = {9,9,9,9,10} (bp_defines_pkg.sv)
SC_MAX_IDX_WIDTH = 10 (bp_defines_pkg.sv)
SC_MAX_FH = 64 (bp_defines_pkg.sv)
The SC does not use PC_HASH_SHIFT (PD-17, BP-127). This list gave PC_HASH_SHIFT = 2. TAGE and ITTAGE keep it.
THIS_INDEX_BITS is the per-table index width, set at instantiation from SC_TBL_IDX[THIS_TABLE]. For ST0-ST3 it is 9. For ST4 it is 10.
THIS_TABLE is the per-table identifier, 0-4, set at instantiation.
sc_idx_hash (ST0-ST3, sc_table)¶
Inputs¶
inp_pc_p2[s] the staged prediction BLOCK START PC, [VA_WIDTH-1:1]
(sc_interfaces.md). The cluster drives every slot
from one staged copy (ftq_bpu_interfaces.md 3), so
both slots carry the same value; the slots are
separated by their own RAMs (sc_decisions.md 6).
This read "staged branch PC". Session-077.
fh_idx_ext the per-table index fold, [SC_MAX_FH-1:0], selected
by THIS_TABLE.
fh_idx_ext selection by THIS_TABLE:
case (THIS_TABLE)
0: fh_idx_ext = 0;
1: fh_idx_ext = sc_t1_idx_fh_p2;
2: fh_idx_ext = sc_t2_idx_fh_p2;
3: fh_idx_ext = sc_t3_idx_fh_p2;
default: assert; // sc_table instantiated only for THIS_TABLE 0-3
endcase
ST0 uses fh_idx_ext=0. SC_TBL_FH[0]=0; ST0 is an unhashed PC slice (sc_decisions.md section 9).
ST4 is not indexed by this function. sc_brimli uses get_br_imli_idx. The default arm is unreachable by construction; the assert is defensive.
Function¶
logic [THIS_INDEX_BITS-1:0] hashed_index =
THIS_INDEX_BITS'(inp_pc_p2[s] ^ fh_idx_ext);
The index drops only the instruction offset. With the C extension that is PC[0], and inp_pc_p2 already starts at PC[1], so the PC is not shifted: for a 9-bit index the PC term is PC[9:1]. ST0 is that slice alone. The PC is XORed with the fold and the result truncated to THIS_INDEX_BITS by the cast.
RULED session-077 (Jeff, PD-17): the prose of this section stands over its formula. The formula read THIS_INDEX_BITS'((inp_pc_p2[s] >> PC_HASH_SHIFT) ^ fh_idx_ext) with PC_HASH_SHIFT = 2, which on a PC that already starts at PC[1] dropped PC[2:1] and started the index at PC[3]. The nine PC bits move from PC[11:3] to PC[9:1]: blocks whose starts differ in bits 2:1 no longer share entries, and ST0 aliases blocks 1 KiB apart where it aliased 4 KiB apart. BUILT by BP-127.
MEASURED by BP-127 on tb_fe_top: 6 of 36 programs change, every one retiring exactly. Mispredicts: hist 27 -> 22, lp 10 -> 8, misp_call 23 -> 22, ftbonly 10 -> 11, multistart 6 -> 7, recur 28 -> 28. hist and lp gain from blocks no longer sharing on bits 2:1; ftbonly, whose copies sit 2 KiB apart, now shares ST0 entries in groups of up to 9 through the 1 KiB alias.
get_br_imli_idx (ST4, sc_brimli)¶
Inputs¶
pc [9:0] PC[15:6] of the branch (sc_decisions.md section 12).
phr [9:0] low 10 bits of path history, sc_phr_p2
(sc_interfaces.md).
br_imli [9:0] BrIMLI counter, held in sc_cntrl, presented to
sc_brimli as an input (sc_decisions.md sections
8, 12).
mode br_imli_mode_e, BR_IMLI_MODE compile-time module
parameter on sc_brimli (default IDX_IMLI_PHR),
propagated from sc.sv SC_BR_IMLI_MODE
(sc_decisions.md section 12, BP-079,
session-059). Not a runtime port.
The pc argument is PC[15:6]. sc_decisions.md section 12 declares the argument as [9:0] and defines last_back_pc and branch_range as PC[15:6]; the [9:0] argument is those 10 bits.
Function¶
logic [9:0] get_br_imli_idx (input [9:0] pc,
input [9:0] phr,
input [9:0] br_imli,
input br_imli_mode_e mode = IDX_IMLI_PHR)
{
logic [9:0] f_idx;
case (mode)
IDX_IMLI_PHR: f_idx = (br_imli == 0) ? phr : br_imli;
IDX_PHR_ONLY: f_idx = phr;
IDX_IMLI_ONLY: f_idx = br_imli;
default: f_idx = (br_imli == 0) ? phr : br_imli;
endcase
return pc ^ f_idx ^ (pc >> 4);
}
Mode semantics (sc_decisions.md section 12, bp_structs_pkg.sv br_imli_mode_e):
IDX_IMLI_PHR (2'b00) IMLI when active, PHR when br_imli cold (==0).
IDX_PHR_ONLY (2'b01) PHR always; IMLI never used.
IDX_IMLI_ONLY (2'b10) IMLI always; no PHR substitution.
IDX_IMLI_RSRV (2'b11) not used.
The mode is a perf-evaluation selector, fixed at elaboration time via the BR_IMLI_MODE parameter (sc_brimli), set from sc.sv's SC_BR_IMLI_MODE parameter. bp_cluster sets SC_BR_IMLI_MODE at the sc.sv instantiation for a non-default perf build (sc_decisions.md section 12, BP-079). Not a runtime input; see sc_table_interfaces.md.
Update-path index¶
No hash on update. upd_index_u0[s] carries the predict-time index from sc_pred_meta.sc_upd_idx[THIS_TABLE] (sc_decisions.md section 10, sc_table_interfaces.md).
sc_interfaces.md
planning/interfaces/sc_interfaces.md on GitHub
SC Interface Specification¶
FILE: sc_interfaces.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-15
CONTACT: Jeff Nye
Overview¶
SC is the Seznec-style Statistical Corrector. It refines the TAGE direction prediction for conditional branches by summing signed confidence counters read from five tables and comparing the sum magnitude against a dynamically adapted threshold. SC fires at p3, one stage after TAGE p2, and overrides TAGE direction when the override-corner logic selects the SC result.
Five tables ST0-ST4. ST0-ST3 hold confidence counters. ST4 is the BrIMLI table. ST0 is indexed by a PC slice with no hash. ST1-ST3 are indexed by PC hashed with a per-table folded history. ST4 is indexed by the BrIMLI index function. Each table contains two RAMs, one per prediction slot (TI6 convention).
Pipeline: p2 is the start of the SC prediction path (TAGE p2 output and staged p0 inputs presented), p3 is the SC result. Update path is u0/u1.
All types defined in bp_defines_pkg.sv and bp_structs_pkg.sv. This document describes port semantics, timing contracts, and consumer/producer obligations. It does not restate struct field layouts -- see bp_structs_pkg.sv. It does not restate parameter values -- see bp_defines_pkg.sv.
Port Naming Convention¶
Signal names follow the pattern:
<signal>_<pipestage>
- `pipestage` : p2, p3 for the prediction path.
u0, u1 for the update path.
There is no px stage. No flush event exists; a
flush is a redirect (fe_decisions.md FE-14).
See IC-SC-06.
Stage notation is p0/p1/p2/p3 for prediction and u0/u1 for update, in every document and in the RTL (PROJECT_CORE.md, Interface specification approach; fe_decisions.md 12). This document carried a local rule that planning narrative uses s0/s1/s2/s3; PROJECT_CORE supersedes it. Session-072.
Slot dimension uses vector index [0:NUM_PRED_SLOTS-1]. clk and rstn carry no pipe stage suffix.
Module Parameters¶
Parameters for SC are found in section :SC parameters: of rtl/core/frontend/bpu/rtl/bp_defines_pkg.sv. Arbitration parameters (SC_UQ_DEPTH, SC_UQ_WR_PORTS, SC_RESP_BUF_DEPTH, SC_PRED_CREDITS, SC_UPD_CREDITS, SC_STARVE_THRESH) are in the same file. Do not copy values into this document.
Port List¶
// clock and reset
input logic clk
input logic rstn
// prediction interface -- TAGE response (p2 in)
input logic [NUM_PRED_SLOTS-1:0] tage_pred_rdy_p2
input tage_pred_meta_t tage_pred_meta_p2[0:NUM_PRED_SLOTS-1]
// prediction interface -- staged p0 inputs presented at p2
input logic [VA_WIDTH-1:1] inp_pc_p2[0:NUM_PRED_SLOTS-1]
input logic [9:0] sc_phr_p2
input logic [SC_MAX_FH-1:0] sc_t1_idx_fh_p2
input logic [SC_MAX_FH-1:0] sc_t2_idx_fh_p2
input logic [SC_MAX_FH-1:0] sc_t3_idx_fh_p2
// prediction interface -- SC result (p3 out)
output logic [NUM_PRED_SLOTS-1:0] sc_pred_rdy_p3
output sc_pred_meta_t sc_pred_meta_p3[0:NUM_PRED_SLOTS-1]
// update interface
input logic [NUM_PRED_SLOTS-1:0] sc_upd_val_u0
input sc_upd_inp_t sc_upd_inp_u0[0:NUM_PRED_SLOTS-1]
output logic [NUM_PRED_SLOTS-1:0] sc_upd_rdy_u1
// arbitration status outputs, and the SC UQ's arbiter handshake
output logic sc_uq_not_full
output logic [NUM_PRED_SLOTS-1:0] sc_upd_rdy
output logic sc_uq_has_data
input logic sc_uq_rd_en
// CSR enable
input logic sc_enable
// ram init interface
output logic sc_ready
Struct Definitions¶
All structs defined in bp_structs_pkg.sv.
tage_pred_meta_t¶
TAGE prediction output. SC consumes the fields tage_pred_strong, tage_pred_medium, tage_pred_tkn, tage_extd_ctr (sc_decisions.md section 9). SC does not consume the remaining fields. See bp_structs_pkg.sv for the authoritative definition.
sc_pred_meta_t¶
SC prediction output and metadata. Carries the SC sum and its magnitude, the SC-local and final directions, the TAGE direction copy, the override flag, the chooser corner, and the per-table index and counter snapshots consumed by the update path. See bp_structs_pkg.sv for the authoritative definition.
sc_upd_inp_t¶
Update input bundle. Carries the sc_pred_meta_t captured at predict time, the resolved direction, the mispredict flag, and the backwards_branch flag and branch_range PC slice used for BrIMLI maintenance, formed by ftq_upd_conv (BP-119; TD#89, TD#90 closed by BP-133). This read "the FTB-supplied backwards_branch flag". See bp_structs_pkg.sv for the authoritative definition.
Prediction Interface¶
Producer: TAGE response buffer (meta), fetch staging (pc/phr/folds)¶
Consumer: BP cluster (override control, p3 redirect, FTQ write)¶
Timing¶
p2: TAGE prediction meta is presented on tage_pred_meta_p2[s] with
tage_pred_rdy_p2[s]. The staged p0 inputs inp_pc_p2[s],
sc_phr_p2, sc_t1_idx_fh_p2, sc_t2_idx_fh_p2, sc_t3_idx_fh_p2
are presented at p2. SC table index hashes are computed at p2.
SC table RAM reads issue at p2.
p3: sc_pred_meta_p3[s] and sc_pred_rdy_p3[s] are valid.
SC begins at p2. The one-cycle SC operation produces the result at p3 (sc_decisions.md section 2).
Staged input derivation¶
The staged p2 inputs are derived from p0/p1 signals and held two cycles (bp_arb_spec.md section 6.1):
inp_pc_p2[s] <- tage_pred_inp_p0[s].pc (p0 -> p2)
sc_phr_p2 <- folded_hist.tage_phr[9:0] (p0 -> p2)
sc_t1_idx_fh_p2 <- folded_hist.sc_t1_idx_fh (p0 -> p2)
sc_t2_idx_fh_p2 <- folded_hist.sc_t2_idx_fh (p0 -> p2)
sc_t3_idx_fh_p2 <- folded_hist.sc_t3_idx_fh (p0 -> p2)
The staging logic lives in the BP cluster, not in SC. SC receives the p2 versions as ports.
Table index inputs¶
ST0 index: sc_idx_hash(inp_pc_p2, SC_TBL_FH[0], 0)
SC_TBL_FH[0] = 0. ST0 is a PC slice, no fold.
ST1 index: sc_idx_hash(inp_pc_p2, SC_TBL_FH[1], sc_t1_idx_fh_p2)
ST2 index: sc_idx_hash(inp_pc_p2, SC_TBL_FH[2], sc_t2_idx_fh_p2)
ST3 index: sc_idx_hash(inp_pc_p2, SC_TBL_FH[3], sc_t3_idx_fh_p2)
ST4 index: get_br_imli_idx(inp_pc_p2[15:6], sc_phr_p2, br_imli)
sc_idx_hash and get_br_imli_idx are defined in sc_table_hash_rules.md (written session-058). ST4 takes PC[15:6] (inp_pc_p2[15:6]).
Semantics¶
tage_pred_rdy_p2[s] = 1 -- tage_pred_meta_p2[s] valid. SC processes
slot s and produces sc_pred_meta_p3[s].
tage_pred_rdy_p2[s] = 0 -- no TAGE result for slot s.
sc_pred_rdy_p3[s] = 0.
sc_pred_rdy_p3[s] = 1 -- sc_pred_meta_p3[s] valid.
Both slots may be valid in the same cycle. Slots predict in parallel from separate table RAMs, but share the threshold, TC, chooser and BrIMLI registers in sc_cntrl, whose adaptation the lowest-indexed valid update slot drives (sc_decisions.md section 2, TD#98). This read "with no cross-slot interaction". Session-071.
SC prediction requires TAGE output. SC updates proceed without TAGE input (sc_decisions.md section 2).
Override¶
The final direction sc_pred_meta_p3[s].sc_pred_tkn is the post- override result. sc_pred_meta_p3[s].sc_override indicates SC reversed the TAGE direction. The chooser corner is sc_pred_meta_p3[s]. sc_chooser. Override selection logic is in sc_decisions.md section 9.
CSR enable¶
sc_enable gates SC participation (bp_arb_spec.md section 0). When deasserted, the BP cluster does not wait for SC responses and issues no SC updates. FTB buffering of SC-related signals continues. The enable is a cluster-level gate on SC consumption; the SC module itself is not required to internally qualify on sc_enable unless the implementing task specifies it. Marked IC-SC-05.
Consumer obligations¶
- Must not consume sc_pred_meta_p3[s] when sc_pred_rdy_p3[s]=0.
- Must set pred_src in bp_ftq_entry_t to PRED_SC when SC overrides TAGE direction (sc_pred_meta_p3[s].sc_override=1).
- Must apply the SC direction over the TAGE direction for a COND branch when sc_override is set, unless ftb_fastpath_p2 is asserted for that branch, in which case the FTB direction stands and no SC override is applied (ftb_confidence_override_rules.md 4.2). The direction priority is SC > TAGE > FTB, 4.3 of the same document. SINCE BP-122 SC DOES NOT OVERRIDE A TRUSTED LOOP PREDICTION: the LP's p2 direction stands at p3 (fe_decisions.md 3.3, ruled).
- Must assert p3 redirect when sc_pred_rdy_p3[s]=1 and the resulting successor differs from the one the cluster's own p2 stage registers hold for that block -- that is, ONLY WHEN SC CHANGES WHAT THE CLUSTER PUBLISHED AT p2 (fe_decisions.md 3.1). THE REDIRECT CONDITION IS NOT THE OVERRIDE: an override that does not change the successor fires nothing, and the comparison is one quantity against the cluster's own staged view, never predictor against predictor and never against the FTQ (fe_decisions.md FE-4, ftq_bpu_interfaces.md 6). An earlier revision gave the condition as "the FTQ-held direction". Corrected session-070.
- Must write sc_pred_meta_p3[s] into the FTQ meta path; the update path requires the captured indices and counters unconditionally.
SC simulation support¶
- SC_FAST_INIT: runtime plusarg (+SC_FAST_INIT=1). Fast init block in sc_table.sv writes bw_ram mem arrays via hierarchical reference at time zero, both banks, both slot RAMs. When set, sram_init is bypassed and sc_ready asserts immediately. When not set, sram_init sequences all entries and sc_ready follows its ready output. Simulation-only. See sc_decisions.md section 13.
- SC_SRAM_INIT_VALUE: localparam int in bp_defines_pkg.sv, default 0.
Update Interface¶
Producer: post-execute resolution path (BP cluster)¶
Consumer: SC¶
Timing¶
u0: sc_upd_inp_u0[s] presented with sc_upd_val_u0[s]. Sampled on
rising clk edge.
u1: sc_upd_rdy_u1[s] asserted when the update has been applied.
Update completes in one cycle. Both slot channels process independently in the same cycle.
Semantics¶
sc_upd_val_u0[s] = 0 -- no update this cycle for slot s.
sc_upd_inp_u0[s] ignored.
sc_upd_val_u0[s] = 1 -- resolved update for slot s. All
sc_upd_inp_u0[s] fields valid.
sc_upd_rdy_u1[s] = 1 -- update applied for slot s.
sc_uq_not_full -- asserted when the SC update queue has room.
Consumer must gate sc_upd_val_u0 on this
signal.
sc_upd_rdy[s] -- the UQ has room and sc_ready is set. The
same value on every slot. An update is
accepted when presented with sc_upd_rdy set;
the producer holds it otherwise (FE-5).
sc_uq_has_data -- the UQ is non-empty or an update is
presented to it. The arbiter's SC update
request.
sc_uq_rd_en -- the arbiter's SC update grant. Pops the UQ
head into sc_cntrl, or passes the presented
update through when the UQ is empty
(bp_arb_spec.md 4.4 bypass).
The four signals above are as BP-126 built them (TD#123, P-3, confirmed session-077). sc_uq_has_data and sc_uq_rd_en are new.
Update behavior¶
The update path reads the captured sc_pred_meta from sc_upd_inp, applies the counter-update gate (SC-wrong OR sum below threshold), steps the consulted counters toward the resolved direction, adapts the threshold via the TC counter, and trains the chooser corners. The definitive operation is in sc_decisions.md section 10.
BrIMLI register maintenance (br_imli, bb_hist, last_back_pc) uses sc_upd_inp.branch_range and sc_upd_inp.backwards_branch. See sc_decisions.md section 12.
Read-during-write contract¶
Prediction and update paths are mutually exclusive by design. Prediction is RAM read only. Update is RAM write only. No read- modify-write is required (sc_decisions.md section 4). The prediction-phase counter snapshots captured in sc_pred_meta supply the update path; the update does not re-read the tables.
Producer obligations¶
- Must provide resolved_taken from execute, not speculative.
- Must pass the sc_pred_meta_t captured at predict time unmodified into sc_upd_inp_u0[s].
- Must supply branch_range (branch PC 15:6) and backwards_branch (taken target below the branch PC) per sc_upd_inp_t; ftq_upd_conv forms both from the FTQ entry and the resolution (BP-133). This read "from FTB (or other external logic)".
Arbitration Model¶
SC tables are single-port RAMs. SC prediction (read, p2->p3) and SC update (write, u0/u1) compete for the one RAM port. The bp_arb_spec.md section 4.5 arbiter governs that contention: a prediction is never delayed, and an update is granted only with no block at p2 that TAGE answers. It was a credit arbiter until BP-121.
SC has no independent prediction FIFO. The TAGE response buffer (TAGE_RESP_BUF_DEPTH) is SC's prediction-side storage and acts as SC's PQ for arbitration (bp_arb_spec.md sections 5.5, 6). SC's prediction rate is gated by TAGE's.
SC has a separate update queue, entry type sc_upd_inp_t. TAGE and SC UQs are separate. A single resolved conditional branch enqueues one TAGE UQ entry and one SC UQ entry at post-execute resolution, not commit (fe_decisions.md FE-6 and section 12; this read "commit", session-071); each entry covers both slots (bp_arb_spec.md section 6.2).
THE UQ IS BUILT in sc.sv by BP-126 (TD#123): SC_UQ_DEPTH entries, each one update cycle of both slots (SC_UQ_WR_PORTS slot writes), with the handshake of Update Interface above. The arbiter is in bp_cluster (bp_arb_spec.md 4.5; group H, rewritten by BP-121, H4 and H8 by BP-126). At the cluster, sc_uq_not_full is the UQ's room with the one-cycle starvation hold (BP-121 D6), and sc_upd_rdy is the UQ's room and sc_enable. This read that sc.sv built no UQ and tied sc_uq_not_full to 1'b1 and sc_upd_rdy to all-ones, the TD#123 gap. Session-077.
When the SC arbiter grants an update and stalls a prediction, the TAGE response buffer head is held, backpressuring TAGE (bp_arb_spec.md section 11 item C). SINCE BP-121 THAT CASE DOES NOT ARISE: an update is granted only when no prediction is presented.
RAM Init Interface¶
Output sc_ready indicates the RAM initialization cycles have completed. It ties to the ready output of the sram_init module.
No prediction or update cycles begin before sc_ready is asserted. SC ignores prediction requests when sc_ready is deasserted. An update presented before sc_ready is refused (sc_upd_rdy low) and held by the producer, since BP-126; this read that SC ignores update requests too. Upstream logic must comprehend this condition. The upstream logic is the FTQ, which holds its p0 request until tage_rdy, ittage_rdy and sc_ready are all high (ftq_decisions.md 4.5 H5, BP-137). See sc_decisions.md section 13.
SC Table Interface¶
The SC-to-sc_table port list and per-table semantics are in sc_table_interfaces.md (written session-058).
Override Chain Position¶
SC is the last stage in the conditional-direction path:
uBTB (p1) -> FTB, TAGE (p2) -> SC (p3)
ON DIRECTION this IS a ranking: SC > TAGE > FTB, all three produce that one quantity, with a trusted loop prediction above all three since BP-122 (fe_decisions.md 3.3), suspended per branch when the FTB fast path fires (ftb_confidence_override_rules.md 4.3, 4.2). ON EVERYTHING ELSE it is stage order, not a ranking: a later stage supersedes an earlier one (fe_decisions.md FE-3 and section 12, narrowed session-070), and targets are selected by branch type.
Stage assignment:
p1: uBTB + Loop
p2: FTB + TAGE + ITTAGE + RAS
p3: SC
SC overrides TAGE direction at p3 for conditional branches. SC does not participate in target selection; FTB provides the target for conditional branches.
Known Gaps and Deferred Items¶
| ID | Item | Status |
|---|---|---|
| IC-SC-01 | sc_idx_hash. Referenced by ST0-ST3 |
CLOSED. |
| index. Defined in | Written | |
sc_table_hash_rules.md. |
session-058. | |
| IC-SC-02 | get_br_imli_idx. Referenced by ST4 |
CLOSED. |
| index. Defined in | Written | |
sc_table_hash_rules.md. |
session-058. | |
| IC-SC-03 | ST4 PC width. get_br_imli_idx pc input |
RESOLVED |
is inp_pc_p2[15:6] (PC[15:6]), the |
session-058. | |
| BrIMLI region. Confirm in | ||
sc_table_hash_rules.md when written. |
||
| IC-SC-04 | sc_table port list and per-table |
CLOSED. |
semantics. In sc_table_interfaces.md. |
Written | |
| session-058. | ||
| IC-SC-05 | sc_enable qualification point. Cluster- |
TBD at impl. |
level gate defined (bp_arb_spec.md |
||
| section 0). Whether the SC module | ||
internally qualifies on sc_enable is |
||
| left to the implementing task. | ||
| IC-SC-06 | Flush port definitions (_px signals). |
CLOSED BP-105. |
| NO FLUSH EVENT EXISTS: a flush is a | fe_decisions | |
| redirect. sc needs no flush port and | FE-14. | |
| none is added. |
Document History¶
2026-09-17 Session-070 audit. First history section in this file;
earlier changes are recorded only in PROJECT_STATUS.
Arbitration Model: the description of sc.sv was
correct and is kept -- the UQ is not built and
sc_uq_not_full / sc_upd_rdy are tied off. The
citation was not. TD#73 and TD#94 are both closed,
and the credit arbiter is implemented and tested in
bp_cluster (TD#73 closed by BP-094 group H, covering
all seven bp_arb_spec 4.5 grant rules). Reworded to
separate the two facts. The unit-level gap is now
raised as TD#123.
sc_table_hash_rules.md and sc_table_interfaces.md
were both called "not yet written". Both were
written in session-058. Corrected at both prose
sites; IC-SC-01, IC-SC-02 and IC-SC-04 closed.
Port Naming Convention described px as "not yet
defined" while IC-SC-06 in this same file records
BP-105: no flush event exists, a flush is a redirect
(FE-14), no flush port is added. Corrected.
Override Chain Position carried "SC > TAGE > FTB >
uBTB" with s1/s2/s3 labels, in a document whose Port
Naming Convention states it uses p-naming. Restated
as stage order per FE-3 with p-labels. The stage
assignment itself was already correct, including
ITTAGE at p2.
2026-09-19 session-071. Arbitration Model: the UQ producer is
post-execute resolution, not commit, per FE-6; the
sentence was carried from bp_arb_spec.md 6.2, which
now carries the same note.
2026-10-08 session-076, PA-direct correction recording BP-121.
Arbitration Model: the credit arbiter replaced
(bp_arb_spec.md 4.5, decision 5); the starvation hold
on sc_uq_not_full at the cluster.
2026-10-10 session-077, after BP-126. Port List and Update
Interface: sc_uq_has_data and sc_uq_rd_en; the UQ's
readies (TD#123, P-3). Arbitration Model: the UQ
built. RAM Init Interface: an update before sc_ready
is refused and held.
2026-10-12 session-079, recording BP-133. sc_upd_inp_t and
Producer obligations: branch_range and backwards_branch
come from ftq_upd_conv, not the FTB (TD#89, TD#90).
2026-10-15 session-080, after BP-137. RAM Init Interface: the FTQ
is the upstream logic.
sc_table_interfaces.md
planning/interfaces/sc_table_interfaces.md on GitHub
SC Table Interface Specification¶
FILE: sc_table_interfaces.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-10
CONTACT: Jeff Nye
Overview¶
The SC prediction tables hold signed confidence counters. The counters are read in parallel during prediction and summed in sc_cntrl. During update the consulted counter in each table is stepped toward the resolved direction. There is no allocation and no tag compare.
There are two phases, prediction request and update request. The phases do not overlap (sc_decisions.md section 4).
SC supports dual prediction. Each table module contains two bw_ram instances, one per prediction slot (RAM0 for slot 0, RAM1 for slot 1). Each prediction slot operates independently. All signals indexed [s] target the per-slot RAM exclusively.
Table description¶
There are SC_NUM_TABLES tables. The current version has 5 tables, ST0-ST4.
There are two table module types.
sc_table implements ST0-ST3. The file is rtl/core/frontend/bpu/rtl/sc_table.sv. sc_brimli implements ST4. The file is rtl/core/frontend/bpu/rtl/sc_brimli.sv.
These read frontend/branch_predictor/rtl/, which is not the tree (PROJECT_CORE.md, package paths). Session-072.
sc_brimli is a separate module to simplify specialization and instantiation in sc.sv. The two modules may be combined in a future revision.
An SC table entry is a single signed confidence counter of width SC_TBL_CTR (6b). SC entries have no tag, no USE field, no EPC field, and no valid bit (SC_TBL_TAG, SC_TBL_USE, SC_TBL_EPC all 0, and SC_MAX_VAL_WIDTH=0 in bp_defines_pkg.sv).
The definitive specification of the field widths is in bp_defines_pkg.sv.
Index difference between the two module types:
sc_table (ST0-ST3) derives its index from the PC and a folded history. ST0 uses SC_TBL_FH[0]=0 and takes a PC slice without a fold. ST1-ST3 hash the PC with the per-table fold.
sc_brimli (ST4) derives its index from the BrIMLI index function get_br_imli_idx over PC[15:6], sc_phr_p2, and br_imli.
Bank Address Assignment¶
Each sc_table and sc_brimli instance contains two bw_ram instances, one per prediction slot. Each bw_ram is instantiated with BANKS=2.
The bank_addr port of each bw_ram is derived from the MSB of the index. The row address is the remaining lower bits. For a THIS_INDEX_BITS-wide index:
bank_addr = index[THIS_INDEX_BITS-1]
row_addr = index[THIS_INDEX_BITS-2:0]
This decomposition applies to prediction reads, update writes, and the tbl_ri initialization path. It is identical for sc_table and sc_brimli.
sc_table (ST0-ST3): SC_TBL_IDX=9, SC_TBL_ENTRIES=512.
bank_addr = index[8], row_addr = index[7:0]. 256 rows/bank.
sc_brimli (ST4): SC_TBL_IDX[4]=10, SC_TBL_ENTRIES[4]=1024.
bank_addr = index[9], row_addr = index[8:0]. 512 rows/bank.
Table Pipeline¶
The prediction phase uses pipestages p2, p3. Table index inputs are presented at p2. The bw_ram read latency is one cycle; ctr_p3 is the flopped read output, available at p3. p3 is the SC result-formation stage in sc_cntrl.
The update phase uses pipestages u0, u1. Table inputs are presented at u0. SRAM write occurs at u1.
Port Naming Convention¶
Signal names follow the pattern:
<signal>_<pipestage>
- `pipestage` : p2 for the index inputs, p3 for the counter output.
u0, u1 for the update path. There is no px stage
and no flush signal: a flush is a redirect
(IC-SCT-03, fe_decisions.md FE-14). This read "px
for flush-related signals (not yet defined)".
Session-071.
Slot dimension uses vector index [0:NUM_PRED_SLOTS-1]. clk and rstn carry no pipe stage suffix.
The ports are not identical between the two table types. They are listed below.
Parameters Types and Structs¶
All types defined in bp_defines_pkg.sv and bp_structs_pkg.sv. This document describes port semantics, timing contracts, and consumer/producer obligations. It does not restate struct field layouts -- see bp_structs_pkg.sv. It does not restate parameter values -- see bp_defines_pkg.sv.
Top Level Parameters¶
These parameters are defined in bp_defines_pkg.sv. They define the limits; they are not table specific.
NUM_PRED_SLOTS : int
SC_MAX_IDX_WIDTH : int
SC_MAX_CTR_WIDTH : int
SC_MAX_FH : int
Top level module parameters are vectored. The vector positions are aligned with the assumption that tables are instantiated in a generate loop and the loop index selects the parameter for that table.
Table specific vectored parameters (values in bp_defines_pkg.sv):
SC_TBL_BANKS[0:4] : int not currently used.
SC_TBL_ENTRIES[0:4] : int entries per bw_ram instance.
SC_TBL_FH[0:4] : int index fold width. ST0=0 (no fold).
ST4 unused (BrIMLI index).
SC_TBL_HIST[0:4] : int history bit count. Duplicate of SC_TBL_FH.
SC_TBL_TAG[0:4] : int tag width. 0 for all SC tables.
SC_TBL_CTR[0:4] : int counter width.
SC_TBL_USE[0:4] : int USE width. 0 for all SC tables.
SC_TBL_EPC[0:4] : int EPC width. 0 for all SC tables.
SC_TBL_IDX[0:4] : int index bus width.
Derived Parameters¶
CNTRL_BITS_WIDTH = SC_TBL_CTR (6b). The SC entry is the counter only.
ALLOC_DATA_WIDTH = CNTRL_BITS_WIDTH. No tag, no separate alloc field.
Internal Module Parameters¶
Internally a table uses the THIS_ nomenclature to specialize the top level parameters for use in the module. These are set at instantiation.
THIS_TABLE : int which table, ST0-ST4.
THIS_INDEX_BITS : int local width of the index bus.
THIS_CTR_WIDTH : int local width of the CTR field.
THIS_ENTRIES : int local bw_ram entry count.
THIS_FH : int local index fold width (sc_table only).
Port Lists¶
There are two prediction slots, 0 and 1, referenced by vector index [0:NUM_PRED_SLOTS-1]. The two slots are independent.
sc_table Port List (ST0-ST3)¶
sc_table prediction ports¶
output logic [THIS_CTR_WIDTH-1:0]
ctr_p3[0:NUM_PRED_SLOTS-1]
output logic [THIS_INDEX_BITS-1:0]
idx_hash_p2[0:NUM_PRED_SLOTS-1]
input logic [NUM_PRED_SLOTS-1:0] sc_pred_val_p2
input logic [VA_WIDTH-1:1] inp_pc_p2[0:NUM_PRED_SLOTS-1]
input logic [SC_MAX_FH-1:0] idx_fh_p2
sc_table update ports¶
input logic [NUM_PRED_SLOTS-1:0] sc_upd_val_u0
input logic [THIS_CTR_WIDTH-1:0] ctr_wd_u0[0:NUM_PRED_SLOTS-1]
input logic [NUM_PRED_SLOTS-1:0] ctr_wr_u0
input logic [THIS_INDEX_BITS-1:0] upd_index_u0[0:NUM_PRED_SLOTS-1]
sc_table misc ports¶
input logic tbl_ri_active
input logic tbl_ri_wr
input logic [THIS_INDEX_BITS-1:0] tbl_ri_wa
input logic [ALLOC_DATA_WIDTH-1:0] tbl_ri_wd
input logic rstn
input logic clk
sc_brimli Port List (ST4)¶
sc_brimli prediction ports¶
output logic [THIS_CTR_WIDTH-1:0]
ctr_p3[0:NUM_PRED_SLOTS-1]
output logic [THIS_INDEX_BITS-1:0]
idx_hash_p2[0:NUM_PRED_SLOTS-1]
input logic [NUM_PRED_SLOTS-1:0] sc_pred_val_p2
input logic [VA_WIDTH-1:1] inp_pc_p2[0:NUM_PRED_SLOTS-1]
input logic [9:0] sc_phr_p2
input logic [9:0] br_imli
sc_brimli update ports¶
input logic [NUM_PRED_SLOTS-1:0] sc_upd_val_u0
input logic [THIS_CTR_WIDTH-1:0] ctr_wd_u0[0:NUM_PRED_SLOTS-1]
input logic [NUM_PRED_SLOTS-1:0] ctr_wr_u0
input logic [THIS_INDEX_BITS-1:0] upd_index_u0[0:NUM_PRED_SLOTS-1]
sc_brimli misc ports¶
input logic tbl_ri_active
input logic tbl_ri_wr
input logic [THIS_INDEX_BITS-1:0] tbl_ri_wa
input logic [ALLOC_DATA_WIDTH-1:0] tbl_ri_wd
input logic rstn
input logic clk
Misc Interface¶
Semantics¶
The tbl_ri ports are not driven by sc_cntrl. They are driven by an SRAM initialization module instantiated in sc.sv. The init module is rtl/lib/rtl/sram_init.sv. The scheme is identical to tage (tage_table_interfaces.md Misc Interface).
tbl_ri_active ram initialization is active.
tbl_ri_wr ram write signal. Converted to an active-low bit
write and a global select. When tbl_ri_active is
asserted, tbl_ri_wr overrides all other write
signals. No case exists where tbl_ri_wr and the
other write signals are asserted together.
tbl_ri_wa ram address. When tbl_ri_active is asserted,
overrides all other ram address signals. Sized to
THIS_INDEX_BITS.
tbl_ri_wd ram write data. When tbl_ri_active is asserted,
overrides all other ram data inputs. Init value is
SC_SRAM_INIT_VALUE (sc_decisions.md section 13).
Prediction Interface¶
sc_table Semantics (ST0-ST3)¶
sc_pred_val_p2[s] enables the bw_ram read for slot s. Produced by
sc top level.
inp_pc_p2[s] staged prediction block start PC, the same on
every slot (this read "staged branch PC";
session-077). Used locally to
derive the index hash via sc_idx_hash
(sc_table_hash_rules.md). Produced by the BP
cluster staging path (sc_interfaces.md).
idx_fh_p2 the per-table index fold, staged to p2. For ST0
this port is tied to constant zero at the ST0
instance in sc.sv (SC_TBL_FH[0]=0, PC slice only);
port presence cannot be parameterized away in
SystemVerilog. For ST1-ST3 this is
sc_t1_idx_fh_p2 / sc_t2_idx_fh_p2 /
sc_t3_idx_fh_p2 selected at instantiation.
Produced by the BP cluster staging path.
ctr_p3[s] the signed counter read from the entry. Raw
SC_TBL_CTR-wide value. sc_cntrl performs the
signed read and sum (sc_decisions.md section 9).
idx_hash_p2[s] the index computed at p2 from inp_pc_p2 and
idx_fh_p2. One value per slot. Consumed by
sc_cntrl to populate sc_upd_idx in the prediction
meta. Rules in sc_table_hash_rules.md.
sc_brimli Semantics (ST4)¶
sc_pred_val_p2[s] enables the bw_ram read for slot s. Produced by
sc top level.
inp_pc_p2[s] staged prediction block start PC, the same on
every slot. sc_brimli uses
inp_pc_p2[s][15:6] as the get_br_imli_idx PC
input (sc_decisions.md section 12). Produced by
the BP cluster staging path.
sc_phr_p2 low 10 bits of the path history, staged to p2.
get_br_imli_idx PHR input. Produced by the BP
cluster staging path.
br_imli the BrIMLI counter. Held in sc_cntrl
(sc_decisions.md sections 8, 12), presented to
sc_brimli as an input. get_br_imli_idx IMLI
input.
ctr_p3[s] the signed counter read from the entry. Raw
SC_TBL_CTR-wide value.
idx_hash_p2[s] the index computed at p2 via get_br_imli_idx.
One value per slot. Consumed by sc_cntrl to
populate sc_upd_idx[4] in the prediction meta.
Rules in sc_table_hash_rules.md.
The two module types have disjoint prediction-index input sets. sc_table takes idx_fh_p2 and does not take sc_phr_p2, br_imli, or br_imli_mode. sc_brimli takes sc_phr_p2 and br_imli as ports (BR_IMLI_MODE is a compile-time parameter, not a port) and does not take a fold.
Update Interface¶
sc_table and sc_brimli Semantics¶
sc_upd_val_u0[s] enables the bw_ram write for slot s. Produced by
sc top level.
ctr_wd_u0[s] the counter write data. The saturated stepped
counter (sat_sc result, sc_decisions.md section
10). Produced by sc_cntrl.
ctr_wr_u0[s] the write enable for the counter. Gated by
THIS_TABLE membership in the update. Produced by
sc_cntrl.
upd_index_u0[s] the entry index for the write. Sourced from
sc_pred_meta.sc_upd_idx captured at predict time,
carried through sc_upd_inp. No re-hash on the
update path (sc_pred_meta_t comment,
sc_decisions.md section 10). Produced by sc_cntrl.
The index hash is prediction-path only. The update path takes the precomputed index on upd_index_u0.
Read-during-write contract¶
Prediction and update paths are mutually exclusive by design. Prediction is bw_ram read only. Update is bw_ram write only. No read-modify-write is required (sc_decisions.md section 4). The prediction-phase counter snapshot captured in sc_pred_meta supplies the write data base for the update; the update does not read the table.
bw_ram read-write conflict is undefined (bw_ram.sv). The mutually- exclusive phase design guarantees no concurrent read and write to the same instance.
Entry Formats¶
The SC table entry is a single signed counter of width SC_TBL_CTR. There is no separate entry-format document: sc_table_entry_formats.md was dropped (sc_decisions.md section 1, document list). This cited "the sc_decisions.md section 7 file-set decision", which section 7 does not contain. Session-071.
Known Gaps and Deferred Items¶
| ID | Item | Status |
|---|---|---|
| IC-SCT-01 | sc_idx_hash, referenced by sc_table | CLOSED. |
| idx_hash_p2. Defined in | sc_table_ | |
| sc_table_hash_rules.md, session-058. | hash_rules.md | |
| IC-SCT-02 | get_br_imli_idx, referenced by | CLOSED. |
| sc_brimli idx_hash_p2. Defined in | sc_table_ | |
| sc_table_hash_rules.md, session-058. | hash_rules.md | |
| Both rows read "not yet defined", TBD, | Session-071. | |
| until session-071. | ||
| IC-SCT-03 | Flush port definitions (_px signals). | CLOSED BP-105. |
| NO FLUSH EVENT EXISTS: a flush is a | fe_decisions | |
| redirect. sc_table needs no flush port | FE-14. | |
| and none is added. |
ftb_decisions.md
planning/arch/ftb_decisions.md on GitHub
FTB Micro-Architectural Decisions¶
FILE: ftb_decisions.md
SOURCE: session-051 / session-052 / session-053
STATUS: DRAFT
UPDATED: 2026-10-12
CONTACT: Jeff Nye
Canonical decision record for the Fetch Target Buffer (FTB), also called the BTB. Companion to ftb_interfaces.md (interface contract) and ftb_confidence_override_rules.md (confidence-override policy). Those documents reference this file for FTB-specific decisions. Claude Code loads this file when working on ftb.sv or related testbenches.
Stage notation is p0/p1/p2/p3 for prediction and u0/u1 for update, in every document and in the RTL (PROJECT_CORE.md, Interface specification approach; fe_decisions.md 12). This document carried a local rule that planning narrative uses s0/s1/s2/s3; PROJECT_CORE supersedes it. Session-072.
1. Role and Pipeline Position¶
FTB provides the authoritative branch target for direct conditional and unconditional branches, and classifies branch type for the whole prediction cluster.
Pipeline stage: p2 output. p0 send, p1 registered, p2 valid.
Override, by quantity. ON DIRECTION there is a ranking: SC > TAGE > FTB, with a trusted loop prediction above all three since BP-122 (fe_decisions.md 3.3), suspended per branch when the fast path fires (ftb_confidence_override_rules.md 4.3, 4.2). ON TARGET there is not: RAS supplies it for a return, ITTAGE for an indirect with the FTB target standing on an ITTAGE miss, FTB otherwise -- selected by branch type and by hit, not ranked. The FTB supersedes the uBTB by stage order, FE-3. An earlier revision compressed all of this into "Override chain: SC > TAGE > FTB > uBTB"; the decomposition below it was already right. fe_decisions.md 12, narrowed session-070.
FTB classifies branch type per block, which gates who supplies the
target at p2:
return -> RAS provides target
indirect -> ITTAGE provides target
conditional -> TAGE provides direction, FTB provides target
direct uncond -> FTB provides target
Branch type classification is FTB's responsibility. JALR OWNERSHIP IS RAS OR ITTAGE, resolved by FTB structural prediction before p2: a return goes to the RAS, every other indirect JALR to ITTAGE. The FTB is NOT a third arm -- its target is what stands when ITTAGE misses (section 4.2), selected by hit rather than by branch flavour. An earlier revision read "three-way JALR split (FTB / RAS / ITTAGE)". Corrected session-070. RAS, ITTAGE, and TAGE depend on FTB's branch type and fallthrough outputs.
1.1 Timing¶
uBTB is the zero-bubble p1 predictor that supplies the fast next-PC. FTB at p2 is therefore not on the critical first-cycle path, which gives FTB a larger, slower read budget. FTB overrides uBTB at p2 on the presumption that the larger, slower structure is more accurate. That override is a p2 redirect and costs a bubble. The bubble is the accepted cost of the timing latitude; it is what allows FTB to be sized and clocked as a second-level structure rather than a zero-bubble one.
2. Structure¶
2.1 Single array¶
ONE FTB data array. One PC indexes one entry per cycle. That entry describes the whole prediction block: its start, its end (fallthrough), its branches, their types, and their basic directions. One read port for prediction; one write port for update (see ftb_interfaces.md section 3).
The entry-level valid bits and the tree-PLRU replacement state do NOT live in the data array. They are held in a parallel flop module, ftb_plru (section 2.4, 5.3). The data array (ftb_array) is therefore pure RAM: a single PC lookup returns one data entry per way of the indexed set, and ftb_cntrl qualifies each way with the matching valid bit read from ftb_plru.
The cluster predicts two branches per cycle. Both branches come from the one indexed entry (two conditional fields, section 4). FTB does NOT use per-slot RAMs. TI6 (per-slot RAMs) is a TAGE/ITTAGE convention and does not apply to FTB structure. Neither does the G8/G17 pred_pc+32 bundle split -- AND THAT SPLIT NO LONGER EXISTS ANYWHERE: tage_interfaces.md TI3 has slot 1's PC supplied on tage_pred_inp_p0[1].pc and records pred_pc+32 as an error that was removed. This paragraph attributed it to TAGE/ITTAGE, which now points at nothing. Corrected session-070; the FTB conclusion is unchanged. A single FTB lookup supplies both predictions.
2.2 Associativity and capacity¶
FTB_WAYS = 4 set-associative, parameterized.
FTB_ENTRIES = 2048 total, single array.
FTB_SETS = 512 FTB_ENTRIES / FTB_WAYS.
4-way is the Xiangshan choice at the same 2048-entry capacity. 8-way was an unmeasured belief; FTB_WAYS is parameterized so 8-way is a synthesis experiment, not a redesign. Revisit with SPEC numbers if time allows.
2048 entries is in the proven range for a fast single-level BTB (Apple M2 ~2048; Xiangshan 2048; Zen 2/3/4 fast tier 512/1536). We are not building a 4096-entry FTB at this time. Relief lever if capacity or timing is tight: 1024 entries (256 sets x 4-way).
Growth path if 2048 proves short under SPEC: a second FTB level (L2 FTB, victim style), consistent with the decoupled frontend. NOT a larger flat L1. Bigger commercial designs go multi-level, not fatter-flat.
2.3 Prediction block vs fetch block¶
FTB prediction block = 32 bytes (FTB_BLOCK_BYTES), 16 two-byte instructions, matched to 8-wide issue and to the two-branch-per-cycle budget. FTB predicts one 32-byte block per cycle.
The FETCH block is 64 bytes (FETCH_BLOCK_BYTES, a fetch-unit / global parameter, not an FTB parameter): the L1I line the IFU reads, from which it extracts one prediction block per request (fe_decisions.md Conventions, ifu_decisions.md IFU-7). The FTQ decouples the FTB from fetch. Fetch does NOT raise the prediction rate, which is two branches per cycle, and as specified it delivers one prediction block per cycle; delivering two is open (ftq_ifu_interfaces.md 8 item 2).
This read "Fetch delivers 64 bytes ... into the FTQ per cycle" and that "the wider fetch gives decode and fusion a larger window". Nothing is delivered into the FTQ but predictions, and the IFU hands the ibuf 16 slots, one block (IFU-5). Session-071.
These two widths are independent and must not be collapsed. Treating the 64-byte fetch as a 64-byte prediction reintroduces a two-block-per-cycle structure, which is wrong (it would demand four conditional-branch predictions per cycle against a two-prediction budget).
2.4 Module boundary¶
FTB is a structural top module (ftb) containing THREE submodules:
- ftb_array -- the single 1R1W FTB DATA array. Pure RAM: data only,
no entry-valid bit, no PLRU state, no compute. It has
no reset (a real SRAM cannot be reset). Sized at
FTB_RAM_ENTRY_WIDTH per way (section 8).
- ftb_plru -- entry-valid bits and tree-PLRU replacement state for
every set, held in resettable flops. Storage only --
it does not compute the victim, the next PLRU state,
or the way-match. Reset clears all entry-valid bits;
this is the FTB cold init.
- ftb_cntrl -- all FTB logic: read, branch-type classification,
way-match (ftb_array tag qualified by ftb_plru
valid), block-boundary and fallthrough computation,
allocate/evict including PLRU victim and next-state
compute, valid set/clear, update field writes,
confidence training and suppression.
The top is structural only, matching the convention of keeping arb logic out of the TAGE/ITTAGE tops. ftb_array and ftb_plru are storage peers; ftb_cntrl is the only logic and drives both.
This split exists to support eventual SRAM migration. By keeping the data array pure (no per-entry resettable state, no decode) it can be replaced by a 1R1W SRAM macro without touching ftb_cntrl. The resettable state that a real SRAM cannot hold -- the entry-valid bits -- lives in ftb_plru flops, so the FTB needs NO sram_init mechanism, unlike the TAGE/ITTAGE tables. The tree-PLRU state lives there too, co-located with validity since both are small per-set flop state that ftb_cntrl maintains.
Storage-module enables are ACTIVE LOW, matching the BPU array convention (ftb_interfaces.md IC-FTB-13). ftb_array has clk only and no reset; ftb_plru reset (rstn) clears its valid and PLRU state. Both storage modules return the OLD contents on a same-cycle read vs same-set write, so a prediction sees a coherent pre-update snapshot of data and validity/replacement together (IC-FTB-14).
Outside FTB: FTQ-level update scheduling, and cluster-wide override resolution at p2.
3. Block Model¶
One FTB entry describes one prediction block. The block runs from the lookup PC to the fallthrough address.
Intra-block branching (a taken branch targeting an address inside the same block) is handled by the next cycle's lookup re-indexing at the branch target. It is NOT handled by predicting two blocks in one cycle. Each cycle is one block prediction from one entry.
A block can contain more branches than NUM_PRED_SLOTS. THE SPLIT (BP-140, ruled by Jeff 2026-10-18): an entry never holds more than NUM_PRED_SLOTS branches. When an update would make it hold more, the lowest positions are kept and the block end becomes the PC of the lowest-position branch not kept; a jump not kept clears the jump field and the end stops before it. At one slot an entry holds one branch, conditional or jump; at two, two in any mix. The branch that falls out becomes the first branch of the next block, which starts at its PC, and gets its own entry (4.6) when it resolves in a block from that start. Branches are never dropped; the block is split. The result is the same whatever order the branches of a block resolve in.
Cost of the split: that block becomes two prediction blocks, two lookups instead of one, on that path. This only happens with three or more conditional branches in one 32-byte block, which is rare.
THE SPLIT IS BUILT, in the FTB and the uBTB, at both slot counts (BP-140). Before it, ftb_cntrl.sv replaced a conditional field when both held other branches (5.5 cases 3 and 4) and wrote the update's end, and the cluster cut (fe_decisions.md 10, BP-139 option A) ended the block at the first branch the FTB reported and no slot carried. Since BP-140 the FTB reports no such branch from an entry it wrote, and the cut is a backstop: 0 events in every tb_fe_top program at both slot counts (2409 at one slot before). THE END AT UPDATE (BP-140, PROVISIONAL). The update's end for a conditional, its block's predicted end, is not written. An entry's end is the start plus FTB_BLOCK_BYTES on allocation, a written jump's resolved end (5.5), or a split point, and it only moves down; a resolution at or after the end, or after the stored jump, changes nothing (it came from a block predicted before the entry was shortened).
MEASURED by BP-131 (session-078, tb_fe_top, 36 programs): blocks with more branches than slots, 9 at two slots (all twocond, two conditionals and a jump) and 243 at one slot; cases 3 and 4 never occur, no test region holds three conditionals. A split end would differ from another start's recorded end in every such block with one (228 of 228 at one slot): with the shared entry (4.6, TD#168) a split adds contention for the one pftAddr. The tb_fe_top programs are directed tests, too small to settle this.
DEFERRED to TD#179 (Jeff, session-078), with the entry shape (2+1, or NUM_PRED_SLOTS fields with a shared last field as XiangShan), the region sharing of TD#168 and the training point, until the performance analysis against compiled benchmarks.
MEASURED by BP-140 (tb_fe_top, 38 programs, base -> final): cycles 36095 -> 30840 at two slots and 38381 -> 31697 at one; the split's contention with other starts (BP-131's count) 0 / 197 -> 0 / 0. The split on the shared region entry, without per-start entries, was measured worse than the starting tree (one slot 42573 cycles, 502 contention events).
4. Entry Format¶
Each entry holds two conditional branch fields and one jump field (2+1). No Xiangshan-style field sharing. Two conditional branches with no jump fill both conditional fields directly.
Entry fields (logical entry; the width is stated in section 8 only):
valid -- entry valid. Held in ftb_plru (flops),
NOT in ftb_array (section 2.4, 8).
tag -- FTB_TAG_BITS, VA[39:14] and the start's
halfword offset VA[4:1]; bit 40 is
NOT covered (4.1, TD#122)
conditional branch 0 -- valid, position, target, conf[2:0]
conditional branch 1 -- valid, position, target, conf[2:0]
jump field -- valid, position, target (reconstructed full
VA_WIDTH from a stored displacement, 4.2),
isCall, isRet, isJalr, rvc (the jump is a
compressed instruction; 5.5, BP-121)
fallthrough -- pftAddr (5 bits from the block start, no
carry; 5.5, 8)
position is the in-block instruction slot (0..15) the branch occupies, counted from the BLOCK START, FTB_BR_POS_BITS = 4, stored and presented in the same form since BP-140 (one entry per start, 4.6; it was stored region-relative in FTB_BR_RPOS_BITS = 5). It is distinct from the TARGET offset of 4.2 (an earlier draft called this field "offset", which collided with the target-offset term -- it is renamed "position" here). It is sourced from ftb_upd_pos_u0 and read out on ftb_brI_pos_p2 / ftb_jmp_pos_p2 (ftb_interfaces.md 2.3/2.5, IC-FTB-15). Storage is in ascending position: br0 below br1, the jump after both; the update keeps that order (5.4a).
conf is a bimodal DIRECTION counter, not a separate confidence-only field: its MSB is FTB's predicted direction for that conditional. There is no always_taken bit -- it was removed (session-053); conf is the sole per-branch direction state. See ftb_confidence_override_rules.md.
Storage partition. The entry-level valid bit (1 per way) is the only field physically relocated to ftb_plru. The remaining bits -- tag, both conditional fields, the jump field, and the fallthrough -- are stored in ftb_array (FTB_RAM_ENTRY_WIDTH, section 8, which is the only place the widths are stated; this line read 105, stale since BP-099 -- session-070; then 112, stale since BP-121 -- session-076). The per-field valid bits of br0/br1/jump stay in the RAM entry; they are don't-care while the entry-valid (in ftb_plru) is 0, so they need no reset. The entry-valid gates the whole entry.
NOTE: this bit has been removed. This reference kept for documentation
of the decision
last_may_be_rvi_call -- 1 bit (section 6)
The 2+1 structure costs the area of two full conditional fields plus a jump field even in the common one-branch block. This is a chosen tradeoff: simpler format, simpler update, no field-sharing decode. Project stance is to trade area for performance; do not optimize the entry toward minimum area at the expense of capability.
UNUSED FIELDS UNDER THE SPLIT (BP-140). An entry holds at most NUM_PRED_SLOTS branches, so at two slots at least one of the three fields is always empty (the jump, 32 bits, in {cond, cond}; br1, 23 bits, in {cond, jump}) and at one slot at least two (46 or 55 bits). Over 2048 entries that is at least 47,104 bits at two slots and 94,208 at one; in the uBTB 5,888 and 11,776. A NUM_PRED_SLOTS-field entry with a shared last field (XiangShan) would recover it; it is an area change only, out of BP-140's scope (TD#179).
4.1 Tag¶
FTB_RTAG_BITS = 26 PINNED, not derived (TD#122, FE-19); the
region tag, VA[39:14]. It was FTB_TAG_BITS.
FTB_TAG_BITS = 30 FTB_RTAG_BITS + FTB_BR_POS_BITS: the region tag
and the start's offset VA[4:1] (BP-140).
It was VA_WIDTH - FTB_IDX_BITS - FTB_OFFSET_BITS = 40 - 9 - 5. VA_WIDTH is now 41, and the tag is PINNED AT 26 rather than widened to 27. The reason is that predictor storage may alias: a tag that does not cover bit 40 mispredicts a block end, which predecode catches (ftq_ifu_interfaces.md 6 and 7), and a wrong target, which the mispredict redirect catches at resolve. Architectural addresses may not truncate; a predictor tag may. Pinning also kept FTB_ENTRY_WIDTH at 110 and the RAM widths untouched, so sim_ftb's 99 checks stand against the tag change. 4.6 widens the stored positions separately. Section 8 is the sole home of the arithmetic.
THE TAG NO LONGER COVERS THE WHOLE UPPER VA. At 26 bits over a 9-bit index and 5 offset bits it spans VA[39:14]. BIT 40 IS DISCARDED, so two PCs differing only in bit 40 ALIAS -- they hit the same entry and the older one's target or block end is returned. Two PCs differing anywhere in VA[39:5] still miss each other, which is the Xiangshan comparison that used to apply to the whole VA: unlike its truncated 20-bit tag, no bits below 40 are discarded.
Bit 40 is only ever set for a guest physical address under V=1 with vsatp.MODE=Bare (FE-19), so the aliasing is confined to that case and is a misprediction, not a fault: predecode catches a wrong block end and the mispredict redirect catches a wrong target. This is the cost of pinning rather than widening to 27, and it is a consequence worth re-reading before TD#122 reaches RTL.
WITHIN one 32-byte region the tag separates since BP-140. Until then FTB_OFFSET_BITS of 5 were in neither the index nor the tag, and two lookup PCs in one region hit the same entry (4.6). BP-140 (ruled by Jeff 2026-10-18) puts the start's halfword offset VA[4:1] in the tag and XORs it into the top of the index: index VA[13:5] XOR (VA[4:1] << FTB_SOFF_SHIFT), FTB_SOFF_SHIFT = FTB_IDX_BITS - FTB_BR_POS_BITS = 5 (PROVISIONAL). Two starts that differ anywhere in VA[39:1] have different (index, tag) pairs. The starts of one region index 16 different sets, and two starts at different offsets share a set only when their regions differ in VA[13:10], 1 KB or more apart.
This is why 4.5 carries a fall-through bounds check. An earlier revision of this section said two different PCs can never alias and 4.5 removed the check on that basis. The claim was true of partial-tag aliasing and false of within-region aliasing, which unaligned blocks make reachable.
4.2 Targets¶
Conditional branch targets are stored as an offset from the block start, with a fit/overflow/underflow status field. A shared entry breaks a start-relative base. RULED session-073, 4.6 O-1: the base is the branch PC, not the block start. Offset storage is lossless -- the target reconstructs exactly -- so it is an area win, not an accuracy tradeoff. The cost is a reconstruct-and-bounds-check step in logic.
The jump field target is stored as a 21-bit displacement (FTB_JMP_TGT_BITS) plus a fit/overflow/underflow status, reconstructed to full width at read. RULED session-073 (Jeff), extending O-1 to the jump: EVERY TARGET IS A DISPLACEMENT FROM ITS OWN INSTRUCTION. A conditional is measured from the branch PC and a jump from the jump PC, each of which is the region base plus that field's stored position, so every sharer of the entry agrees on it. BP-110 built the conditional half and BP-111 the jump half, so both targets are measured from their own instruction in the RTL. TD#137 closed.
The one observable difference is WHERE THE REACH WINDOW SITS. Any in-reach target reconstructs correctly under either base, because the region base and the jump PC are both shared by every start; what changes is which targets are in reach. BP-111 pinned it with a jump target at the edge of the 21-bit reach (tb_ftb J2), which comes back wrong from both starts under the region base.
It is load-bearing for the cluster:
ITTAGE has no IT0 base table. An ITTAGE miss therefore produces no
ITTAGE target. The FTB jump target is the architectural fallback for
the terminal control instruction:
- direct jump (JAL, fixed target): the FTB jump target IS the
answer.
- indirect (JALR): ITTAGE overrides on hit; on ITTAGE MISS, the
target falls back to the FTB jump target.
- return: RAS overrides; the FTB jump target is the fallback when
RAS is empty (connects to the RAS commit-stack fallback).
The override chain therefore has an implied "...else FTB jump target" floor. FTB must keep the jump target current even for branches that ITTAGE or RAS normally own. See section 5 (update) -- the jump target is rewritten on every resolve of that jump, not gated on an ITTAGE miss.
Target widths (session-052, ruled): the stored displacement widths are set by ISA branch/jump reach in the EXPANDED address space, not by in-block granularity. A conditional B-type reaches +/-4 KB in original code; in the worst all-RVC-expanded case that span doubles to +/-8 KB, so FTB_BR_TGT_BITS = 13. A J-type reaches +/-1 MB original, +/-2 MB expanded, so FTB_JMP_TGT_BITS = 21. Both pair with TAR_STAT_BITS = 2. The position field (which instruction in the block) is separate and is FTB_BR_POS_BITS = 4 ($clog2(16)), in-block granularity: sixteen 2-byte positions in a 32-byte block, BP-099.
4.3 conf: bimodal direction¶
One 3-bit saturating bimodal counter per conditional branch (FTB_CONF_WIDTH = 3). Its MSB is FTB's predicted direction for that branch (1 = taken, 0 = not-taken); its magnitude is the strength. FTB always submits a direction for a valid conditional: ftb_brI_taken_p2 = ftb_brI_valid_p2 & conf_brI[MSB]. The two saturated states (111 strongly taken, 000 strongly not-taken) are the only states eligible for the fast-path (section 7). conf replaces the removed always_taken bit as the sole per-branch direction state. Training, fast-path, init, and self-correction rules are in ftb_confidence_override_rules.md (summarized in section 7).
4.4 Offset and fallthrough widths¶
pacino expands RVC instructions to 32b in the IFU, DOWNSTREAM of the FTB (ifu_decisions.md IFU-1 and IFU-4, dcd_decisions.md 1), so the FTB never sees an expanded instruction. It addresses branches at 2-BYTE granularity, not at the expanded 4-byte granularity. A branch may begin at any 2-byte boundary under the C extension, so a coarser position could not separate two RVC branches in one aligned word. BP-099, 2026-08-19, widened FTB_BR_POS_BITS from 3 to 4 for this reason. An earlier revision of this paragraph said the opposite and described the pre-BP-099 state.
PARAMETER NOTE, 2026-08-19. The shift that reduces and reconstructs the partial fall-through address is POS_OFFSET_BITS, derived as FTB_OFFSET_BITS - FTB_BR_POS_BITS so it cannot disagree with the position width. It was INST_OFFSET, a parameter that also carried an unrelated meaning: the low PC bits dropped before a predictor index hash, now PC_HASH_SHIFT. The two were split because they are not the same quantity and would have to move independently if the position granularity ever changed. POS_OFFSET_BITS is 1 after BP-099, FTB_OFFSET_BITS 5 minus FTB_BR_POS_BITS 4, which is two bytes per position. PC_HASH_SHIFT is unchanged at 2. Both were 2 when the split was made, and the split is why only one of them moved.
Two different quantities must not be conflated here:
- IN-BLOCK quantities (position offset, pftAddr) ARE granularity-
dependent. Do NOT inherit Xiangshan's log2(PredictWidth)=4 position
or its pftAddr sizing -- those address 16 RVC instructions at
2-byte granularity. This design now matches it: 16 positions per
32-byte block, FTB_BR_POS_BITS = 4, PFTADDR_BITS per 8.1.
- TARGET DISPLACEMENT widths are set by ISA branch/jump REACH, not by
in-block granularity. Xiangshan's BR_OFFSET_LEN=12 / JMP_OFFSET_LEN
=20 encode the B-type/J-type immediate reaches and DO transfer,
adjusted for the expanded address space: FTB_BR_TGT_BITS = 13,
FTB_JMP_TGT_BITS = 21 (see 4.2). The earlier blanket "do not
inherit BR_OFFSET_LEN/JMP_OFFSET_LEN" was too broad; it correctly
excluded the position/pftAddr widths and wrongly swept in the
target widths. Corrected here.
All widths of the fields the entry holds are ruled. None remain derived-at-RTL.
TWO FIELDS ARE PROPOSED AND NOT RULED. TD#89 would add PC[15:6] of each conditional branch (20 bits) and TD#90 a backwards-branch bit per conditional (2 bits), both for sc_upd_inp (sc_decisions.md, BrIMLI Update). Neither is in the entry arithmetic (8.1). Both may be derivable rather than stored: the branch PC is block start plus pos (4.6 R-2), and a backwards branch is target < branch PC, both reconstructed at the read. Not the sign of the stored displacement alone while 4.2 measured it from the block start. 4.6 O-1 ruled session-073: the base is the branch PC, so the two now agree. Recorded session-072; this read "All widths are now ruled" with both TDs open against the format.
4.5 Fallthrough reconstruction: bounds checked¶
pftAddr is stored partial (8.1). The full fallthrough is reconstructed as the block start plus pftAddr shifted by POS_OFFSET_BITS (BP-140; it was the aligned region base). No carry term: 5.5 deleted the carry bit session-070.
FTB-G1 The reconstructed end is compared against the looked-up
block start. If the end is not above the start, pftAddr is
discarded and the fallthrough is start + FTB_BLOCK_BYTES.
FTB-G3 RULED session-073, 4.6 O-2. An end beyond start +
FTB_BLOCK_BYTES + 2 also takes the FTB-G2 fallback. An end
recorded from a start at region offset 30 can otherwise lie
64 bytes above a later start at offset 0 and pass FTB-G1.
FTB-G1 AND FTB-G3 WERE BUILT BY BP-110 (session-073). Until then
ftb_cntrl reconstructed UNCONDITIONALLY: the session-069 restoration
of FTB-G1 was recorded here and never reached the RTL, which is what
the "no error check" comment at ftb_cntrl.sv 500 meant. A document
saying a rule is restored is not evidence that it is built.
FTB-G2 The fallback is start + FTB_BLOCK_BYTES, one PREDICTION
block of 32 bytes. It is NOT Xiangshan's start +
FetchWidth*4. A fetch-width literal here would map to
FETCH_BLOCK_BYTES, the 64-byte fetch block, so copying the
Xiangshan literal would substitute a fetch-block
fallthrough and re-commit the block-versus-fetch collapse
banned by 2.3. Adopt the
semantics, never the literal.
Xiangshan carries this guard because its truncated 20-bit tag lets two PCs alias to one entry, so a wrong-entry hit gives a pftAddr that is garbage relative to the looked-up start.
A previous revision of this section removed the guard, reasoning that pacino's full tag (4.1) makes a wrong-entry hit impossible. That reasoning covered only partial-tag aliasing. FTB_OFFSET_BITS of 5 are in neither the index nor the tag, and prediction blocks are unaligned, so two lookup PCs inside one 32-byte region hit the same entry and the aliased pftAddr is measured from a different block start. Pacino reaches Xiangshan's failure by a different route and needs the same guard. Session-069.
The alternative considered and not taken at session-069, widening the tag to cover the start offset, was TAKEN by BP-140 (Jeff reopened 4.6 for it, 2026-10-18): the tag carries VA[4:1] (4.1). The guards stay. A stored end is in bounds unless a jump's resolved end is out of them, and the update's past-the-end test uses the bounded end (ftb_cntrl.sv eff_end), so an out-of-bounds end does not freeze the entry.
4.6 Stored positions are region-relative¶
REPLACED BY BP-140 (Jeff reopened 4.6 for it, 2026-10-18). The entry is identified by its block start PC (4.1), so no entry is shared by two starts and nothing in it needs a region-relative form. Positions, targets and pftAddr are stored start-relative; the window of R-1 (and the hiding of a field past the visible jump), the region offset of R-2 and the read compaction of O-3b are removed (PROVISIONAL). O-1 stands (a target is a displacement from its own instruction, now the start plus the position), O-2 stands (FTB-G3), O-3a stands as ascending position order per start. The ports were and are start-relative (R-2). What follows records the region design as built from BP-110 to BP-139.
RULED session-071 (Jeff), option (R). An entry is shared by every lookup PC in its 32-byte region (4.1, 4.5), so every in-block quantity it STORES must mean the same thing to every one of them. Positions did not: the update path wrote them relative to the block start and bp_cluster.sv read them relative to the aligned region base. TD#125.
R-1 A stored position is REGION-relative, FTB_BR_RPOS_BITS = 5.
A block starting at halfword offset k covers region
positions k to k+15, so the largest is 30, which 5 bits hold.
No region-crossing rule is needed. A read keeps only the
fields whose stored position lies in [k, k+16); a field
outside that window reports invalid. That hides branches
before the start and branches past this block's end that an
earlier start recorded.
A field whose stored position lies past this start's visible
jump is hidden as well: the jump ends the block, so nothing
after it belongs to the block. BUILT by BP-121 (D4), recorded
session-076. Before it, a conditional that another start had
recorded past the jump was reported in slot 0 with the jump
after it.
R-2 The conversion is INSIDE the FTB (and the uBTB,
ubtb_interfaces.md). ftb_cntrl adds k to ftb_upd_pos_u0 at
the write, from the update PC, and subtracts k at the read,
from the lookup PC. Every port, the FTQ entry, the backend
resolution and the predecode writeback stay START-relative,
FTB_BR_POS_BITS = 4, and the branch PC is block start plus
pos << POS_OFFSET_BITS.
R-3 A uBTB miss steps to lookup PC + FTB_BLOCK_BYTES, with no
resync to the region (bp_cluster.md Block width). Unchanged
in the documents; bp_cluster.sv uses the aligned base.
Cost: one bit per stored position, three per entry, 110 to 113 (section 8). A package change.
This matches XiangShan V3, whose main BTB stores positions from an aligned base and qualifies a hit on the position being at or after the start's offset within it.
UNDER TD#125, each a consequence of (R):
O-1 TARGET BASE. RULED session-073 (Jeff), as proposed. A
conditional target is a displacement from the BRANCH PC,
which is the region base plus the stored position. 4.2's
block-start base broke on a shared entry the same way the
positions did. Every sharer agrees on the branch PC, and
the ISA reach of 4.2 stays exact.
O-2 UPPER BOUND ON THE FALL-THROUGH. RULED session-073 (Jeff),
as proposed, FTB-G3: a reconstructed end beyond start +
FTB_BLOCK_BYTES + 2 takes the FTB-G2 fallback, as an end
at or below the start already does under FTB-G1. FTB-G1
alone passed an end recorded from a start at region offset
30 that lies 64 bytes above a later start at offset 0.
O-3 SLOT MAPPING AND FILL ORDER. RULED session-073 (Jeff), as
proposed, in three parts. With the window mask br0 can be
hidden while br1 is visible, so IC-FTB-16's "slot 0 is the
first branch" holds per region in storage and per start on
the ports, and 5.4a's program-order fill is restated for
starts that share an entry.
O-3a STORAGE is in ascending REGION position order. br0
holds the lower stored position, br1 the higher,
whatever start wrote them. This is what makes the
entry mean one thing to every sharer.
O-3b THE READ COMPACTS. After the [k, k+16) window mask,
the surviving fields are packed onto the ports in
ascending position, so port slot 0 is always the
first branch at or after the start. IC-FTB-16 then
holds PER START on the ports and PER REGION in
storage, and the consumer needs no window knowledge.
Without compaction a start that hides br0 reports
its only branch in slot 1, and the FTQ entry, the
predecode writeback and the resolution all have to
learn the window rule.
O-3c 5.4a IS RESTATED ON REGION POSITION. Which
conditional field a branch fills is decided by its
region position, not by program order within one
start. For a single start the two agree; for two
starts sharing an entry only the region position is
well defined.
5.4a and IC-FTB-16 are amended to match, and the read path
gains the compaction, which is inside ftb_cntrl by R-2.
All of 4.6 is ruled, and R-1, R-2, R-3, O-1 (conditional),
O-2 and O-3 were BUILT IN THE FTB by BP-110, session-073.
THE uBTB DIVERGES DELIBERATELY: it masks out-of-window
fields but does not compact or reorder them, keeps
region-base targets, and has no fall-through bounds check.
Ruled session-073; ubtb_interfaces.md states each
divergence and is the home for it.
KEPT, session-075 (Jeff, BP-121 decision 7), and REOPENED
by Jeff for BP-140 (2026-10-18). Sharing one entry, and so
one jump field, among every start in a region made two jumps
of one region take turns in that field (TD#168). Per-start
entries ended it: jump-field turn-taking 703 -> 0 events over
the tb_fe_top programs, coro 32 -> 5 mispredicts at both slot
counts (BP-121 measured 39).
5. Allocation and Update¶
Update happens post-execute, not at retire.
5.1 Hit updates, miss allocates¶
When a branch resolves at execute:
- Tag hit (entry for this block already in the set): update in
place. Write the resolved branch's target and conf to ftb_array.
- Tag hit, this branch not yet stored, a branch field free: write it
into the free field. conf for that field starts weak in the
resolved direction (FTB_CONF_INIT_TKN / FTB_CONF_INIT_NTK, 5.4).
- Tag miss (no entry for this block): allocate a new entry. The
evicted way is chosen by the replacement policy (5.3). ftb_cntrl
writes the entry data to ftb_array and sets the entry-valid for the
allocated way in ftb_plru in the same cycle.
The whole block's branches live in one entry, because the entry sets the block boundary and fallthrough. One branch per entry would not work.
Way selection on update is carried, not recomputed. The predicted way (writeWay) and the hit/miss result are determined by ftb_cntrl at the prediction READ -- way-match over the ftb_array tags qualified by the ftb_plru valid bits gives the hit way on a tag hit, or the tree-PLRU victim way from ftb_plru on a miss (5.3) -- and travel with the prediction through the FTQ. At update, ftb_cntrl writes the carried way directly; it does NOT re-look-up the tag. On a carried hit, the carried way is overwritten; on a carried miss, the carried victim way is allocated (data to ftb_array, valid set in ftb_plru). This matches Xiangshan (writeWay/hit carried in the prediction meta) and removes a second tag lookup on the update path. See ftb_interfaces.md IC-FTB-10.
THE CARRIED HIT/MISS IS CHECKED, IN BOTH DIRECTIONS. RULED session-075 (Jeff, BP-121 decision 2, TD#163), BUILT by BP-121 (D11). Another write can land in the set between the prediction read and the update, so the carried result can be stale. At the update ftb_cntrl reads the carried way's tag and entry-valid (a read of one way, not an associative re-lookup) and recomputes the hit: the carried way is valid and its tag matches the update. A carried miss whose way now holds the same tag merges into it rather than overwriting its other fields. A carried hit whose way now holds a different block allocates rather than writing into that block's entry. Before BP-121 a stale miss overwrote a live entry of the same block and discarded its other fields.
5.2 Track every branch, not just taken ones¶
FTB allocates and tracks any conditional branch or jump that resolves in a fetched block, taken or not. A taken-only FTB does not work here: a not-taken conditional that FTB did not store would give TAGE nothing to override at p2, put the block boundary in the wrong place, and give RAS the wrong fallthrough.
Cost: more entries than a taken-only BTB, so more pressure on the 2048-entry capacity. If capacity runs short under SPEC, this is the first thing to revisit, alongside the capacity relief lever (2.2).
5.3 Replacement: tree-PLRU¶
On a tag-miss allocate, the evicted way is chosen by tree-PLRU, PLRU_BITS = 3 per set for the 4-way. The tree-PLRU state AND the entry-valid bits live in ftb_plru (resettable flops), not in ftb_array (section 2.4). ftb_cntrl reads the set's PLRU state from ftb_plru at the prediction read and selects the victim from it; on a tag hit the carried way is the hit way, on a miss it is the PLRU victim. That way is carried through the FTQ to the update (5.1).
ftb_cntrl computes the next PLRU state and writes it back to ftb_plru
on two events:
- prediction hit: mark the hit way used.
- update or allocate write: mark the written way used.
ftb_plru exposes separate valid and PLRU write ports, so an allocate
(set valid + mark used) does both in one cycle. The two PLRU-touch
events above are funneled by ftb_cntrl onto the single PLRU write
port; if both target the same set in one cycle, the update/allocate
write wins and the prediction-hit touch is dropped -- a dropped touch
costs prediction accuracy, never correctness.
A carried victim can go stale if another write lands in the same set between the prediction read and the update. This is tolerated: an occasional suboptimal eviction costs prediction accuracy, never correctness. Same stance as Xiangshan. The carried hit/miss itself is checked at the update (5.1).
The victim is the tree-PLRU choice. Allocation does not preferentially fill an invalid way first; an invalid way is simply a low-value eviction candidate the PLRU may or may not pick. (If invalid-first allocation is ever wanted, ftb_cntrl already has the per-way valid vector from ftb_plru to implement it; it is not specified now.)
5.4 Field values at allocate¶
entry valid: set to 1 in ftb_plru for the allocated way (5.1).
field valid: 1 for a filled branch field, 0 for an unused one
(stored in the ftb_array entry).
tag: the block tag.
position: the resolving branch's in-block slot, from
ftb_upd_pos_u0 (each filled conditional and the jump).
conf: weak in the resolved direction --
FTB_CONF_INIT_TKN (3'b100) if allocated taken,
FTB_CONF_INIT_NTK (3'b011) if not-taken. Unsaturated, so
a fresh entry never fast-paths on first use
(ftb_confidence_override_rules.md 7).
target (cond): the resolved taken target, as an offset with
fit/overflow/underflow status.
target (jump): the resolved jump target, as a 21-bit displacement
(FTB_JMP_TGT_BITS) with fit/overflow/underflow status.
isCall / isRet / isJalr: from the resolved jump's type.
fallthrough (pftAddr): the block start plus FTB_BLOCK_BYTES, as a
position offset from the BLOCK START, or a jump's
resolved end when the allocating update is a jump, or
the split point (section 3). Five bits, no carry. The
update's end for a conditional is not written
(BP-140, PROVISIONAL).
5.4a Which conditional field a branch fills¶
IC-FTB-16. The conditional fields are filled in PROGRAM ORDER: br0 holds the branch at the lower in-block position, br1 the higher, and a block with one conditional always fills br0. The FTQ forms ftb_upd_br_idx_u0 and owns this; the FTB neither reorders nor checks.
This makes the prediction slot array program-ordered, so slot 0 is the first branch of the block, and it makes the jump field's lowest-free-slot placement program order in every case rather than only the common one. Full statement in ftb_interfaces.md IC-FTB-16.
PER START AGAIN since BP-140 (4.6 replaced). br0 holds the lower position and br1 the higher, and the jump is after both, in every entry. ftb_cntrl sorts the held branches and the resolving one by position at the update. ftb_upd_br_idx_u0 is no longer read: the resolving branch's position names its field (5.5).
5.5 Field writes when an existing branch resolves¶
conf: bimodal step on the resolved OUTCOME
(ftb_confidence_override_rules.md 3.2): taken outcome
increments toward 111, not-taken decrements toward 000,
saturating. Outcome-driven, not FTB-correctness-driven;
this also carries the direction (conf MSB).
position: NOT rewritten when the SAME branch resolves -- it is
static for a filled field (the branch does not move).
Written when the field is first filled (allocate /
free-field, 5.4) from ftb_upd_pos_u0 rebased to the
region (4.6 R-2), and reset by reallocation.
THE SAME BRANCH MEANS THE SAME POSITION. RULED
session-075 (Jeff). An update to a filled field whose
region position differs from the stored one is a
DIFFERENT branch of the region (the entry is shared
by every start in it, 4.6), and the stored fields are
not kept for it:
jump field: the whole field is rewritten from the
update -- position, target, isCall, isRet,
isJalr, rvc (since BP-121) -- and pftAddr if
the boundary moves.
conditional field: the update is a new branch, as
the free-field case of 5.1 and 5.4: position
written, conf initialised weak in the resolved
direction, target written, the 5.4a order
restored and pftAddr recomputed.
AS BUILT BEFORE THIS RULING (found by BP-119),
ftb_cntrl.sv kept the stored position whenever the
stored jump was visible from the update's start, and
rewrote only target and type, so two jumps of one
region produced a field with one jump's type and
target at the other's position (coro: every
RETURN_CALL mispredicted). The conditional fields
kept their position the same way. BUILT BY BP-120
(TD#156 closed). ftb_cntrl maps a conditional update
to a field in this order: a field at the update's
region position (either field; the same branch);
else a free field, br0 first; else the field the
port slot names; else the field hidden from this
start. MEASURED: coro's two jumps of the 0x600
region now take turns in the one jump field (9
times) and both still mispredict, 39 before and
after. Fixing that reopens 4.6, the sharing of one
entry by every start in a region: TD#168.
BP-140 (per-start entries, the split) restated
the mapping on the start's own branches: a
conditional at a stored conditional's position is
updated in place; a jump at the stored jump's
position rewrites the field; the other kind at a
stored position replaces it; a new branch joins the
held ones in position order, and a new jump removes
the conditionals after it; then the split (section
3). Cases 3 and 4 above no longer exist.
conditional target: rewrite if the resolved taken target differs
from the stored offset.
jump target: rewrite on EVERY resolve of that jump, including when
ITTAGE or RAS normally supplies the runtime target.
ITTAGE has no base table, so an ITTAGE miss falls back
to this stored target; RAS falls back here when empty.
The stored target must stay current. Do NOT gate this
write on "ITTAGE missed" -- write it whenever the jump
resolves. See 4.2.
rvc: the jump field's one-bit compressed flag, written
with the jump's type from ftb_upd_jmp_rvc_u0, which
carries the backend resolution's is_rvc
(ftq_backend_interfaces.md 4). RULED session-075
(Jeff, BP-121 decision 3, TD#164), BUILT by BP-121
(D3). For a block that ends at its jump, the RAS push
and the block fall-through are the jump's own PC
(block start plus its position) plus 2 when rvc is
set, else plus 4. They are NOT pftAddr: pftAddr is
shared by every start in the region (4.6) and holds
whichever start's block end was written last, so it
is not this jump's return address. The bit is a
package change (section 8).
fallthrough (pftAddr): written by a jump update (its resolved
end, the FTQ's pc + 2 or 4 of the taken jump,
TD#164) and by the split (the PC of the first branch
not kept, section 3); otherwise kept. It only moves
down. Stored from the BLOCK START (BP-140).
All of the above are writes into the ftb_array entry (the carried way). The entry-valid in ftb_plru is unchanged on an in-place update -- it was set at allocate and is only set/cleared there. THERE IS NO FLUSH AND THERE WILL NOT BE: a flush is a redirect (fe_decisions.md FE-14, BP-105), and ftb_interfaces.md IC-FTB-07 and G24 are closed on that basis. This read "(and on flush, when that protocol exists)". Session-070.
Full-to-partial reduction (ftb_cntrl), BP-140: pftAddr = off[POS_OFFSET_BITS +: PFTADDR_BITS] where off = end - block start; five bits (PFTADDR_BITS = FTB_BR_POS_BITS + 1, 8.1). An end lies in (start, start + FTB_BLOCK_BYTES + 2], 17 positions at most. The reconstruction adds pftAddr << POS_OFFSET_BITS to the lookup PC, bounds checked (4.5). The region-relative six-bit form of session-070 (BP-110) is retired with 4.6; tb_ftb R1 and tb_ubtb TC16 still pin the straddling end, now from a jump.
6. last_may_be_rvi_call¶
THIS BIT HAS BEEN ELIMINATED. THIS DISCUSSION KEPT INCASE THE DECISION NEEDS TO BE REVISITED IN THE FUTURE.
WHY THE ELIMINATION IS SAFE, session-069. pft_addr carries the
true instruction end rather than a value clamped at the block
boundary, and the encoding reaches past the block: under the
session-070 ruling (5.5) pftAddr is six bits measured from the
ALIGNED REGION BASE and covers 0 to 126 bytes, which holds any
block end including a straddle. A 32-bit call beginning at the
block's last halfword ends at block start plus 34 and is
representable wherever the block starts within its region.
AN EARLIER REVISION read "pftAddr holds 0 to 16 at 2-byte
granularity, 0 to 32 bytes, and carry adds a further 32. A 32-bit
call beginning at the block's last halfword ends at block start
plus 34, which is pftAddr = 1 with carry set." That worked only
for a 32-byte-aligned block start. Blocks are unaligned, and from
a start at region offset 30 the same call ends 64 bytes above the
region base, which one carry bit cannot express. 5.5, TD#124.
Since a call is a taken branch and terminates the block, that end IS the return address the RAS needs.
SUPERSEDED, session-076. That holds for one start, but pftAddr is shared by every start in a region (4.6), so the RAS pushed whichever start's end was written last (TD#164). Since BP-121 the return address is the call's own PC plus 2 or 4, from the jump field's rvc bit (5.5). The elimination of the straddle bit stands: the call's PC plus its length is right whether or not the call straddles the block boundary.
ras_decisions.md 8 described the eliminated +2 correction until
session-069 and has been corrected.
A 1-bit field. It flags the case where the last instruction in a block is a call whose second half spills into the next block. The RAS return address depends on where the call actually ends, so the bit signals that a straddle correction applies.
The bit is kept because an instruction straddling a block boundary cannot be guaranteed not to happen. The straddle correction itself is part of the fallthrough / pftAddr arithmetic (section 4.4), computed at RTL/doc time -- it is not a separate stored width. The bit is the only added storage.
7. Confidence Direction and Fast-Path¶
FTB carries a 3-bit saturating BIMODAL DIRECTION counter (conf) per conditional branch. Its MSB is FTB's predicted direction; FTB always submits a direction for a valid conditional. This is a multi-predictor interaction and is specified separately in ftb_confidence_override_rules.md. Summary:
- conf MSB = FTB direction: ftb_brI_taken_p2 = ftb_brI_valid_p2 & conf_brI[MSB].
- Trains bimodally at execute on the resolved OUTCOME (taken -> increment, not-taken -> decrement, saturating), per field br0/br1.
- Fast-path (ftb_fastpath_en = 1 AND conf saturated, i.e. 111 or 000): FTB commits its direction at p2 and skips the TAGE/SC wait, ignoring the TAGE/SC direction override for that branch -- saving the p3 SC wait cycle (1.1). Output is ftb_fastpath_p2 (2-bit, bit0 br0, bit1 br1).
- Otherwise (en=0 or conf unsaturated): FTB waits for TAGE/SC and is overridden as normal -- ordinary BTB behavior under the longer-history predictors.
- Target overrides (ITTAGE/RAS) are never affected by conf.
- A wrong fast-path commit steps conf out of saturation, disabling the fast-path until it re-saturates (self-correcting).
- TAGE/SC are still requested and trained under fast-path; the fast-path suppresses USE, not training (a bp_cluster obligation, FTB-2).
There is no suppression threshold and no always_taken bit; both were removed (session-053). See ftb_confidence_override_rules.md for the full policy.
8. Parameters¶
Defined in bp_defines_pkg.sv. Do not use numeric literals for these.
VA_WIDTH = 41 ruled session-070, FE-19; the
package still says 40, TD#122.
FTB_WAYS = 4 set-associative (package fixed to 4 in
BP-065; an earlier draft annotation read
"currently 8" -- stale, struck).
FTB_ENTRIES = 2048 total, single array.
FTB_SETS = 512 FTB_ENTRIES / FTB_WAYS.
FTB_IDX_BITS = 9 $clog2(FTB_SETS).
FTB_WAY_BITS = 2 $clog2(FTB_WAYS). Encoded carried
writeWay (5.1).
FTB_BLOCK_BYTES = 32 FTB prediction block (16 positions).
FTB_OFFSET_BITS = 5 $clog2(FTB_BLOCK_BYTES).
FTB_RTAG_BITS = 26 PINNED, NOT DERIVED (4.1, TD#122).
The region tag VA[39:14]; bit 40
aliases, a misprediction, not a fault.
It was FTB_TAG_BITS until BP-140.
FTB_TAG_BITS = 30 FTB_RTAG_BITS + FTB_BR_POS_BITS: the
region tag and the start offset VA[4:1]
(BP-140, 4.1).
FTB_SOFF_SHIFT = 5 FTB_IDX_BITS - FTB_BR_POS_BITS. The
index is VA[13:5] XOR (VA[4:1] <<
FTB_SOFF_SHIFT) (BP-140, PROVISIONAL).
PLRU_BITS = 3 FTB_WAYS - 1 (tree-PLRU). Stored in
ftb_plru.
FTB_BR_POS_BITS = 4 $clog2(FTB_BLOCK_BYTES/2). In-block
position, sixteen 2-byte positions
(BP-099, 2026-08-19). START-relative;
the width of every position PORT.
FTB_BR_TGT_BITS = 13 conditional target displacement. B-type
+/-4 KB original -> +/-8 KB expanded.
FTB_JMP_TGT_BITS = 21 jump target displacement. J-type
+/-1 MB original -> +/-2 MB expanded.
TAR_STAT_BITS = 2 fit / overflow / underflow status,
shared by conditional and jump targets.
PFTADDR_BITS = 5 FTB_BR_POS_BITS + 1. The stored block
end as a 2-byte-granular offset from the
BLOCK START, covering 0 to 62 bytes
(an end needs at most 34) (5.5, 8.1).
No carry bit. Six bits from the region
base until BP-140.
Logical entry width (the full per-way entry, including the entry-valid held in ftb_plru):
FTB_ENTRY_WIDTH (logical, per way) = 114 bits:
1 valid -- held in ftb_plru (flops), not ftb_array
+ 30 tag -- 26 region tag + 4 start offset
+ 2 * (1 + 4 + 13 + 2 + 3) = 46 br0 + br1 (valid,pos,tgt,
stat,conf -- no always_taken)
+ (1 + 4 + 21 + 2 + 3 + 1) = 32 jump (valid,pos,tgt,stat,type,
rvc)
+ 5 = 5 pftAddr (from the start, no
carry bit)
FTB_SET_WIDTH = FTB_WAYS * FTB_ENTRY_WIDTH = 456 bits (logical).
THE BP-140 DELTA IS ZERO, 114 to 114: the tag gains the four start- offset bits and the three positions and pftAddr each lose one (no region form, 4.6). FTB_RAM_ENTRY_WIDTH stays 113; the elaboration check in ftb_cntrl holds.
THE BP-121 DELTA IS ONE BIT, 113 to 114: the jump field's rvc bit (5.5, TD#164). In bp_defines_pkg.sv the jump term went from TAR_STAT_BITS + 3 to TAR_STAT_BITS + 4. The FTB lint and simulation targets passed in BP-121's regression; BP-121 does not mention the elaboration check itself. Recorded session-076.
The session-071 delta is three bits, 110 to 113, one each on the stored br0, br1 and jump positions, which widen from FTB_BR_POS_BITS to FTB_BR_RPOS_BITS (4.6). pftAddr is unaffected. BUILT by BP-110: the package elaborates at 113 / 112, and ftb_cntrl carries an elaboration check that $bits(ftb_entry_t) == FTB_RAM_ENTRY_WIDTH.
THIS BLOCK IS THE SOLE HOME OF THE ENTRY ARITHMETIC. Nothing else in the tree restates it; FTB-1 and section 10 cite it. That rule exists because BP-099 changed one parameter and the consequence landed in four places, of which two were corrected and two were not, leaving three different widths in circulation until session-069.
The BP-099 delta is four bits, 106 to 110, one each on br0.pos, br1.pos, jump.pos and pftAddr. Three position fields, not four. The older 108 in the session-065 history entry predates the always_taken removal of session-053 and is correct for its date.
RAM entry width (what ftb_array actually stores -- the logical entry minus the relocated entry-valid):
FTB_RAM_ENTRY_WIDTH = FTB_ENTRY_WIDTH - 1 = 113 bits/way.
The br0/br1/jump FIELD-valid bits remain in the RAM entry; only the
ENTRY-level valid moves to ftb_plru.
FTB_RAM_SET_WIDTH = FTB_WAYS * FTB_RAM_ENTRY_WIDTH = 452 bits.
ftb_array is sized at FTB_RAM_* (data only). ftb_plru holds, per set, FTB_WAYS entry-valid bits + PLRU_BITS tree-PLRU bits = 7 bits (512 sets x 7 = 3584 flops). FTB_ENTRY_WIDTH / FTB_SET_WIDTH remain the LOGICAL widths; FTB-1 / IC-FTB-08 reconcile to the new width (always_taken removed, session-053) -- the width is settled, not open.
Confidence parameters (see ftb_confidence_override_rules.md):
FTB_CONF_WIDTH = 3 bimodal direction counter; MSB = dir.
FTB_CONF_INIT_TKN = 3'b100 allocate value, branch resolved taken
(weakly taken, MSB=1, unsaturated).
FTB_CONF_INIT_NTK = 3'b011 allocate value, branch resolved
not-taken (weakly not-taken, MSB=0,
unsaturated).
Invariant: both init values unsaturated (TKN != '1, NTK != '0) with
MSB matching the direction. A fresh entry cannot fast-path on first
use. (FTB_CONF_SUPPRESS_THRESH removed -- fast-path eligibility is the
saturated endpoints, not a threshold.)
FETCH_BLOCK_BYTES = 64 is a global / fetch-unit parameter, already in bp_defines_pkg.sv. It is NOT an FTB parameter; it is the fetch block, the L1I line the IFU reads (2.3). This read "the fetch width". Session-071.
Control polarity: ftb_array and ftb_plru enables are active low (rd_en_n, wr_en_n, val_we_n, plru_we_n), per the BPU array convention (IC-FTB-13). ftb_array has no reset; ftb_plru rstn clears valid + PLRU.
8.1 Partial fall-through address derivation¶
pftAddr = partial fall-through address. It is the block's end stored as a short 2-byte-granular offset from the BLOCK START (since BP-140; the 32-byte-aligned region base before it). The full fall-through reconstructs from the start plus pftAddr shifted by POS_OFFSET_BITS, and the result is bounds checked; see 4.5.
PFTADDR_BITS = FTB_BR_POS_BITS + 1
The maximum it must represent is a full block plus a straddling halfword: FTB_BLOCK_BYTES + 2 = 34 bytes = 17 positions, which five bits hold.
9. Open Items¶
FTB-1: CLOSED (session-052; reconciled session-053). All offset,
target and pftAddr widths are ruled and listed in
SECTION 8, WHICH IS THE SOLE HOME OF THE ARITHMETIC. The
numbers are not restated here: this entry carried them
until session-069 and went stale after BP-099, which is
the reason for the single-home rule. The storage split
partitions the logical entry into FTB_RAM_ENTRY_WIDTH
(ftb_array) + 1 valid (ftb_plru). The
width is settled, not open. (Historical: last_may_be_rvi_call
was eliminated; no straddle correction exists.)
FTB-5: CLOSED by BP-121 (session-075), recorded session-076.
Three defects found by BP-120, each ruled by Jeff during
BP-121's run and built in it:
TD#162 (2.4, IC-FTB-09). An update borrows the read port
and the prediction lookup of that cycle was dropped, so
after a backend redirect the redirect target's block got
no p2 classification and no RAS operation. RULED: hold p0
in the cycle before an FTB update issues (ftq_decisions.md
4.5 H4). One p0 bubble per FTB update. The IA recommended
this option and counted it as the PA's FTB-5
recommendation, which read "retry the dropped lookup the
next cycle (p0 stalls one cycle)".
TD#163 (5.1, IC-FTB-10). RULED: the carried way is checked
in both directions (5.1). The PA had recommended the
stale-miss half only.
TD#164 (IC-FTB-03). RULED: an rvc bit in the jump field
and is_rvc in the backend resolution; the RAS push and the
fall-through of a block ending at its jump are the jump PC
plus 2 or 4 (5.5, section 8). As the PA recommended.
FTB-6: TD#179, BP-140 (2026-10-19). Built: per-start FTB and
uBTB entries (4.1, 4.6 replaced) and the split at update
(section 3), the uBTB on the same rule. Open: the entry
shape (2 + 1 leaves fields unused under the split, section
4); training at resolve against commit; per-start occupancy
on compiled benchmarks (tb_fe_top uses at most 38 FTB
entries per program); the index fold and the end rule are
PROVISIONAL.
FTB-2: Confidence-override interaction with the TAGE update/meta
path. Flagged, not yet analyzed. Resolve at bp_cluster
integration.
FTB-3: CLOSED. Update channel arbitration (G9). FTB exposes one
update port; how multiple resolved branches are scheduled
onto it was a cluster/FTQ concern and the FTQ has decided
it: ftq_decisions.md 5.7, BUILT as ftq_ftb_sched (BP-100).
ftb_interfaces.md IC-FTB-09 and PROJECT_STATUS G9 both
record it decided. This read "resolved at bp_cluster
integration" as though still pending. Session-070.
FTB-4: CLOSED (session-053). The in-block position field
(FTB_BR_POS_BITS per branch) was stored but had no producer or
consumer -- a spec omission carried since the entry format was
written and missed by the session-052 width close (which
audited stored bits, not field-to-port linkage). BP-066
surfaced it by storing pos=0. Resolved by adding ftb_upd_pos_u0
(producer) and ftb_brI_pos_p2 / ftb_jmp_pos_p2 (consumers); see
IC-FTB-15. No width change. RTL wired in BP-066b. Standing rule
from this: a stored field is not settled until it has a named
producer and consumer, not just a width.
10. Interactions With Other Planning Documents¶
ftb_interfaces.md -- FTB module interface contract. Port list,
timing, producer/consumer obligations.
Sections 3 (ftb_array) and 3a (ftb_plru) carry
the storage-module ports; IC-FTB-12/13/14 carry
the storage-split invariants.
ftb_confidence_override_rules.md
-- conf as a bimodal direction counter, bimodal
training, the saturated-endpoint fast-path, and
ftb_fastpath_en.
bp_cluster.md -- pipeline staging, override chain, FTQ entry
contents, decoupled frontend.
ras_decisions.md -- RAS pushes the jump PC plus 2 or 4 (5.5),
which the cluster drives on
ras_fall_through; FTB jump target is the RAS
fallback when RAS is empty.
ittage -- FTB jump target is the ITTAGE-miss fallback
(no IT0 base table).
bp_defines_pkg.sv -- FTB_WAYS, FTB_ENTRIES, FTB_SETS, FTB_IDX_BITS,
FTB_WAY_BITS, FTB_BLOCK_BYTES, FTB_OFFSET_BITS,
FTB_RTAG_BITS, FTB_TAG_BITS, FTB_SOFF_SHIFT,
PFTADDR_BITS, PLRU_BITS, FTB_ENTRY_WIDTH and
FTB_SET_WIDTH (logical), FTB_RAM_ENTRY_WIDTH
and FTB_RAM_SET_WIDTH (ftb_array),
FTB_CONF_WIDTH, FTB_CONF_INIT_TKN,
FTB_CONF_INIT_NTK.
11. Document History¶
2026-10-08 session-076, PA-direct correction recording BP-121.
4.6 R-1: a field past the start's visible jump is
hidden (D4); 4.6 kept (TD#168). 5.1: the carried
hit/miss checked both ways (TD#163). 5.5: the jump
field's rvc bit; the RAS push and the jump block's
fall-through are the jump PC plus 2 or 4; the update
carries the resolved block end (TD#164). 6: the
pftAddr return-address claim superseded. 8: entry
113 -> 114, RAM entry 112 -> 113, sets 452 -> 456 and
448 -> 452. 9: FTB-5 closed, with the recommendation
history. 4: stale 112 and 113
removed from prose.
2026-10-08 session-075, after BP-120. 5.5: built, with the field
mapping order and the coro measurement. Defects found
by BP-120 recorded in section 9: TD#162, TD#163,
TD#164, TD#168.
2026-10-07 session-075, after BP-119. 5.5: a filled field
keeps its position only for the same branch; a
different position rewrites the jump field or is a
new conditional (ruled, Jeff). TD#156, BP-120.
2026-09-22 session-073, after BP-111. 4.2: the jump target is
built from the jump PC; TD#137 closed. The reach
window is the only observable difference and tb_ftb
J2 pins it.
2026-09-22 session-073, after BP-110. 5.5, 4.5, 4.6 and section 8
record what is BUILT: six-bit pftAddr with no carry,
region-relative stored positions at 113/112, FTB-G1
and FTB-G3, O-1 for conditionals, O-3a and O-3b. 4.5
records that FTB-G1 had never been built despite
session-069 recording it restored. 5.4a restated on
region position (O-3c). 4.2: O-1 extended to the jump
target by Jeff -- every target is a displacement from
its own instruction. BP-111 built it the same day;
TD#137 closed. The uBTB
divergence is ruled and stated in 4.6.
2026-09-22 session-073. 4.6 O-1 and O-2 RULED by Jeff as
proposed: the conditional target base is the branch
PC, and FTB-G3 bounds the reconstructed end at
start + FTB_BLOCK_BYTES + 2. 4.2 and 4.4 updated
where they called O-1 open. O-3 stays open and now
carries the PA's three-part proposal (O-3a storage
in region order, O-3b the read compacts onto the
ports, O-3c 5.4a restated on region position).
2026-09-22 session-073. 4.6 O-3 RULED by Jeff as proposed, all
three parts. Every open item under 4.6 is now
closed; TD#125 carries the RTL and the 5.4a and
IC-FTB-16 amendments.
Entries below that were written before session-072 use the
retired s-stage labels in their text. s0=p0, s1=p1, s2=p2,
s3=p3 (PROJECT_CORE.md); the labels are not live stage names.
2026-06-24 session-051/052. Initial draft, expanded from
ftb_decision_record.md. Single-array structure
(one lookup per cycle, one entry per block, 2+1 fields).
4-way / 2048 entries / 32-byte block / 26-bit full tag /
tree-PLRU. Confidence override split to its own document.
Jump target full width as the ITTAGE-miss / RAS-empty
fallback.
Decision changed: this
last_may_be_rvi_call kept.
is now this:
last_may_be_rvi_call eliminated.
2026-06-24 session-052 (later pass). Update-side way selection
ruled: writeWay and hit carried from the prediction read
through the FTQ, no update-side re-lookup (5.1, 5.3),
matching Xiangshan. FTB_WAY_BITS added. Fallthrough
reconstruction error check (Xiangshan fallThroughErr)
ruled OUT: the full tag makes wrong-entry hits
unreachable, and FTB is not made defensive against its
own corrupt state (4.5). Restore guard recorded: any
reinstated fallback is start + FTB_BLOCK_BYTES, never
start + FetchWidth*4. pftAddr/carry write rule added to
5.4 (allocate) and 5.5 (boundary-move recompute).
2026-06-24 session-052 (widths pass). Entry widths ruled and FTB-1
closed. FTB_BR_POS_BITS=3 (in-block position, expanded
granularity). FTB_BR_TGT_BITS=13 and FTB_JMP_TGT_BITS=21
(target displacements from ISA reach in the expanded
address space; jump moved from full-width to 21+status).
TAR_STAT_BITS=2 shared by conditional and jump targets.
4.4 corrected: the blanket "do not inherit Xiangshan
BR_OFFSET_LEN/JMP_OFFSET_LEN" was too broad -- it
excludes in-block position/pftAddr (granularity) but the
target displacement widths derive from ISA reach and do
transfer. Full-to-partial fallthrough reduction
arithmetic added to 5.5. ENTRY_WIDTH = 108 bits/way,
SET_WIDTH = 432, fully determined.
2026-06-25 session-053. Storage split for SRAM migration. Entry-
valid and tree-PLRU state moved out of the data array
into a new ftb_plru flop module (2.4); ftb_array reduced
to pure 1R1W data RAM, no reset, FTB_RAM_ENTRY_WIDTH=107 /
FTB_RAM_SET_WIDTH=428 (8). ftb_plru reset clears the
entry-valid bits -- the FTB cold init, no sram_init
(unlike TAGE/ITTAGE). PLRU victim/next-state compute and
way-match stay in ftb_cntrl; ftb_plru and ftb_array are
storage only. Storage-module enables made active low
(BPU convention). Both storage modules read-old-on-
collision for a coherent prediction snapshot. Edits in
2.1, 2.4, 4 (storage partition note), 5.1, 5.3, 5.4, 8,
10. Logical entry unchanged at 108; FTB-1 stays closed.
Stale "FTB_WAYS currently 8" annotation struck (package
confirmed 4 in BP-065). Companion: ftb_interfaces.md
sections 3/3a and IC-FTB-12/13/14. RTL finalized in
BP-065a.
2026-06-25 session-053 (confidence redefine). conf is now a BIMODAL
DIRECTION counter (MSB = direction); FTB always submits a
direction. always_taken bit REMOVED (conf is the sole
direction state): each conditional field drops 1 bit, so
logical entry 108 -> 106, FTB_RAM_ENTRY_WIDTH 107 -> 105,
FTB_RAM_SET_WIDTH 428 -> 420. Threshold suppression
replaced by a saturated-endpoint FAST-PATH gated by
ftb_fastpath_en (renamed from the chicken bit; 1 enables
the bypass): at conf 111/000 with en=1, FTB commits its
direction at s2 and skips the TAGE/SC wait/override for
that branch (saves the s3 SC cycle). conf trains bimodally
on the resolved outcome (FTB_CONF_SUPPRESS_THRESH and the
ftb_upd_ftb_dir_u0 input removed). Allocate sets conf weak
in the observed direction (FTB_CONF_INIT_TKN=3'b100 /
FTB_CONF_INIT_NTK=3'b011). Output ftb_suppress_dir_p2
renamed ftb_fastpath_p2; ftb_brI_always_taken_p2 output
removed. Edits: 4 (entry), 4.3 (now conf direction), 4.6
deleted, 5.1, 5.4, 5.5, 7, 8, 9, 10. Companion:
ftb_confidence_override_rules.md rewritten;
ftb_interfaces.md port/width deltas. RTL fix: BP-066a.
2026-06-25 session-053 (superseded note). An interim 4.6
"present implies taken" ratification was entered earlier
this session and then REVERSED: conf is a bimodal
direction counter (both directions), not taken-only, so
4.6 was deleted and the confidence mechanism redefined per
the entry above. Recorded so the reversal is not lost.
2026-06-25 session-053 (position fix, FTB-4). In-block position
(FTB_BR_POS_BITS per branch) was a stored field with no
producer or consumer -- BP-066 stored it as 0. Sourced via
ftb_upd_pos_u0 and sunk via ftb_brI_pos_p2 / ftb_jmp_pos_p2
(ftb_interfaces.md 2.3/2.5, IC-FTB-15). The entry-format
field name "offset" (which collided with the target-offset
term) renamed "position" in 4. Position is static per
filled field (written at allocate/free-field, not on
in-place update). No width change. FTB-4 closed. RTL:
BP-066b.
2026-06-25 session-053 (RTL + verification complete). FTB built and
verified; STATUS promoted DRAFT -> COMPLETE. Bringup:
ftb_array (BP-065), storage split finalize + ftb_plru
(BP-065a), ftb_cntrl (BP-066), ftb structural top
(BP-067), conf/fast-path redefine RTL fix (BP-066a),
position source/sink (BP-066b), tb_ftb + sim_ftb (BP-068).
sim_ftb 99/0; full bpu suite green, no TAGE/ITTAGE/RAS
regression. Open items FTB-2 (conf x TAGE meta) and FTB-3
(update-channel arbitration / G9) remain deferred to
bp_cluster, consistent with the TAGE/ITTAGE pattern; they
do not block COMPLETE. Decisions are settled; remaining FTB
work is downstream at cluster integration.
2026-08-19 FTB_BR_POS_BITS 3 -> 4 and PFTADDR_BITS 4 -> 5:
in-block positions are now 2-byte granular, sixteen
per 32-byte block, so a branch at any RVA23 C-extension
boundary has its own position. Entry 106 -> 110 bits
per way, set 424 -> 440, array 217,088 -> 225,280.
Nothing was restructured: every width derives from
$clog2(FTB_BLOCK_BYTES / N), and BP-098 had already
split the granularity shift out of INST_OFFSET so
POS_OFFSET_BITS rescaled 2 -> 1 on its own. Section
4.4's "8 expanded instructions" model is retired.
All 47 bpu targets green; only sim_bp_cluster's count
moved, 997 -> 1765, because its position sweep now
covers 16x16 pairs instead of 8x8.
2026-09-15 session-069. 4.5 RESTORED the fall-through bounds
check removed earlier. 4.1 qualified: the full tag
removes partial-tag aliasing but FTB_OFFSET_BITS of 5
are in neither index nor tag, and blocks are unaligned,
so two lookup PCs in one 32-byte region share an entry.
Stale BP-099 text corrected at 4.2, 4.4, 5.5, section 8
and FTB-1: FTB_BR_POS_BITS 4 not 3, PFTADDR_BITS 5 not
4, ENTRY_WIDTH 110 not 106, POS_OFFSET_BITS 1 not 2,
and 4.4 no longer claims expanded-granularity
addressing.
Section 8 ARITHMETIC corrected in the same pass and
declared the SOLE HOME of the entry widths. Its
header said 110 while its own breakdown summed to
106, and FTB_SET_WIDTH 424, FTB_RAM_ENTRY_WIDTH 105
and FTB_RAM_SET_WIDTH 420 were all 106-derived. Now
110 / 440 / 109 / 436, with the breakdown at
FTB_BR_POS_BITS 4 and PFTADDR_BITS 5. PFTADDR_BITS
added to the parameter list; it was cited in 5.5 and
defined nowhere. FTB-1 reduced to a citation.
The 2026-08-19 entry below already recorded 106->110
and 424->440 correctly. The body was never updated
to match, and the RAM widths were not in that entry
at all, which is why 105 and 420 survived. Three
different entry widths were in circulation until
this pass.
2026-09-19 session-071. 4.6 added: stored positions are
region-relative at FTB_BR_RPOS_BITS = 5 with a read
window mask, converted inside the FTB so every port
stays start-relative (ruled, Jeff, option R). Entry
110 -> 113, RAM entry 109 -> 112, sets 440 -> 452 and
436 -> 448 (section 8). Three consequences recorded
open under TD#125: target base, a fall-through upper
bound, slot mapping under the mask. 2.3 and 8: the
fetch block is the L1I line, not a fetch width, and
nothing is delivered into the FTQ but predictions.
2026-09-20 session-072. 4.4: TD#89 and TD#90 recorded as proposed
fields, not ruled and not in the entry arithmetic.
A stray code fence in 2.2 that turned sections 2.2
to 10 into one code block, and one that split this
history, removed.
2026-09-20 session-072. 4.4: RVC expansion is in the IFU,
downstream of the FTB; this read "before the FTB".
2026-09-20 session-072. D5: the local stage-notation rule is
replaced by PROJECT_CORE's p-stage rule and the
narrative s2/s3 swept to p2/p3. D4: the unaligned-block
citation moved from ftq_decisions.md 4.4 to 4.7.
2026-09-20 session-072. E22: Document History sorted into date order;
newer entries had been appended at the wrong end.
2026-09-20 session-072. D29: the history section notes that older
entries use the retired s-labels.
2026-10-12 session-078, after BP-131. Section 3: the split is not
built at either slot count; BP-131's measurement
recorded; deferred to TD#179 (Jeff).
2026-10-17 session-081, after BP-138. 3: a jump behind as many
conditionals as slots ends the block at the jump PC.
2026-10-19 session-081, after BP-139. 3: the cut for any branch the
FTB reports and no slot carries (option A).
2026-10-19 session-081, after BP-140. 3: the split at update, built.
4: unused fields under the split. 4.1: the tag
identifies the block start. 4.5, 4.6: the per-start
entry replaces region sharing (Jeff reopened 4.6).
5.4a, 5.5: the field mapping and the end under the
split. 8: parameters. 9: FTB-6. Provisional choices
accepted (Jeff).
ftb_confidence_override_rules.md
planning/arch/ftb_confidence_override_rules.md on GitHub
FTB Confidence Direction and Fast-Path Rules¶
FILE: planning/arch/ftb_confidence_override_rules.md
SOURCE: session-051/052/053
STATUS: DRAFT
UPDATED: 2026-10-09
CONTACT: Jeff Nye
Policy document for the FTB per-branch confidence counter (conf) and its role as a bimodal DIRECTION predictor plus the fast-path that lets a high-certainty FTB direction skip the TAGE/SC wait. Canonical authority is ftb_decisions.md. This document governs the conf mechanism only.
Single-array reminder: FTB is one data array, one lookup per cycle, one entry per block. The two conditional fields br0 and br1 both come from that one entry (ftb_decisions.md 2.1). This document refers to br0 and br1, never to slot-0 / slot-1.
Field note: the entry no longer carries an always_taken bit -- it was removed (session-053). conf is the sole per-branch direction state.
1. Purpose¶
conf is a per-branch BIMODAL DIRECTION counter. Its MSB is FTB's predicted direction for that conditional; its magnitude is the strength of that prediction. FTB always submits a direction for every valid conditional.
When conf is SATURATED (all-ones or all-zeros) and the fast-path is enabled, FTB commits its own direction at p2 and does NOT wait for TAGE/SC, ignoring any TAGE/SC direction difference for that branch. This saves the cycle that waiting for the p3 SC response would cost (ftb_decisions.md 1.1). When conf is not saturated, or the fast-path is disabled, FTB waits for TAGE/SC and is overridden as normal -- ordinary BTB-like behavior.
conf never affects TARGET overrides. ITTAGE and RAS target overrides are independent of this mechanism.
2. Counter Structure (C1)¶
conf[FTB_CONF_WIDTH-1:0] 3-bit saturating bimodal counter
(FTB_CONF_WIDTH = 3) per conditional branch field.
States 000 (strongly not-taken) .. 111 (strongly
taken). One conf field per conditional field (br0,
br1); two conf fields per entry.
Direction = conf[FTB_CONF_WIDTH-1] (the MSB).
1 = predict taken, 0 = predict not-taken.
Strength = distance from the midpoint. 111 / 000 are the two
saturated (maximum-certainty) states.
conf is exposed at p2 on ftb_br0_conf_p2 / ftb_br1_conf_p2 (ftb_interfaces.md 2.3).
3. Direction and Training (C2, C9)¶
3.1 FTB direction is the conf MSB¶
For a valid conditional, FTB's predicted direction is the conf MSB:
ftb_brI_taken_p2 = ftb_brI_valid_p2 & conf_brI[FTB_CONF_WIDTH-1]
This is FTB's submitted direction whether or not the fast-path fires.
3.2 Train at execute; bimodal toward the resolved outcome (C9)¶
Training fires when a conditional branch resolves at execute, per field br0/br1 INDEPENDENTLY, each only when its own branch resolves. A field read in the prediction but not reached on the executed path does not train (control left the block first).
The update is the conventional bimodal counter step, driven by the RESOLVED OUTCOME (ftb_upd_taken_u0), saturating:
resolved taken : conf = (conf == '1) ? conf : conf + 1
resolved not-taken : conf = (conf == '0) ? conf : conf - 1
Training is on the OUTCOME, not on whether FTB's prediction was used or was correct. No ftb_upd_ftb_dir_u0 input is required (removed). The counter is a pure bimodal observer of the branch's direction history.
3.3 Training is independent of the fast-path and of TAGE/SC use¶
conf trains on every resolution regardless of ftb_fastpath_en and regardless of whether the fast-path fired or TAGE/SC overrode. This is what makes the fast-path self-correcting (3.4).
3.4 Self-correction at the saturated endpoints¶
A saturated entry that mispredicts steps OUT of saturation on that resolve (111 -> 110 on a not-taken outcome, 000 -> 001 on a taken outcome). The fast-path (section 4) then stops firing for that branch until conf re-saturates. A single wrong outcome ends the fast-path eligibility; the branch must re-earn saturation. This bounds the cost of a wrong fast-path commit to its own misprediction plus recovery.
4. Fast-Path (C3, C4)¶
4.1 Condition¶
For each conditional branch i in {0 = br0, 1 = br1}, the fast-path fires when:
ftb_valid_p2 AND ftb_brI_valid_p2 AND ftb_fastpath_en
AND (conf_brI == '1 OR conf_brI == '0) -- saturated
The two saturated states are the only fast-path-eligible states. A fresh or flapping entry is mid-range and never fast-paths (section 7).
4.2 Effect¶
When the fast-path fires for branch i:
- FTB commits its own direction (conf MSB) at p2 for that branch.
- FTB does NOT wait for the p3 SC response -- this is the saved cycle.
- Any TAGE or SC DIRECTION difference for that branch is ignored; no
TAGE/SC direction override is applied.
- TARGET overrides (ITTAGE / RAS) are unaffected and proceed normally.
The fast-path output is ftb_fastpath_p2, a 2-bit vector: bit 0 = br0, bit 1 = br1 (ftb_interfaces.md 2.4). It tells the cluster override logic "FTB direction stands for this branch; do not apply a TAGE/SC direction override and do not stall for SC."
4.3 Not firing¶
When ftb_fastpath_en = 0, or conf is not saturated, the fast-path does not fire: FTB submits its direction (3.1) but waits for TAGE/SC and is overridden as normal. The priority is the standard chain LP (trusted) > SC > TAGE > FTB on direction.
THE LOOP PREDICTOR TERM, since BP-122 (ruled session-076, fe_decisions.md 3.3). A trusted p2 loop direction is the slot's direction at p2, over TAGE, and SC does not override it at p3. As BP-122 reports the build, the trusted LP direction is the slot's direction at p2 without qualification, so it also stands over an FTB fast-path direction for that branch.
5. ftb_fastpath_en (C6)¶
ftb_fastpath_en 1-bit global enable for the fast-path.
= 1 : fast-path active per section 4 (saturated conf may bypass the
TAGE/SC wait/override).
= 0 : fast-path disabled. FTB always waits for TAGE/SC and is
overridable as normal -- FTB behaves as an ordinary BTB-like
structure under the longer-history predictors.
Naming note: this is the inverse-sense of a classic "chicken bit." Here the 1 state ENABLES the optimization (the bypass); the 0 state is the safe, always-overridable mode. Source is TBD at bp_cluster integration (CSR, static tie, or runtime). It gates the bypass only -- it does NOT gate conf training (section 3.3) or TAGE/SC training (section 6).
6. TAGE/SC still requested and trained (C5)¶
Even when the fast-path fires and FTB ignores the TAGE/SC direction, TAGE/SC are still REQUESTED for that branch and still UPDATED/trained later. The fast-path suppresses the USE of the TAGE/SC direction, not its prediction or its training. Skipping the training would let TAGE/SC go cold exactly on the branches FTB currently fast-paths, so they could never re-take a branch whose behavior changes.
This is a cluster/FTQ obligation: the override-resolution and update paths must keep the TAGE/SC predict+update alive when FTB fast-paths. Resolved at bp_cluster integration (ftb_decisions.md FTB-2).
7. Parameters and Reset/Allocation (C8)¶
FTB_CONF_WIDTH Counter width. 3 bits, states 0-7.
FTB_CONF_INIT_TKN Allocate value when the branch allocated TAKEN.
Default 3'b100 (weakly taken: MSB=1, unsaturated).
FTB_CONF_INIT_NTK Allocate value when the branch allocated
NOT-TAKEN. Default 3'b011 (weakly not-taken:
MSB=0, unsaturated).
On entry allocation, conf for the resolved conditional is set weak in
the OBSERVED direction:
conf = ftb_upd_taken_u0 ? FTB_CONF_INIT_TKN : FTB_CONF_INIT_NTK
This carries the correct first direction (the MSB matches the observed
outcome) at minimum strength.
Invariant (assert in RTL and tb):
FTB_CONF_INIT_TKN is not saturated (!= '1) and MSB = 1
FTB_CONF_INIT_NTK is not saturated (!= '0) and MSB = 0
A fresh entry must start unsaturated so it cannot fast-path on first
use; it must earn saturation through repeated same-direction
outcomes.
There is no suppression threshold. The previous FTB_CONF_SUPPRESS_THRESH parameter and the threshold-compare are removed; fast-path eligibility is the two saturated endpoints only.
Reallocation overwrites conf with the weak init for the new branch's observed direction, so a reallocated entry never carries the previous branch's conf.
FTB_CONF_INIT_TKN and FTB_CONF_INIT_NTK ARE IN bp_defines_pkg.sv, added by BP-065/065a/066a and listed with their values in ftb_decisions.md 8. This asked for them to be added "at RTL task time". Session-072.
8. Interaction Summary¶
| Condition | Direction used |
|---|---|
| FTB miss (ftb_valid_p2=0) | Upstream (uBTB/loop) |
| FTB hit, en=1, conf saturated (111 or 000) | FTB (fast-path, |
| conf MSB, no wait) | |
| FTB hit, en=1, conf not saturated | TAGE/SC (override |
| as normal) | |
| FTB hit, en=0 (any conf) | TAGE/SC (override |
| as normal) | |
| Trusted p2 loop prediction (any of the | LP (BP-122, 4.3) |
| above) |
The table is per conditional branch (br0 and br1 evaluate independently). FTB always SUBMITS a direction (conf MSB); the table is about whose direction is USED. Target prediction source is never affected; ITTAGE/RAS target overrides proceed independently.
9. Verification Notes¶
Tests must cover:
- conf direction = MSB: predict taken when MSB=1, not-taken when
MSB=0, for a valid conditional.
- Bimodal training: taken outcome increments (saturates at 111),
not-taken outcome decrements (saturates at 000).
- Training fires on the outcome regardless of fast-path or whether
TAGE/SC would override; per-field br0/br1 independence; a field not
reached on the executed path does not train.
- Self-correction: a saturated entry that mispredicts steps out of
saturation (111->110, 000->001) and stops fast-pathing until it
re-saturates.
- Fast-path fires only when ftb_fastpath_en=1 AND conf saturated AND
ftb_brI_valid_p2 AND ftb_valid_p2; ftb_fastpath_p2[i] asserted.
- Fast-path does NOT fire when ftb_fastpath_en=0, even at a saturated
conf.
- Fast-path does NOT fire at an unsaturated conf, even with
ftb_fastpath_en=1.
- Allocate sets conf weak in the observed direction (TKN->100,
NTK->011); a fresh entry does not fast-path on first use.
- Reallocation resets conf to the new branch's weak init.
- Target overrides (ITTAGE, RAS) are not affected at any conf value.
- Invariants: FTB_CONF_INIT_TKN unsaturated with MSB=1;
FTB_CONF_INIT_NTK unsaturated with MSB=0.
10. Open Items¶
- Fast-path interaction with the TAGE update/meta path, and the
obligation to keep TAGE/SC predict+update alive under fast-path
(section 6): flagged, resolve at bp_cluster integration
(ftb_decisions.md FTB-2).
- ftb_fastpath_en source: CSR, static tie, or runtime signal. TBD at
bp_cluster integration.
- TD #80: conf hysteresis sweep. FTB_CONF_WIDTH is the knob if the
3-bit bimodal hysteresis proves wrong under SPEC; widen, or disable
the fast-path via ftb_fastpath_en. Width/policy sweep, not a
format change.
11. Document History¶
Entries below that were written before session-072 use the
retired s-stage labels in their text. s0=p0, s1=p1, s2=p2,
s3=p3 (PROJECT_CORE.md); the labels are not live stage names.
2026-06-24 session-052. Regenerated from the session-051 draft for
the single-array correction (slot-0/slot-1 framing
removed, ftb_suppress_dir_p2 2-bit output, signal names
aligned, STATUS DRAFT).
2026-06-25 session-053. Mechanism redefined. conf is now a BIMODAL
DIRECTION counter (MSB = direction), not a one-directional
confidence/suppression counter. always_taken removed (conf
is the sole per-branch direction state). Threshold
suppression replaced by a SATURATED-endpoint FAST-PATH:
when ftb_fastpath_en=1 and conf is 111 or 000, FTB commits
its direction at s2, skips the SC wait, and ignores TAGE/SC
direction overrides for that branch (saving a cycle).
FTB_CONF_SUPPRESS_THRESH removed. FTB_CONF_INIT split into
FTB_CONF_INIT_TKN (3'b100) / FTB_CONF_INIT_NTK (3'b011),
allocate weak-in-observed-direction. chicken_bit_enable
renamed ftb_fastpath_en (inverse sense: 1 enables the
bypass). ftb_suppress_dir_p2 output renamed ftb_fastpath_p2.
Training is bimodal on the resolved outcome
(ftb_upd_taken_u0); ftb_upd_ftb_dir_u0 input removed. TAGE/
SC still requested and trained under fast-path (section 6).
Self-correction at the endpoints added (3.4).
2026-09-20 session-072. The local s-stage narrative swept to
p-stage (PROJECT_CORE). FTB_CONF_INIT_TKN / _NTK are
already in bp_defines_pkg.sv, not pending an RTL task.
2026-09-20 session-072. D29: the history section notes that
older entries use the retired s-labels.
2026-10-09 session-076, recording BP-122. 4.3 and 8: a trusted
loop prediction outranks SC, TAGE and FTB, including
the fast path as built (ruled; fe_decisions.md 3.3).
ftb_interfaces.md
planning/interfaces/ftb_interfaces.md on GitHub
FTB Interface Contracts¶
FILE: planning/interfaces/ftb_interfaces.md
SOURCE: ftb_decisions.md (canonical), session-051/052/053
STATUS: DRAFT
UPDATED: 2026-10-10
CONTACT: Jeff Nye
Interface contract for the FTB module. Derived from ftb_decisions.md, which is the canonical authority. Where this file and ftb_decisions.md disagree, ftb_decisions.md wins and this file is wrong.
Conventions:
- Stage notation: p0/p1/p2/p3 for prediction and u0/u1 for update,
in every document and in the RTL (PROJECT_CORE.md,
fe_decisions.md 12). This read that planning narrative uses
s-stage; PROJECT_CORE supersedes that. Session-072.
- FTB is a SINGLE data array, one lookup per cycle, one entry per
block. There are NO per-slot RAMs and NO NUM_PRED_SLOTS unpacking
on FTB ports. The cluster's two branches per cycle are br0 and br1
of the one indexed entry (ftb_decisions.md 2.1).
- TI6 per-slot RAMs is a TAGE/ITTAGE convention and does NOT
apply to FTB. The G8/G17 pred_pc+32 bundle split does not apply
either, AND NO LONGER EXISTS ANYWHERE: tage_interfaces.md TI3
has slot 1's PC supplied on tage_pred_inp_p0[1].pc and records
pred_pc+32 as an error that was removed. An earlier revision
called it a TAGE/ITTAGE convention, which pointed the reader at
something TAGE disowns. Corrected session-070; the FTB
conclusion is unchanged.
- Active-low reset: rstn. Rising-edge clock: clk. Storage-module
enables are active low (IC-FTB-13).
- VA_WIDTH = 41. All full-width addresses are [VA_WIDTH-1:0].
41 because H is mandatory through Sha and a V=1 vsatp.MODE=Bare
fetch PC is a 41-bit guest physical address (fe_decisions.md
FE-19). Was 40; TD#122 tracks the RTL.
- conf is a bimodal DIRECTION counter; its MSB is FTB's predicted
direction. There is no always_taken bit (removed session-053).
1. Module Hierarchy¶
ftb (top, structural only)
ftb_array (single 1R1W DATA array; one instance; pure RAM)
ftb_plru (entry-valid bits + tree-PLRU state; flops; resettable)
ftb_cntrl (read, branch-type classify, way-match using ftb_plru
valid AND ftb_array tag, block-boundary and fallthrough
compute, allocate/evict incl. PLRU victim and next-state,
valid set/clear, update field writes, conf bimodal
direction + fast-path)
See ftb_decisions.md section 2.4. The top is structural only. The two storage modules are discrete so a 1R1W SRAM macro can replace ftb_array without touching ftb_cntrl, and so all resettable state (valid, PLRU) lives in flops in ftb_plru. ftb_cntrl is the only logic. PLRU victim selection, next-state compute, and way-match live in ftb_cntrl, not in the storage modules (IC-FTB-12).
2. ftb Top Ports¶
2.1 Clock and reset¶
clk -- rising-edge clock
rstn -- active-low synchronous reset (to ftb_plru and
ftb_cntrl; ftb_array has no reset)
2.2 Prediction request (p0 in, registered p1)¶
input logic pred_valid_p0
-- 1 = prediction request valid this cycle.
input logic [VA_WIDTH-1:0] pred_pc_p0
-- block start PC. One PC. The single entry
covers the 32-byte block from this PC. No
slot-1 PC; FTB is not slot-split.
bp_cluster owns pipeline advance (p0 -> p1 -> p2). FTB registers the request internally; outputs in 2.3 are valid at p2.
2.3 Prediction outputs (to bp_cluster override logic, at p2)¶
One entry's worth of outputs. br0 and br1 are the two conditional fields of the one indexed entry, not two slots.
output logic ftb_valid_p2
-- 1 = FTB tag hit for this block.
-- carried for update (writeWay scheme, IC-FTB-10)
output logic ftb_hit_p2
-- 1 = tag hit, 0 = miss. Carried through the
FTQ to the update port as ftb_upd_hit_u0.
output logic [FTB_WAY_BITS-1:0] ftb_way_p2
-- predicted writeWay: the hit way on a hit,
or the tree-PLRU victim way on a miss.
Carried through the FTQ as ftb_upd_way_u0.
-- conditional branch 0
output logic ftb_br0_valid_p2
-- 1 = conditional field 0 is occupied.
output logic [FTB_BR_POS_BITS-1:0] ftb_br0_pos_p2
-- br0 in-block position: which 2-BYTE SLOT
(0..15) within the 32-byte block this
branch occupies, counted from the BLOCK
START, and stored so since BP-140
(one entry per start; region-relative
with a read window from session-071).
Used by the cluster/FTQ
to locate the taken branch in the bundle.
NOT to order br0 against br1 -- br0 is
always the earlier branch by fill order
(IC-FTB-16, ftb_decisions.md 4).
Written at allocate/free-field from
ftb_upd_pos_u0 (2.5); static while the
same branch holds the field (IC-FTB-15).
This read "static for the life of the
field"; session-075.
This entry read "which expanded-
instruction slot" and "order br0 vs br1".
BP-099 took positions to 2-byte
granularity and retired the
expanded-instruction model
(ftb_decisions.md 4.4 and 11).
Session-070.
output logic ftb_br0_taken_p2
-- FTB direction for br0 = conf MSB, qualified
by valid: ftb_br0_taken_p2 =
ftb_br0_valid_p2 & conf_br0[MSB]. 1 = taken.
output logic [FTB_CONF_WIDTH-1:0] ftb_br0_conf_p2
-- br0 bimodal direction counter value (MSB =
direction). Exposed for the cluster and for
observability.
output logic [VA_WIDTH-1:0] ftb_br0_target_p2
-- br0 taken target, reconstructed full width
by ftb_cntrl from the stored displacement
(4.2). Valid only when br0 taken.
-- conditional branch 1 (same fields as br0)
output logic ftb_br1_valid_p2
output logic [FTB_BR_POS_BITS-1:0] ftb_br1_pos_p2
output logic ftb_br1_taken_p2
output logic [FTB_CONF_WIDTH-1:0] ftb_br1_conf_p2
output logic [VA_WIDTH-1:0] ftb_br1_target_p2
(No ftb_brI_always_taken_p2 -- the always_taken bit was removed,
session-053; conf is the sole per-branch direction state.)
-- jump field (terminal: uncond jump / call / return)
output logic ftb_jmp_valid_p2
-- 1 = jump field occupied.
output logic [FTB_BR_POS_BITS-1:0] ftb_jmp_pos_p2
-- jump in-block position (0..15), same meaning
as the conditional positions. Written at
allocate from ftb_upd_pos_u0 (2.5), and
when a different jump of the region
rewrites the field (IC-FTB-01).
output logic [VA_WIDTH-1:0] ftb_jmp_target_p2
-- jump target, reconstructed full width by
ftb_cntrl from the stored 21-bit
displacement + status (FTB_JMP_TGT_BITS).
Architectural fallback for ITTAGE miss (no
IT0 base table) and RAS empty. Always
current regardless of whether ITTAGE or RAS
normally supplies the runtime target
(IC-FTB-01).
output logic ftb_is_call_p2
output logic ftb_is_ret_p2
output logic ftb_is_jalr_p2
-- jump type for this block. Gates JALR
ownership, RAS or ITTAGE, resolved by FTB
before p2 (ftb_decisions.md section 1).
The FTB is not a third arm: its target is
the ITTAGE-miss fallback, section 4.2.
An earlier revision said "three-way JALR
split (FTB / RAS / ITTAGE)".
output logic ftb_jmp_rvc_p2
-- 1 = the jump is a compressed instruction (2
bytes), 0 = 4 bytes. The cluster forms the
RAS push and the fall-through of a block
ending at its jump as the jump PC plus 2 or
4 (IC-FTB-03, ftb_decisions.md 5.5). Added
by BP-121 (TD#164).
-- fallthrough (block end)
output logic [VA_WIDTH-1:0] ftb_pft_addr_p2
-- predicted fallthrough address, full width,
reconstructed by ftb_cntrl from the stored
partial pftAddr -- five bits from the
block start (BP-140), NO CARRY BIT
(ftb_decisions.md 5.5, ruled session-070,
BUILT by BP-110). Bounds checked per
ftb_decisions.md 4.5: an end not above
the start (FTB-G1), or beyond start +
FTB_BLOCK_BYTES + 2 (FTB-G3, ruled
session-073), is replaced by start +
FTB_BLOCK_BYTES. BOTH CHECKS ARE BUILT
by BP-110; before it ftb_cntrl
reconstructed unconditionally, so this
entry's earlier "AS BUILT" note was
correct and the restoration recorded in
session-069 had never reached the RTL.
The uBTB does NOT have this check; see
ubtb_interfaces.md.
The fall-through of a block with no
visible jump. For a block ending at its
jump, the fall-through and the RAS push
are the jump PC plus 2 or 4 instead
(IC-FTB-03). This read "Authoritative for
the cluster; RAS push uses this value";
session-076.
2.4 Fast-path (direction bypass) (to override logic, p2)¶
input logic ftb_fastpath_en
-- 1 = fast-path enabled; a saturated conf may
bypass the TAGE/SC direction wait/override.
0 = disabled, FTB is always overridable
(ordinary BTB). A cluster input whose
source is undecided: G25 (PROJECT_STATUS.md
BP Cluster Open TBDs, fe_decisions.md
FE-20); its CSR is TD#178. This read
"Source TBD at bp_cluster (confidence doc
section 10)"; session-077. Renamed from the
former chicken_bit_enable (inverse sense:
1 enables the optimization).
output logic [1:0] ftb_fastpath_p2
-- bit 0 = br0, bit 1 = br1.
1 = FTB commits its direction for that branch
and the cluster must NOT apply a TAGE/SC
DIRECTION override and must not stall for SC
(saves the p3 SC cycle). Asserted when
ftb_fastpath_en AND conf saturated (111 or
000) AND ftb_valid_p2 AND the matching
ftb_brI_valid_p2 (IC-FTB-02). Target
overrides (ITTAGE/RAS) are never affected.
Full policy in
ftb_confidence_override_rules.md. (Renamed
from ftb_suppress_dir_p2.)
2.5 Update port (from FTQ, post-execute)¶
ONE update port. FTB does not arbitrate or serialize multi-branch updates; the FTQ routes and serializes onto this single port (F20, IC-FTB-05).
input logic ftb_upd_valid_u0
-- 1 = update active this cycle.
input logic [VA_WIDTH-1:0] ftb_upd_pc_u0
-- block start PC of the entry being updated.
input logic ftb_upd_hit_u0
-- carried from the prediction read: 1 = this
block hit in FTB at predict time. Guides
the write: overwrite the carried way on a
hit, allocate the carried victim on a miss.
Checked against the carried way at the
write (IC-FTB-10).
input logic [FTB_WAY_BITS-1:0] ftb_upd_way_u0
-- carried writeWay from the prediction read.
ftb_cntrl does NOT re-look-up the tag
(IC-FTB-10).
-- conditional-branch resolve
input logic ftb_upd_is_br_u0
-- 1 = this resolve is a conditional branch.
input logic ftb_upd_br_idx_u0
-- NOT READ by ftb_cntrl since BP-140: the
resolving branch's position names its
field (ftb_decisions.md 5.5). The port
stays (ports unchanged). RESERVED, as the
flush port is (Jeff, session-081).
input logic ftb_upd_taken_u0
-- resolved direction. 1 = taken. Drives the
bimodal conf step (increment toward 111 on
taken, decrement toward 000 on not-taken,
saturating) and, at allocate, the weak conf
init direction (ftb_decisions.md 5.4/5.5).
input logic [VA_WIDTH-1:0] ftb_upd_target_u0
-- resolved taken target, full width.
ftb_cntrl converts to the stored
displacement form for conditional storage
(4.2).
input logic [FTB_BR_POS_BITS-1:0] ftb_upd_pos_u0
-- in-block position of the resolving branch
(0..15), = (branch_pc - block_start) >>
POS_OFFSET_BITS, supplied by the FTQ/resolve
side. START-relative, stored as given
(BP-140). It names the field: the same
position is the same branch; a new
position joins the held branches in
position order, subject to the split
(ftb_decisions.md 3, 5.5).
(No ftb_upd_ftb_dir_u0 -- conf trains bimodally on the resolved
OUTCOME, not on FTB-prediction correctness, so FTB's original
direction is not needed on the update port. Removed session-053.)
-- jump resolve
input logic ftb_upd_is_jmp_u0
-- 1 = this resolve is a jump (call/ret/jalr).
input logic [VA_WIDTH-1:0] ftb_upd_jmp_target_u0
-- resolved jump target, full width. Written
to the jump field unconditionally on every
jump resolve (IC-FTB-01).
input logic ftb_upd_is_call_u0
input logic ftb_upd_is_ret_u0
input logic ftb_upd_is_jalr_u0
input logic ftb_upd_jmp_rvc_u0
-- 1 = the resolved jump is a compressed
instruction, from the backend resolution's
is_rvc (ftq_backend_interfaces.md 4).
Written to the jump field's rvc bit with
the type. Added by BP-121 (TD#164).
-- block boundary
input logic [VA_WIDTH-1:0] ftb_upd_pft_addr_u0
-- resolved block end (fallthrough), full
width. ftb_cntrl reduces it to the stored
partial pftAddr at the write -- relative
to the ALIGNED REGION BASE, not the block
start, six bits, no carry
(ftb_decisions.md 5.4/5.5, TD#124).
It is the RESOLVED block end: the FTQ
rewrites the entry's pft_addr at the
resolution of a taken jump
(ftq_entry_formats.md 2). Before BP-121
it carried the predicted end.
There is no last_may_be_rvi_call port. The bit was eliminated (ftb_decisions.md section 6).
2.6 Flush input¶
input logic ftb_flush_px
-- flush. REDUNDANT, and retained rather
than removed. A flush is a redirect
(fe_decisions.md FE-14); the FTB is
cleared by withholding its stage valid,
which bp_cluster already does. The port
is not driven. ftb_cntrl.sv gates the
combinational prediction outputs while
it is asserted; that behaviour is
RATIFIED as harmless and is not a flush
protocol. Update-queue drain is owned by
the FTQ and is not a flush question.
3. ftb_array Module Ports¶
One instance. Single 1R1W DATA array. Read port for prediction, write port for update, independent read and write addresses usable in the same cycle. ftb_array holds NO entry-valid bit and NO PLRU state -- those live in ftb_plru. It is pure data RAM so a 1R1W SRAM macro can substitute it directly. Enables are ACTIVE LOW (IC-FTB-13).
clk -- rising-edge clock
-- read port (prediction)
rd_en_n -- active low; 0 = read this cycle
rd_addr -- [FTB_IDX_BITS-1:0] set index
rd_data -- [FTB_RAM_SET_WIDTH-1:0] all ways of the set
(data only, no valid); way match and select in
ftb_cntrl, qualified by ftb_plru valid
-- write port (update / allocate)
wr_en_n -- active low; 0 = write this cycle
wr_addr -- [FTB_IDX_BITS-1:0] set index
wr_way -- [FTB_WAYS-1:0] one-hot way select
wr_data -- [FTB_RAM_ENTRY_WIDTH-1:0] one way's entry data
(no entry-valid; that is set in ftb_plru)
There is NO clk reset of the data array (pure SRAM-style storage). Cold validity is owned entirely by ftb_plru (IC-FTB-12). Do not rely on array power-up contents.
FTB_RAM_SET_WIDTH = FTB_WAYS * FTB_RAM_ENTRY_WIDTH
FTB_RAM_ENTRY_WIDTH = FTB_ENTRY_WIDTH - 1 (the relocated entry-valid
lives in ftb_plru)
THE ARITHMETIC IS NOT RESTATED HERE. ftb_decisions.md 8 is its sole home and says so. This block carried a full field-by-field sum with FTB_RAM_ENTRY_WIDTH = 105, a 106-bit logical entry, FTB_RAM_SET_WIDTH = 420, FTB_BR_POS_BITS = 3 and PFTADDR_BITS = 4 plus a carry bit. Every one of those was stale: BP-099 took FTB_BR_POS_BITS to 4 and the entry to 110 / 109 / 440 / 436, and session-070 took PFTADDR_BITS to 6 and deleted the carry (TD#124). Restating it here is how it went stale, so it is now a pointer. Removed session-070.
Way-slice packing: way w occupies rd_data/wr_data [w*FTB_RAM_ENTRY_WIDTH +: FTB_RAM_ENTRY_WIDTH]; wr_way[w] selects way w. ftb_cntrl uses the same convention.
Same-cycle read and write to the same set/way: the read returns the OLD value (F19, IC-FTB-14). Substitution invariant: any 1R1W array primitive (register file or SRAM macro) may replace ftb_array without changing ftb_cntrl port connections.
3a. ftb_plru Module Ports¶
One instance. Flop storage, parallel to ftb_array. Holds, per set, the FTB_WAYS entry-valid bits and the PLRU_BITS tree-PLRU state. Storage only: ftb_plru does NOT compute the victim, the next PLRU state, or the way-match -- those are in ftb_cntrl (IC-FTB-12). Enables ACTIVE LOW (IC-FTB-13). Reset clears all entry-valid bits; this is the FTB cold init -- there is no sram_init for the FTB.
clk -- rising-edge clock
rstn -- active-low reset; clears all entry-valid bits to
0 and resets all PLRU state to 0
-- read port (prediction; combinational)
rd_en_n -- active low; 0 = read this cycle
rd_addr -- [FTB_IDX_BITS-1:0] set index
rd_valid -- [FTB_WAYS-1:0] per-way entry-valid for the
set (ftb_cntrl ANDs with tag-match for the hit)
rd_plru -- [PLRU_BITS-1:0] tree-PLRU state for the set
-- valid write port (synchronous): set or clear one way's valid
val_we_n -- active low; 0 = valid write this cycle
val_addr -- [FTB_IDX_BITS-1:0] set index
val_way -- [FTB_WAYS-1:0] one-hot way (mirrors
ftb_array wr_way)
val_set -- 1 = set the selected way's valid (allocate);
0 = clear it. Reserved. NOT a flush
mechanism: there is no flush event
(fe_decisions.md FE-14, IC-FTB-07 closed).
Retained for invalidate-on-allocate use.
-- PLRU write port (synchronous): replace a set's tree-PLRU state
plru_we_n -- active low; 0 = PLRU write this cycle
plru_addr -- [FTB_IDX_BITS-1:0] set index
plru_wdata -- [PLRU_BITS-1:0] next PLRU state, computed
by ftb_cntrl
Same-cycle read vs same-set valid/PLRU write returns the OLD value, so the prediction read of ftb_array and ftb_plru together yields a coherent pre-update snapshot of the set (IC-FTB-14).
Per-set storage: FTB_WAYS valid bits + PLRU_BITS = (4 + 3) = 7 bits.
Total flops: FTB_SETS * 7 = 512 * 7 = 3584.
4. Interface Invariants¶
IC-FTB-01:
ftb_jmp_target_p2 reflects the most recently resolved target for the
jump in this block, regardless of whether ITTAGE or RAS normally
owns that branch type. The update write is unconditional on every
jump resolve; it is NOT gated on an ITTAGE miss (ftb_decisions.md
4.2 / 5.5). This is the override-chain "...else FTB jump target"
floor.
The jump field holds ONE jump. A resolve of the jump at the stored
region position rewrites target and type and keeps the position. A
resolve of a different jump of the region (a different position)
rewrites the whole field: position, target, isCall, isRet, isJalr,
rvc (since BP-121), and pftAddr if the boundary moves. Ruled
session-075 (Jeff), ftb_decisions.md 5.5. Built by BP-120 (TD#156): every
jump resolve writes position, target and type. Before it, ftb_cntrl.sv kept
the stored position whenever the stored jump was visible from the
update's start, which mixed two jumps in one field.
IC-FTB-02:
ftb_fastpath_p2[i] is valid only when ftb_valid_p2 is asserted and
the matching ftb_brI_valid_p2 is asserted. Do not sample the
fast-path on an FTB miss or an empty conditional field.
IC-FTB-03:
ftb_pft_addr_p2 is the fall-through of a block with no visible
jump. For a block ending at its jump, the fall-through and the
pushed return address (ras_fall_through) are the jump PC plus 2
when ftb_jmp_rvc_p2 is set, else plus 4. RULED session-075 (Jeff,
BP-121 decision 3, TD#164), BUILT by BP-121 (D3). This read "RAS
uses this value as the pushed return address": pftAddr is shared
by every start in a region (ftb_decisions.md 4.6), so the push
took whichever start's end was written last.
No straddle correction is applied. The value is BOUNDS CHECKED
(ftb_decisions.md 4.5, FTB-G1, FTB-G3), built by BP-110 (2.3).
This entry said "as built, ftb_cntrl.sv line 500 reconstructs
unconditionally, TD#124" and that ubtb_interfaces.md applies the
same check to blk_p1; both stale, the uBTB is ruled NOT bounds
checked (ubtb_interfaces.md). Corrected session-075.
IC-FTB-04:
br0 and br1 are the two conditional fields of one entry from one
lookup. FTB does not produce a second, separately-indexed
prediction. There is no slot-1 lookup and no slot-1 output.
IC-FTB-05:
The FTQ owns update scheduling. FTB exposes one update port and does
not serialize or arbitrate multi-branch updates internally (F20).
IC-FTB-06 (session-053):
conf allocate-init invariant. FTB_CONF_INIT_TKN and FTB_CONF_INIT_NTK
must both be UNSATURATED (TKN != all-ones, NTK != all-zeros) with the
MSB matching their direction (TKN MSB=1, NTK MSB=0), so a freshly
allocated entry cannot fast-path on first use. Assert in ftb_cntrl
and tb_ftb. (Replaces the former INIT < SUPPRESS_THRESH invariant;
there is no threshold.)
IC-FTB-07 (CLOSED, BP-105):
Flush protocol (ftb_flush_px). CLOSED BY DECISION, not by writing a
protocol: there is no flush event to define. A flush is a redirect
(fe_decisions.md FE-14). The port is redundant and retained.
This item previously read "Do not implement flush logic until
specified" while ftb_cntrl.sv already gated prediction outputs on
ftb_flush_px. The document and the tree disagreed. Resolved by
RATIFYING the existing gate: it is harmless, the port is never
driven, and removing it would touch a green module for no gain.
IC-FTB-08 (resolved, session-052; reconciled session-053):
Field widths are ruled in ftb_decisions.md 8 and are NOT restated
here. This block gave FTB_BR_POS_BITS = 3, FTB_RAM_ENTRY_WIDTH =
105 and FTB_RAM_SET_WIDTH = 420, all stale since BP-099. The
current values are in ftb_decisions.md 8 only. Corrected
session-070 by removing the copy; session-071 removed the "110 /
109 / 440 / 436" this entry still restated, stale once the
stored positions widened.
IC-FTB-09 (resolved, 2026-08-19):
G9 update channel arbitration. Multi-branch update scheduling onto
the single FTB update port is an FTQ concern and is
ftq_decisions.md 5.7. This item was OPEN, not decided: the single
port was never analysed against a target update rate.
The analysis: at the 8-issue target, with 15 to 20 percent branch
density, 1.2 to 1.6 branches resolve per cycle in steady state and
every one writes the FTB (5.5 steps conf on every resolve). One
write per cycle is below the target rate, and under FE-5 as
originally written the deficit backpressured resolution and stalled
the backend -- a training limit becoming a throughput limit.
The resolution: the FTQ schedules onto the port with a one-deep
skid and MAY DROP an update, but only a LOW-value one, meaning the
FTB hit at predict and the branch was predicted correctly. An
update that allocates an entry (predict-time miss) or corrects a
mispredict is never dropped; if accepting one would force such a
drop the FTQ backpressures instead. FE-5 is amended to match, and
only for this path.
The FTB itself is UNCHANGED. No second write port, no banking, no
wider payload. Two escalations are recorded in ftq_decisions.md
5.7.5 should measurement ever show the drop rate matters: merging
two same-entry updates into one ftb_array write, which needs no
extra port, and banking ftb_array by index.
(This item also covered the prediction-vs-update read port sharing
surfaced in BP-066; that half is unaffected.)
READ PORT SHARING, TD#162. An update borrows the read port, and
the prediction lookup of that cycle was dropped (found by
BP-120). RULED session-075 (Jeff, BP-121 decision 1), BUILT by
BP-121 (D7): ftq_npc holds p0 in the cycle before an FTB update
issues, so no lookup is dropped (ftq_decisions.md 4.5 H4). One p0
bubble per FTB update.
IC-FTB-10 (resolved, session-052):
Update-side way selection. ftb_cntrl does NOT re-look-up the tag on
update. The predicted way (writeWay) and the hit result are
determined at the prediction read (ftb_way_p2 / ftb_hit_p2) and
carried through the FTQ on ftb_upd_way_u0 / ftb_upd_hit_u0. On a
carried hit, overwrite the carried way; on a carried miss, allocate
the carried tree-PLRU victim. A carried victim may go stale if
another write hits the same set between read and update; tolerated
(prediction accuracy, never correctness). A direct carried-way READ
of the entry for the conf/target read-modify-write is still required
and permitted -- IC-FTB-10 forbids the associative re-lookup, not the
carried-way read.
THE CARRIED HIT/MISS IS CHECKED, BOTH WAYS. RULED session-075
(Jeff, BP-121 decision 2, TD#163), BUILT by BP-121 (D11). The
write recomputes the hit from that carried-way read: the way is
valid and its tag matches. A stale miss on a same-tag way merges;
a stale hit on a way now holding another block allocates.
ftb_decisions.md 5.1.
IC-FTB-11 (resolved session-052, REOPENED session-070):
Fallthrough reconstruction error. Ruled OUT in session-052 because
the full 26-bit tag made wrong-entry hits unreachable. TWO THINGS
HAVE CHANGED. ftb_decisions.md 4.5 restored a bounds check in
session-069 (FTB-G1, FTB-G2) because blocks are unaligned and two
lookup PCs in one 32-byte region share an entry, which is not a
wrong-entry hit. And the tag is now PINNED at 26 over a 41-bit VA
(4.1, TD#122), so it no longer covers the whole upper VA.
RESOLVED AS SPECIFIED session-071: the reconstruction is bounds
checked per ftb_decisions.md 4.5 (FTB-G1, FTB-G2), with the
start + FTB_BLOCK_BYTES fallback, and the upper bound is FTB-G3
(ruled session-073). Both built by BP-110, TD#124 closed. This read
"as built there is still no fallback mux ... an upper bound is
open"; corrected session-075.
IC-FTB-12 (session-053):
Storage split. ftb_array is pure 1R1W DATA RAM: no entry-valid, no
PLRU state, no compute. The entry-valid bits and the tree-PLRU state
live in ftb_plru, in resettable flops. Reset clears the valid bits;
this is the FTB cold init -- the FTB has NO sram_init mechanism.
Way-match, PLRU victim selection, PLRU next-state, and valid set/clear
are all computed in ftb_cntrl, which drives both storage modules. The
logical entry is partitioned: 1 valid bit/way in ftb_plru, the
FTB_RAM_ENTRY_WIDTH bits in ftb_array. This carried the number,
which read 105 until session-070 and 109 until session-071;
ftb_decisions.md 8 is the authority and is no longer copied here.
Session-072.
IC-FTB-13 (session-053):
Active-low controls. All enables on ftb_array and ftb_plru are active
low (rd_en_n, wr_en_n, val_we_n, plru_we_n), matching the BPU array
convention. Reset is rstn (active low). ftb_array has no reset (pure
RAM); ftb_plru reset clears valid + PLRU state.
IC-FTB-14 (session-053):
Coherent snapshot on collision. Both storage modules return the OLD
contents on a same-cycle read vs same-set write (F19 extended to
ftb_plru). A prediction that reads a set in the same cycle an update
writes that set sees a coherent pre-update view of both the data
(ftb_array) and the validity/replacement state (ftb_plru).
IC-FTB-15 (session-053, FTB-4 resolved):
In-block position is sourced and sunk. Each stored position field
(br0, br1, jump; FTB_BR_POS_BITS each, start-relative since
BP-140) has a producer and a consumer:
written from ftb_upd_pos_u0 (2.5), the field named by the position
and the kind (ftb_upd_is_br_u0 / ftb_upd_is_jmp_u0);
read out on ftb_br0_pos_p2 / ftb_br1_pos_p2 / ftb_jmp_pos_p2 (2.3).
Position is static while the SAME branch holds the field -- not
rewritten when an update at the stored region position steps conf
or rewrites the target. An update at a different position is a
different branch: the jump field is rewritten whole (IC-FTB-01);
a conditional field is filled as a new branch, with position,
weak conf, target and the IC-FTB-16 order (ruled session-075,
ftb_decisions.md 5.5, which gives the field mapping order; built
by BP-120). This read "static for the life of
a filled field ... reset only by reallocation". No stored
field may be left write-only (0-stuffed) or read-only: a field is not
"settled" until it has a named producer and consumer.
IC-FTB-16 (2026-08-19, amended session-073):
br0 holds the earlier branch. STORAGE IS IN ASCENDING POSITION
per start (BP-140, one entry per start): br0 holds the lower
position, br1 the higher, the jump is after both. ftb_cntrl sorts
at the write; the read reports the fields as stored, br1 only with
br0. The read window and compaction of session-073 are gone with
the region entry (ftb_decisions.md 4.6 replaced).
Two consequences follow.
The prediction slot array becomes program-ordered. br0 maps to slot
0 and br1 to slot 1 (ftq_bpu_interfaces.md 5.1), so slot 0 is the
first branch of the block and slot 1 the second. fe_decisions.md
FE-10 already states that the slot is the array index and carries no
identifier; it is now an ORDERED index.
The jump field's lowest-free-slot placement is program order in
every case, not merely the common one. A jump terminates the block,
so no conditional follows it; and because conditionals fill from br0
upward, the free slot the jump takes is always above every filled
conditional slot. Without this invariant a block whose only
conditional sat in br1 would place the jump in slot 0, ahead of an
earlier branch.
When no slot reads a reported field (br1 at one slot; the
jump when every slot holds a conditional) that branch is in
no slot, and the cluster ends the block at the PC of the first
such branch (fe_decisions.md 10, BP-139 option A; BP-138 cut
the jump only). Since BP-140 an entry holds at most
NUM_PRED_SLOTS branches (the split, ftb_decisions.md 3), so the FTB
reports no such branch from an entry it wrote; the cut is a
backstop (0 events in tb_fe_top).
Position is still required. It locates the branch in the fetch
bundle (IC-FTB-15), forms the branch PC reported to bp_history
(BP-092a), and is the key the backend returns at resolution
(ftq_backend_interfaces.md 4). This invariant removes its ORDERING
role, not the field.
5. Parameters¶
All from bp_defines_pkg.sv. THE VALUES ARE NOT RESTATED HERE: ftb_decisions.md 8 and 8.1 are their sole home, as section 3's arithmetic-not-restated block and IC-FTB-08 in section 4 both say. The names this interface uses:
VA_WIDTH, FTB_WAYS, FTB_ENTRIES, FTB_SETS, FTB_IDX_BITS,
FTB_WAY_BITS, FTB_BLOCK_BYTES, FTB_OFFSET_BITS, FTB_TAG_BITS,
PLRU_BITS, PFTADDR_BITS, TAR_STAT_BITS, FTB_BR_POS_BITS
(the width of every position PORT, start-relative),
FTB_RTAG_BITS (the region tag), FTB_SOFF_SHIFT (the index
fold; both BP-140),
FTB_BR_TGT_BITS, FTB_JMP_TGT_BITS, FTB_CONF_WIDTH,
FTB_CONF_INIT_TKN, FTB_CONF_INIT_NTK, and the entry arithmetic
FTB_ENTRY_WIDTH / FTB_SET_WIDTH (logical, including the valid bit)
and FTB_RAM_ENTRY_WIDTH / FTB_RAM_SET_WIDTH (the ftb_array data).
Invariant: both conf init values unsaturated, MSB matches
direction (IC-FTB-06). There is no FTB_CONF_SUPPRESS_THRESH.
This section carried every value and the entry arithmetic, against the rule the file states about itself twice. The copies agreed with ftb_decisions.md 8 at the time they were removed, having been stale at 105 / 420 until session-070 and at 109 / 436 until session-071 -- which is the argument for not keeping them. Session-072.
ftb_array uses the FTB_RAM_* widths; ftb_plru holds the valid bit per way and the PLRU state. All FTB field widths are settled. IC-FTB-07, the flush protocol, is CLOSED by decision -- no flush event exists, FE-14. IC-FTB-09, update-channel arbitration, is resolved by ftq_decisions.md 5.7 and built as ftq_ftb_sched (BP-100).
FETCH_BLOCK_BYTES = 64 is a global / fetch-unit parameter, already in the package. It is NOT an FTB parameter. The FTB prediction block is FTB_BLOCK_BYTES (32), decoupled from the fetch block, the 64-byte L1I line the IFU reads, by the FTQ. Do not collapse the two (ftb_decisions.md 2.3; this read "fetch width", session-071).
6. Interactions With Other Planning Documents¶
ftb_decisions.md -- canonical FTB authority. This file is
subordinate to it.
ftb_confidence_override_rules.md
-- conf as a bimodal direction counter, bimodal
training, the saturated-endpoint fast-path,
ftb_fastpath_en, init/self-correction.
bp_cluster.md -- pipeline staging, override chain, FTQ entry
contents, decoupled frontend, pipeline advance,
update-channel arbitration, keeping TAGE/SC
trained under the FTB fast-path (FTB-2).
ras_decisions.md -- RAS pushes the jump PC plus 2 or 4, formed
by the cluster from ftb_jmp_pos_p2 and
ftb_jmp_rvc_p2 (IC-FTB-03);
ftb_jmp_target_p2 is the RAS-empty fallback.
ittage -- ftb_jmp_target_p2 is the ITTAGE-miss fallback
(ITTAGE has no IT0 base table).
bp_defines_pkg.sv -- all FTB parameters in section 5.
7. Document History¶
2026-06-24 session-052. Regenerated from ftb_decisions.md (single
array, single update port, VA_WIDTH=40, FTB_TAG_BITS=26,
expanded-instruction granularity, partial pftAddr).
2026-06-24 session-052 (later/widths passes). IC-FTB-10 (writeWay
carry) and IC-FTB-11 (fallThroughErr out) resolved.
IC-FTB-08 widths ruled; ENTRY_WIDTH 108 / SET_WIDTH 432.
2026-06-25 session-053 (storage split). Hierarchy to three modules
(ftb_array data RAM, ftb_plru valid+PLRU flops, ftb_cntrl
logic). Section 3 ftb_array reduced to pure data RAM with
active-low enables; section 3a ftb_plru added. IC-FTB-12/
13/14 added. Storage-module enables active low. Stale
"FTB_WAYS currently 8" annotation removed.
2026-06-25 session-053 (confidence redefine). conf is a bimodal
DIRECTION counter (MSB = direction); ftb_brI_taken_p2 =
valid & conf MSB. always_taken removed: conditional field
22 bits, FTB_RAM_ENTRY_WIDTH 107 -> 105, FTB_RAM_SET_WIDTH
428 -> 420, logical entry 108 -> 106; IC-FTB-08 reconciled.
ftb_brI_always_taken_p2 output removed. Suppression-
threshold mechanism replaced by the saturated-endpoint
fast-path: ftb_suppress_dir_p2 renamed ftb_fastpath_p2;
chicken_bit_enable input renamed ftb_fastpath_en (now a
listed top input). ftb_upd_ftb_dir_u0 update input removed
(conf trains bimodally on ftb_upd_taken_u0). IC-FTB-06
repurposed to the conf init-unsaturated invariant
(FTB_CONF_INIT_TKN/NTK; FTB_CONF_SUPPRESS_THRESH removed).
IC-FTB-10 clarified: carried-way read for the conf/target
RMW is permitted (only the associative re-lookup is
barred). IC-FTB-09 extended to cover the pred-vs-update
read-port sharing surfaced in BP-066.
2026-06-25 session-053 (position fix, FTB-4). The in-block position
field (FTB_BR_POS_BITS per branch) was stored but had no
producer or consumer (BP-066 stored it as 0). Added
ftb_upd_pos_u0 (2.5) as the producer and ftb_br0_pos_p2 /
ftb_br1_pos_p2 / ftb_jmp_pos_p2 (2.3) as the consumers;
IC-FTB-15 added (every stored field must have a named
producer and consumer). No width change -- pos already
occupied bits in the 105-bit entry. RTL wired in BP-066b.
2026-09-19 session-071. Positions on every port are
start-relative; ftb_cntrl stores them region-relative
at FTB_BR_RPOS_BITS = 5 and applies a read window
(ftb_decisions.md 4.6, ruled, option R). IC-FTB-15
and IC-FTB-16 note the stored form and the open slot
mapping question. Section 5: FTB_BR_RPOS_BITS added,
entry 110 -> 113. TD#125 tracks the RTL.
2026-09-20 session-072. D5: the local stage-notation rule replaced
by PROJECT_CORE's.
2026-09-20 session-072. D5: the s-stage section heads and timing
text swept to p-stage.
2026-09-20 session-072. D13: section 5 and IC-FTB-12 no longer
restate the field widths or the entry arithmetic;
ftb_decisions.md 8 is the sole home, as section 3's
arithmetic-not-restated block and IC-FTB-08 already
said. Both citations read "3.4", a section this file
does not have; session-072.
2026-09-20 session-072. E4: UPDATED brought to the session date.
2026-10-07 session-075, after BP-119. IC-FTB-01, IC-FTB-15 and
the 2.3 and 2.5 position text: a field keeps its
position only for the same branch (ruled, Jeff),
TD#156. IC-FTB-03 and IC-FTB-11: stale "as built"
notes brought to the BP-110 build.
2026-10-08 session-075, after BP-120. IC-FTB-01, IC-FTB-15: the
position rule built. Open defects TD#162 to TD#164 are
in ftb_decisions.md 9, FTB-5.
2026-10-08 session-076, PA-direct correction recording BP-121.
2.3: ftb_jmp_rvc_p2; ftb_pft_addr_p2 no longer the RAS
push. 2.5: ftb_upd_jmp_rvc_u0; ftb_upd_pft_addr_u0 is
the resolved end. IC-FTB-01: rvc in the rewrite list.
IC-FTB-03: push source (TD#164). IC-FTB-09: hold p0
before an update (TD#162). IC-FTB-10: carried way
checked both ways (TD#163). 6: ras line.
2026-10-10 session-077, after BP-126. 2.4: ftb_fastpath_en's
source is G25, its CSR TD#178.
2026-10-17 session-081, after BP-138. IC-FTB-16: a jump in no slot
ends the block at the jump PC.
2026-10-19 session-081, after BP-139. IC-FTB-16: any branch in no
slot ends the block at its PC (option A).
2026-10-19 session-081, after BP-140. Per-start entries and the
split: the lookup, the position, end and update fields,
IC-FTB-16. ftb_upd_br_idx_u0 is no longer read and is
kept reserved (Jeff).
loop_pred_interfaces.md
planning/interfaces/loop_pred_interfaces.md on GitHub
Loop Predictor Interface Specification¶
FILE: loop_pred_interfaces.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-09
CONTACT: Jeff Nye
Overview¶
The Loop Predictor is a 256-entry 4-way associative predictor per prediction slot. It fires at p1 alongside uBTB and provides a direction prediction for branches detected as constant-iteration loops. It overrides uBTB at p1 when lp_pred_is_loop=1, which requires confidence at maximum (cnf == LP_CONF_LEVEL) and, since BP-122, a known speculative count. SINCE BP-122 IT ALSO PREDICTS AT p2: a trusted p2 direction (pred_p2) is the slot's direction at p2 and p3, over TAGE and SC (ruled session-076, fe_decisions.md 3.3). This read "It does not participate in the p2/p3 override chain".
Override control (not this module) makes the final p1 mux decision. The loop predictor exposes lp_pred_is_loop and the prediction; it does not directly suppress the uBTB output.
Stage naming is p0/p1/p2/p3, matching the port suffixes and ftq_bpu_interfaces.md. Earlier revisions of this document used s0/s1/s2/s3 for the same stages.
Types are defined in bp_structs_pkg.sv and the sizing parameters in bp_defines_pkg.sv. This document describes port semantics, timing contracts, and consumer/producer obligations. It does not restate struct field layouts -- see bp_structs_pkg.sv.
Module Parameters¶
LP_TBL_ENTRIES : int -- default 256, per slot
LP_TBL_WAYS : int -- default 4
LP_TAG_BITS : int -- default 14
LP_ITR_BITS : int -- default 14
LP_CNF_BITS : int -- default 2
LP_AGE_BITS : int -- default 8
LP_N_SETS : int -- LP_TBL_ENTRIES / LP_TBL_WAYS
LP_IDX_BITS : int -- $clog2(LP_N_SETS)
LP_CONF_LEVEL : int -- (1 << LP_CNF_BITS) - 1
NUM_PRED_SLOTS : int -- elaboration-time only. 1 or 2.
Value 3+ is undefined.
NUM_PRED_SLOTS defaults to 1 in the module and is overridden at instantiation from bp_defines_pkg::NUM_PRED_SLOTS, the same way it is for ubtb. The module elaborates at either value.
Every prediction and update port carries NUM_PRED_SLOTS elements and the table is replicated as one bank per slot (TI6). Slot banks are independent: a write to one bank cannot change another.
Slot PC derivation¶
All slots index from the single p0 request PC presented on their own pred_pc_p0 element. There is no per-slot PC at p0.
The index and tag hashes take no slot discriminator: two slots given the same PC address the same set and the same tag in their own bank. The banks diverge only because they are written by different slots' updates.
An earlier revision of this document stated that slot 1 predicts the prediction block following slot 0 at pred_pc + 32. That is superseded. Session-063 retired the two-PC-range block model, G8 and G17 are superseded, and BP-086 removed the pred_pc_p0 + 32 slot 1 lookup from ubtb.sv.
Port List¶
clk : input logic -- rising edge
rstn : input logic -- active low
pred_pc_p0 : input logic [VA_WIDTH-1:0]
[0:NUM_PRED_SLOTS-1] -- p0 input
pred_valid_p0 : input logic [NUM_PRED_SLOTS-1:0] -- p0 input
pred_p1 : output lp_pred_t
[0:NUM_PRED_SLOTS-1] -- p1 output
upd_p0 : input lp_upd_t
[0:NUM_PRED_SLOTS-1] -- post-execute
upd_valid_p0 : input logic [NUM_PRED_SLOTS-1:0] -- post-execute
Added by BP-122 (TD#169), as built:
pred_p2 : output lp_pred_t [0:NUM_PRED_SLOTS-1] -- p2 re-read
of the p1 lookup: current count (the iteration
number), trust and direction
spec_ck_p2 : input logic -- write the
checkpoint of the p2 block
spec_idx_p2 : input logic [FTQ_IDX_BITS-1:0] -- its FTQ index
spec_val_p2 : input logic [NUM_PRED_SLOTS-1:0] -- advance bank
s's p2 entry (a reachable conditional of a live p2
block)
spec_tkn_p2 : input logic [NUM_PRED_SLOTS-1:0] -- its p2
direction
rst_val : input logic -- restore from
the checkpoint of rst_idx
rst_idx : input logic [FTQ_IDX_BITS-1:0] -- the FTQ entry
rst_ex : input logic [NUM_PRED_SLOTS-1:0] -- slot s
executed (re-advance) or not (put back)
rst_tkn : input logic [NUM_PRED_SLOTS-1:0] -- its corrected
direction
inv_val : input logic -- mark every
count unknown (an FTQ-raised rollback)
Slot dimension style follows the tage, ittage, sc and ras ports of this unit: a packed vector for the per-slot valid bits and an unpacked ascending array for the per-slot payload and address.
The prediction output was named pred_p0 before the TD#105 retrofit while its value was already valid at p1. It is now named for the stage at which it is valid. No other port stage suffix changed; the update ports keep the p0 suffix, not u0 (ftq_bpu_interfaces.md section 8).
Reset State¶
Reset is asynchronous, active low, and clears every bank.
- Every entry of every bank: v=0, tag=0, past_itr=0, curr_itr=0,
age=0, cnf=0, curs=0, curs_v=0.
- pred_p1 reads all-zero on every slot.
Consequences a consumer may rely on after reset, before any update: every lookup reports lp_hit=0 and lp_pred_is_loop=0, and victim selection reports way 0, because every way is invalid and priority 1 of victim selection is the lowest-indexed invalid way.
Prediction Interface¶
Producer: loop_pred¶
Consumer: BP cluster (override control, p1 mux, FTQ write)¶
Timing¶
pred_pc_p0[s] is presented at p0 (combinational input).
pred_p1[s] is registered at the end of p0, valid at the start of
p1.
pred_p1[s] is held stable until the next pred_pc_p0[s] is
presented.
pred_valid_p0[s] gates the lookup for slot s only. When
pred_valid_p0[s]=0, pred_p1[s].lp_pred_is_loop=0 and
pred_p1[s].lp_pred_taken=0. The remaining pred_p1[s] fields still
report the addressed entry.
Slots are independent in the same cycle: any subset of
pred_valid_p0 may be asserted, each slot with its own PC.
Semantics¶
pred_p1[s].lp_pred_is_loop = 1 -- loop predictor hit in bank s
with confidence at maximum. All
lp_pred_t fields are valid and must
be consumed by the cluster override
control.
pred_p1[s].lp_pred_is_loop = 0 -- miss, or hit with confidence
below LP_CONF_LEVEL, or that slot's
pred_valid_p0 bit low. Override
control must ignore lp_pred_taken
and defer to uBTB.
On lp_pred_is_loop=0: the BP cluster uses the uBTB prediction
for that slot at p1. The loop predictor does not assert any
redirect or stall signal.
pred_p1 field semantics¶
lp_pred_is_loop : 1 when the loop predictor is trusted and
override control should select this output
over uBTB. 0 otherwise.
lp_pred_taken : predicted direction. Valid only when
lp_pred_is_loop=1. 1 = predict taken (still
inside loop body, curr_itr < past_itr).
0 = predict not-taken (loop exit).
lp_idx : set index derived from pred_pc_p0[s]. Used
by the update path to address the correct
set without re-deriving from PC.
lp_tag : tag derived from pred_pc_p0[s]. Used by the
update path for entry validation.
lp_way : way of the matching entry. Valid when
lp_hit=1. Used by the update path to write
back to the correct way directly.
lp_hit : 1 when bank s contains an entry matching
pred_pc_p0[s] (tag match, any confidence).
0 on cold miss. Valid regardless of
lp_pred_is_loop value, and not gated by
pred_valid_p0.
lp_age : age counter value of the matching entry
at predict time. Captured for update.
lp_conf : confidence counter value at predict time.
Captured for update.
lp_past_itr : known loop iteration count at predict time.
Captured for update.
lp_curr_itr : current iteration counter at predict time.
Captured for update.
lp_curs : speculative iteration progress counter at
predict time. Captured for update.
lp_curs_v : 1 when lp_curs is valid. Captured for update.
lp_victim : way selected for replacement if the update
path needs to allocate a new entry. Computed
at predict time to avoid a re-read at update.
On a miss the entry-derived fields (lp_age, lp_conf, lp_past_itr, lp_curr_itr, lp_curs, lp_curs_v) report way 0 of the addressed set, which is the default the hit scan starts from.
Victim selection¶
Evaluated on every lookup, in priority order:
1. lowest-indexed invalid way
2. lowest-indexed valid way with age == 0
3. the lowest-numbered way among 1, 2, 3 whose age is less than
way 0's age; way 0 if none qualifies
Consumer obligations¶
- Must not use pred_p1[s].lp_pred_taken when lp_pred_is_loop=0.
- Must write all lp_pred_t fields into the FTQ meta path
(bp_ftq_meta_t lp_* fields) per slot when pred_valid_p0[s]=1,
regardless of lp_pred_is_loop value. The update path requires
these fields unconditionally.
- Must set pred_src in bp_ftq_slot_t to identify the loop
predictor as provider when lp_pred_is_loop=1 and override
control selects the loop predictor output.
- The loop predictor takes no part in the redirect comparison.
The cluster compares the successor it would publish at p2
against its own p1 stage registers (fe_decisions.md FE-4), and
the LP is not a redirect source. This read "Must compare pred_p1
against the p2 FTB/TAGE result and fire the p2 redirect if they
disagree, same as uBTB". Session-071.
Update Interface¶
Producer: post-execute resolution path (BP cluster)¶
Consumer: loop_pred¶
Timing¶
upd_p0[s] is a synchronous input. Sampled on rising clk edge.
upd_valid_p0[s] may be asserted in any cycle.
No ordering constraint between update channels. Every channel is
processed independently in the same cycle, into its own bank.
upd_p0[s] is ignored entirely when upd_valid_p0[s]=0, including
when another slot's valid is asserted in that cycle.
Semantics¶
upd_valid_p0[s] = 0 -- no update to bank s this cycle. All
upd_p0[s] fields are ignored.
upd_valid_p0[s] = 1 -- resolved update. All upd_p0[s] fields
are valid and will be processed.
upd_p0 field semantics¶
pc : fetch PC of the resolved branch. With target, it
forms the backward-branch filter on the
allocation path. It does NOT address the table:
lp_idx and lp_way do.
target : resolved target address. Allocation requires
target < pc.
actual_taken : resolved branch direction.
lp_hit : value of lp_hit captured at predict time.
lp_pred_is_loop : value of lp_pred_is_loop captured at predict
time.
lp_pred_taken : predicted direction captured at predict
time. Used to detect mispredicted exit.
lp_idx, lp_tag, lp_way, lp_age, lp_conf, lp_past_itr,
lp_curr_itr, lp_curs, lp_curs_v, lp_victim:
All captured from lp_pred_t at predict time.
The update path uses these directly. No
re-read of the table is performed.
SUPERSEDED by BP-122: see Read before write and
the speculative count, below.
Write path selection¶
The write path is chosen by lp_pred_is_loop and lp_hit together, not by lp_pred_is_loop alone:
lp_pred_is_loop=1 OR lp_hit=1
-- update in place at mem[lp_idx][lp_way]
both 0, AND actual_taken=1, AND target < pc
-- allocate at mem[lp_idx][lp_victim]
otherwise
-- no write
Update behavior¶
The in-place cases are evaluated in this order. The first match wins; the ordering matters because the mispredicted-exit case is a subset of the taken-branch case.
1. Mispredicted exit -- lp_pred_is_loop=1, lp_pred_taken=0,
actual_taken=1:
- Reset cnf to 0. Reset curr_itr to 0.
2. Taken branch hit -- lp_pred_is_loop=1, actual_taken=1:
- Increment curr_itr, saturating at the LP_ITR_BITS max.
- If curs_v: increment curs, saturating.
3. Learning hit -- lp_hit=1, lp_pred_is_loop=0, actual_taken=1:
- Increment curr_itr, saturating. No confidence change.
4. Correct not-taken exit -- none of the above matched and
curr_itr == past_itr:
- Increment cnf, saturating at LP_CONF_LEVEL.
- Copy curr_itr to past_itr. Reset curr_itr to 0.
- Reset age to maximum.
5. Wrong not-taken exit -- none of the above matched and
curr_itr != past_itr:
- Reset cnf to 0.
- Copy curr_itr to past_itr. Reset curr_itr to 0.
Cases 4 and 5 are the fall-through of the chain. They do not test
lp_pred_is_loop: an entry reached through lp_hit alone takes them
as well.
Every field not named by the matched case is written back from
the captured upd_p0[s] value unchanged, and v is set to 1 and tag
to upd_p0[s].lp_tag.
On allocation (miss, actual_taken=1, target < pc):
- Allocate at way upd_p0[s].lp_victim of set upd_p0[s].lp_idx.
- Initialize: past_itr=0, curr_itr=1, cnf=0, age=max, v=1,
curs=0, curs_v=0.
- Write tag from upd_p0[s].lp_tag.
curr_itr=1 because the first iteration has already been
observed.
Read-during-write contract¶
If an update and a lookup address the same set of the same bank
in the same cycle, pred_p1 reflects the pre-update (registered)
state. The new entry is visible on the following cycle.
The producer must not depend on same-cycle readback.
Producer obligations¶
- Must provide resolved actual_taken, not speculative.
- Must pass all lp_pred_t fields captured at predict time
unmodified into lp_upd_t. No recomputation at update.
- Must not present two updates for the same branch on two
channels in the same cycle. Two channels resolving the same PC
address the same set and way of two different banks and would
diverge that PC's state between the banks.
Read before write and the speculative count (TD#169)¶
RULED session-075 (Jeff), after BP-121, reversing BP-121 decision 6 ("leave as specified"). BUILT by BP-122. Where this section and the Update behavior and field notes above disagree, this section holds.
WHY. In BP-121 the loop predictor received 1193 updates across 19 programs and none of its predictions was used. Each update rewrites the entry from the snapshot captured at prediction (Update behavior above, Producer obligations), and many iterations of a loop are predicted before the first update lands, so the snapshots are stale and the count never settles. Every loop exit mispredicts.
THE RULE.
- The update reads the entry before it writes it. This is allowed
for the loop predictor because its table is flops, not RAM
(fe_decisions.md 2.1). Single cycle, no bubble.
- The table stays one bank per slot (TI6). Each slot predicts from
and updates only its own bank, so two slots never read or write
one entry, and two predictions of one loop in one cycle do not
interact. The ruling's "slot 1 wins on a shared entry" has no
case to apply to. Confirmed session-076 (Jeff).
- A prediction in the same cycle as an update to its entry sees
the old value, as the Read-during-write contract above already
says.
- Each prediction carries its iteration number, so the order in
which updates arrive does not matter.
- The speculative iteration count (curs, curs_v; LI4, TD#7) is
built with it, and restored on a redirect (PROJECT_STATUS
TD#169).
- Physical design bounds the entry count at the target frequency.
The added logic costs FMAX; the cost is accepted.
AS BUILT by BP-122:
- THE COUNT. The speculative count advances at p2 by the p2
direction, after the p2 re-read (pred_p2). p1 keeps the early
guess from the p0 read, which can be up to two iterations stale
in a one-block loop; p2 corrects it, at the cost of a p2
redirect at a loop exit rather than a backend mispredict. An
allocated entry's count is unknown (curs_v clear) until its
first exit; a taken advance or a restore of an unknown count
keeps it unknown. A prediction is trusted only with cnf ==
LP_CONF_LEVEL and a known count.
- THE CHECKPOINT is in loop_pred, per bank, FTQ_DEPTH deep,
written at p2 for the p2 block (as bp_history keeps its own).
- RESTORE, option A, RULED session-076 (Jeff): a redirect restores
the redirecting block's own entry exactly from its checkpoint
(executed not taken -> 0; executed taken -> count + 1; not
executed -> put back), and an FTQ-raised rollback marks every
other count unknown. A p3 redirect restores as it rolls back the
history. A restore of an entry since replaced writes nothing.
Cost: a loop whose run contains an unrelated backend or
predecode redirect loses one exit to resynchronise. Option B
(invalidate only entries a squashed block advanced) gave the same
lp and loops results on a scratch copy and costs about 4 kbit.
- THE UPDATE looks the tag up again (a stale carried way still
finds the entry; a replaced entry is not written), recomputes
the victim, and trains from the carried lp_curs / lp_curs_v:
taken at a known count >= past_itr -> cnf = 0
exit at a known count == past_itr -> cnf++, age = max
exit otherwise -> cnf = 0,
past_itr = count
unknown carried count -> trains nothing
These replace Update behavior cases 1 to 5 above, and the
producer obligation "No recomputation at update" and the field
note "No re-read of the table is performed".
- Of lp_pred_t's snapshot fields the update reads lp_idx, lp_tag,
lp_curs and lp_curs_v only. No package change was made.
MEASURED (BP-122, lengthened lp and loops, ruled): the LP supplied 94 p1 and 86 p2 directions in lp and 56 and 49 in loops (0 before); lp's exit mispredicted at most once after warm-up (6 times before). The LP is trusted after five exits at the earliest.
Miss Signaling Contract¶
The loop predictor has no miss output port. Miss is implied by pred_p1[s].lp_pred_is_loop=0. The BP cluster override control is responsible for detecting this condition and falling back to the uBTB prediction for that slot.
The loop predictor does not stall, does not generate a redirect, and does not communicate miss reason externally.
Known Gaps and Deferred Items¶
| ID | Item | Status |
|---|---|---|
| LI1 | Slot 1 PC derivation (pred_pc + 32) | CLOSED. Model |
| retired in | ||
| session-063. All | ||
| slots index from | ||
| the p0 request | ||
| PC. G8 and G17 | ||
| superseded. | ||
| LI2 | Override control threshold -- loop pred | CLOSED at |
| trusted when cnf==LP_CONF_LEVEL | bp_cluster: the | |
| p1 mux takes the | ||
| loop direction | ||
| per slot when | ||
| lp_pred_is_loop. | ||
| LI3 | Update channel arbitration when two | CLOSED by TI6. |
| channels write the same set in the same | Banks are per | |
| cycle | slot; there is | |
| no shared write | ||
| port to arbitrate | ||
| LI4 | curs/curs_v speculative iteration | CLOSED by BP-122. |
| tracking -- rollback policy not | Checkpoint per | |
| defined. Seznec uses external SLIM | FTQ entry, | |
| structure for this purpose. | restore option A | |
| (ruled). TD#7, | ||
| TD#169. This read | ||
| "Resolve at | ||
| bp_cluster impl". | ||
| LI5 | Allocation policy -- allocates | DECIDED: backward branch filter |
| on backward branches only. | required. Only upd_valid with | |
| Forward branches do not trigger | actual_taken=1 and target < | |
| allocation. | pc qualify for allocation. | |
| LI6 | lp_pred_t and bp_loop_meta_t carry the | CLOSED by TD#106, |
| same thirteen fields in a different order | BP-092. lp_pred_t | |
| with two spelled differently. Retiring | survives; | |
| one of the two is an open decision. | bp_loop_meta_t | |
| deleted, and the | ||
| bp_ftq_meta_t lp | ||
| member is now | ||
| lp_pred_t. |
Document History¶
2026-10-08 session-076, PA-direct correction recording the ruling
made after BP-121. Ruled Change: read before write,
per-slot banks kept, each prediction carries its
iteration number, speculative iteration count built
with it (TD#169, BP-122). LI4 ruled. This document had no history
section; earlier changes are in PROJECT_STATUS.
2026-10-09 session-076, recording BP-122. Overview: the LP
predicts at p2 and outranks TAGE and SC (ruled). Port
List: the BP-122 ports. Read before write: built, with
the count, checkpoint, restore option A (ruled) and
the update rules. LI4 closed.
ittage_cntrl_decisions.md
planning/arch/ittage_cntrl_decisions.md on GitHub
ittage_cntrl Design Decisions¶
FILE: ittage_cntrl_decisions.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-09-20
CONTACT: Jeff Nye
Scope¶
This document captures settled design decisions for ittage_cntrl.sv. It is a companion to ittage_interfaces.md and ittage_table_interfaces.md. It does not restate information already in those documents unless a decision modifies or extends them.
Dual Prediction Support¶
ittage_cntrl supports two simultaneous prediction requests via vector-indexed ports sized to NUM_PRED_SLOTS. Slot 0 and slot 1 operate identically and independently -- there is no cross-slot interaction in prediction logic, update logic, or UAON counter state. Both slots may have ittage_pred_val_p0 asserted in the same cycle. Each slot has its own uaon counter (uaon[0], uaon[1]) and aging interval counter (lcl_aging_interval[0], lcl_aging_interval[1]). Provider selection, alternate provider selection, UAON mux, and ittage_pred_meta population are replicated per slot. Slot 1 PC is supplied by the fetch unit via ittage_pred_inp_p0[1].pc. No offset derivation is performed in ittage_cntrl.
No Base Table¶
ITTAGE has no IT0 base table. Unlike TAGE there is no unconditional fallback provider. When no IT1-IT5 table hits, ittage_hit is de-asserted in the response and the consumer uses the FTB target. ittage_pred_rdy_p2 is still asserted -- the response is valid even when ittage_hit == 0. There is no equivalent of T0 behavior, T0 CTR encoding, or T0 direction output. All rows in the CTR update table that reference comp==0 map to no-hit, not a base table.
CTR Encoding (IT1-IT5, 3b)¶
CTR is a confidence counter. It does not encode direction.
000 null no confidence (target replacement candidate,
UAON trigger point)
001 low1 low confidence
010 low2 low confidence
011 low3 low confidence
100 high0 high confidence
101 high1 high confidence
110 high2 high confidence
111 high3 maximum confidence
Direction = not applicable. ITTAGE predicts target address only.
NULL is 000 only; every other value is NOT NULL. The UAON trigger is null alone (below), and ittage_pred_strong means NOT NULL on the final provider (ittage_cntrl_uaon_update_rules.md). ITTAGE has no strong, weak or boundary classes: those are the TAGE direction counter's (tage_cntrl_decisions.md). This read "Strong states: 000 (null), 111", "Weak states: 001 ... 110" and "Boundary states: 011 and 100 -- UAON trigger points", carried from TAGE and contradicting the trigger and the strong flag below. Session-071.
Newly allocated entries initialize to 3'b000 (null confidence).
use_alt_on_na Counters¶
Two 4b saturating counters (IT_UAON_WIDTH=4), one per prediction slot. Both owned by ittage_cntrl. Both operate independently. No cross-slot interaction in prediction or update. Initial value: IT_UAON_THRES=8.
Trigger condition: provider CTR is 3'b000 (null) only.
Expressed as: (ctr == 3'b000)
ittage_use_alt_on_na captures the trigger decision into meta. Counter state at predict time is not stored in meta. Only the single-bit trigger decision (ittage_use_alt_on_na) is captured.
For mux selection logic and counter update rules see ittage_cntrl_uaon_update_rules.md.
Prediction Phase -- ittage_cntrl Responsibilities¶
Provider selection (p1, combinational)¶
Scan IT5 down to IT1 for hit_p1[slot] asserted. Longest history hit wins -- this is the primary provider. If no tagged table hits: ittage_hit de-asserted in response. ittage_pred_rdy_p2 still asserts. No fallback base table.
Captures into meta:
ittage_prm_idx -- already-hashed RAM index of primary hit
ittage_prm_comp -- table index of primary provider
ittage_prm_useful -- useful field of primary provider entry
ittage_prm_ctr -- CTR field of primary provider entry
ittage_prm_tgt -- target from primary provider entry
Alternate provider (p1, combinational)¶
Continue scan below primary hit for next longest hit. If primary is IT1 or ittage_hit == 0, alternate is absent (ittage_alt_comp == 0).
Captures into meta:
ittage_alt_idx -- already-hashed RAM index of alternate
ittage_alt_comp -- table index of alternate provider
ittage_alt_useful -- useful field of alternate provider entry
ittage_alt_ctr -- CTR field of alternate provider entry
ittage_alt_tgt -- target from alternate provider entry
Allocation candidate (p1, combinational)¶
See ittage_cntrl_alloc_rules.md for full rules.
ittage_cntrl generates ittage_alc_idx directly (pre-hashed). Source is the idx_hash_p0 that was used to access the candidate table during prediction. Written into meta as-is. Update path uses it as a direct RAM address with no rehashing.
Captures into meta:
ittage_alc_comp -- table index of allocation candidate
ittage_alc_idx -- pre-hashed RAM index of candidate
ittage_alc_tag -- tag captured at predict time
Decoration flags (p1, combinational)¶
ittage_pred_strong -- provider ctr was != 0
ittage_use_alt_on_na -- use_alt_on_na was used to select
ittage_using_primary -- provider was primary, else alternate
ittage_hit -- at least one IT1-IT5 table hit
branch_id -- copied from ittage_pred_inp_t
Final target (p1, combinational)¶
ittage_cntrl does not pick a single predicted target. It captures both candidate targets and the selector into meta and leaves the choice to the consumer:
ittage_prm_tgt -- target from primary provider entry ittage_alt_tgt -- target from alternate provider entry ittage_using_primary -- selector: 1 = primary, 0 = alternate
The consumer selects: ittage_using_primary == 1 -> ittage_prm_tgt ittage_using_primary == 0 -> ittage_alt_tgt
ittage_using_primary is set during provider selection (p1): primary when ittage_prm_ctr != 3'b000; on null primary CTR, alternate when use_alt_on_na fired (UAON counter >= IT_UAON_THRES), else primary. See ittage_cntrl_uaon_update_rules.md for the mux rule.
When ittage_hit == 0 there is no provider target; the consumer uses the FTB target. ittage_pred_rdy_p2 still asserts.
All meta fields are flopped at p2 (see p2 flop). The selection above is performed by the consumer on the p2 meta.
p2 flop¶
All meta fields flopped at p2. These are packed into the ittage_pred_meta_t struct.
ittage_pred_rdy flopped alongside, gated on ittage_pred_val_p0 delayed one cycle.
CTR Update Rules¶
See ittage_cntrl_ctr_update_rules.md for the full table.
Summary of cases. The table is organised by the provider,
ittage_using_primary (UP), not by which comps are nonzero:
- H == 0: no hit. No CTR update. Allocation path only. Row 1.
- UP == 0: the alternate provided (the primary was null and
use_alt_on_na fired). Only the alternate CTR is updated,
INC on a correct target and DEC on a mispredict. Rows 2-17.
- UP == 1: the primary provided. Only the primary CTR is
updated, INC or DEC the same way. Rows 18-33.
- prm_comp == 0 and alt_comp > 0: cannot arise from a
prediction, because the alternate is found only below a
primary (Alternate provider, above). The even rows 2 to 16
carry pCMP == 0 under UP == 0; pCMP is don't-care there and
those rows exist for test coverage of the update input, not
as reachable states.
This read "rows 2-5" for both providers tagged and "Rows 6-9"
for a primary hit with no alternate. The table's rows 2-17 are
UP == 0 and rows 6-9 are alternate-provider mispredicts.
Session-071.
Target Update Rules¶
Target field write gating is defined in ittage_interfaces.md section Target Write Gating.
Useful Counter and Aging Rules¶
See ittage_cntrl_use_update_rules.md. Key difference from TAGE: useful counter governs allocation candidate eligibility. Aging and UAON interaction follow the same principles as TAGE unless noted otherwise.
Allocation Rules¶
See ittage_cntrl_alloc_rules.md for full rules.
Concurrent CTR and USE Writes¶
When the CTR update rules and the useful update rules both target the same table and same index in the same cycle, the two writes are performed as a single RAM write.
ittage_cntrl must combine the active write enables and align both the CTR write data and the USE write data into a single ram_din word. The bweb_n mask must have bits cleared for both the CTR field range and the USE field range simultaneously.
This is structurally supported by bw_ram and the existing bweb_n logic in ittage_table.sv. ittage_cntrl is responsible for asserting both strobes in the same cycle with correctly aligned data. ittage_table performs the merged write.
Concurrent CTR and TGT Writes¶
It is the intent expressed by Seznec that the target field is only replaced during a misprediction if the corresponding CTR is 0.
On misprediction if the CTR is 0 the target field is written; if the CTR is non-zero, the CTR is decremented, the target field is not written.
Previously, the CTR and TGT writes were required to be mutually exclusive. This is unnecessarily restrictive.
Open Items¶
-
CLOSED session-036: ittage_table_interfaces.md created.
-
CLOSED session-037: II6 target write gating defined, on the two declared strobes prm_tgt_wr_u0 and alt_tgt_wr_u0. This read "tgt_wr_u0", a single strobe no port list declares; session-072. See ittage_interfaces.md Target Write Gating section.
ittage_cntrl_alloc_rules.md
planning/arch/ittage_cntrl_alloc_rules.md on GitHub
ittage cntrl Allocation Rules¶
FILE: ittage_cntrl_alloc_rules.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-09-20
CONTACT: Jeff Nye
Scope¶
This document covers allocation candidate selection at predict time and the allocation write at update time. It is a companion to ittage_cntrl_decisions.md and ittage_table_interfaces.md.
Trigger¶
Allocation fires during update when:
indir_mispredict == 1
AND ittage_prm_comp < M (provider is not the longest table)
Where M is the index of IT5 (the longest history table).
If provider is IT5 and mispredicts: update CTR and target only,
no allocation.
Count¶
One entry allocated per misprediction event.
Candidate Selection at Predict Time (p1, combinational)¶
Scan tables IT(provider+1) through IT5 for u_eff == 0.
u_eff is used for the useful == 0 test, not raw USEFUL.
No allocation in consecutive tables -- if ITj is selected,
ITj+1 is skipped even if u_eff == 0.
Select the shortest-history qualifying table.
If provider table is the last table, no allocation should
occur and ittage_alc_comp should be set to zero.
ittage_cntrl generates ittage_alc_idx directly (pre-hashed).
Source is the idx_hash_p0 that drove the candidate table
during prediction. No rehashing at update time.
Captures into meta:
ittage_alc_comp -- table index of selected candidate.
Set to 0 (IT0 placeholder) when no
candidate found.
ittage_alc_idx -- pre-hashed RAM index of candidate
ittage_alc_tag -- tag for the new entry, captured at
predict time
No-candidate sentinel¶
ittage_alc_comp == 0 (IT0 placeholder) indicates no allocation candidate was found. IT0 is never a valid allocation target -- allocation only targets tables longer than the provider. This sentinel is unambiguous. When ittage_alc_comp == 0 arrives at update time, alc_wr_u0 is suppressed for all tables. No allocation write is issued. Epoch aging (EPC field) handles starvation prevention. Useful bit decrement on failed allocation is not implemented.
No-hit Allocation¶
When ittage_hit was 0 at predict time (no table hit), allocation scans from IT1. ittage_pred_rdy_p2 asserts whether or not a table hit (ittage_interfaces.md Semantics); ittage_hit is the no-hit signal. This keyed the scan on ittage_pred_rdy being 0, which never marks a no-hit. Session-072. The no-consecutive-table constraint still applies.
Initialization of Allocated Entry¶
CTR = 3'b000 (null confidence) USE = 2'b00 (null useful) EPC = current lcl_epoch value for the slot TAG = ittage_alc_tag from meta TGT = resolved_target from execute VALID = 1'b1
Allocation Write Data Assembly¶
The allocation write data is constructed per the entry layout
in ittage_table_entry_formats.md. TAG bits are the MSBs:
[TAG, TGT, EPC, USE, CTR, VALID]
This maps directly to alc_wd_u0[THIS_ALLOC_DATA_WIDTH-1:0], the
derived parameter ittage_table_interfaces.md declares and sizes
the port with. This read IT_ALLOC_DATA_WIDTH, which occurs nowhere
else. Session-072.
Write Strobe Generation¶
alc_wr_u0[slot] is asserted at update time when:
indir_mispredict == 1
AND ittage_prm_comp < M
AND ittage_alc_comp != 0 (valid candidate was found)
The no-consecutive-table constraint is enforced at predict
time during candidate selection. The write strobe at update
time does not re-evaluate adjacency.
alc_wr_u0 is gated per table inside ittage_table by comparing
THIS_TABLE to ittage_alc_comp (via alc_tbl_sel_u0). Only
the selected candidate table performs the write.
EPC Field¶
The current lcl_epoch value for the slot is written to the EPC field of the allocated entry at update time. See ittage_cntrl_use_update_rules.md for aging rules.
ittage_cntrl_ctr_update_rules.md
planning/arch/ittage_cntrl_ctr_update_rules.md on GitHub
ittage_cntrl CTR Update Rules¶
FILE: ittage_cntrl_ctr_update_rules.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-09-20
CONTACT: Jeff Nye
Notes¶
- prm_comp > 0 : primary provider is a tagged table (IT1-IT5)
- alt_comp > 0 : alternate provider is a tagged table (IT1-IT5)
- comp == 0 : no hit. ITTAGE has no base table. When H=0
there is no entry to update and no CTR action
is taken for either provider.
- indir_mispredict: supplied at update time via ittage_upd_inp_t.
ITTAGE predicts target not direction. There is
no pred_diff in ITTAGE. See
ittage_cntrl_decisions.md CTR Update Rules.
- x : don't care
- - : not applicable
- -- : no action
CTR Semantics¶
CTR is a confidence counter in ITTAGE, not a direction counter. INC means increment toward max (higher confidence). DEC means decrement toward zero (lower confidence). CTR reaching null triggers target replacement on next misprediction. See ittage_interfaces.md Target Write Gating; allocation is a separate path, ittage_cntrl_alloc_rules.md.
The legend read PT as ittage_pred_target, a signal ittage_cntrl does not produce, and pT / aT as ittage_prm_target / ittage_alt_target, where the meta fields are _tgt. This section pointed target replacement at the allocation rules. Session-072.
CTR Update Table¶
This table is entered when pred_src == PRED_ITTAGE. The H column gates all rows -- when H=0 no update is performed regardless of any other signal state (row 1). Rows marked ASSERT are impossible conditions enforced by ittage_assert.sv at simulation time.
Legend:
H = ittage_hit
UP = ittage_using_primary
PT = VIRT_ittage_pred_tgt: ittage_prm_tgt when UP=1,
ittage_alt_tgt when UP=0. Not a physical signal
(ittage_interfaces.md Semantics); ittage_cntrl does
not select a target (ittage_cntrl_decisions.md Final
target).
RT = resolved_target
pT = ittage_prm_tgt
aT = ittage_alt_tgt
MIS = indir_mispredict, supplied in ittage_upd_inp_t. It
equals (PT != RT); the table is not evaluated by
comparing targets.
pCMP = ittage_prm_comp
aCMP = ittage_alt_comp
pACT = action for primary CTR
aACT = action for alternate CTR
x = don't care
-- = no action
A, B = distinct target address values (abstractions)
if PT == RT then MIS = 0 (correct prediction)
if PT != RT then MIS = 1 (misprediction)
When UP=0: alt is provider. pT and pCMP are don't care
for CTR update purposes. Rows retain explicit
pT and pCMP values for test coverage -- each
row maps to one test case in tb_ittage.sv.
When UP=1: primary is provider. aT and aCMP are don't care
for CTR update purposes. Same test coverage
rationale applies.
UP=0 with pCMP=0 (rows 2, 4, 6, 8, 10, 12, 14, 16) cannot
arise from a prediction: the alternate is found only below a
primary, and UP=0 requires a null primary
(ittage_cntrl_decisions.md). Those rows are update inputs a
test can present, with pCMP don't-care; they are not reachable
states. Session-071.
| # | H | UP | PT | RT | MIS | pT | aT | pCMP | aCMP | pACT | aACT | Explanation |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 0 | x | x | x | x | x | x | x | x | -- | -- | No hit, no update |
| 2 | 1 | 0 | A | A | 0 | A | A | =0 | >0 | -- | INC | UP=0, correct, pT=A aT=A pCMP=0 |
| 3 | 1 | 0 | A | A | 0 | A | A | >0 | >0 | -- | INC | UP=0, correct, pT=A aT=A pCMP>0 |
| 4 | 1 | 0 | A | A | 0 | B | A | =0 | >0 | -- | INC | UP=0, correct, pT=B aT=A pCMP=0 |
| 5 | 1 | 0 | A | A | 0 | B | A | >0 | >0 | -- | INC | UP=0, correct, pT=B aT=A pCMP>0 |
| 6 | 1 | 0 | A | B | 1 | A | A | =0 | >0 | -- | DEC | UP=0, mispredict, pT=A aT=A pCMP=0 |
| 7 | 1 | 0 | A | B | 1 | A | A | >0 | >0 | -- | DEC | UP=0, mispredict, pT=A aT=A pCMP>0 |
| 8 | 1 | 0 | A | B | 1 | B | A | =0 | >0 | -- | DEC | UP=0, mispredict, pT=B aT=A pCMP=0 |
| 9 | 1 | 0 | A | B | 1 | B | A | >0 | >0 | -- | DEC | UP=0, mispredict, pT=B aT=A pCMP>0 |
| 10 | 1 | 0 | B | A | 1 | A | B | =0 | >0 | -- | DEC | UP=0, mispredict, pT=A aT=B pCMP=0 |
| 11 | 1 | 0 | B | A | 1 | A | B | >0 | >0 | -- | DEC | UP=0, mispredict, pT=A aT=B pCMP>0 |
| 12 | 1 | 0 | B | A | 1 | B | B | =0 | >0 | -- | DEC | UP=0, mispredict, pT=B aT=B pCMP=0 |
| 13 | 1 | 0 | B | A | 1 | B | B | >0 | >0 | -- | DEC | UP=0, mispredict, pT=B aT=B pCMP>0 |
| 14 | 1 | 0 | B | B | 0 | A | B | =0 | >0 | -- | INC | UP=0, correct, pT=A aT=B pCMP=0 |
| 15 | 1 | 0 | B | B | 0 | A | B | >0 | >0 | -- | INC | UP=0, correct, pT=A aT=B pCMP>0 |
| 16 | 1 | 0 | B | B | 0 | B | B | =0 | >0 | -- | INC | UP=0, correct, pT=B aT=B pCMP=0 |
| 17 | 1 | 0 | B | B | 0 | B | B | >0 | >0 | -- | INC | UP=0, correct, pT=B aT=B pCMP>0 |
| 18 | 1 | 1 | A | A | 0 | A | A | >0 | =0 | INC | -- | UP=1, correct, aT=A aCMP=0 |
| 19 | 1 | 1 | A | A | 0 | A | A | >0 | >0 | INC | -- | UP=1, correct, aT=A aCMP>0 |
| 20 | 1 | 1 | A | A | 0 | A | B | >0 | =0 | INC | -- | UP=1, correct, aT=B aCMP=0 |
| 21 | 1 | 1 | A | A | 0 | A | B | >0 | >0 | INC | -- | UP=1, correct, aT=B aCMP>0 |
| 22 | 1 | 1 | A | B | 1 | A | A | >0 | =0 | DEC | -- | UP=1, mispredict, aT=A aCMP=0 |
| 23 | 1 | 1 | A | B | 1 | A | A | >0 | >0 | DEC | -- | UP=1, mispredict, aT=A aCMP>0 |
| 24 | 1 | 1 | A | B | 1 | A | B | >0 | =0 | DEC | -- | UP=1, mispredict, aT=B aCMP=0 |
| 25 | 1 | 1 | A | B | 1 | A | B | >0 | >0 | DEC | -- | UP=1, mispredict, aT=B aCMP>0 |
| 26 | 1 | 1 | B | A | 1 | B | A | >0 | =0 | DEC | -- | UP=1, mispredict, aT=A aCMP=0 |
| 27 | 1 | 1 | B | A | 1 | B | A | >0 | >0 | DEC | -- | UP=1, mispredict, aT=A aCMP>0 |
| 28 | 1 | 1 | B | A | 1 | B | B | >0 | =0 | DEC | -- | UP=1, mispredict, aT=B aCMP=0 |
| 29 | 1 | 1 | B | A | 1 | B | B | >0 | >0 | DEC | -- | UP=1, mispredict, aT=B aCMP>0 |
| 30 | 1 | 1 | B | B | 0 | B | A | >0 | =0 | INC | -- | UP=1, correct, aT=A aCMP=0 |
| 31 | 1 | 1 | B | B | 0 | B | A | >0 | >0 | INC | -- | UP=1, correct, aT=A aCMP>0 |
| 32 | 1 | 1 | B | B | 0 | B | B | >0 | =0 | INC | -- | UP=1, correct, aT=B aCMP=0 |
| 33 | 1 | 1 | B | B | 0 | B | B | >0 | >0 | INC | -- | UP=1, correct, aT=B aCMP>0 |
| A1 | 1 | x | x | x | x | x | x | =0 | =0 | ASSERT | ASSERT | Invalid: H=1 pCMP=0 aCMP=0. |
| ittage_assert.sv assertion 1. | ||||||||||||
| A2 | 1 | 1 | x | x | x | x | x | =0 | x | ASSERT | ASSERT | Invalid: UP=1 pCMP=0. |
| ittage_assert.sv assertion 2. | ||||||||||||
| A3 | 1 | 0 | x | x | x | x | x | x | =0 | ASSERT | ASSERT | Invalid: UP=0 H=1 aCMP=0. |
| ittage_assert.sv assertion 3. |
ittage_cntrl_uaon_update_rules.md
planning/arch/ittage_cntrl_uaon_update_rules.md on GitHub
ittage_cntrl UAON Update Rules¶
FILE: ittage_cntrl_uaon_update_rules.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-06-10
CONTACT: Jeff Nye
USE_ALT_ON_NA (UAON) Background¶
In TAGE like predictors, including Indirect Target TAGE (ITTAGE) a set of register(s) are used to possibly prefer the alternative component's predictions over the primary component's prediction.
USE_ALT_ON_NA (Use Alternate Prediction on Newly Allocated, aka UAON) controls what happens when a tagged component provides a prediction from a newly allocated entry -- one that hasn't yet been trained and therefore has a null confidence counter.
Specifically, when the matching tagged component's CTR is null (3'b000 -- no confidence, target replacement candidate), the predictor must decide:
- Use the tagged component's prediction anyway, or
- Fall back to the alternate (next-longest-history) prediction
USE_ALT_ON_NA is a saturating counter that tracks whether trusting newly allocated entries or deferring to the alternate has been more accurate recently. If it is biased toward "use alternate," the predictor ignores null-CTR entries and falls back; if biased toward "use new," it trusts them immediately.
This design implements two USE_ALT_ON_NA (UAON) registers to heuristically qualify the selection of primary or alternative components during prediction. During update the UAON registers are conditionally modified based on the correctness of the predictions.
UAON has no impact when the tagged tables have missed. If ittage_hit == 0 this section does not apply.
UAON Implementation¶
Two registers: uaon_0 and uaon_1, one per prediction slot. Both are unsigned 4b saturating counters owned by ittage_cntrl. Both operate independently. No cross-slot interaction.
Parameter: IT_UAON_THRES = 8, defined in bp_defines_pkg.sv.
Terminology¶
Primary component: the table with a tag hit and the longest history length. ittage_prm_comp holds its table index.
Alternative component: the table with the next lower history length and a tag hit. ittage_alt_comp holds its table index.
NOT NULL: CTR is not null when ittage_prm_ctr != 3'b000. Null state is 3'b000 only -- the newly allocated, zero confidence state. All other CTR values are NOT NULL.
ittage_pred_strong: set when the final provider CTR is NOT NULL after the UAON mux has selected primary or alternative. Reflects the NOT NULL condition on whichever component actually supplied the prediction. See bp_structs_pkg.sv for field definition.
Component Selection During Prediction¶
Primary component CTR is available in ittage_prm_ctr.
if (ittage_prm_ctr != 3'b000)
select primary component
else
if (uaon_N >= IT_UAON_THRES)
select alternative component
else
select primary component
NOT NULL condition:
not_null = (ittage_prm_ctr != 3'b000)
ittage_using_primary reflects the result of this selection. ittage_pred_strong reflects NOT NULL on the final provider CTR.
UAON Modification During Update¶
These rules apply independently to uaon_0 and uaon_1.
Signal names¶
Full signal paths for reference:
ittage_pred_strong = ittage_upd_inp_u0[s].ittage_pred_meta.ittage_pred_strong
ittage_prm_tgt = ittage_upd_inp_u0[s].ittage_pred_meta.ittage_prm_tgt
ittage_alt_tgt = ittage_upd_inp_u0[s].ittage_pred_meta.ittage_alt_tgt
indir_mispredict = ittage_upd_inp_u0[s].indir_mispredict
resolved_target = ittage_upd_inp_u0[s].resolved_target
Correctness definitions¶
ITTAGE predicts target address. Correctness is target match.
prm_correct = (resolved_target == ittage_prm_tgt)
prm_wrong = (resolved_target != ittage_prm_tgt)
alt_correct = (resolved_target == ittage_alt_tgt)
alt_wrong = (resolved_target != ittage_alt_tgt)
Update rules¶
if (!rstn) (rstn aka reset, is active low)
-> set uaon registers to IT_UAON_THRES
else if (ittage_hit == 0)
-> do nothing
else if (ittage_pred_strong)
-> do nothing
else if (ittage_prm_comp == 0 || ittage_alt_comp == 0)
-> do nothing
else if (prm_wrong && alt_correct)
-> increment uaon_N (saturate at 4b max)
else if (prm_correct && alt_wrong)
-> decrement uaon_N (saturate at 0)
else
-> do nothing
Truth table¶
| ittage_pred_strong | prm_wrong | alt_correct | prm_correct | alt_wrong | Action |
|---|---|---|---|---|---|
| 1 | X | X | X | X | none |
| 0 | 1 | 1 | 0 | 0 | INC uaon_N |
| 0 | 0 | 0 | 1 | 1 | DEC uaon_N |
| 0 | 1 | 0 | 0 | 1 | none (both wrong) |
| 0 | 0 | 1 | 1 | 0 | none (both right) |
ittage_cntrl_use_update_rules.md
planning/arch/ittage_cntrl_use_update_rules.md on GitHub
ittage_cntrl Useful Counter Update Rules¶
FILE: ittage_cntrl_use_update_rules.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-09-20
CONTACT: Jeff Nye
Background¶
Each tagged ITTAGE table entry (IT1-IT5) contains a 2-bit USEFUL counter field. The USEFUL field records whether an entry has recently provided a correct prediction that disagreed with the alternative provider. An entry with a non-zero USEFUL value has demonstrated recent predictive value and is protected from eviction during allocation. An entry whose USEFUL value has decayed to zero is a candidate for replacement.
The epoch-based aging mechanism described below allows this protection to decay over time without requiring explicit per-entry writes: as the lcl_epoch counter advances, the effective USEFUL value (u_eff) seen by the allocation logic decreases for entries that have not been recently updated, making them eligible for eviction even if their raw USEFUL field is non-zero.
USEFUL is updated only when the primary and alternate providers predict different targets -- when they agree, no information about relative provider quality is available and no update is performed.
Note: Seznec's original ITTAGE uses a 1-bit U field with a global TICK-based reset. This implementation extends U to 2 bits with INC/DEC semantics, consistent with the TAGE useful counter extension used in this project.
Useful Counter Aging¶
The ITTAGE predictor periodically ages the USEFUL counters in table entries. Useful aging gradually removes replacement protection from predictor entries that have not recently demonstrated value, allowing stale entries to be evicted (allocated) in favor of new ones without explicitly clearing the tables.
Aging is a two-phase process that fits within the existing prediction request/update request process. During prediction requests, the EFFECTIVE useful bits are used to determine which entry across the tables is the target for replacement/allocation. The EFFECTIVE useful bits are the aged view of the USEFUL bits across the entries.
The EFFECTIVE USEFUL values are returned in the prediction response and used in the subsequent update phase.
There is an enable bit, ittage_enable_aging, as a primary input to ittage and ittage_cntrl.
There is a 32b bus that supplies the aging interval as a primary input to ittage and ittage_cntrl, called ittage_aging_interval.
There are two local 32b registers in ittage_cntrl that hold the running interval count, called lcl_aging_interval_0 and lcl_aging_interval_1. Each register serves one of the two prediction slots.
There are local 2b registers in ittage_cntrl that hold the running epoch count, called lcl_epoch_0 and lcl_epoch_1. Each register serves one of the two prediction slots.
Interval and Epoch Operation¶
On reset: lcl_aging_interval_0 and lcl_aging_interval_1 are loaded with the current value of ittage_aging_interval.
lcl_aging_interval_0 decrements on each assertion of ittage_pred_rdy_p2[0].
lcl_aging_interval_1 decrements on each assertion of ittage_pred_rdy_p2[1].
ittage_pred_rdy_p2 is one port carrying the slot as a packed vector (ittage_interfaces.md Port List). This read ittage_pred_rdy_0_p2 and _1_p2, which do not exist. Session-072.
When lcl_aging_interval_0 reaches zero:
lcl_epoch_0 increments (2b wrapping).
lcl_aging_interval_0 reloads from ittage_aging_interval.
When lcl_aging_interval_1 reaches zero:
lcl_epoch_1 increments (2b wrapping).
lcl_aging_interval_1 reloads from ittage_aging_interval.
Aging is only active when ittage_enable_aging is asserted.
Aging Disabled¶
When ittage_enable_aging=0 the epoch mechanism is inactive. The effective USEFUL value is always equal to the raw USEFUL field:
u_eff = USEFUL (aging disabled, equivalent to age==0 path)
Manual tests are expected to run with ittage_enable_aging=0. A test failure under this condition indicates a table rule violation, not an aging interaction.
Effective Useful Computation¶
At predict time, ittage_cntrl computes u_eff for the primary and alternative components using the slot's lcl_epoch register.
age = (IT_AGE_EPOCH - EPOCH) mod 4
if (age == 0) u_eff = USEFUL;
else if (age == 1) u_eff = USEFUL >> 1;
else u_eff = 0;
This read as three bare statements, so the else bound to the age == 1 test alone and age == 0 fell through to u_eff = 0. The chain above is the rule, as tage_cntrl_use_update_rules.md gives it. Session-072.
Where:
IT_AGE_EPOCH = lcl_epoch_0 or lcl_epoch_1 for the slot
EPOCH = EPC field of the RAM entry
USEFUL = USE field of the RAM entry
u_eff is a 2b saturating value.
The provider component's modified u_eff is returned in the prediction response (ittage_pred_meta) on ittage_prm_useful and ittage_alt_useful.
On the subsequent update, u_eff is written back to the USEFUL field of the entry. The values are carried in the update data:
ittage_upd_inp_u0[s].ittage_pred_meta.ittage_prm_useful
ittage_upd_inp_u0[s].ittage_pred_meta.ittage_alt_useful
(The port is ittage_upd_inp_u0, as the Table 7 legend below and ittage_interfaces.md give it; this read ittage_upd_inp. Session-072.)
Which field is written (prm or alt) is determined by the table below. The current lcl_epoch value is written to the EPC field of the entry at the same time.
Theory: since lcl_epoch_0/1 is used to form u_eff, the simple action of incrementing IT_AGE_EPOCH effectively ages all entries in all tables without the need to update each entry individually.
NOTE: USE write-back value is u_eff (aged), not raw USE: on update the field is written u_eff+1 (INC) / u_eff-1 (DEC) and EPC is refreshed to lcl_epoch in the same write, resetting age to 0. When seeded EPC != lcl_epoch, raw USE may show no delta (e.g. u_eff=0, INC writes 1).
Useful Counter Update Table¶
This table is entered when pred_src == PRED_ITTAGE. Signals are prefixed by ittage_upd_inp_u0[s].ittage_pred_meta unless otherwise noted. Prefix removed from column headers for brevity.
Legend¶
DIFF = ittage_prm_tgt != ittage_alt_tgt (stored targets differ)
HIT = ittage_hit (at least one tagged table hit)
UP = ittage_using_primary
MISP = indir_mispredict (from ittage_upd_inp_t, not pred_meta)
uWR = useful write enable
uACT = useful action (Inc/Dec u_eff)
uSEL = useful component select
PRM = ittage_prm_comp
ALT = ittage_alt_comp
uIDX = useful index select
PRM = ittage_prm_idx
ALT = ittage_alt_idx
uWD = useful write data select
PRM = ittage_prm_useful
ALT = ittage_alt_useful
x = don't care
- = not applicable
Table 7 - USEFUL modification truth table¶
| # | DIFF | HIT | UP | MISP | uWR | uACT | uSEL | uIDX | uWD |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0 | x | x | x | 0 | - | x | x | x |
| 2 | x | 0 | x | x | 0 | - | x | x | x |
| 3 | 1 | 1 | 1 | 0 | 1 | INC | PRM | PRM | PRM |
| 4 | 1 | 1 | 1 | 1 | 1 | DEC | PRM | PRM | PRM |
| 5 | 1 | 1 | 0 | 0 | 1 | INC | ALT | ALT | ALT |
| 6 | 1 | 1 | 0 | 1 | 1 | DEC | ALT | ALT | ALT |
Row suppression notes¶
Rows 1 and 2 both independently suppress the useful write (uWR=0). They have no priority relationship between them. If both conditions are true simultaneously (DIFF=0 and HIT=0) the outcome is the same: uWR=0. No ordering is required and no priority encoding should be inferred. Rows 3-6 are only reachable when both row 1 and row 2 conditions are false (DIFF=1 and HIT=1).
Row 1: predictions agreed -- primary and alternate stored the same target. No useful information about relative provider quality is available regardless of outcome.
Row 2: no tagged table hit. There is no entry to update. HIT=0 with DIFF=1 is structurally impossible -- if no table hit occurred then neither prm_tgt nor alt_tgt holds a valid stored value and DIFF is a don't care. The uWR=0 outcome is the same.
ittage_table_entry_formats.md
planning/arch/ittage_table_entry_formats.md on GitHub
ITTAGE table entry formats¶
FILE: ittage_table_entry_formats.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-09-22
CONTACT: Jeff Nye
Scope¶
This describes the field ordering for tables in ITTAGE.
Entry Format¶
IT0¶
There is no IT0 entry format. ITTAGE has no base table.
IT1-IT5 Table Entry¶
The ordering of the fields in the tagged ITTAGE tables is show
MSB LSB
TAG TGT EPC USE CTR VALID
Field widths for EPC, USE, CTR, TGT, and VALID
are defined by parameters found in bp_defines_pkg.sv
The VALID bit is always 1 bit.
The remaining fields have table specific parameters selected from the named parameter array. [t] indicates the table, IT0-IT5.
Only t=1-5 is actually used. The IT0 position is a placeholder for consistent parameter array semantics.
The fields are listed from LSB to MSB
VALID : 1 bit
CTR : `IT_TBL_CTR[t]`
USE : `IT_TBL_USE[t]`
EPC : `IT_TBL_EPC[t]`
TGT : `IT_TBL_TGT_WIDTH[t]`
TAG : `IT_TBL_TAG[t]`
TAG field¶
The TAG width is specified by IT_TBL_TAG[t]. This document does
not define the tag's VALUE: it is tag_hash_p0, computed inside
ittage_table from the PC and two folded histories
(ittage_table_hash_rules.md, Tag Hash Function), and ittage_cntrl
captures it into ittage_alc_tag at predict time.
This read that the tag "is extracted from the virtual address beginning with bit 1", a second and different derivation: the hash shifts the PC by THIS_INDEX_BITS and XORs fh1 and fh2 into it. The hash rules are the sole home for the derivation; the heading was also duplicated. Session-072.
CTR field usage in ITTAGE¶
CTR encodes confidence in the stored target. CTR is incremented on correct prediction and decremented on misprediction. When CTR reaches null on misprediction, the target field is replaced with the resolved target.
In ITTAGE CTR is not a direction predictor as it is in TAGE.
TGT field¶
The TGT width is IT_TBL_TGT_WIDTH[t], 40 for every tagged table.
THE FIELD HOLDS VA[40:1]. Bit 0 is not stored because it is always
zero at 2-byte granularity, and the reconstruction is
{stored, 1'b0}. NO BITS ARE INFERRED: there is no sign or zero
extension anywhere in the path.
RULED session-073 (Jeff), raised by BP-109 as TD#132. The field was 38 bits, pinned session-070, with bits 40:39 supplied by extension. No extension rule is correct for both a V=1 guest physical address (zero extended, bit 38 significant) and a V=0 Sv39 kernel address (bits 40:39 set), and a wrong entry cannot be corrected by any update because the update writes back the bits the entry already holds. Widening costs 2 bits x 2048 entries x the TWO PER-SLOT RAM COPIES (u_ram_s0, u_ram_s1) = 8,192 bits; the array goes 226,304 -> 234,496 bits, measured by BP-111. IT_TBL_BANKS divides a copy and does not duplicate it, so it is not the factor here. misc/prop1.md records the alternatives that were rejected. ftq_bpu_interfaces.md 5.2 is the reconstruction's home.
Maximum field widths¶
The maximum range for each field is stored in a parameter. These parameters
are found in bp_defines_pkg.sv
IT_MAX_TAG_WIDTH
IT_MAX_TGT_WIDTH
IT_MAX_EPC_WIDTH
IT_MAX_USE_WIDTH
IT_MAX_CTR_WIDTH
IT_MAX_VAL_WIDTH
ittage_table_hash_rules.md
planning/arch/ittage_table_hash_rules.md on GitHub
ittage_table Hash Rules¶
FILE: ittage_table_hash_rules.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-09-20
CONTACT: Jeff Nye
Scope¶
Define the hash functions used locally within each ittage_table instance to derive idx_hash_p0 and tag_hash_p0 for IT1-IT5. This read index_hash_p0, which no port list declares; the declared output is idx_hash_p0 (ittage_table_interfaces.md). Session-072. There is no IT0 -- ITTAGE has no base table and no direct PC index path.
Input Ports Associated with Hashing Functions for IT1-IT5¶
Each ittage_table generates four hashed values: an index hash for prediction slot 0 and slot 1, and a tag hash for prediction slot 0 and slot 1.
There are two PCs supplied by ittage_pred_inp_p0:
ittage_pred_inp_p0[0].pc
ittage_pred_inp_p0[1].pc
These are inputs to both the index and tag hash functions.
The primary input struct bp_folded_hist_t folded_hist provides the folded history buses used for both the index and tag hashes. Each table, indicated by the module parameter THIS_TABLE, selects one of the five groups in folded_hist. There are 3 buses in each group. The fh bus is used by the index hash function. The fh1 and fh2 buses are used by the tag hash function.
The buses are named as it_tN_idx_fh, it_tN_tag_fh1, it_tN_tag_fh2, where tN is t1, t2, t3, t4, or t5.
The width parameters for these buses are similarly named:
IT_TBL_FH[N], IT_TBL_FH1[N], IT_TBL_FH2[N]
where N is the value of THIS_TABLE (1 through 5).
Relevant Parameters¶
PC_HASH_SHIFT is a global parameter which defines the right shift of the PC address. This shift is 2 at present.
THIS_INDEX_BITS is a module level parameter that defines the table-specific width of the index.
THIS_TAG_BITS is a module level parameter that defines the table-specific width of the tag field.
THIS_TABLE is a module level parameter that defines the table component id. Valid range is 1 through 5.
VA_WIDTH is a global parameter that sets the MSB of the PC. The PC is zero indexed.
Hashing Functions for IT1-IT5¶
Index Hash Function¶
The index hash function takes the PC and the idx folded history as inputs. The outputs are the slot 0 and slot 1 index hashes.
Output width: THIS_INDEX_BITS. PC input width: VA_WIDTH. fh input width: IT_TBL_FH[THIS_TABLE].
The hashing operation is:
tmpA = (PC >> PC_HASH_SHIFT) ^ fh
output = tmpA[THIS_INDEX_BITS-1:0]
There are two instances of this function, one for slot 0 and one for slot 1, producing idx_hash_p0[0] and idx_hash_p0[1].
Tag Hash Function¶
The tag hash function takes the PC and two tag folded histories as inputs. The outputs are the slot 0 and slot 1 tag hashes.
Output width: THIS_TAG_BITS. PC input width: VA_WIDTH. fh1 input width: IT_TBL_FH1[THIS_TABLE]. fh2 input width: IT_TBL_FH2[THIS_TABLE].
The hashing operation is:
tmpA = PC >> THIS_INDEX_BITS
tmpB = tmpA ^ fh1 ^ (fh2 << 1)
output = tmpB[THIS_TAG_BITS-1:0]
There are two instances of this function, one for slot 0 and one for slot 1, producing tag_hash_p0[0] and tag_hash_p0[1].
No IT0 Hash¶
There is no IT0 in ITTAGE. There is no direct PC index path and no base table. All five active tables (IT1-IT5) use the hash functions defined above. There is no equivalent of the TAGE T0 pc[12:2] direct index.
ittage_interfaces.md
planning/interfaces/ittage_interfaces.md on GitHub
ITTAGE Interface Specification¶
FILE: ittage_interfaces.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-15
CONTACT: Jeff Nye
Overview¶
ITTAGE is an indirect target tagged geometric history length predictor providing target address prediction for indirect branches. It fires at p2 alongside FTB and TAGE and SUPPLIES THE TARGET for an indirect branch when it hits; the FTB target stands on a miss (ftb_decisions.md 4.2). Target selection is by hit and is independent of the conf direction mechanism, which never affects target overrides (ftb_confidence_override_rules.md 1). The p2 redirect is a separate question: it fires only when the successor the cluster would publish differs from the one its own p1 stage registers hold (fe_decisions.md FE-4 and 2.5). ITTAGE does not predict direction -- it predicts a 40-bit target, VA[40:1]; bit 0 is always zero for instruction alignment and is not stored. IT_MAX_TGT_WIDTH and IT_TBL_TGT_WIDTH are 40 and the reconstruction is {stored, 1'b0}: no target bit is inferred by extension. Built by BP-111 (TD#132, closed).
AN EARLIER REVISION described a 38-bit field (VA[38:1]) that was deliberately not widened, with a reconstruction that had to zero-extend (TD#122). BP-109 found that no extension rule is right for both a V=1 guest physical address and a V=0 Sv39 kernel address, and that a wrong entry could not be corrected by any update; BP-111 widened the field instead (PROJECT_STATUS TD#132). Stale since BP-111; corrected session-076.
Five active tables: IT1-IT5. No IT0 base table. IT0 index position in parameter arrays is a placeholder only and is never instantiated. When no IT1-IT5 entry matches, ittage_hit is de-asserted in the response and the consumer falls through to the FTB target.
Branch type partitioning is THE FTB's, not the decoder's.
ftb_decisions.md 1 makes classification the FTB's
responsibility, and the type reaches p2 from the FTB entry.
Predecode does see instruction bits, but FE-8 forms no predictor
update from it, so it is not the source of the partition. An
earlier revision said the partition was "resolved upstream by
the decoder and carried in the FTB entry"; the second half was
right and the first was not. Corrected session-070.
ITTAGE operates on indirect branches that are neither RETURN nor RETURN_CALL, including indirect CALL with a history-dependent target. RETURN_CALL was added session-069 and this read "not RETURN" alone; session-070. RAS handles RETURN and RETURN_CALL. RAS also tracks CALL for its own speculative-stack push (return-address bookkeeping); this is unrelated to target prediction.
THE FTB TARGET IS THE ITTAGE-MISS FALLBACK, NOT A SEPARATE
ARM. fe_decisions.md 3.3 selects ITTAGE on br_type indirect,
and ftb_decisions.md 4.2 makes the FTB target what stands when
ITTAGE misses. An earlier revision said "FTB provides the target
for indirect CALL with a fixed stable target", which reads as a
type-based split between the two. There is no such split: the
selection is by hit, not by how stable the target is. Corrected
session-070.
No dynamic arbitration between ITTAGE and RAS is required at p2.
Alternate provider and USE_ALT_ON_NA (UAON) are implemented, following the same principles as TAGE. IT_UAON_WIDTH=4, IT_UAON_THRES=8.
Pipeline: p0 index and tag hash calculation, p1 SRAM read and tag match, p2 final target output.
All types defined in bp_defines_pkg.sv and bp_structs_pkg.sv. This document describes port semantics, timing contracts, and consumer/producer obligations. It does not restate struct field layouts -- see bp_structs_pkg.sv.
Port Naming Convention¶
Signal names follow the pattern:
<signal>_<pipestage>
- `pipestage` : p0, p1, p2 for prediction path.
u0, u1 for update path.
There is no px stage. No flush event exists; a
flush is a redirect (fe_decisions.md FE-14,
BP-105). Corrected session-070.
Slot dimension uses vector index [0:NUM_PRED_SLOTS-1]. clk and rstn carry no pipe stage suffix.
Module Parameters¶
Parameters for ITTAGE are found in section :ITTAGE parameters: of rtl/core/frontend/bpu/rtl/bp_defines_pkg.sv
Port List¶
// clock and reset
input logic clk
input logic rstn
// prediction interface
input logic [NUM_PRED_SLOTS-1:0] ittage_pred_val_p0
input ittage_pred_inp_t ittage_pred_inp_p0[0:NUM_PRED_SLOTS-1]
output logic [NUM_PRED_SLOTS-1:0] ittage_pred_rdy_p2
output ittage_pred_meta_t ittage_pred_meta_p2[0:NUM_PRED_SLOTS-1]
// update interface
input logic [NUM_PRED_SLOTS-1:0] ittage_upd_val_u0
input ittage_upd_inp_t ittage_upd_inp_u0[0:NUM_PRED_SLOTS-1]
output logic [NUM_PRED_SLOTS-1:0] ittage_upd_rdy_u1
// arbitration status outputs, driven by ittage_arb (BP-132)
// renamed by BP-132 (TD#49): were pq_not_full and upd_rdy
output logic ittage_pq_not_full
output logic [NUM_PRED_SLOTS-1:0] ittage_uq_not_full
// aging control -- shared across both slots
input logic ittage_enable_aging
input logic [31:0] ittage_aging_interval
input bp_folded_hist_t folded_hist
// ram init interface
output logic ittage_rdy
Struct Definitions¶
All structs defined in bp_structs_pkg.sv.
ittage_pred_inp_t¶
Input bundle presented with each prediction request. Carries branch PC and branch_id for the slot. See bp_structs_pkg.sv for the authoritative definition.
ittage_pred_meta_t¶
Prediction output and metadata. Carries primary and alternate component indices, confidence counters, useful bits, allocation target, predicted targets for both primary and alternate, UAON flag, ittage_hit, and branch_id. See bp_structs_pkg.sv for the authoritative definition.
ittage_upd_inp_t¶
Update input bundle. Contains prediction metadata captured at predict time plus resolution fields supplied by the top level. See bp_structs_pkg.sv for the authoritative definition.
Prediction Interface¶
Producer: ittage¶
Consumer: BP cluster (p2 target mux, FTQ write)¶
Timing¶
ittage_pred_inp_p0[s] is presented at p0. folded_hist
(bp_folded_hist_t from bp_history) is also presented at p0.
Index and tag hash logic is combinational within each
ittage_table instance at p0.
p1: SRAM read completes. Tag match and hit processing
execute in p1.
p2: Final target flopped out. ittage_pred_meta_p2[s]
and ittage_pred_rdy_p2[s] are valid at p2.
Metadata timing (BP-094)¶
Every member of ittage_pred_meta_t, branch_id INCLUDED, describes the request that produced it, and the whole struct is staged to p2 together. No member is read live from the p0 input at p1.
ITTAGE was inspected in BP-094 for the staging defect found in tage_cntrl and does NOT have it. ittage_cntrl registers branch_id p0 -> p1 into branch_id_p1[] in its pred_val_reg block and the p2 metadata register takes it from there, alongside the index and tag hashes, so the struct has always been on one request. The statement is recorded here so the property is specified rather than merely true.
Consumers may rely on this: ittage_pred_meta_p2[s].branch_id is the FTQ index a consumer must compare its own stage index against, and a mismatch means the response is stale or delayed, never merely skewed.
Folded History Input¶
folded_hist is the bp_folded_hist_t output of
bp_history. It is shared across both prediction slots
and passed directly to each ittage_table instance.
Each ittage_table instance selects its table-specific
fields and derives idx_hash_p0 and tag_hash_p0 locally.
ITTAGE consumes the following fields for index and tag
computation:
it_t1_idx_fh, it_t1_tag_fh1, it_t1_tag_fh2
it_t2_idx_fh, it_t2_tag_fh1, it_t2_tag_fh2
it_t3_idx_fh, it_t3_tag_fh1, it_t3_tag_fh2
it_t4_idx_fh, it_t4_tag_fh1, it_t4_tag_fh2
it_t5_idx_fh, it_t5_tag_fh1, it_t5_tag_fh2
PHR contribution to index and tag hashing is TBD. All current folds are GHR-derived only.
Semantics¶
ittage_pred_val_p0[s] = 1 -- valid prediction request for
slot s. ITTAGE will process and
produce ittage_pred_meta_p2[s]
two cycles later.
ittage_pred_val_p0[s] = 0 -- no request for slot s.
ittage_pred_rdy_p2[s] will be
0 at p2.
ittage_pred_rdy_p2[s] = 1 -- ittage_pred_meta_p2[s] is valid.
Both slots may have ittage_pred_val_p0 asserted in the same cycle. Slots operate independently with no cross-slot interaction.
ITTAGE has no base table (no IT0). When no IT1-IT5 table hits, ittage_hit is de-asserted in ittage_pred_meta_p2[s] and the consumer uses the FTB target. ittage_pred_rdy_p2[s] still asserts -- the response is valid regardless of hit status.
ittage_pred_meta_p2[s].ittage_prm_tgt and ittage_pred_meta_p2[s].ittage_alt_tgt carry the predicted target address from the primary and alternate components when ittage_hit is asserted.
The consumer uses ittage_pred_meta_p2[s].ittage_using_primary to select the actual prediction.
For the purposes of description we define a virtual signal called VIRT_ittage_pred_tgt which is either ittage_prm_tgt or ittage_alt_tgt depending on the value of ittage_using_primary. VIRT_ittage_pred_tgt is not a physical signal.
The primary component is the longest-history tagged table with a matching entry. The alternate component is the next-longest hitting table.
Selection of primary or alternative:¶
The provider is either a) primary component b) alternative component c) none when no tagged table is hit.
All tables are accessed in parallel. Each table returns a hit value, if those hit values are organized as a vector with the table with the longest history in the MSB then the primary and alternative components are the left most hit (primary) and next left most hit (alternative).
It is possible for there to be 0, 1, or many hits. When there are no hits ittage sets ittage_hit=0. Else ittage_hit=1.
Normally the primary component is selected since by design it has the longest history length, but this selection is modified by the primary component's CTR and the current value of the UAON for that prediction slot.
When the primary component's CTR is zero (null confidence) and the UAON counter is >= IT_UAON_THRES the alternative component becomes the provider.
For full provider selection scan logic see ittage_cntrl_decisions.md section Prediction Phase.
Operation of the UAON is described in ittage_cntrl_uaon_update_rules.md.
ITTAGE processes up to two indirect branches, one for each prediction slot.
Hash Functions¶
Each ittage_table instance generates idx_hash_p0 and tag_hash_p0 locally. These hashes are used to access the RAMs in p0.
The hash operations are defined in ittage_table_hash_rules.md.
Consumer Obligations¶
Note: VIRT_ittage_pred_tgt is a virtual signal described above.
- Must not consume VIRT_ittage_pred_tgt when ittage_hit is not asserted.
- Must use FTB target when ittage_hit is not asserted.
- Must write ittage_pred_meta_p2[s] into FTQ meta path when ittage_pred_val_p0[s] was asserted, regardless of hit status. The update path requires these fields unconditionally.
- Must set pred_src in bp_ftq_entry_t to PRED_ITTAGE when the cluster takes the ITTAGE target for the slot.
- Must assert p2 redirect when ittage_hit is asserted and the successor implied by VIRT_ittage_pred_tgt differs from the one the cluster's own p1 stage registers hold. THE COMPARISON IS NOT AGAINST THE FTB: it is one quantity, the successor, against the cluster's own staged view. fe_decisions.md FE-4 and ftq_bpu_interfaces.md 6 -- no predictor is compared against another predictor, and the cluster does not read the FTQ. An earlier revision said "disagrees with FTB target". That the FTB target is what stands on an ITTAGE miss (ftb_decisions.md 4.2) is a selection rule, not a comparison. Corrected session-070.
- Must gate ITTAGE prediction on indirect branch type, excluding RETURN AND RETURN_CALL. Indirect CALL is in scope for both ITTAGE and RAS: ITTAGE predicts the target, RAS pushes the return address. RETURN and RETURN_CALL are handled by the RAS exclusively -- RETURN_CALL pops for its target and then pushes, and ras_decisions.md 2 makes it unambiguously the RAS's.
This rule said "excluding RETURN" only. RETURN_CALL is an
indirect JALR and is not RETURN, so by the letter of it ITTAGE
would predict a RETURN_CALL, against ras_decisions.md 2,
fe_decisions.md FE-U9 and ftq_entry_formats.md 3.1. Corrected
session-070. Whether RETURN_CALL TRAINS ITTAGE at resolution is a
separate question and is still open: FE-U9.
ITTAGE Simulation Support¶
-
ITTAGE_FAST_INIT: runtime plusarg (+ITTAGE_FAST_INIT=1). Read in ittage.sv and ittage_table.sv. When set: ittage_table initial blocks write bw_ram mem arrays via hierarchical reference at time zero. ittage.sv straps all tbl_ri_* to zero and drives ittage_rdy=1 immediately. sram_init elaborates but is fully bypassed. When not set: sram_init sequences all entries, ittage_rdy follows tbl_ri_rdy from sram_init. Simulation-only mechanism. No synthesis impact. bw_ram.sv is not modified.
-
IT_SRAM_INIT_VALUE: localparam int in bp_defines_pkg.sv, default 0. Used by sram_init (.INIT_VAL) and ittage_table initial blocks.
Update Interface¶
Producer: post-execute resolution path (BP cluster)¶
Consumer: ittage¶
Timing¶
ittage_upd_inp_u0[s] is presented at u0. Sampled on rising clk edge. ittage_upd_rdy_u1[s] is asserted at u1 when the update has been applied. Update completes in one cycle. ittage_upd_val_u0[s] may be asserted in any cycle. No ordering constraint between update channels when NUM_PRED_SLOTS=2. Both channels processed independently in the same cycle.
RAM Init Interface¶
Output ittage_rdy indicates that the RAM initialization cycles have completed. It ties to the ready output of the sram_init module.
No prediction or update cycles begin before ittage_rdy has been asserted. ITTAGE does not gate requests on ittage_rdy; the upstream logic does. The upstream logic is the FTQ: ftq_npc holds ftq_pred_val_p0 low until tage_rdy, ittage_rdy and sc_ready are all high (ftq_decisions.md 4.5 H5; ruled session-080, built by BP-137). No FTQ entry, so no update, exists before the first request. This read that ITTAGE ignores prediction and update requests before ittage_rdy; it does not. Session-080.
Semantics¶
ittage_upd_val_u0[s] = 0 -- no update this cycle for slot s.
ittage_upd_inp_u0[s] ignored.
ittage_upd_val_u0[s] = 1 -- resolved update for slot s.
All ittage_upd_inp_u0[s] fields
valid.
ittage_upd_rdy_u1[s] = 1 -- update applied for slot s.
ittage_upd_rdy_u1[s] -- flopped version of ittage_upd_val_u0[s].
All updates complete in one cycle.
No backpressure is currently required.
Consumer may ignore this signal.
Retained as placeholder for future
backpressure if required.
ittage_pq_not_full -- asserted when the prediction queue has
room to accept a new prediction request.
Consumer must gate ittage_pred_val_p0
on this signal. Since BP-121 it also
drops for one cycle as the starvation
hold, so that a waiting update finds a
cycle with no prediction
(bp_arb_spec.md 4.5). A prediction is
never delayed by an update. Was
pq_not_full; renamed by BP-132 (TD#49).
ittage_uq_not_full -- asserted when the update queue is not
full. Consumer must gate
ittage_upd_val_u0 on this signal. Was
upd_rdy; renamed by BP-132 (TD#49).
bp_cluster connects it to its own port
ittage_upd_rdy, which keeps that name
(ruled, Jeff, session-078).
Both are driven by ittage_arb.sv, the
ITTAGE arbitration (PQ, UQ, arbiter; no
response buffer), a submodule of
ittage.sv since BP-132 (TD#52).
Update Behavior¶
CTR is a confidence counter, not a direction counter. It tracks confidence in the stored target address for the provider entry.
The provider is determined by ittage_using_primary: when 1 the primary table entry supplied the prediction; when 0 the alternate supplied it. The corresponding CTR write port is asserted -- either prm_ctr_wr_u0 or alt_ctr_wr_u0, never both in the same cycle. Both write ports are real and active. They are mutually exclusive by design, not by omission.
The definitive operation of CTR updates is found in ittage_cntrl_ctr_update_rules.md.
The definitive operation of update time allocations is found in ittage_cntrl_alloc_rules.md.
Target Write Gating (prm_tgt_wr_u0 / alt_tgt_wr_u0)¶
THERE ARE TWO TARGET STROBES, one per provider, declared in ittage_table_interfaces.md. This section read "tgt_wr_u0", a single strobe that no port list declares. Session-072.
A target write is issued only when all three conditions hold:
indir_mispredict == 1
AND provider CTR from meta == 3'b000 (null confidence)
AND THIS_TABLE matches that provider's table selector
ittage_using_primary selects which strobe carries the write, and with it which selector gates the table:
ittage_using_primary == 1: prm_tgt_wr_u0, gated on prm_tbl_sel_u0
ittage_using_primary == 0: alt_tgt_wr_u0, gated on alt_tbl_sel_u0
The two are mutually exclusive for a slot, as prm_ctr_wr_u0 and alt_ctr_wr_u0 are. Both carry tgt_wd_u0 as their write data.
From Seznec: if CTR is non-null on misprediction, decrement CTR -- no target write. If CTR is null on misprediction, replace target -- CTR stays at null, no CTR write. Under this rule the two do not coincide, but the active target strobe and the active CTR write port (prm_ctr_wr_u0 or alt_ctr_wr_u0) are NOT REQUIRED to be mutually exclusive: a same-entry CTR and TGT write is one merged RAM write, as for CTR and USE (ittage_cntrl_decisions.md, Concurrent CTR and TGT Writes). This read that the two "are mutually exclusive" and "are never asserted in the same cycle for the same entry", the requirement that document dropped. Session-071.
Explicitly: Even when the gating conditions are satisfied for both the primary and the alternate hitting tables, only the component that provided the prediction has its target field modified.
Read-during-Write Contract¶
Prediction and update paths are mutually exclusive by design. The prediction path is read-only. The update path is write-only. No read-modify-write cycles are required or permitted.
Producer Obligations¶
- Must provide resolved_target from execute, not speculative.
- Must pass ittage_pred_meta_p2[s] captured at predict time unmodified into ittage_upd_inp_u0[s]. No recomputation at update.
- Must not assert upd_val on the same branch_id via both channels in the same cycle (undefined update order).
Bank Address Assignment¶
See ittage_table_interfaces.md section Bank Address Assignment.
Override Chain Position¶
ITTAGE fires at p2 alongside FTB and TAGE, and supplies the target (not the direction) for an indirect branch when it hits:
p1: uBTB + Loop
p2: FTB + TAGE + ITTAGE + RAS
p3: SC
Target selection at p2, by branch class then by hit:
RETURN RAS ras_pop_addr_p2
indirect ITTAGE on hit; the FTB target on an ITTAGE miss
otherwise FTB target
THIS IS SELECTION, NOT A PRIORITY CHAIN. An earlier revision wrote it as "ITTAGE > FTB" and "RAS > FTB", which reads as contenders ranked for one output. The FTB is not a third arm competing with the other two: it is what stands when ITTAGE misses (ftb_decisions.md 4.2), and RAS and ITTAGE are gated by branch class, not ranked. fe_decisions.md FE-3 and section 12. Corrected session-070.
ITTAGE and RAS operate on mutually exclusive branch classes. No dynamic arbitration between them is required.
SC at p3 supplies the direction for conditional branches only. SC does not interact with ITTAGE target prediction.
Known Gaps and Deferred Items¶
| ID | Item | Status |
|---|---|---|
| II1 | bp_folded_hist_t missing | Complete |
| it_t5_idx_fh, it_t5_tag_fh1, | ||
| it_t5_tag_fh2. Comment in | ||
| bp_structs_pkg.sv states "IT5 is | ||
| BrIMLI -- no folds" which is | ||
| incorrect. | ||
| II2 | PHR contribution to index/tag hashing | TBD at impl. |
| All current folds are GHR-derived only. | ||
| II3 | Flush port definitions (_px signals). | CLOSED BP-105. |
| NO FLUSH EVENT EXISTS: a flush is a | fe_decisions | |
| redirect. ittage needs no flush port | FE-14. | |
| and none is added. | ||
| II4 | FTQ meta overload scheme for ITTAGE | G10 in |
| and TAGE sharing index fields at | bp_cluster.md. | |
| update. | ||
| II5 | No-hit allocation scan direction. | Complete |
| Confirm scan from IT1 at impl. | ||
| II6 | Target write gating definition. | Complete |
| Gating conditions, and the CTR write | ||
| relationship (not required exclusive), | ||
| Target Write Gating section above | ||
| and in ittage_cntrl_decisions.md. |
ittage_table_interfaces.md
planning/interfaces/ittage_table_interfaces.md on GitHub
ITTAGE Table Interface Specification¶
FILE: ittage_table_interfaces.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-14
CONTACT: Jeff Nye
Overview¶
ITTAGE is a indirect target tagged geometric history length branch predictor providing target prediction for indirect branches. It fires at p2 alongside FTB and SUPPLIES THE TARGET for an indirect branch when it hits; the FTB target stands on a miss (ftb_decisions.md 4.2). This is target selection by hit and is independent of the conf direction mechanism, which never affects target overrides (ftb_confidence_override_rules.md 1).
THE p2 REDIRECT IS A SEPARATE QUESTION: it fires only when the successor the cluster would publish differs from the one its own p1 stage registers hold, so a target that matches the one already staged fires nothing (fe_decisions.md FE-4 and 2.5). An earlier revision said "s2_redirect fires on override". Corrected session-070.
There are two phases in a ITTAGE design, prediction request and update request. The phase do not overlap.
ITTAGE supports dual prediction. Each table type contains two rams one for each prediction request/update request. The dual nature is also described as dual slots.
Each prediction slot operates independently. All signals indexed [s] target RAMs exclusively. Slot 0 and slot 1 may perform any combination of read, write, or allocation simultaneously without interference.
ITTAGE is comprised only tagged components, also know as tables. There are no untagged components in ITTAGE.
Up to 2 components (primary and alternative) may supply CTR-field provenance during an update, but only one CTR write actually occurs per slot: prm_ctr_wr_u0 and alt_ctr_wr_u0 are mutually exclusive, never both asserted in the same cycle for the same slot. Unlike TAGE, ITTAGE never writes both provider CTRs in the same update.
Table description¶
There are a parameterized number of tables. Current working version has 5 tables.
Tables are also known as components (unrelated to this projects library of components). The term components is often used in the literature.
There is only one table type in ITTAGE, tagged. There are five tagged tables, IT1-IT5.
Tagged tables use module ittage_table, the file is rtl/core/frontend/bpu/rtl/ittage_table.sv
The tagged tables are IT1-IT5, and entry in a tagged table include a valid bit, an CTR field (confidence counter), a USE (usefulness counter), an EPC (epoch field used for usefulness aging), a TGT field (target address), and TAG ( a compare tag based on the PC and a hashing function.).
The widths of these fields are parameterized. The valid is not parameterized it is alway 1 bit wide.
The widths are specified in parameter array's allowing per table specialization of the widths.
The maximum range for each field is stored in a parameter. These parameters
are found in bp_defines_pkg.sv
IT_MAX_TAG_WIDTH
IT_MAX_TGT_WIDTH
IT_MAX_EPC_WIDTH
IT_MAX_USE_WIDTH
IT_MAX_CTR_WIDTH
IT_MAX_VAL_WIDTH
ITTAGE Tagged Table Entry Format¶
The field formats for tables IT1-IT5 are defined
in planning/arch/ittage_table_entry_formats.md
Bank Address Assignment¶
Each ittage_table instance contains two bw_ram instances, one per prediction slot (RAM0 for slot 0, RAM1 for slot 1). Each bw_ram is instantiated with BANKS=2.
The bank_addr port of each bw_ram is derived from the MSB of the index. The row address is the remaining lower bits. For a THIS_INDEX_BITS-wide index:
bank_addr = index[THIS_INDEX_BITS-1]
row_addr = index[THIS_INDEX_BITS-2:0]
This decomposition applies to prediction reads, normal update writes, and the tbl_ri initialization path.
Table Pipeline¶
The prediction phase uses pipestages p0, p1, p2. Table inputs are presented on p0, SRAM read/compare/tag match occurs on p1. P2 is not used by tables.
The update phase uses pipestages u0, u1. Table inputs are presented on u0, SRAM write occurs in u1.
Port Naming Convention¶
Port naming convention follows ittage_interfaces.md section Port Naming Convention. The ports are not identical between the two table types. They are listed below.
Parameters Types and Structs¶
All types defined in bp_defines_pkg.sv and bp_structs_pkg.sv. This document describes port semantics, timing contracts, and consumer/producer obligations. It does not restate struct field layouts -- see bp_structs_pkg.sv.
Top Level Parameters¶
These parameters are defined in bp_defines_pkg.sv (this read br_defines_pkg.sv, session-072). These parameters define the limits, they are not table specific.
NUM_PRED_SLOTS : int
IT_MAX_IDX_WIDTH : int
IT_MAX_TAG_WIDTH : int
IT_MAX_TGT_WIDTH : int
IT_MAX_EPC_WIDTH : int
IT_MAX_USE_WIDTH : int
IT_MAX_CTR_WIDTH : int
IT_MAX_VAL_WIDTH : int
Top level module parameters are vectored, the vector positions are aligned with the assumption that tables will be instantiated in a generate loop and the loop index will select the proper parameter for that table.
These are the table specific vectored parameters. These values are for explanation the values to use during design are found in bp_defines_pkg.sv.
These parameters are shared across all tables. Note: position zero is a placeholder for the non-existent IT0.
IT_TBL_BANKS[0:5] : int this parameter is not currently used
IT_TBL_ENTRIES[0:5] : int this describes the number of entries in each
bw_ram instance.
IT_TBL_FH[0:5] : int this is the width of the index folded history (fh)
IT_TBL_FH1[0:5] : int this is the width of the 1st tag folded history (fh1)
IT_TBL_FH2[0:5] : int this is the width of the 2nd tag folded history (fh2)
IT_TBL_HIST[0:5] : int this is the number of history bits
IT_TBL_TAG[0:5] : int this is the width of the tag field
IT_TBL_CTR[0:5] : int this is the width of the CTR field
IT_TBL_USE[0:5] : int this is the width of the USE field
IT_TBL_EPC[0:5] : int this is the width of the EPC field
IT_TBL_IDX[0:5] : int this is the width of the index bus for tables
IT_TBL_TGT_WIDTH[0:5] : int this is the width of the target bus
Derived Parameters¶
IT1-IT5¶
THIS_CNTRL_BITS_WIDTH : int THIS_EPC_WIDTH + THIS_USE_WIDTH
+ THIS_CTR_WIDTH + THIS_TGT_WIDTH
+ THIS_VAL_WIDTH
THIS_ALLOC_DATA_WIDTH : int THIS_CNTRL_BITS_WIDTH + THIS_TAG_BITS
Internal Module Parameters¶
Internally a table uses the THIS_ nomenclature to specialized the top level module level parameters for use in the module. These are set by the table specific assignments that occur above this level at module instantiation.
Common internal module parameters¶
THIS_TABLE : int this indicates which table IT0-IT5.
IT0 is a placeholder only and is never
instantiated. Valid range is IT1-IT5.
TBL_SEL_WIDTH : int this is the width of the table select bus,
typically tbl_sel or alc_sel buses.
THIS_VAL_WIDTH : int = 1 this is a static value, the parameter is
only used for documentation.
Internal module parameters¶
These are assigned during instantiation.
THIS_INDEX_BITS : int this is the local width of the index bus
THIS_TAG_BITS : int this is the local width of the TAG field
THIS_EPC_WIDTH : int this is the local width of the EPC field
THIS_USE_WIDTH : int this is the local width of the USE field
THIS_CTR_WIDTH : int this is the local width of the CTR field
THIS_TGT_WIDTH : int this is the local width of the TGT field
Port Lists¶
There are two prediction slots, 0 and 1, these are referenced by a vector index 0/1. These are two independent prediction slots.
IT1-IT5 Port List (ittage_table)¶
Prediction Ports¶
output [NUM_PRED_SLOTS-1:0] hit_p1
output [IT_MAX_TGT_WIDTH-1:0] pred_tgt_p1[0:NUM_PRED_SLOTS-1]
output [THIS_CNTRL_BITS_WIDTH-1:0] cntrl_bits_p1[0:NUM_PRED_SLOTS-1]
output logic [THIS_INDEX_BITS-1:0] idx_hash_p0[0:NUM_PRED_SLOTS-1]
output logic [IT_MAX_TAG_WIDTH-1:0] tag_hash_p0[0:NUM_PRED_SLOTS-1]
input [NUM_PRED_SLOTS-1:0] ittage_pred_val_p0
input ittage_pred_inp_t ittage_pred_inp_p0[0:NUM_PRED_SLOTS-1]
Update Ports¶
input [NUM_PRED_SLOTS-1:0] ittage_upd_val_u0
input [THIS_CTR_WIDTH-1:0] prm_ctr_wd_u0[0:NUM_PRED_SLOTS-1]
input [THIS_CTR_WIDTH-1:0] alt_ctr_wd_u0[0:NUM_PRED_SLOTS-1]
input [THIS_USE_WIDTH-1:0] use_wd_u0[0:NUM_PRED_SLOTS-1]
input [THIS_EPC_WIDTH-1:0] epc_wd_u0[0:NUM_PRED_SLOTS-1]
input [IT_MAX_TGT_WIDTH-1:0] tgt_wd_u0[0:NUM_PRED_SLOTS-1]
input [THIS_ALLOC_DATA_WIDTH-1:0] alc_wd_u0[0:NUM_PRED_SLOTS-1]
input [NUM_PRED_SLOTS-1:0] prm_ctr_wr_u0
input [NUM_PRED_SLOTS-1:0] alt_ctr_wr_u0
input [NUM_PRED_SLOTS-1:0] use_wr_u0
input [NUM_PRED_SLOTS-1:0] epc_wr_u0
input [NUM_PRED_SLOTS-1:0] prm_tgt_wr_u0
input [NUM_PRED_SLOTS-1:0] alt_tgt_wr_u0
input [NUM_PRED_SLOTS-1:0] alc_wr_u0
input [TBL_SEL_WIDTH-1:0] prm_tbl_sel_u0[0:NUM_PRED_SLOTS-1]
input [TBL_SEL_WIDTH-1:0] alt_tbl_sel_u0[0:NUM_PRED_SLOTS-1]
input [THIS_INDEX_BITS-1:0] upd_index_u0[0:NUM_PRED_SLOTS-1]
input [TBL_SEL_WIDTH-1:0] alc_tbl_sel_u0[0:NUM_PRED_SLOTS-1]
input [THIS_INDEX_BITS-1:0] alc_index_u0[0:NUM_PRED_SLOTS-1]
prm_ctr_wr_u0 and alt_ctr_wr_u0 are mutually exclusive. They are never both asserted in the same cycle for the same slot. Both are real write paths -- the distinction from TAGE is that TAGE may assert both simultaneously; ITTAGE never does.
prm_tgt_wr_u0 / alt_tgt_wr_u0 are asserted only on misprediction AND provider CTR was null at predict time. The active strobe is selected by ittage_using_primary: prm_tgt_wr_u0 gated by THIS_TABLE vs prm_tbl_sel_u0, alt_tgt_wr_u0 gated by THIS_TABLE vs alt_tbl_sel_u0. See ittage_interfaces.md section Target Write Gating for full gating conditions and the relationship to CTR writes, which are NOT required to be mutually exclusive with a target write. This read "mutual exclusion with CTR writes", which that section withdrew session-071. Session-072.
Misc Ports¶
input tbl_ri_active
input tbl_ri_wr
input [THIS_INDEX_BITS-1:0] tbl_ri_wa
input [THIS_ALLOC_DATA_WIDTH-1:0] tbl_ri_wd
input bp_folded_hist_t folded_hist
input rstn
input clk
Misc Interface¶
Semantics:¶
The tbl_ri ports are not driven by ittage_cntrl. They are driven by an SRAM initialization module instantiated in ittage.sv. The init module is found rtl/lib/rtl/sram_init.sv
tbl_ri_active ram initialization is active
tbl_ri_wr ram write signal, this needs to be converted to an active low
bit write and a global select. When tbl_ri_active is
asserted, tbl_ri_wr overrides all other write signals. But there
is no case where tbl_ri_wr and the other write signals are
asserted.
tbl_ri_wa ram address signal. When tbl_ri_active is asserted, tbl_ri_wa
overrides all other ram address signals. Sized to
THIS_INDEX_BITS.
tbl_ri_wd ram write data signal When tbl_ri_active is asserted, tbl_ri_wd
overrides all other ram data input signals.
Prediction Interface¶
Port Semantics¶
ittage_pred_val_p0[s] trigger that enables SRAM read for
slot s. Produced by ittage top level.
ittage_pred_inp_p0[s] carries branch PC and branch_id for
slot s. PC used locally to derive
idx_hash_p0 and tag_hash_p0. Produced by
ittage top level.
folded_hist bp_folded_hist_t output of bp_history,
shared across both prediction slots.
Each ittage_table selects the three
fields for its THIS_TABLE value
(it_tN_idx_fh, it_tN_tag_fh1,
it_tN_tag_fh2). Produced by bp_history.
hit_p1[s] result of tag compare gated with valid
bit. One bit per slot.
pred_tgt_p1[s] 40-bit target address read from the
matching entry. Valid only when
hit_p1[s]=1.
cntrl_bits_p1[s] control bit portion of entry used by
ittage_cntrl to form response metadata.
idx_hash_p0[s] combinational index hash from pc and
folded_hist at p0. Used by ittage_cntrl
to populate ittage_prm_idx and
ittage_alc_idx in prediction meta.
The rules for idx_hash_p0 generation are
found in ittage_table_hash_rules.md
tag_hash_p0[s] combinational tag hash from pc and
folded_hist at p0. Used by ittage_cntrl
to populate ittage_alc_tag in prediction
meta. The rules for tag_hash_p0 generation
are found in ittage_table_hash_rules.md
Update Interface¶
Port Semantics¶
ittage_upd_val_u0[s] trigger that enables SRAM writes for
slot s. Produced by ittage top level.
prm_ctr_wd_u0[s] CTR write data for the primary provider
entry. Produced by ittage_cntrl.
alt_ctr_wd_u0[s] CTR write data for the alternate provider
entry. Produced by ittage_cntrl.
use_wd_u0[s] USE field write data.
Produced by ittage_cntrl.
epc_wd_u0[s] EPC field write data.
Produced by ittage_cntrl.
tgt_wd_u0[s] 40-bit target write data. Written only on
misprediction when provider CTR was null.
Produced by ittage_cntrl.
alc_wd_u0[s] allocation write data. Writes all control
bits, tag, and target for a new entry.
Produced by ittage_cntrl.
prm_ctr_wr_u0[s] write enable for primary provider CTR.
Gated by THIS_TABLE vs prm_tbl_sel_u0.
Mutually exclusive with alt_ctr_wr_u0.
alt_ctr_wr_u0[s] write enable for alternate provider CTR.
Gated by THIS_TABLE vs alt_tbl_sel_u0.
Mutually exclusive with prm_ctr_wr_u0.
use_wr_u0[s] write enable for USE field. Opens on
THIS_TABLE vs prm_tbl_sel_u0 with
prm_ctr_wr_u0, or THIS_TABLE vs
alt_tbl_sel_u0 with alt_ctr_wr_u0.
epc_wr_u0[s] write enable for EPC field. Gated as
use_wr_u0 is.
THE USEFUL AND EPOCH WRITE GOES TO THE
PROVIDER, the component
ittage_cntrl_use_update_rules.md Table 7
selects: the primary when
ittage_using_primary is 1, the alternate
when it is 0. ittage_cntrl raises use_wr_u0
and epc_wr_u0 without a table select of their
own; the table opens them with the CTR strobe
of the provider, prm_ctr_wr_u0 on
prm_tbl_sel_u0 or alt_ctr_wr_u0 on
alt_tbl_sel_u0, which ittage_cntrl raises for
the provider only. ittage_cntrl drives
prm_tbl_sel_u0 from the primary and
alt_tbl_sel_u0 from the alternate in every
case. The address is upd_index_u0 (below).
Every Table 7 write row (3-6) has a hit and a
tagged provider, so the provider's CTR strobe
is always raised with it.
prm_tgt_wr_u0[s] write enable for target field via the
primary provider. Asserted only on
misprediction when provider CTR was null
at predict time and ittage_using_primary=1.
alt_tgt_wr_u0[s] write enable for target field via the
alternate provider. Asserted only on
misprediction when provider CTR was null
at predict time and ittage_using_primary=0.
alc_wr_u0[s] write enable for allocation. Gated by
THIS_TABLE vs alc_tbl_sel_u0.
prm_tbl_sel_u0[s] primary provider table index. Used to
gate field write enables.
Produced by ittage_cntrl.
alt_tbl_sel_u0[s] alternate provider table index. Used to
gate alt_ctr write enable.
Produced by ittage_cntrl.
upd_index_u0[s] RAM address for update writes. ittage_cntrl
produces the primary index and the alternate
index on separate buses; ittage.sv selects one
for each table instance: the primary when
THIS_TABLE equals prm_tbl_sel_u0[s], the
alternate otherwise.
alc_tbl_sel_u0[s] table index for allocation.
Produced by ittage_cntrl.
alc_index_u0[s] RAM address for allocation write.
Produced by ittage_cntrl.
ras_decisions.md
planning/arch/ras_decisions.md on GitHub
RAS Micro-Architectural Decisions¶
FILE: ras_decisions.md
SOURCE: session-050
STATUS: DRAFT
UPDATED: 2026-10-29
CONTACT: Jeff Nye
Canonical decision record for the Return Address Stack (RAS) predictor. Companion to bp_cluster.md (architectural summary) and bp_arb_spec.md (arbitration model). Those documents reference this file for RAS-specific decisions. Claude Code loads this file when working on ras.sv or related testbenches.
1. Role and Pipeline Position¶
RAS predicts the target of return-type indirect branches (JALR/C.JR/C.JALR matching return register convention).
Pipeline stage: p2 push/pop, p3 registered. Override: RAS supplies the TARGET for a return and takes no part in the direction ranking (SC > TAGE > FTB on direction, with a trusted loop prediction above all three since BP-122, fe_decisions.md 3.3; ftb_confidence_override_rules.md 4.3). It is type-gated -- active only when FTB identifies the branch type as return. An earlier revision placed it "outside the conditional branch override chain (SC > TAGE > FTB > uBTB)", which compresses a direction ranking and a target selection into one chain. fe_decisions.md 12, narrowed session-070.
At p2: RAS overrides FTB target for return branches. At p3: p3 repair applied if p3 structural prediction differs from p2.
p2/p3 repair table:
p2=push, p3=no-op -> repair: pop
p2=no-op, p3=pop -> repair: pop
p2=pop, p3=no-op -> repair: push
p2=no-op, p3=push -> repair: push
p2=return-call, p3=no-op -> repair: undo both, as one operation
p2=no-op, p3=return-call -> repair: missed pop, then missed push
Note: push->pop and pop->push within one p2/p3 pair cannot occur.
The two return-call rows were added after BP-119, which built them. The undo restores TOSR to its value before the p2 operation, held in a register (exact for the pointers by FE-11). A recursion count the pop decremented or the push incremented is restored by the undo (BP-133, TD #78 closed session-079).
A return-call paired at the other stage with a plain push or pop is
not specified. As built by BP-120 (tb_ras TC-33a..d):
p2=return-call, p3=return -> undo-push; gives the p3 result
p2=return, p3=return-call -> missed push; gives the p3 result
p2=return-call, p3=call -> undo-pop; the push is lost; WRONG
p2=call, p3=return-call -> missed pop retracts the push; WRONG
None of the four could occur before BP-121: bp_cluster gave the
repair the registered p2 qualification as the p3 one, so p2 and p3
never differed (TD#166). SINCE BP-121 (D10, TD#166 closed) the p3
view is qualified by p3 reachability, which uses the SC direction:
ras_pred_val_p3 = r_val_p3 & r_brv_p3 & w_reach_p3. The p3 view now
differs from p2 when SC reverses a direction that skips or reaches a
call or return, and the repair runs.
TD#165 CLOSED session-076 (Jeff), UNREACHABLE BY CONSTRUCTION. The two wrong pairings need the p2 and p3 TYPES of one slot to differ. The p3 type is the registered p2 type (IC-RAS-12), so they never do; only the p3 qualification differs since BP-121, and that gives a plain undo or a plain missed operation, which are right. BP-122 confirmed it from the RTL. IF THE p3 TYPE IS EVER TAKEN FROM ANYWHERE BUT THE REGISTERED p2 TYPE, these two rows become reachable and must be fixed first: ras.sv gets them wrong today (tb_ras TC-33c, d).
Repair label semantics: the push/pop labels above denote
stack-height restoration of resident entries, not fresh
allocation or array clear.
- p2=push, p3=no-op (undo-push): TOSR retract of the
still-resident frontier slot. If that slot carried a
recursion count the count is decremented in place;
otherwise TOSR moves back one slot. The array entry is
not cleared. A push that met a saturated count (15)
changed nothing, and its undo changes nothing (BP-134;
before it the undo decremented the count).
- p2=pop, p3=no-op (undo-pop): TOSR re-expose. TOSR is
restored to its pre-op value (BP-120), re-exposing the
still-resident entry the pop uncovered, and a count the pop
decremented is incremented back (BP-133). No return address
is written, TOSW held. When the pop began on an empty stack,
TOSR is restored to BOS as it is at the undo (BP-138); the
same holds for the undo of a whole return-call.
- p2=no-op, p3=pop (missed pop): same TOSR retract as
undo-push.
- p2=no-op, p3=push (missed push): the only case that
allocates and writes. The registered fallthrough is
written at the frontier and TOSW advances.
Undo-pop over a recursion-decrement pop (BP-133, TD #78 closed session-079): the pop held TOSR and decremented the count; the undo restores the pre-op TOSR and increments the count back. tb_ras TC-21 (BP-064 pinned the non-reversing behavior until BP-133) and TC-38; tb_fe_top rec_undo (BP-134) reaches it end to end at two slots. At one slot it cannot occur: the p3 view of slot 0 always equals its p2 operation (BP-134). This paragraph read "Limitation (TD #78): undo-pop re-expose does NOT reverse a recursion-decrement pop".
RAS does not generate a redirect signal in the same sense as TAGE or SC. Its p0 TOS read is an input to the p1 prediction, which the cluster registers and applies when the p1 mux forms a RETURN slot (fe_decisions.md 2.2); this read "It provides the initial p0 prediction (TOS read)", session-071. It supplies the target for a return at p2, which participates in the p2 redirect when the resulting successor differs from the one the cluster's p1 stage registers hold. An earlier revision said it participates "when FTB disagrees with the uBTB p0 result", which is wrong twice: the comparison is not predictor against predictor (FE-4), and the p1 successor is the uBTB's or the loop predictor's, whichever the p1 mux selected, held at p1 rather than p0 (fe_decisions.md 2.5). Corrected session-070.
No PQ, UQ, or credit arbiter. RAS does not have synchronous SRAMs. See bp_arb_spec.md section 7.2.
1.1 Stage and update notes¶
THE NAME spec_pop_addr IS RETIRED. ras.sv declares ras_tos_addr_p0, the p0 top-of-stack read the cluster registers and applies at p1, and ras_pop_addr_p2, the p2 pop output that supplies the return target and the p2 redirect target (ras_interfaces.md Port List). spec_pop_addr named the second of those in this document, bp_cluster.md, fe_decisions.md and ittage_interfaces.md, and the first of them in fe_decisions.md 9, and was declared by nothing. Swept session-072.
- Stage: p2 push/pop + ras_pop_addr_p2; p3 = p2 registered.
- Update: speculative at p2 (separate from main update channels).
Commit stack updated at retire/commit, not post-execute.
- Outside the conditional branch override chain.
1.2 Role in redirect architecture¶
p2_redirect: fires when the successor the cluster would publish
at p2 differs from the one its own p1 stage registers hold. NOT
"disagrees with uBTB p1": the p1 successor is the uBTB's or the
loop predictor's, whichever the p1 mux selected (fe_decisions.md
2.5), and the comparison is one quantity against the cluster's
own staged view, never predictor against predictor (FE-4).
Corrected session-070. For return branches, the redirect target is
ras_pop_addr_p2.
p3_redirect: RAS p3 = p2 registered, qualified by p3
reachability (section 1, BP-121). Stack repair applied at
p3 if p3 structural prediction disagrees with p2 (see repair
table above). The repair restores stack height of resident
entries; it does not allocate (except the missed-push case)
or clear the array. Undo-pop reverses a recursion-decrement
pop (BP-133). See the repair label semantics in section 1.
2. Call and Return Detection¶
Detection is by RISC-V register convention, not by opcode alone. FTB structural prediction provides branch type to RAS.
Call instructions (push trigger):
JAL rd=x1 or rd=x5
JALR rd=x1 or rd=x5
C.JALR (implicit rd=x1)
Return instructions (pop trigger, pop ONLY):
JALR rs1=x1 or rs1=x5, with rd not a link register or rd==x0
C.JR rs1=x1 or rs1=x5
C.JALR is NEVER a pop-only return: it expands to JALR x1, rs1, 0,
so its rd is always a link register.
Pop-then-push (RETURN_CALL):
JALR rd and rs1 BOTH link registers and rd != rs1
C.JALR with rs1=x5 -- its rd is x1, so this is that same case
The C.JALR line above read "C.JALR with rs1=x5 is excluded from
return classification", which is true of POP-ONLY return and was
being read as excluding it from RETURN_CALL too. C.JALR rs1=x5 is
a pop-then-push; C.JALR rs1=x1 is push only, since rd == rs1.
Session-070.
JALR follows the RISC-V hint table exactly. Link means x1 or x5:
rd rs1 rs1 == rd RAS action
!link !link -- none
!link link -- pop RETURN
link !link -- push call
link link no pop, push RETURN_CALL
link link yes push call
The compressed forms map onto that table, they are not extra cases:
C.JR rs1 = JALR x0, rs1, 0. rd = x0, never link.
rs1 link -> pop. rs1 !link -> none.
C.JALR rs1 = JALR x1, rs1, 0. rd = x1, ALWAYS link.
rs1 = x1 -> rs1 == rd -> push.
rs1 = x5 -> both, unequal -> pop, push.
rs1 !link -> push.
SO C.JALR IS NEVER A POP-ONLY RETURN, and a JALR is a return only when rd is not a link register.
The hint table and the compressed-form mapping moved here from bp_cluster.md session-071, which this section had pointed to for them; this is now their only home.
RETURN_CALL, session-069. The specification's return-address-stack hints make a JALR whose rd and rs1 are both link registers and are UNEQUAL a pop followed by a push. An earlier revision of the return rule excluded every JALR with a link rd, which covers two different cases:
rd == rs1, both link push only. The exclusion is CORRECT; the
specification agrees.
rd != rs1, both link pop THEN push. The exclusion dropped the
pop, so the stack grew by one on every
such instruction instead of staying level.
bp_br_type_e gains RETURN_CALL at 3'b111, the one free encoding
in the 3-bit enum. It is a package edit, so the verification run
widens to both units.
THE OWNERSHIP RULE BELOW SURVIVES IT. The package comment on the enum worried that a JALR satisfying both the call and the return rule would break the mutually exclusive RAS / ITTAGE split. It does not, because RETURN_CALL is a SINGLE classification and it is unambiguously the RAS's: ownership decides which predictor handles an instruction, and this one is handled by the RAS performing two operations rather than by two predictors performing one each. An earlier revision called this a "three-way ... FTB / RAS / ITTAGE split"; the FTB is not an arm of it, see below.
JALR ownership:
RAS: JALR/C.JR/C.JALR matching return register convention
ITTAGE: every other indirect JALR
RAS and ITTAGE are mutually exclusive by branch type, resolved by FTB structural prediction before p2. THE FTB IS NOT A THIRD ARM. An earlier revision read "Three-way JALR split with FTB and ITTAGE" with "FTB: JALR with fixed stable target (most direct calls)". The FTB target is the ITTAGE-MISS FALLBACK (ftb_decisions.md 4.2), selected by hit rather than by how stable the target is, so it is not a type-based arm alongside the other two. ittage_interfaces.md and bp_cluster.md carried the same error. fe_decisions.md 3.3. Corrected session-070.
3. Dual-Stack Structure¶
3.1 Structure decision¶
DECIDED session-050: static partition, two independent physical arrays. One speculative stack, one commit stack.
Rejected: unified pool (single 48-entry array shared between speculative and commit). Rationale: static partition keeps overflow detection at fixed limits, mispredict restore touches only the speculative array, commit advancement touches only the commit array. Pointer arithmetic and verification complexity both minimized. 48-entry total budget is generous enough that the flexibility of a unified pool is not needed.
Revisit trigger: SPEC benchmark performance analysis at bp_cluster integration. If commit stack overflow is a measured event under real workloads, rebalance the split before any structural change.
3.2 Speculative stack¶
Entries: 16
Structure: circular buffer with a next-on-stack link per entry
(ruled session-075, below). This read "simple circular
buffer. No linked-list structure."
Purpose: Covers in-flight call depth between fetch and commit.
Snapshot for mispredict recovery: three pointers (TOSR, TOSW, BOS) saved per FTQ entry. On mispredict, restore all three from the FTQ snapshot of THE ENTRY THE REDIRECT NAMES by its index (ftq_backend_interfaces.md 5 D2), including when _self marks that entry squashed. This read "the last known-good entry"; 4.3 said "the mispredicted entry" and 4.4 "the youngest valid entry before the flush point". One rule, three phrasings; D2 is the reference. Session-070. Full speculative history is preserved in the circular buffer -- no replay of individual operations needed provided the buffer has not wrapped.
DECIDED session-050: simple circular buffer chosen over the Xiangshan Kunminghu linked circular array. Academic literature (Desmet et al., ACM TACO) shows no measurable IPC benefit from linked speculative stacks over a simple circular buffer with a BTB fallback for detected corruption. Commercial designs (AMD Zen 1-5, Intel Golden Cove through Lion Cove) all use pointer-only recovery. Complexity cost not justified.
Revisit trigger: RAS misprediction rate under SPEC benchmarks shows wrong-path corruption as a significant contributor. Candidate remedies at that point: linked structure or corruption detector per Desmet et al.
DEFECT IN THE POINTER RULES BELOW, found by BP-119, TD#159. Push writes at TOSW and TOSW only advances; pop moves TOSR to TOSR-1. After a pop then a push, TOSR-1 is the slot just popped, not the entry below it. So the CORRECT path mispredicts: f calls g (push Rf, push Rg), g returns (pop: TOSR at Rf), f calls h (push Rh, written above Rg), h returns (pop: TOSR at Rg, not Rf), and f's return is predicted to Rg. This is not the wrong-path corruption the session-050 comparison weighed. That comparison was between a simple buffer that pushes at TOSR+1 and the linked array; the rules below are the linked array's pointers (TOSR, TOSW) without its link, and are correct for neither.
RULED session-075 (Jeff): ADD THE LINK. This reverses "No linked-list structure" above and the session-050 choice of the simple buffer. Each speculative entry carries nos, RAS_PTR_BITS wide, the index of the entry below it on the stack. A push writes the current TOSR into the new entry's nos. A pop that does not only decrement a recursion count sets TOSR to the popped entry's nos. TOSW, BOS, the sentinel, the three-pointer snapshot and the restore of 4.3 are unchanged, and restore stays exact while the buffer has not wrapped, since TOSW only advances and a wrong-path push never overwrites a live entry. Exact for the pointers and the stored addresses and links: a recursion count changed in place on the wrong path is array data and is not restored (ras.sv:335-343, 413-421). No tb_ras case covers it (TD#194, DOC-011). The p3 repair follows the link (undo-pop restores the pre-op TOSR; missed pop follows nos). Rejected: pushing at TOSR+1 and dropping TOSW, which matches the session-050 wording but loses exact restore and rewrites the snapshot, sentinel and overflow rules. Cost 16 x 4 = 64 bits. BUILT BY BP-120 (TD#159 closed), in ras.sv with no port or package change. On the sentinel skip (the wrap) the new entry's nos is BOS, not TOSR, so the wrap leaves one reachable entry above BOS as the overflow effect below describes; nos = TOSR would link the entry into slots the wrap is reusing. CONFIRMED session-075 (Jeff, BP-121 decision 4); this read "the IA's, PROVISIONAL until Jeff rules". BP-121's deep program, a chain of 18 calls, takes the wrap.
MEASURED: no tb_fe_top number moved with the link alone. The RAS rarely operated at p2 in the integrated front end because of TD#162, which BP-121 closed; across BP-121's programs it now supplies 2089 used return targets (BP-121 per-predictor table).
Entry fields:
ret_addr : VA_WIDTH bits -- PC+2 or PC+4 of instruction
after call (compressed vs full)
rctr : 4b -- recursion counter (see section 5)
nos : RAS_PTR_BITS -- next on stack: the entry below this
one (ruled session-075, BP-120)
bot : 1b -- bottom: pushed onto an empty stack
or by the sentinel skip (BP-138)
Pointers (all RAS_PTR_BITS wide, $clog2(RAS_SPEC_ENTRIES)=4b):
TOSR -- Top Of Stack Read: current top for predictions
TOSW -- Top Of Stack Write: next free allocation slot
BOS -- Bottom Of Stack: boundary of committed state
Push: write ret_addr, rctr and nos = TOSR (BOS on the sentinel
skip) to the TOSW slot,
with bot = 1 when the stack is empty or on the sentinel
skip. TOSR = TOSW.
TOSW advances to next slot. The BOS index is a permanent
sentinel: a push that would land TOSW on BOS allocates at
BOS+1 instead. This occurs at cold-start after reset, or on
a full circular wrap. The sentinel keeps a single live
entry distinguishable from empty.
Pop: present TOSR entry as prediction. TOSR = that entry's
nos, or BOS as it is then when the entry is bottom (BP-138).
No data overwritten on pop. This read "TOSR
decrements", the TD#159 defect; session-075.
Empty condition: TOSR == BOS. On pop when empty, fall through to commit stack top as prediction result. Commit stack entry is not consumed (read-only fallback).
TOSR == BOS HOLDS EXACTLY WHEN THE STACK IS EMPTY, across commits
(BP-138, D2). A commit moves BOS; four rules keep the test exact:
- the pop that removes a bottom entry sets TOSR to BOS as it is
then, not to nos;
- a commit that moves BOS while TOSR == BOS moves TOSR with it
(3.3);
- a p3 undo of an operation that began on an empty stack restores
TOSR to BOS as it is at the undo (section 1).
- a RETURN commit whose snapshot is an empty stack (snapshot
TOSR == snapshot BOS) does not move BOS (BP-140, PROVISIONAL).
That snapshot TOSR is the BOS of the cycle the return popped a
bottom entry; the commits of the older blocks have since moved
BOS off it, and the sentinel skip protects only the current BOS,
so the slot may hold a younger push. Moving BOS to it made
TOSR != BOS read a slot the stack did not hold, or TOSR == BOS
read empty over a held one (tb_ras TC-44; tb_fe_top region after
BP-140, RS2).
A bottom entry's nos still names the BOS of its push. Cost 16 bits
of bot, plus one register bit per slot for the undo. Rejected:
empty = TOSR older than BOS in TOSW allocation order, which a
sentinel skip breaks (BP-138).
Usable speculative depth: RAS_SPEC_ENTRIES - 1 = 15 entries (16 physical). One slot is always reserved as the BOS sentinel so that empty (TOSR == BOS) is never aliased by a full stack.
Full condition: TOSW + 1 == BOS (mod RAS_SPEC_ENTRIES). 15 slots allocated beyond BOS since BOS last moved, one push remaining. A pop does not retreat TOSW, so fewer entries may be live (tb_ras TC-44; DOC-011; this read "15 entries live"). Overflow (wrap) condition: the next push finds TOSW == BOS and takes the sentinel skip. No fault is raised and no error signal is asserted.
Overflow effect: the wrap is not the loss of one entry. Allocation lands at BOS+1, so TOSR becomes BOS+1 and the reachable depth (BOS to TOSR) collapses to one entry in a single push. The older entries stay physically resident but are unreachable -- the following pop hits TOSR == BOS and takes the commit-stack fallback. Degradation is bounded by that fallback, not gradual. Do not describe this as graceful single-entry loss.
3.3 Commit stack¶
Entries: 32
Structure: conventional circular stack.
Purpose: Covers steady-state live call nest depth for
committed instruction stream.
Entry fields:
ret_addr : VA_WIDTH bits
The commit stack carries no recursion count: commit_rctr was written zero and read by nothing, and BP-134 removed it (section 5). This listed rctr : 4b.
Pointer:
CSP -- Commit Stack Pointer: the NEXT FREE slot. The top is at
CSP-1. This line read "points to current top", which
contradicts that. Session-070.
Count -- occupancy, 0 to RAS_COMMIT_ENTRIES, beside CSP
(RAS_COMMIT_PTR_BITS + 1 bits). EMPTY IS THE COUNT AT 0.
Added by BP-126 (TD#121). Before it empty was CSP == 0,
which a full stack also reads after the wrap.
Update: when a call-containing prediction block commits from the FTQ, the return address is pushed onto the commit stack and CSP advances. BOS in the speculative stack advances to the committing entry's post-op TOSR (ras_commit_snapshot.tosr), marking the new committed boundary. When TOSR == BOS, TOSR moves to the new BOS with it (BP-138, 3.2). A mispredict restore in the same cycle wins over commit for BOS (restore > commit > hold).
On commit of a return: CSP decrements. The commit stack entry is consumed. BOS likewise advances to the committing entry's post-op TOSR (ras_commit_snapshot.tosr), except when that snapshot is an empty stack (snapshot TOSR == snapshot BOS): BOS then stays (3.2, BP-140).
On commit of a RETURN_CALL: the return rule above, then the push rule, applied to the state the return leaves (RAS-DS1: pop first, then push). Built by BP-119. The net CSP movement is whatever those two steps give; it is not specified separately. BOS advances once, to the committing entry's post-op TOSR. Added session-072: this section had no RETURN_CALL rule, and ras_interfaces.md IC-RAS-10 put RETURN_CALL in the push arm, advancing CSP, while saying it commits as the net effect of a pop and a push.
Overflow condition: CSP is a free pointer with no base register and wraps on the 32nd consecutive commit push. A call committed on a full stack overwrites the oldest entry and the count holds at 32. A return committed on an empty stack does nothing. No fault is raised.
Overflow effect: a full stack reads NON-EMPTY. commit_top_valid stays asserted, so the p0 TOS read and the speculative-empty pop fallback keep their source. After more than 32 consecutive pushes the oldest entries are lost, and 32 pops empty the stack. BUILT by BP-126, TD#121 CLOSED (tb_ras TC-36, TC-37). This read "the wrap makes a FULL commit stack read as EMPTY ... Accepted, not guarded"; the 16/32 sizes are unchanged and the rebalance trigger of 3.1 stands on its own. Session-077.
4. Snapshot and Restore Protocol¶
4.1 Snapshot contents¶
bp_ras_snapshot_t is a packed struct stored in bp_ftq_entry_t.
Fields (from bp_structs_pkg.sv):
tosr : RAS_PTR_BITS -- speculative TOS read pointer
tosw : RAS_PTR_BITS -- speculative TOS write pointer
bos : RAS_PTR_BITS -- committed boundary pointer
RAS_PTR_BITS = $clog2(RAS_SPEC_ENTRIES) = $clog2(16) = 4b. Total snapshot width = 3 * RAS_PTR_BITS = 12b per FTQ entry.
FTQ access pattern: entry.ras.tosr, entry.ras.tosw, entry.ras.bos
4.2 Snapshot write timing¶
Snapshot is written into the FTQ entry at p2, for EVERY valid block, from ras_snapshot_p2[NUM_PRED_SLOTS-1] -- the state after both slots' operations -- on ftq_bpu_interfaces.md 4c. It is not gated on a RAS operation or on the FTB answering. One snapshot per FTQ entry. The p1 value from bpu_pred_ras_p1 only initialises the field and is always overwritten.
On a push (call detected): snapshot the post-push pointer state. On a pop (return detected): snapshot the post-pop pointer state. On neither: snapshot current pointer state unchanged.
RULED session-071 (Jeff). This read "at the time the prediction that consumed or produced the RAS state is issued", and ras_interfaces.md IC-RAS-12 gated the write per slot on ras_pred_val_p2, which left the p1 value in a block with no FTB result. Whether the p3 repair of section 1 also needs to rewrite the snapshot is open (ftq_bpu_interfaces.md 4c, TD#149, measured by BP-121 and left open).
4.3 Restore on mispredict¶
On mispredict redirect from any predictor: restore TOSR, TOSW, BOS from the FTQ snapshot of the entry the redirect names by its index (ftq_backend_interfaces.md 5 D2). This read "the mispredicted entry"; see 3.2. Session-070. The history restores from the same entry: ftq_decisions.md 3.2 used the entry BEFORE it when _self is set and this note recorded the divergence; session-071 ruled the named entry for both. The circular buffer data is not cleared -- restoration is pointer- only. Subsequent pushes and pops write into slots above the restored TOSR, which may overwrite stale speculative data from the wrong path. This is correct behavior.
NO RESTORE ON THE CLUSTER'S OWN REDIRECT. When the redirect is the cluster's own p2 or p3 redirect, the restore is not applied: the redirecting block survives its own redirect (fe_decisions.md FE-14), and its own push or pop already stands, so a restore would undo it. bp_cluster masks the input: w_ras_restore_val = ras_restore_val & ~(w_own_p2 | w_own_p3). BUILT by BP-121 (D9).
A SQUASHED BLOCK OPERATES NOTHING. A block younger than a redirect is squashed (FE-14) and performs no RAS operation: its p2 push or pop is not written and its p3 operation is registered as none, on ras_p2_keep (ras_interfaces.md Port List). BUILT by BP-121 (D8). Before it, blocks younger than a redirect still pushed and popped.
4.4 Restore on flush -- DECIDED, RAS-3 CLOSED¶
THIS SECTION IS THE SINGLE SOURCE FOR THE RAS RESPONSE TO A FLUSH. Every other document points here. Do not restate it elsewhere and do not re-derive it.
THE DECISION. RAS restore on flush is the same pointer-restore protocol as mispredict recovery, section 4.3: TOSR, TOSW and BOS are restored from the FTQ snapshot of the entry the redirect names by its index, exactly as in 4.3. This read "the youngest valid entry before the flush point". Session-070.
The circular data is not cleared. There is NO flush-specific RAS behaviour, no separate flush protocol, and nothing for a flush to do to the RAS that a redirect does not already do.
THE MECHANISM IS BUILT AND TESTED. It is ras_restore_val /
ras_restore_snapshot, D2 of ftq_backend_interfaces.md 5, wired
through bp_cluster and implemented in ras.sv: the three pointers are
restored under restore > commit > hold priority, and tb_ras drives
it. This is not a plan. It is working RTL with coverage.
A backend redirect carries mispredict, trap and replay on ONE port set (ftq_backend_interfaces.md 5), so the trap case reaches the RAS through the same restore as any other redirect. That is why no additional path is needed.
Even the residual case is bounded. Speculative RAS corruption is self-correcting from both ends: TOSR unwinds toward BOS as the program returns, and on a pop when TOSR == BOS the prediction falls through to the commit stack (section 3.2), which is architectural state; and BOS advances toward TOSR on every commit (section 3.3). Corruption is squeezed, not merely drained.
4.4.1 What is still open, and what it is not¶
NOTHING. BP-105 closed the last piece: THERE IS NO FLUSH EVENT. A flush is a redirect (fe_decisions.md FE-14), the front end has no separate flush protocol, and a predictor is cleared by withholding its stage valid rather than by being told anything.
This subsection previously said the _px signalling was an open
front-end-wide question tracked as G24 / IC-FTB-07. Both are now
closed by decision. The _px ports are redundant and retained.
So the RAS response to a flush is the pointer restore of 4.3, because a flush IS a redirect and that is what a redirect does.
4.4.2 Do not reopen this -- read this first¶
RAS-3 was carried as OPEN from session-050 to 2026-08-20 while this section already specified the answer. It was re-raised repeatedly. Three artifacts caused that, and all three are still present by design:
ras_flush_valandras_flush_snapshotare DECLARED ON ras.sv AND READ BY NOTHING. They are redundant with the restore group above. They are deliberately LEFT IN PLACE; removing them is not worth touching a green module for. A DECLARED PORT WITH NO BEHAVIOUR IS NOT EVIDENCE OF AN OPEN DESIGN QUESTION. Here it is evidence of a redundant port, and that is all.- This section previously OPENED with "Flush (_px signals) not yet defined", so a reader met the gap before the decision and stopped there. The decision now comes first.
- The registry entry said "Recovery on flush. OPEN" while this section said what recovery on flush is. The registry contradicted the section it pointed to.
If you have arrived here because something looked unfinished: it is not. The RAS half of flush is closed. If you are defining the flush EVENT, see 4.4.1 -- that work does not touch this section.
4.5 Commit¶
On FTQ entry commit: the speculative entry is confirmed. BOS advances to the committing entry's post-op TOSR (ras_commit_snapshot.tosr), except for a RETURN whose snapshot is an empty stack, which leaves BOS (3.2, BP-140); when TOSR == BOS and BOS moves, TOSR moves with it (BP-138). No speculative RAM write occurs. A mispredict restore in the same cycle wins over commit for BOS (restore > commit > hold). Commit stack is updated as described in section 3.3.
5. Recursion Counter¶
DECIDED session-050: 4-bit counter per entry, in scope for initial design.
Purpose: when the same return address is pushed multiple times (self-recursive or mutually recursive calls), increment the counter of the current TOS entry rather than allocating a new entry. Suppresses duplicate pushes and preserves stack depth budget for non-recursive call depth.
Counter width: 4b. Tracks up to 15 repeated pushes of the same return address before saturating. Saturation behavior: counter holds at 15, additional pushes are suppressed. On pop: if rctr > 0, decrement rctr without moving TOSR. If rctr == 0, pop normally (TOSR follows nos, 3.2).
Match condition: incoming push address equals ret_addr at TOSR and the speculative stack is not empty (TOSR != BOS).
Recursion detection applies to the speculative stack only. The commit stack has no recursion count: every committed call is its own entry, so recursion depth is kept as repeated entries and the commit-stack fallback reads it at depth, up to RAS_COMMIT_ENTRIES calls (BP-133, tb_ras TC-39). TD #79 closed session-079: the fallback is not degraded and no recursion-count source is needed on the commit interface. The commit_rctr field was removed by BP-134. This read that a recursive call that commits reads back as a single entry.
6. Dual-Slot Interaction¶
DECIDED session-050.
6.1 The two slots (REWRITTEN session-069)¶
Both slots are branch fields of ONE 32-byte prediction block.
Slot 0 is the block's first branch in program order and slot 1
the second, each located by its own pos inside the block's 16
two-byte positions (fe_decisions.md FE-10,
ftq_entry_formats.md, ubtb_interfaces.md). Neither slot has
a fixed PC.
THE PREVIOUS TEXT DESCRIBED A SUPERSEDED MODEL and is kept here because the RTL may still implement it. It had slot 0 cover pred_pc to pred_pc+31 and slot 1 cover pred_pc+32 to pred_pc+63, with slot 1's PC always pred_pc+32:
Fixed boundary split. Slot 0 covers pred_pc to pred_pc+31.
Slot 1 covers pred_pc+32 to pred_pc+63. Slot 1 PC is always
pred_pc+32. Static, not data-dependent on slot 0 prediction.
That is two 32-byte blocks inside a 64-byte region, which is
FETCH_BLOCK_BYTES standing in for FTB_BLOCK_BYTES. The two are
independent and must not be collapsed (ftb_decisions.md 2.3).
The text dates from session-050 and predates the single-lookup
32-byte block model of session-063.
Evaluation order is unchanged and still needed: slot 0 before slot 1, slot 1 seeing the pointer state slot 0 left. That is IC-RAS-03 slot priority.
6.2 Same-cycle combinations (SUPERSEDED session-069)¶
AT MOST ONE SLOT CAN CARRY A RAS OPERATION. fe_decisions.md
FE-11: a RAS operation is a call or a return, both taken
branches, so a RAS operation in slot 0 ends the block before
slot 1 is reached. With 6.1 corrected, both slots are in the
same block, so this applies to every combination below.
NONE OF THE FIVE COMBINATIONS CAN OCCUR. They are retained, not deleted, because 6.3 and 6.4 describe logic in the RTL. CONFIRMED DOC-011: ras.sv evaluates the slots in one scan, and a later slot's pop reads the working top the earlier slot's push left (ras.sv:224-226, 679), so the combinations work at module level (tb_ras TC-04..TC-07, TC-11). There is no separate type-gated path. bp_cluster gives RAS types only to the single jump field, one slot per block (bp_cluster.sv:993-1046), so the integrated front end does not reach them. This read "Confirming that is an RTL task".
THE ONE REAL TWO-OPERATION CASE IS NOT AMONG THEM. A JALR whose
rd and rs1 are both link registers and are not equal is a
POP FOLLOWED BY A PUSH: one instruction, one slot, one position,
two RAS operations (dcd_decisions.md DCD-11, from the
specification's return-address-stack hints). FE-11's premise
excludes it wrongly; its conclusion, one snapshot per FTQ entry,
survives, because a pop-then-push at a single position needs no
second recovery point.
RAS-DS1 The RAS accepts is_call and is_ret both set on one
instruction and performs the pop first, then the
push. On `ras_br_type_p2` that arrives as RETURN_CALL
(section 2). THE ORDER IS DECIDED HERE: pop first, then
push. dcd_decisions.md DCD-U2 asks for that order "if
the RAS treats them as two operations", and this rule
says it does, so DCD-U2 is answered by RAS-DS1 rather
than gating it. This read "Ordering is DCD-U2" as
though still open. Session-070. BUILT BY BP-119:
before it, ras.sv treated RETURN_CALL as a no-op at
p2, in the p3 repair and at commit (TD-DCD-2, closed).
The superseded five follow.
The five combinations the RAS must handle in a single cycle:
slot0=call, slot1=call:
Two pushes. If both addresses match current TOS and each
other, increment rctr by 2 (or increment once per slot in
priority order, clamped at 15). If addresses differ, push
slot0 first, then slot1. TOSW advances by 2 (or 1 if
recursion suppressed one push).
slot0=return, slot1=return:
Two pops. Pop slot0 first (TOSR decrements or rctr
decrements). Pop slot1 from resulting state. Prediction
for slot1 may require two levels of TOS traversal in the
same cycle.
slot0=call, slot1=return:
Push slot0 return address. The address just pushed is
immediately needed by slot1 pop. Same-cycle bypass
required: slot1 pop target is forwarded from the slot0
push data path without reading back from the array.
slot0=return, slot1=call:
Pop slot0 (TOSR decrements). Push slot1 return address
to new TOSW. No bypass needed -- the push follows the pop
with no dependency.
neither slot is call or return:
No RAS action.
6.3 Same-cycle bypass (SUPERSEDED session-069)¶
The case this serves, slot0=call with slot1=return, cannot occur under 6.2. The bypass is the scan's working top of stack, not a separate path; it works at module level and bp_cluster does not reach it (6.2, DOC-011).
The slot0=call, slot1=return case requires a bypass path. The return address pushed by slot0 is forwarded directly to slot1's pop output in the same cycle. The bypass is detected when slot0 is a call and slot1 is a return and the pushed address would become the new TOS before slot1 pops.
This is a combinational forwarding path within the RAS push/pop logic, not a RAM bypass. It is always present in the RTL; the condition gating it is combinationally determined from the slot0 and slot1 branch type inputs.
6.4 Recursion counter with two simultaneous pushes¶
(SUPERSEDED session-069)¶
Two simultaneous pushes require calls in both slots, which cannot occur under 6.2. If this path exists in the RTL it is dead logic. The single-push recursion counter of section 5 is unaffected.
If slot0 and slot1 both push the same return address:
- If that address matches the current TOS ret_addr:
Increment rctr by 2 (saturating at 15).
TOSW does not advance.
- If that address does not match current TOS:
Push once, set rctr to 1 (representing two occurrences).
TOSW advances by 1.
If slot0 and slot1 push different addresses:
- Push slot0 first (rctr check against current TOS).
- Push slot1 second (rctr check against new TOS after slot0).
- TOSW advances by 0, 1, or 2 depending on recursion matches.
7. Push Timing¶
OPEN ITEM RAS-1 from bp_arb_spec.md.
Push occurs at p2, when FTB structural prediction confirms the branch type as call. Predecode provides an early hint that may allow the push to be initiated before FTB confirms, but the authoritative push is gated on FTB branch type at p2.
This is consistent with bp_cluster.md: RAS push/pop executes at p2, ras_pop_addr_p2 valid at p2, p3 = p2 registered.
Implication: the return address is available one cycle after the call instruction enters the prediction pipeline (p2). The corresponding return will not appear until several cycles later at minimum. No timing hazard from push latency under normal conditions.
PARTIAL RESOLUTION: push occurs at p2 gated on FTB branch type. Predecode early hint is an optimization deferred to RTL implementation phase. RAS-1 may be closed when RTL confirms the p2 push timing is sufficient for all call/return interleavings.
8. Return Address Value¶
ret_addr stored in the stack is PC+2 or PC+4 of the instruction
after the call:
- Full-width RVI call (4b): ret_addr = call_pc + 4
- Compressed RVC call (2b): ret_addr = call_pc + 2
The cluster computes this value and drives it on ras_fall_through_p2: the call's own PC plus 2 when the FTB jump field's rvc bit is set, else plus 4 (ftb_decisions.md 5.5, ftb_interfaces.md IC-FTB-03). The RAS writes what it is given and does not compute PC+2 or PC+4. RULED session-075 (Jeff, BP-121 decision 3, TD#164), BUILT by BP-121 (D3). This read "The FTB fallThroughAddr field provides this value". pftAddr is shared by every start in a region (ftb_decisions.md 4.6), so it held whichever start's block end was written last.
NO STRADDLE CORRECTION EXISTS. An earlier revision of this section
said a +2 correction applies for full-width RVI calls truncated at
a prediction block boundary. That was the last_may_be_rvi_call
mechanism, which ftb_decisions.md 6 ELIMINATED; FTB-1 records
that no straddle correction exists. Corrected session-069.
It is eliminated rather than forgotten because the call's own PC
plus its length is the address after the call whether or not the
call straddles the block boundary, so no correction is needed. A
32-bit call beginning at the block's last halfword returns to its PC
plus 4. Until BP-121 this paragraph made the same argument through
pft_addr, which was true for one start and not for a region shared
by several (TD#164); the six-bit, no-carry encoding it cited was
built by BP-110 (TD#124, closed).
The straddle case is real, not hypothetical: ifu_decisions.md
IFU-8 covers 34 bytes and 17 halfword positions for exactly this
reason. It is handled by the fall-through arithmetic rather than
by a correction at the RAS.
VA_WIDTH = 41b. It is not a virtual address width in the plain sense: H is mandatory through Sha, the G-stage is Sv39x4, and with V=1 and vsatp.MODE=Bare the fetch PC is a 41-bit guest physical address. An earlier revision read "VA_WIDTH = 40b covers the RVA23 implementation VA space". fe_decisions.md FE-19, TD#122, which tracks the RTL.
9. Parameters¶
Defined in bp_defines_pkg.sv, added by BP-062. This read "Names and values to be added when RAS RTL task is written". Session-071.
RAS_SPEC_ENTRIES = 16 -- speculative stack depth
RAS_COMMIT_ENTRIES = 32 -- commit stack depth
RAS_RCTR_WIDTH = 4 -- recursion counter bits
RAS_ADDR_WIDTH = VA_WIDTH -- return address width
Pointer width (already present in bp_defines_pkg.sv as
RAS_PTR_BITS; it is a parameter, and section 11 and
ras_interfaces.md both place it there. This read
bp_structs_pkg.sv, which holds types only
(PROJECT_STATUS.md, package split). Session-072):
RAS_PTR_BITS = $clog2(RAS_SPEC_ENTRIES) = 4b
bp_ras_snapshot_t uses RAS_PTR_BITS for tosr, tosw, bos. Total snapshot width = 3 * RAS_PTR_BITS = 12b per FTQ entry.
Commit stack pointer width:
RAS_COMMIT_PTR_BITS = $clog2(RAS_COMMIT_ENTRIES) = 5b
Already present in bp_defines_pkg.sv.
The occupancy count of 3.3 is RAS_COMMIT_PTR_BITS + 1 bits
(BP-126); no package parameter names it.
10. Open Items¶
RAS-1: Push timing. PARTIALLY RESOLVED. Push at p2 gated
on FTB branch type. Predecode early hint deferred.
Close when RTL confirms p2 timing is sufficient.
RAS-2: Stack depth. RESOLVED session-050.
16 speculative + 32 commit. See section 3.
RAS-3: Recovery on flush. CLOSED 2026-08-20 -- and it was
ALREADY ANSWERED by section 4.4 long before that date;
only this label said otherwise. The RAS response to a
flush is the pointer restore of 4.3, which is built and
tested as ras_restore_val. BP-105 then closed the flush
EVENT too: there is none, a flush is a redirect
(fe_decisions.md FE-14). See 4.4.1.
Do not re-raise from the unread ras_flush_* ports; see
4.4.2.
11. Interactions With Other Planning Documents¶
bp_cluster.md -- architectural summary. Its RAS
section is a short summary pointing
here; this document is the only home
of the RAS rules (PROJECT_CORE.md).
Session-050 had recorded the full
duplication as intentional;
reconciled session-071.
bp_arb_spec.md -- arbitration model. Section 7.2
covers RAS non-RAM status. Open
item RAS-2 now closed. RAS-1
partially resolved. RAS-3 closed
2026-08-20 (section 4.4, section
10).
Section 2 predictor inventory RAS
row: p0 is TOS read only; push/pop
and redirect participation is at p2.
bp_defines_pkg.sv -- RAS_PTR_BITS, RAS_SPEC_ENTRIES,
RAS_COMMIT_ENTRIES, RAS_RCTR_WIDTH,
RAS_ADDR_WIDTH, RAS_COMMIT_PTR_BITS
all present.
bp_structs_pkg.sv -- bp_ras_snapshot_t confirmed present
with tosr/tosw/bos fields at
RAS_PTR_BITS each, matching section
4.1. Comment updated session-050 to
remove linked-array reference.
tage_interfaces.md -- no RAS interaction.
ittage_interfaces.md -- no direct RAS interaction. JALR
ownership, RAS or ITTAGE, is defined in
section 2 of this document and in
bp_cluster.md. An earlier revision said
"three-way JALR split (FTB/RAS/ITTAGE)";
the FTB target is the ITTAGE-miss
fallback, not a third arm.
ftb_decisions.md 4.2.
12. Document History¶
2026-06-23 session-050. Initial draft.
Decisions recorded: static partition (G5),
4b recursion counter (G6), fixed bundle split
(G8), slot1 PC = pred_pc+32 (G17), simple
circular buffer (internal structure).
Full bp_cluster.md RAS content folded in:
p2/p3 repair table, return address value
(section 8), stage and update notes (section
1.1), redirect architecture role (section 1.2).
Dual-slot interaction cases enumerated.
Same-cycle bypass documented.
Open items RAS-1 partially resolved,
RAS-2 closed, RAS-3 carried forward.
Consistency pass session-050: parameter name
aligned to RAS_PTR_BITS (matches bp_structs_
pkg.sv). Section 11 corrected to reflect that
bp_cluster.md duplication is intentional.
2026-09-15 session-069. Section 6 reworked. 6.1 REWRITTEN: both
slots are branch fields of one 32-byte block, each
located by pos; the old fixed split at pred_pc+32
was FETCH_BLOCK_BYTES standing in for
FTB_BLOCK_BYTES and predates the session-063
single-lookup model. 6.2, 6.3 and 6.4 SUPERSEDED:
with 6.1 corrected, FE-11 makes all five cross-slot
combinations unreachable, so the bypass and the
two-push recursion path are dead logic if built.
RAS-DS1 added: the one real two-operation case is
DCD-11's pop-then-push within a single JALR.
Superseded text retained, not deleted.
2026-09-17 Section 11 bp_arb_spec.md entry read "RAS-3 open"
while section 4.4's heading and section 10 both read
CLOSED 2026-08-20. Corrected. This was the third
artifact class of 4.4.2 -- a pointer entry
contradicting the section it points at -- surviving
one section below the warning against it. No
protocol change; the label was the only thing wrong.
2026-09-19 session-071. 1: the p0 TOS read is an input to the p1
prediction, not the initial p0 prediction. 4.2: the
snapshot is written at p2 for every valid block from
the post-both-slots state, on ftq_bpu_interfaces.md
4c (ruled, Jeff); the p3 repair question is open.
4.3: history and RAS restore from the same named
entry; the divergence note is retired.
2026-09-19 session-071. 2: the JALR hint table and compressed
mapping moved here from bp_cluster.md, whose RAS
section is now a summary. 9: the parameters exist,
BP-062. 11: the duplication with bp_cluster.md is
reconciled, not intentional.
2026-09-20 session-072. 3.3: RETURN_CALL commit rule added, the
return rule then the push rule (RAS-DS1).
2026-09-20 session-072, second pass. 1.1: spec_pop_addr retired in favour of
the declared ras_tos_addr_p0 and ras_pop_addr_p2.
2026-09-20 session-072. D22: RAS_PTR_BITS is in
bp_defines_pkg.sv, not bp_structs_pkg.sv.
2026-09-20 session-072. E21: the history section was a paragraph
followed by a code block; the whole section is now
fenced.
2026-10-07 session-075, after BP-119. 1: return-call rows in the
p2/p3 repair table, built. RAS-DS1 and 3.3 built;
TD-DCD-2 closed. 3.2: the pointer rules mispredict on
the correct path after a pop then a push, TD#159.
Ruled (Jeff): add the next-on-stack link; reverses
session-050's simple buffer.
2026-10-08 session-075, after BP-120. 3.2: the link built; the
wrap links to BOS, provisional. 1: the four
return-call pairings as built, two wrong, none
reachable; TD #78 note restated for the restore.
2026-10-08 session-076, PA-direct correction recording BP-121.
1, 1.2: p3 qualified by p3 reachability (D10,
TD#166). 3.2: wrap to BOS confirmed (decision 4);
TD#162 closed. 4.2: TD#149 measured. 4.3: no restore
on the cluster's own redirect (D9); a squashed block
performs no RAS operation (D8). 8: the return address
is the call PC plus 2 or 4 (TD#164).
2026-10-09 session-076. 1: TD#165 closed as unreachable by
construction (Jeff), with the condition that would
reopen it.
2026-10-10 session-077, after BP-126. 3.3: empty is the
occupancy count at 0; a full commit stack reads
non-empty; a call on a full stack overwrites the
oldest entry, a return on an empty one does nothing.
TD#121 closed. 9: the count's width.
2026-10-12 session-079, recording BP-133 and BP-134 (rulings,
Jeff). 1: the undo restores the recursion counts the p2
operation changed (TD #78 closed); the undo of a push
that met a saturated count changes nothing (BP-134). 3.3
and 5: the commit stack has no recursion count and keeps
depth as repeated entries; commit_rctr removed (TD #79
closed).
2026-10-17 session-081, after BP-138. 3.2: a bottom bit per entry;
TOSR == BOS kept exact across commits by three rules.
1: the undo of an operation begun on an empty stack.
3.3, 4.5: TOSR moves with BOS when the stack is empty.
2026-10-19 session-081, after BP-140. 3.2, 3.3, 4.5: a RETURN
commit whose snapshot is an empty stack leaves BOS
(provisional, accepted by Jeff). 3.2: four rules.
2026-10-29 session-082, after DOC-011. 3.2: the push link on the
sentinel skip; the full condition counts allocations;
a wrong-path recursion count is not restored (TD#194).
6.2, 6.3: the bypass confirmed in the RTL, unreachable
from bp_cluster.
ras_interfaces.md
planning/interfaces/ras_interfaces.md on GitHub
RAS Interface Specification¶
FILE: ras_interfaces.md
SOURCE: session-050
STATUS: DRAFT
UPDATED: 2026-10-29
CONTACT: Jeff Nye
Interface contract for ras.sv. Companion to planning/arch/ras_decisions.md (micro-architectural decisions) and planning/arch/bp_arb_spec.md section 7.2 (arbitration role). Claude Code loads this file when implementing or modifying ras.sv or tb_ras.sv.
Stage notation is p0/p1/p2/p3 for prediction and u0/u1 for update, in every document and in the RTL (PROJECT_CORE.md, Interface specification approach; fe_decisions.md 12). This document carried a local rule that planning narrative uses s0/s1/s2/s3; PROJECT_CORE supersedes it. Session-072.
1. Module Overview¶
Single module ras.sv owns:
- Speculative stack (16 entries, circular buffer with a
next-on-stack link per entry, ras_decisions.md 3.2; this read
"simple circular buffer")
- Commit stack (32 entries, conventional circular stack)
- Push/pop logic per prediction slot. AT MOST ONE SLOT CARRIES A
RAS OPERATION: a RAS operation is a taken branch and ends the
block (FE-11, ras_decisions.md 6.2, SUPERSEDED session-069).
This read "for both prediction slots in a single cycle".
- Same-cycle bypass for slot0=call, slot1=return. THAT CASE CANNOT
OCCUR under FE-11. The bypass is the scan's working top of stack;
it works at module level and bp_cluster does not reach it
(ras_decisions.md 6.2, 6.3, IC-RAS-04; DOC-011).
- Recursion counter management
- p0 TOS read, an input the cluster registers for the p1
prediction (fe_decisions.md 2.2). Not itself a prediction
- Snapshot output per prediction for FTQ storage
- Restore input from FTQ on mispredict
- Commit stack update on FTQ commit
- p3 repair logic
No PQ, UQ, or credit arbiter. No synchronous SRAMs. Both stacks are register files.
RAS is outside the conditional branch override chain. It is type-gated: push fires when br_type==DIRECT_CALL or INDIRECT_CALL; pop fires when br_type==RETURN; RETURN_CALL pops then pushes (IC-RAS-01, IC-RAS-02, ras_decisions.md 2). All other branch types produce no RAS action. This list omitted RETURN_CALL. Session-071. Branch type classification is the responsibility of FTB; RAS does not classify instructions independently.
2. Parameters¶
Defined in bp_defines_pkg.sv. All RAS RTL must use these names. Do not use numeric literals for stack depths, pointer widths, or counter widths.
RAS_SPEC_ENTRIES -- speculative stack depth (16)
RAS_COMMIT_ENTRIES -- commit stack depth (32)
RAS_RCTR_WIDTH -- recursion counter width (4)
RAS_PTR_BITS -- speculative pointer width
$clog2(RAS_SPEC_ENTRIES) = 4b
Already present in bp_defines_pkg.sv.
RAS_COMMIT_PTR_BITS -- commit pointer width
$clog2(RAS_COMMIT_ENTRIES) = 5b
RAS_ADDR_WIDTH -- return address width = VA_WIDTH = 41b
3. Port Naming Convention¶
Signal names follow the pattern:
<signal>_<pipestage>
pipestage: p0, p1, p2 for prediction path.
p3 for repair.
u0, u1 for update/commit path.
NO px STAGE. A flush is a redirect (fe_decisions.md
FE-14), and the two flush ports, ras_flush_val and
ras_flush_snapshot, carry no stage suffix; they are
reserved and unread, and there is no flush event and
no flush protocol. See RI-1 and ras_decisions.md
4.4. This listed "px for flush signals", against
every other predictor document. Session-072.
Prediction slot dimension uses array index [0:NUM_PRED_SLOTS-1] on the signal, not a suffix. Example:
input logic ras_pred_val_p2[0:NUM_PRED_SLOTS-1]
clk and rstn carry no pipe stage suffix.
4. Port List¶
module ras (
input logic clk,
input logic rstn,
// ----------------------------------------------------------
// p0: TOS read, before the FTB result.
// Combinational read of current TOSR entry per slot.
// Registered by the cluster and applied by the p1 mux as
// the target of a RETURN slot. Drives no FTQ port.
// No push or pop at p0.
// ----------------------------------------------------------
output logic [VA_WIDTH-1:0] ras_tos_addr_p0[0:NUM_PRED_SLOTS-1],
output logic ras_tos_valid_p0[0:NUM_PRED_SLOTS-1],
// ----------------------------------------------------------
// p2: Prediction inputs
// FTB structural prediction valid. Push/pop gates on these.
// ----------------------------------------------------------
input logic ras_pred_val_p2[0:NUM_PRED_SLOTS-1],
input bp_br_type_e ras_br_type_p2[0:NUM_PRED_SLOTS-1],
// Return address per slot: the call PC plus 2 or 4, formed by
// the cluster from the FTB jump position and rvc bit (BP-121,
// TD#164). Pushed as ret_addr on call. RAS does not compute
// PC+2/+4. The name is historical: it carried the FTB
// fall-through until BP-121.
input logic [VA_WIDTH-1:0] ras_fall_through_p2[0:NUM_PRED_SLOTS-1],
// ----------------------------------------------------------
// p2: Prediction outputs
// ----------------------------------------------------------
// Pop address (return target prediction) per slot.
output logic [VA_WIDTH-1:0] ras_pop_addr_p2[0:NUM_PRED_SLOTS-1],
// Asserted when a valid pop address is available.
// Deasserted when both speculative and commit stacks empty.
output logic ras_pop_valid_p2[0:NUM_PRED_SLOTS-1],
// RAS snapshot per slot for FTQ fast-path write.
// Post-operation pointer state (see IC-RAS-08).
output bp_ras_snapshot_t ras_snapshot_p2[0:NUM_PRED_SLOTS-1],
// ----------------------------------------------------------
// p3: Repair inputs
// Registered FTB prediction, one cycle after p2.
// Used to detect and undo incorrect p2 push/pop.
// See IC-RAS-11 and ras_decisions.md section 1.
// ----------------------------------------------------------
input logic ras_pred_val_p3[0:NUM_PRED_SLOTS-1],
input bp_br_type_e ras_br_type_p3[0:NUM_PRED_SLOTS-1],
// ----------------------------------------------------------
// p2 keep (BP-121, D8; fe_decisions.md FE-14). One bit. High
// when this cycle's p2 pass is on the path. Low drops the p2
// operation (pointer and array writes) and registers it as
// none for p3; the p3 repair still applies. Driven by
// bp_cluster as ~w_kill_p2, w_kill_p2 = ftq_rollback_val &
// ~w_own_p2. Declaration reported by BP-122.
// ----------------------------------------------------------
input logic ras_p2_keep,
// ----------------------------------------------------------
// Mispredict restore (driven by FTQ)
// ----------------------------------------------------------
input logic ras_restore_val,
input bp_ras_snapshot_t ras_restore_snapshot,
// ----------------------------------------------------------
// Commit inputs (driven by FTQ at retire)
// One commit event per cycle. FTQ retires one entry per
// cycle; dual-slot commit is not required.
// ----------------------------------------------------------
input logic ras_commit_val,
input bp_br_type_e ras_commit_br_type,
input logic [VA_WIDTH-1:0] ras_commit_ret_addr,
input bp_ras_snapshot_t ras_commit_snapshot,
// ----------------------------------------------------------
// Flush. RESERVED AND UNREAD -- not TBD. A flush is a
// redirect (fe_decisions.md FE-14); the RAS response is the
// pointer restore above. These two ports are redundant and
// are intentionally left unread. Read ras_decisions.md 4.4
// and 4.4.2 before reopening this.
// ----------------------------------------------------------
input logic ras_flush_val,
input bp_ras_snapshot_t ras_flush_snapshot
);
5. Struct Definitions¶
All structs defined in bp_structs_pkg.sv.
bp_br_type_e¶
Branch type enum. RAS acts on:
DIRECT_CALL, INDIRECT_CALL -- push trigger
RETURN -- pop trigger
RETURN_CALL -- POP THEN PUSH, one instruction,
two operations (ras_decisions.md 2
and RAS-DS1, dcd_decisions.md
DCD-11a)
All other values: no RAS action.
RETURN_CALL was added to bp_br_type_e at 3'b111 in session-069 and was missing from this list and from IC-RAS-01, IC-RAS-02 and IC-RAS-10. Session-070.
bp_ras_snapshot_t¶
Packed struct, 3 * RAS_PTR_BITS wide:
tosr : RAS_PTR_BITS -- speculative TOS read pointer
tosw : RAS_PTR_BITS -- speculative TOS write pointer
bos : RAS_PTR_BITS -- committed boundary pointer
With RAS_PTR_BITS=4: total 12b per snapshot. Access pattern: entry.ras.tosr, entry.ras.tosw, entry.ras.bos
6. Prediction Interface¶
Producer: bp_cluster (FTB branch type; return address from the¶
FTB jump position and rvc bit)¶
Consumer: RAS¶
Timing¶
p0: Combinational TOS read. ras_tos_addr_p0 and
ras_tos_valid_p0 are valid combinationally from
current TOSR. No push or pop at p0.
p2: ras_pred_val_p2 and ras_br_type_p2 valid.
Push or pop executes combinationally.
ras_pop_addr_p2, ras_pop_valid_p2, ras_snapshot_p2
all valid combinationally in p2.
p3: ras_br_type_p3 is the registered p2 type;
ras_pred_val_p3 is qualified by p3 reachability
(BP-121, IC-RAS-12). Repair logic compares the p3
view against the p2 operation applied and executes
the inverse if they disagree.
Semantics¶
ras_pred_val_p2[s] = 1 -- valid FTB result for slot s.
RAS evaluates br_type and executes
push or pop as appropriate.
ras_pred_val_p2[s] = 0 -- no valid FTB result for slot s.
No push or pop for slot s.
ras_pop_valid_p2[s] = 1 -- ras_pop_addr_p2[s] is valid.
Used by the p2 redirect logic when
br_type==RETURN. This read
"s2_redirect logic": that is this
document's own consumer, not a signal
name. The XiangShan s2_redirect /
s3_redirect citation is
fe_decisions.md 11. Session-072.
ras_pop_valid_p2[s] = 0 -- both stacks empty; no valid
return address available.
ras_tos_valid_p0[s] = 1 -- ras_tos_addr_p0[s] holds the
current TOS return address.
Valid before FTB result at p2.
ras_tos_valid_p0[s] = 0 -- speculative and commit stacks
both empty.
Both slots may have ras_pred_val_p2 asserted in the same cycle. Slot 0 is processed before slot 1. Slot 1 sees the post-slot-0 pointer state.
7. Interface Contracts¶
IC-RAS-01: Push gating¶
Push fires if and only if:
ras_pred_val_p2[s] == 1
AND ras_br_type_p2[s] == DIRECT_CALL, INDIRECT_CALL
or RETURN_CALL
No push on any other branch type. On RETURN_CALL the push follows the pop of IC-RAS-02 in the same operation. RAS does not make its own call/return classification.
IC-RAS-02: Pop gating¶
Pop fires if and only if:
ras_pred_val_p2[s] == 1
AND ras_br_type_p2[s] == RETURN or RETURN_CALL
No pop on any other branch type. On RETURN_CALL the pop comes FIRST and supplies the predicted target; the push of IC-RAS-01 follows it (ras_decisions.md RAS-DS1).
IC-RAS-03: Slot priority¶
AT MOST ONE SLOT CAN CARRY A RAS OPERATION. FE-11: a RAS operation is a taken branch, so it ends the block before slot 1 is reached (ras_decisions.md 6.2, SUPERSEDED session-069). The slot-priority rule is retained because the RTL may implement it: when both slots are active, slot 0 is processed before slot 1 and slot 1 sees the post-slot-0 pointer state. This read "This applies to all five same-cycle combinations"; none of the five can occur. Session-070.
IC-RAS-04: Same-cycle bypass¶
When slot 0 is DIRECT_CALL or INDIRECT_CALL and slot 1 is RETURN in the same cycle, slot 1's pop target is forwarded combinationally from slot 0's push data without reading back from the speculative stack array.
ras_pop_addr_p2[1] receives the forwarded value in this case.
THE CASE CANNOT OCCUR. slot0=call with slot1=return needs two RAS operations in one block, which FE-11 excludes (ras_decisions.md 6.2 and 6.3, SUPERSEDED session-069). CONFIRMED DOC-011: there is no separate type-gated path; slot 1's pop reads the working top of stack slot 0's push left (ras.sv:224-226, 679), tested at module level by tb_ras TC-06. bp_cluster does not reach it. This read "confirming that is an RTL task".
IC-RAS-05: Recursion counter¶
On push: if ras_fall_through_p2[s] equals ret_addr at TOSR and the speculative stack is not empty (TOSR != BOS), increment rctr at TOSR rather than allocating a new entry. TOSW does not advance.
On pop: if rctr at TOSR > 0, decrement rctr without moving TOSR. If rctr == 0, pop normally (TOSR follows the entry's next-on-stack link, ras_decisions.md 3.2; this read "TOSR decrements").
Saturation: rctr saturates at (2^RAS_RCTR_WIDTH - 1) = 15. Additional pushes beyond saturation are suppressed.
See ras_decisions.md section 5 for the single-push recursion counter. Section 6.4, two-slot simultaneous push, is SUPERSEDED: two pushes need calls in both slots, which FE-11 excludes. The single-push rule above is unaffected. Session-070.
IC-RAS-06: Speculative stack overflow¶
TOSW + 1 == BOS (mod RAS_SPEC_ENTRIES) is the FULL condition: 15 slots allocated beyond BOS since BOS last moved, one push remaining. A pop does not retreat TOSW, so fewer entries may be live (tb_ras TC-44). The next push finds TOSW == BOS, takes the sentinel skip, and wraps. No error signal is asserted.
The wrap is not the loss of one entry. Allocation lands at BOS+1, so TOSR becomes BOS+1 and reachable depth collapses to one entry. The older entries remain physically resident but unreachable: the following pop hits TOSR == BOS and takes the IC-RAS-07 commit fallback. Consumers must not assume graceful single-entry loss across a wrap.
IC-RAS-07: Speculative stack empty fallback¶
When TOSR == BOS (speculative stack empty) and a pop is requested, ras_pop_addr_p2[s] is driven from the commit stack top, which is the CSP-1 entry, not the CSP entry (ras_decisions.md 3.3). ras_pop_valid_p2[s] remains asserted. The commit stack entry is NOT consumed.
The same fallback applies to ras_tos_addr_p0[s] at p0: when the speculative stack is empty, the commit stack top is presented as the TOS value.
If both speculative and commit stacks are empty, ras_pop_valid_p2[s] and ras_tos_valid_p0[s] deassert.
TOSR == BOS holds exactly when the speculative stack is empty, across commits (ras_decisions.md 3.2, BP-138). A pop never presents a speculative entry the stack does not hold.
IC-RAS-08: Snapshot timing¶
ras_snapshot_p2[s] reflects post-operation pointer state combinationally in p2. It is not registered before output.
Slot 0 snapshot reflects the state after slot 0's operation only. Slot 1 snapshot reflects the state after both slot 0 and slot 1 operations have been applied.
The FTQ captures ras_snapshot_p2[NUM_PRED_SLOTS-1], the state after both slots, on the rising edge closing p2, for every valid block, through ftq_bpu_interfaces.md 4c. See ras_decisions.md section 4.2.
IC-RAS-09: Restore priority¶
ras_restore_val takes priority over any p2 push or pop in the same cycle. When ras_restore_val is asserted, pointer state is loaded from ras_restore_snapshot and no p2 push/pop is applied.
Only pointer state is restored. Circular buffer data is not cleared. See ras_decisions.md section 4.3.
The p3 repair of that cycle is dropped as well: no array write and no pointer move. The p2 operation is registered as none for p3 (ras.sv:808-831, 855; DOC-011).
bp_cluster does not assert the restore for its own p2 or p3 redirect (ras_decisions.md 4.3, BP-121 D9).
IC-RAS-10: Commit stack update¶
On ras_commit_val with DIRECT_CALL or INDIRECT_CALL:
- Push ras_commit_ret_addr onto commit stack.
- CSP advances.
- BOS in speculative stack updated from ras_commit_snapshot.
On ras_commit_val with RETURN:
- CSP decrements.
- BOS updated from ras_commit_snapshot, unless the snapshot is an
empty stack (tosr == bos), when BOS stays (ras_decisions.md 3.2,
BP-140).
On ras_commit_val with RETURN_CALL:
- The RETURN arm, then the call arm, the second applied to the
state the first leaves (ras_decisions.md 3.3, RAS-DS1).
- BOS updated once, from ras_commit_snapshot.
In every arm, if TOSR == BOS when the commit moves BOS, TOSR moves to the new BOS in the same update (ras_decisions.md 3.2, BP-138).
RETURN_CALL was listed in the call arm, so CSP advanced, while this section said it commits as the net effect of its pop and push. ras_decisions.md 3.3 owns the rule. Session-072. Built by BP-119; before it, ras.sv did nothing with a RETURN_CALL commit.
Commit is registered (takes effect the cycle after ras_commit_val is asserted). Commit does not interact with p2 push/pop combinationally, except that the TOSR move above applies to the TOSR the p2 scan leaves (BP-138).
One commit event per cycle. The FTQ retires one entry per cycle; dual-slot simultaneous commit does not occur.
IC-RAS-11: p3 repair¶
At p3 (p2 registered), if ras_br_type_p3[s] disagrees with the p2 operation that was applied, an inverse repair is applied to the speculative stack:
p2=push, p3=no-op -> repair: pop (undo the push)
p2=no-op, p3=pop -> repair: pop (apply missed pop)
p2=pop, p3=no-op -> repair: push (undo the pop)
p2=no-op, p3=push -> repair: push (apply missed push)
p2=return-call, p3=no-op -> undo both, as one operation: TOSR
restored to its pre-op value
p2=no-op, p3=return-call -> missed pop, then missed push
push->pop and pop->push within one p2/p3 pair cannot occur. The return-call rows were built by BP-119 (ras_decisions.md 1). Repair applies to the speculative stack only. See ras_decisions.md section 1 (p2/p3 repair table).
Repair semantics: the push/pop labels denote stack-height restoration of resident entries, not fresh allocation or array clear. Undo-pop (p2=pop, p3=no-op) and undo-push (p2=push, p3=no-op) move TOSR over still-resident entries and write no return address; undo-push decrements an in-place recursion count when present, unless the push met a saturated count and changed nothing (BP-134). Since BP-120 undo-pop restores the pre-op TOSR, and undo-push and a missed pop follow the popped entry's next-on-stack link (ras_decisions.md 3.2). Only the missed-push case (p2=no-op, p3=push) allocates and writes a new frontier entry. Undo-pop and the undo of a whole return-call restore the recursion counts the p2 operation changed (BP-133, TD #78 closed); tb_ras TC-21, TC-38. The undo of an operation that began on an empty stack restores TOSR to BOS as it is at the undo (BP-138, tb_ras TC-43). A return-call paired with a plain push or pop: ras_decisions.md 1, as built, two of four wrong, unreachable by construction because ras_br_type_p3 is the registered p2 type (TD#165 closed session-076; ras_decisions.md 1 states what would reopen it).
IC-RAS-12: Producer obligations (bp_cluster / FTQ)¶
- Must gate ras_pred_val_p2[s] on FTB result valid.
- Must present ras_br_type_p2[s] from FTB structural prediction, not from predecode or decode.
- Must present ras_br_type_p3[s] as the registered version of ras_br_type_p2[s] from the previous cycle.
- Must qualify ras_pred_val_p3[s] by p3 reachability, which uses the SC direction: r_val_p3 & r_brv_p3 & w_reach_p3. BUILT by BP-121 (D10, TD#166). Given the registered p2 qualification, the p3 view never differed from p2 and the repair never ran.
- Must drive ras_p2_keep low for a block at p2 that a redirect squashes (FE-14, BP-121 D8).
- Must write ras_snapshot_p2[NUM_PRED_SLOTS-1] into bp_ftq_entry_t.ras for EVERY valid p2 block, through ftq_bpu_interfaces.md 4c, whether or not ras_pred_val_p2 was asserted for any slot. This read "ras_snapshot_p2[s] ... when ras_pred_val_p2[s] was asserted", which left the p1 initial value in a block with no FTB result. Session-071, ruled.
- Must assert ras_restore_val for one cycle on a redirect and present the FTQ snapshot of the entry the redirect names (ftq_backend_interfaces.md 5 D2). This read "the mispredicted entry". Session-071. Not for the cluster's own p2 or p3 redirect, whose block keeps its operation (ras_decisions.md 4.3, BP-121 D9).
- Must assert ras_commit_val when a call- or return- containing FTQ entry commits.
- Must set pred_src = PRED_RAS in bp_ftq_entry_t when RAS provides the return target at p2.
- Must gate RAS override on br_type==RETURN or RETURN_CALL. This read "RETURN only"; RETURN_CALL's pop supplies the predicted target too (IC-RAS-02, ras_decisions.md RAS-DS1). Session-070.
8. Override Chain Position¶
RAS supplies the TARGET for a return. It takes no part in the direction ranking, which is SC > TAGE > FTB on direction (a trusted loop prediction above all three since BP-122, fe_decisions.md 3.3) and is suspended per branch when the FTB fast path fires (ftb_confidence_override_rules.md 4.3, 4.2). Target is selected by branch type, not ranked. An earlier revision read "RAS sits outside the conditional branch override chain: SC > TAGE > FTB > uBTB", which compresses the two. fe_decisions.md 12, narrowed session-070.
RAS is type-gated alongside TAGE and ITTAGE at p2:
p1: uBTB + Loop
p2: FTB + TAGE + ITTAGE + RAS
p3: SC
RAS provides the return target at p2 when FTB identifies the branch type as RETURN or RETURN_CALL -- for RETURN_CALL the pop supplies the target and the push follows (ras_decisions.md RAS-DS1). RAS supplies the target for those two types only. It does not participate in direction prediction. This read "the branch type as RETURN ... for return branches only". Session-070.
The p0 TOS read (ras_tos_addr_p0) is available before the FTB. The cluster registers it and the p1 selection mux applies it as the target of a RETURN slot; the p1 prediction the FTQ acts on is the cluster's, formed at p1 (fe_decisions.md FE-2, 2.2), and the p2 result may correct it. This read that the TOS read "is the initial prediction the FTQ acts on". Session-071.
9. Timing Notes¶
9.1 Return address sourcing¶
ret_addr pushed to the speculative stack comes from ras_fall_through_p2[s], the call PC plus 2 or 4 formed by the cluster (BP-121, TD#164). This read "FTB-provided fallthrough address". RAS does not independently compute PC+2 or PC+4. See ras_decisions.md section 8.
9.2 Combinational paths in p2¶
The following signals are combinational in p2:
ras_br_type_p2[0] -> push/pop decision slot 0
-> TOSR/TOSW update (slot 0)
ras_br_type_p2[1] -> push/pop decision slot 1
-> TOSR/TOSW update (slot 1, uses
post-slot-0 pointer state)
-> ras_pop_addr_p2[1] (working top of
stack, ras.sv:679)
post-slot-0 state -> ras_snapshot_p2[0]
post-slot-1 state -> ras_snapshot_p2[1]
Verilator stl_sequent note: always_comb blocks that must re-evaluate after FF updates must read at least one FF output. Gate the scan on a registered valid signal to force nba_sequent classification. See CLAUDE.md.
10. Reset Behavior¶
On rstn deassert (active low, synchronous):
- TOSR, TOSW, BOS all reset to 0.
- CSP and the commit-stack occupancy count reset to 0
(ras_decisions.md 3.3; the count since BP-126).
- All rctr fields reset to 0.
- All ret_addr fields in both stacks reset to 0.
- nos and bot of every speculative entry, and the p2->p3 repair
registers, reset to 0 (ras.sv:785-803).
- ras_pop_valid_p2 and ras_tos_valid_p0 deassert on
the first cycle after reset.
11. Known Gaps and Deferred Items¶
| ID | Item | Status |
|---|---|---|
| RI-1 | Flush port behavior. CLOSED. The RAS | ras_decisions.md |
| response to a flush is the pointer | 4.4. Do not | |
| restore of 4.3, built as | reopen from the | |
| ras_restore_val. ras_flush_val and | unread ports; | |
| ras_flush_snapshot are redundant and | see 4.4.2. | |
| intentionally left unread. | ||
| RI-2 | CLOSED session-072. s/p stage | CLOSED. |
| notation. PROJECT_CORE rules p0-p3 | p-notation | |
| and u0/u1 everywhere, so the dual | throughout. | |
| p/s labels here are swept to p. Not | ||
| a future cleanup task. | ||
| RI-3 | PHR/GHR contribution to RAS. | N/A. RAS does |
| not use folded | ||
| history. No action. |
12. Interactions With Other Planning Documents¶
ras_decisions.md -- canonical decision record.
All micro-architectural decisions
cited by IC number above live there.
bp_arb_spec.md -- section 7.2: RAS non-RAM status,
snapshot/restore protocol overview.
bp_cluster.md -- pipeline staging, redirect
architecture, FTQ entry split
(bp_ras_snapshot_t in ftq_entry_t).
bp_structs_pkg.sv -- bp_ras_snapshot_t, bp_br_type_e,
bp_pred_src_e (PRED_RAS).
bp_defines_pkg.sv -- RAS_SPEC_ENTRIES, RAS_COMMIT_ENTRIES,
RAS_RCTR_WIDTH, RAS_PTR_BITS,
RAS_COMMIT_PTR_BITS, RAS_ADDR_WIDTH.
13. Document History¶
Entries below that were written before session-072 use the
retired s-stage labels in their text. s0=p0, s1=p1, s2=p2,
s3=p3 (PROJECT_CORE.md); the labels are not live stage names.
2026-06-23 session-050. Initial draft.
Port list corrected: slot dimension uses
[0:NUM_PRED_SLOTS-1] array index, not _p0/_p1
suffix. p-stage suffix denotes pipeline stage.
s/p notation equivalence documented (RI-2).
p0/s0 TOS read ports added (ras_tos_addr_p0,
ras_tos_valid_p0). p3/s3 repair ports and
IC-RAS-11 in scope for initial design.
Dual-slot commit closed: one commit per cycle
by FTQ design, no second channel needed.
IC-RAS-07 extended to cover p0 TOS empty
fallback. Open items reduced to RI-1 through
RI-3.
2026-09-19 session-071. The p0 TOS read is an input to the p1
prediction, not the initial prediction the FTQ acts
on (sections 1, 4 and 8). IC-RAS-08 and
IC-RAS-12: the post-both-slots snapshot is written for
every valid p2 block through ftq_bpu_interfaces.md
4c; the restore presents the snapshot of the entry
the redirect names.
2026-09-20 session-072. IC-RAS-10: RETURN_CALL moved out of the
call arm into its own arm, citing ras_decisions.md 3.3.
2026-09-20 session-072. D5: the local stage-notation rule replaced
by PROJECT_CORE's. D12: the RAS inventory row points
at ras_decisions.md 1 and 1.2, not "p1".
2026-09-20 session-072. D5: the dual p/s stage labels swept to
p-notation and RI-2 closed; it listed the notation as a
future cleanup task.
2026-09-20 session-072. D5: the last s-notation site, "s2_redirect
logic", is the p2 redirect logic.
2026-09-20 session-072. D23: the pipestage list no longer declares a
px stage; the two flush ports carry no suffix.
2026-09-20 session-072. D29: the history section notes that older
entries use the retired s-labels.
2026-10-07 session-075, after BP-119. IC-RAS-10: the RETURN_CALL
commit built. IC-RAS-11: the two return-call repair
rows, built; undo-pop and missed pop follow the
next-on-stack link ruled in ras_decisions.md 3.2.
2026-10-08 session-075, after BP-120. IC-RAS-11: the repair on the
link, built; return-call pairings pointed to
ras_decisions.md 1.
2026-10-08 session-076, PA-direct correction recording BP-121.
1: linked buffer, not simple. 4: ras_p2_keep (D8),
declaration to be confirmed; ras_fall_through_p2
carries the call PC plus 2 or 4 (TD#164). 6, IC-RAS-12:
p3 qualified by p3 reachability (D10); no restore on
the cluster's own redirect (D9). IC-RAS-05: TOSR
follows the link. 9.1: push source.
2026-10-09 session-076. 4: ras_p2_keep declared (one bit, as
built, reported by BP-122). IC-RAS-11: TD#165 closed,
unreachable by construction.
2026-10-10 session-077, after BP-126. 4: ras_pc_p2 removed from
the port list; BP-126 removed it from ras.sv, tb_ras
and bp_cluster (TD#101). It was declared and unread. 10:
the commit-stack occupancy count resets with CSP.
2026-10-12 session-079, recording BP-133 and BP-134. IC-RAS-11:
the undo restores recursion counts (TD #78 closed); the
undo of a push that met a saturated count changes
nothing.
2026-10-17 session-081, after BP-138. IC-RAS-07: TOSR == BOS exact
across commits. IC-RAS-10: TOSR moves with BOS when
the stack is empty. IC-RAS-11: the undo of an
operation begun on an empty stack.
2026-10-19 session-081, after BP-140. IC-RAS-10: a RETURN commit
whose snapshot is an empty stack leaves BOS.
2026-10-29 session-082, after DOC-011. 1, IC-RAS-04, 9.2: the
bypass is the scan's working state, unreachable from
bp_cluster. 2: the TD#122 note removed. IC-RAS-06: the
full condition counts allocations. IC-RAS-09: the repair
is dropped in a restore cycle. 10: nos, bot and the
repair registers reset.
bp_history_decisions.md
planning/arch/bp_history_decisions.md on GitHub
bp_history Micro-Architectural Decisions¶
FILE: bp_history_decisions.md
SOURCE: session-054
STATUS: DRAFT
UPDATED: 2026-10-12
CONTACT: Jeff Nye
Decision record for bp_history. Companion to bp_history_interfaces.md (interface contract). This file records the resolution of G20/G21/G22 (= HI1/HI3/HI4 in the interface doc).
The three G-item policy choices (dual-slot update, rollback priority, stale-fold handling) ratify behavior already in the as-built RTL (bp_history.sv, dated 2026-05-21). The pointer- ownership decision (section 2) does NOT: it rules module-owned where the RTL is caller-owned, and so changes both the RTL and the interface port list. Section 9 separates the doc-only reconciliation from the RTL changes.
Section 6 is the canonical fold definition: the bit-exact geometry of every folded history this module produces, stated in the project's own terms so the RTL, the testbench reference, and any downstream check derive expected fold values from this document rather than from an external source.
The interface DRAFT (BP-002, dated 2026-03-28) predates the RTL and is stale on several ports.
1. Role and Ownership¶
bp_history owns all branch history state for the BP cluster: the GHR (256b), the PHR (32b), and every folded history consumed by TAGE (T1-T4), ITTAGE (IT1-IT5), and SC (ST1-ST3). It is owned by the BP cluster, not by rename or dispatch. It contains no SRAM; all state is registered flops.
GHR and PHR are single registered buffers (ghr_mem, phr_mem), not shift registers. bp_history also owns the live GHR/PHR pointers and the checkpoint array, so all history state -- buffers, pointers, checkpoints, folds -- is internal (section 2). A prediction writes one bit per slot at the internal pointer; folds advance incrementally. On rollback the pointer is restored from an internal checkpoint and the folds are recomputed from buffer contents at the restored pointer.
2. Pointer Model: module-owned¶
bp_history owns all of its pointer state. The live GHR and PHR pointers are internal registers, advanced inside the module; the checkpoint array is internal; rollback restores the pointer from a checkpoint by index. No pointer value is driven into the module.
This diverges from the as-built RTL (bp_history.sv, 2026-05-21), which takes ghist_ptr/phist_ptr and rollback_ghist_ptr/ rollback_phist_ptr as inputs. The interface DRAFT (BP-002) specified module-owned and outputs; the RTL flipped to caller-owned without a recorded rationale. This document rules module-owned as the decision. The RTL and interface port list change to match (section 9).
2.1 Advance¶
The internal pointer advances by num_branches each cycle (0, 1,
or 2), modulo buffer width. The advance is sequential only:
reset and checkpoint-restore are the only events that load a
non-incremented value. There is no external pointer-load path.
Sequential-only advance with checkpoint-indexed restore matches
standard speculative-history recovery practice: the Alpha 21264
saves prior history in an outstanding-branch queue and restores
on misprediction; IBM's GHV scheme tags each fetch group with a
shift count and restores by that count. Both index recovery by a
monotonic per-fetch-group value, neither injects an arbitrary
pointer. No surveyed design requires a non-sequential pointer.
2.2 Rollback by index¶
Rollback supplies a checkpoint INDEX, not a pointer value. On
rollback the module reads ckpt_gptr[idx] / ckpt_pptr[idx],
loads the live pointer from it, and recomputes the folds from
ghr_mem/phr_mem at that restored position (section 5).
BP-072 reconciliation (pointer-walk addressing; geometry UNCHANGED).
The fold geometry -- position mapping posmap(i) = (i+W-1)%W, newest
bit inserted at the high end (W-1), leaving bit removed at (H-1)%W --
is defined canonically in section 6 (origin: BP-071 convention)
and did NOT change. What BP-072 set is the buffer-walk
ADDRESSING that feeds that geometry under the module-owned
incrementing pointer (section 2.1): the newest bit sits just below
the live pointer, so the recompute walks the GHR DOWNWARD (offset
i -> ghr_mem[anchor - i]) and the incremental fold_step fetches its
leaving bit at write_addr - H. The recompute anchors at ckpt - 1
because the checkpoint stores the post-advance pointer (section 7)
and the newest bit of the bundle is one position behind it.
fold_step is the exact incremental form of fold_ghr for this
mapping (section 6.4), so the rollback recompute reproduces the
incremental fold; TD #74 (tb_bp_history) confirms it in simulation
for single-slot, dual-slot, GHR-boundary wrap, and SC ST3 (H=W=64).
No fold value consumed by the TAGE/ITTAGE/SC tables changed -- only
the recompute walk direction and the checkpoint anchor were fixed
to match the incrementing pointer.
Holding both an internal checkpoint array and an external
rollback pointer input -- as the current RTL does -- is
redundant. With the checkpoint internal, the index is sufficient.
2.3 Outputs for FTQ visibility¶
Pointer VISIBILITY outside the module is separate from pointer
OWNERSHIP and is retained. The current pointer is exposed as a
registered output for FTQ entry construction (ghist_ptr /
phist_ptr become outputs; ckpt_ghist_ptr / ckpt_phist_ptr
continue to expose the snapshot written on a checkpoint). The
cluster reads these; it does not drive them.
This makes bp_history self-contained on history state. The cluster drives prediction bits, num_branches, checkpoint writes, and a rollback index. Nothing pointer-valued enters the module.
3. Prediction Update: dual-slot (G20 / HI1 RESOLVED)¶
Decision: two branches update history in ONE cycle, applied as a combined slot-0-then-slot-1 fold. This is the resolution of HI1 (NUM_PRED_SLOTS=2). The interface DRAFT's single pred_valid/pred_taken/pred_pc is superseded; the RTL ports are pred_taken[NUM_PRED_SLOTS-1:0], pred_pc[NUM_PRED_SLOTS] and num_branches[PRED_CNT_BITS-1:0] (BP-129; they read [1:0], [2] and [1:0], which is their width at NUM_PRED_SLOTS = 2). At NUM_PRED_SLOTS = 1 a bundle holds one branch and this section's dual-slot case does not arise.
3.1 num_branches semantics¶
num_branches = 0 -- no branch this cycle. GHR, PHR, the pointer,
and all folds HOLD. No write, no advance.
num_branches = 1 -- slot 0 only. One bit into GHR at ghist_ptr,
one path bit into PHR at phist_ptr, one
incremental fold step per table. Pointer
advances by 1.
num_branches = 2 -- slot 0 then slot 1. Slot 0 writes ghr at
ghist_ptr / phr at phist_ptr; slot 1 writes
ghr at ghist_ptr+1 / phr at phist_ptr+1
(both modulo buffer width). Each fold takes
two incremental steps, slot 0 first. Pointer
advances by 2.
ghist_ptr / phist_ptr here are the internal pointer registers (section 2), not inputs. A count above NUM_PRED_SLOTS is undefined (3 at two slots; at one slot the port is one bit). num_branches = 2 exists only at NUM_PRED_SLOTS = 2. The RTL writes branch b, for each b below num_branches, at ghist_ptr + b with one fold step per branch in branch order, in one loop (BP-129, which also did 3.6).
3.2 Write content¶
GHR bit: pred_taken[slot].
PHR bit: pred_pc[slot][2] ^ pred_pc[slot][3] (path_bit).
pred_pc is the BRANCH PC, not the prediction-block PC.
pred_pc is the block START plus that branch's in-block position, pos << POS_OFFSET_BITS, with pos counted from the block start (not the 32-byte-aligned base, which bp_cluster.sv used until BP-110 removed it; TD#125, closed), and the ports are indexed by BRANCH NUMBER after the cluster compacts its valid slots, not by slot number.
AN EARLIER REVISION OF THIS LINE SAID THE FETCH-BLOCK PC. It was wrong and the fold arithmetic above is why: the PHR write consumes bits [3] and [2] only. The block PC gives a path bit that is nearly constant because a block start moves only when the block boundary moves; the branch PC varies by construction because its in-block position does.
THE REASON GIVEN FOR THAT WAS WRONG and does not depend on alignment. An earlier revision read "A block start is 2'b00 there whenever it is a fall-through from an aligned predecessor, which is most of them." Blocks are unaligned (ftq_decisions.md 4.7, ifu_decisions.md IFU-6), so a fall-through inherits its predecessor's low bits, and even from an aligned start the fall-through is 2'b00 there only when the block length is a multiple of 16 bytes. Corrected session-070.
The branch-PC reading was corrected 2026-09-17 to match bp_history_interfaces.md Producer obligations, ftq_bpu_interfaces.md 9 and BP-092a, which have carried the branch-PC reading since session-064.
PHR does not currently contribute to any fold; all folds are GHR-derived (HI2, deferred -- section 9).
3.3 Combined fold: ordering is load-bearing¶
The slot-1 fold step consumes the slot-0 fold result within the same cycle (nested fold_step in RTL). Folding slot-0-then-slot-1 is not equal to the reverse order. The ordering invariant is:
The incremental two-step fold (slot 0 at ptr, slot 1 at ptr+1)
must equal the full recompute over the same two new bits walked
by age from the newest (section 6.4). The rollback recompute
walks the buffer by age from the restored pointer, so the two
paths agree only if the incremental order matches the age walk.
Slot 0 first, slot 1 second is that order.
This equivalence is the core correctness property of the dual-slot path. It is the obligation TD #74's directed test proves against the canonical fold definition (section 6, section 9). Proven in simulation (TD #74, tb_bp_history).
3.4 Checkpoint granularity¶
The checkpoint captures one pointer pair per FTQ ENTRY, written at the bundle (one checkpoint per accepted prediction bundle), not per branch. There is no checkpoint position between slot 0 and slot 1 of the same bundle. Bundle granularity is the intended recovery unit under post-execute update, and a redirect targets a bundle boundary, not an intra-bundle slot.
TWO CORRECTIONS, 2026-09-17. This paragraph said "per FTQ slot" where it means per FTQ ENTRY -- the checkpoint array is indexed by FTQ index and the prediction slot is a different concept (fe_decisions.md FE-10). And it cited "the fixed bundle split (G8/G17)" as the reason for bundle granularity. G8 and G17 are SUPERSEDED (session-063) and the pred_pc+0:31 / +32:63 split does not govern block prediction. IT NO LONGER EXISTS ANYWHERE EITHER: tage_interfaces.md TI3 has slot 1's PC supplied on tage_pred_inp_p0[1].pc and records pred_pc+32 as an error that was removed. An earlier revision of this paragraph called it "the TAGE/ITTAGE bundle convention"; corrected session-070.
The conclusion survives without them -- one checkpoint per accepted bundle is a property of when the checkpoint is written, not of how the block is split.
Rollback-by-index (section 2.2) applies to EVERY redirect that
names an entry. ftq_backend_interfaces.md D1 lists them:
RC_MISPREDICT, RC_TRAP and RC_REPLAY. Only RC_UNSPEC is excluded,
and it is excluded because it names no entry to repair from, not
because its history is unwanted (that document's U5).
THE INDEX ALWAYS RESOLVES, FOR ANY CAUSE. The granularity rule
above is why: one checkpoint per accepted prediction bundle, not
per branch, and ftq_entry_formats.md carries ghist_ptr and
phist_ptr in every entry. A bundle with no branch in it has a
checkpoint like any other.
AN EARLIER REVISION OF THIS PARAGRAPH restricted rollback to
branch-mispredict redirects and had exceptions and interrupts
discard and reinitialize the speculative history instead. Its
argument was that a mispredict rewinds to a bundle which by
definition contained a branch and therefore has a checkpoint. That
is true and it does not distinguish: bundle granularity makes it
true of every bundle. The revision also asked for confirmation at
bp_cluster that no third redirect type needed restore onto a
no-branch bundle. RC_TRAP and RC_REPLAY are that third and fourth
type, the no-branch bundle is not a problem, and
ftq_backend_interfaces.md had already answered it the other way.
WHY RESTORE RATHER THAN REINITIALIZE ON A TRAP. A trap does not un-execute the branches that already resolved in the naming bundle, so the checkpoint of the entry being corrected is the state to resume from; reinitializing would discard resolved history, not only speculative history. And traps here means every syscall, timer interrupt and page fault, so zeroing on each one destroys the correlation the predictors depend on and returns through sret into a stream whose history has been erased. The restore path already exists for mispredicts.
The case against, recorded because it is not empty: a handler is a different control-flow context, so pre-trap history is arguably noise for predicting inside it. That argues for a separate handler history, which nothing in this design proposes, rather than for zeroing. Session-069.
3.5 History corrected on a redirect (DECIDED, REVERSED)¶
DECISION: the history is CORRECTED on a redirect. RULED session-075 (Jeff, BP-121 decision 8), BUILT by BP-121 (D14, D16). This reverses the decision recorded here from session-069 to session-075, that the restored history was imprecise and accepted as such.
THE RULE. The rollback carries a correction with the index. On rollback bp_history restores the pointer to the FIRST bit of the named bundle rather than past its last, writes the corrected bits, and rewrites that entry's checkpoint. The correction is formed by ftq_npc for a backend redirect, from bkend_ftq_redir_pos and bkend_ftq_redir_taken (ftq_backend_interfaces.md 5), and by the cluster for its own p2 and p3 redirects. It reaches bp_history on rollback_corr, rollback_n, rollback_tkn and rollback_pbit, declared in bp_history_interfaces.md (the cluster-boundary ports are ftq_bpu_interfaces.md 9). rollback_n is the number of corrected bits written. The bundle's FIRST bit is located from the checkpoint and a stored bundle size, ckpt_nb, one per entry: the first bit is the post-advance checkpoint minus ckpt_nb. ckpt_nb is num_branches at the checkpoint write and rollback_n after a corrected rollback rewrites the entry. The RTL has stored it since BP-121.
THIS READ "rollback_n ... read with the post-advance checkpoint it locates the bundle's first bit, so the checkpoint needs no slot count (PA reading of the declarations BP-122 reported)". The PA reading was wrong: rollback_n is the count of the corrected bundle, not the predicted one, and the RTL locates the first bit from ckpt_nb. Found by BP-130, corrected session-078.
THE CORRECTION IS AT MOST TWO BITS at either slot count. RULED session-078 (Jeff), BUILT by BP-130: at most one not-taken bit for a branch of the entry before the redirecting one, then the redirecting branch's resolved bit. The correction ports are RB_CORR_BITS = 2 wide, with the count RB_CNT_BITS, at either NUM_PRED_SLOTS; ckpt_nb is RB_CNT_BITS. At one slot a backend mispredict of a branch held in no slot (BP-128 D2) carries two bits for an entry whose prediction wrote one, and both reach the history. BP-129 had limited the correction to NUM_PRED_SLOTS bits, provisionally, and that dropped the not-taken bit: six tb_fe_top programs mispredicted more at one slot (indir 71 to 86). BP-130 restored every one-slot figure to its value before BP-129. Not one more bit than the number of slots: at two slots the correction stays at two, and a branch past both slots is not represented (the cap at two is Jeff's, session-078).
HISTORY STOPS AT THE FIRST TAKEN SLOT (D16). A bundle writes one bit per slot up to and including its first taken slot and none after it, since a slot after a taken slot is off the path. Before BP-121 the p1 history wrote a bit for a slot past a taken one, which the p2 and p3 corrected bundle then repaired.
WHAT WAS IMPRECISE. The checkpoint stores the POST-advance pointer (section 7), so restoring the named entry put the pointer past both of the bundle's bits, which held PREDICTED directions: the mispredicted branch's own bit, and a slot 1 bit for a branch off the corrected path. They stayed wrong for H predictions, H being the history length of the longest table (119, TAGE T4). The old text argued that no fix was possible without a port change; BP-121 made that port change, the alternative this section had recorded as not taken.
CHECKED: after a conditional's mispredict the newest history bit is its resolved direction, in every tb_fe_top program, and tb_bp_history TC17. Reverting the correction fails the tb_fe_top check (BP-121 m13).
3.6 RTL fix: if / else-if for the slot cases¶
DONE by BP-129 (session-078). The two slot blocks are one loop over branch number calling one fold step per branch (fold_all_step), so each case assigns the fold registers once. The text below is the record.
The RTL applies num_branches>=1 and num_branches==2 as two separate if blocks that both assign the fold registers. On num_branches==2 the slot-0-only assignment is computed and then overwritten by the dual assignment, correct only by nonblocking last-write-wins. Convert to if / else-if (num_branches==2 else num_branches==1) so each case assigns the registers once. No behavior change; removes the dead assignment and the coverage skew. Apply when TD #74 touches the file (section 9).
4. Rollback Priority (G21 / HI3 RESOLVED)¶
Decision: rollback wins. When rollback and a prediction update would land in the same cycle, the history state takes the rollback and the prediction update is dropped for that cycle.
Rationale: a redirect invalidates any same-cycle speculative prediction. Letting rollback win keeps the recovery path the single source of next-cycle history state and removes the need for a merge between a restore and a forward advance.
RTL: rollback_valid is a distinct branch in the update if/else ladder (reset / rollback_valid / normal). When rollback_valid is asserted, the normal-update branch (including both slots and the checkpoint write) does not execute. The two are mutually exclusive by construction, so no priority encoder is needed. Under the module-owned decision (section 2) the rollback branch reads the internal checkpoint by index and loads the pointer from it; the current RTL instead consumes an external rollback pointer, which changes with the port edit (section 9). The priority structure is unaffected by that change.
This places the complexity in isolation: rollback is its own state transition, never a blend with prediction update.
Producer obligation: the cluster may assert rollback_valid and pred/num_branches in the same cycle; if it does, the prediction is understood to be discarded. The cluster is not required to suppress the prediction inputs, because the RTL ignores them under rollback_valid. (The interface DRAFT's stricter "producer must not assert both" obligation is relaxed to "rollback wins if both are asserted." See section 9.)
5. Folded History After Rollback: stale, not invalid¶
(G22 / HI4 RESOLVED, and decoupled from G15)
Decision: on the rollback cycle the fold outputs are STALE, not invalid, and the cluster MAY issue a prediction on stale folds. The precision cost is accepted and handed to performance analysis.
5.1 Stale vs invalid¶
The fold register (fh_r) is neither cleared nor driven to X on rollback. It holds its current value during the rollback cycle and presents the recomputed value from the next cycle onward (folds are registered, one-cycle recompute latency). The value visible in the rollback cycle is therefore the wrong-path history that is about to be replaced -- stale, not undefined.
The interface DRAFT's word "invalid" overstates this and its "consumer must not fire a prediction in that cycle" obligation is withdrawn.
5.2 Why stale is safe to consume¶
Folds feed index/tag hashing for advisory predictors. A stale fold yields a weak or wrong prediction that a later redirect corrects. It never corrupts architectural state. Because rollback and normal update are mutually exclusive (section 4), the stale fold is read by consumers in that cycle but is never fed back into an incremental fold step -- the next cycle starts from the recomputed-correct state. The stale value cannot poison the fold chain.
5.3 Decoupling from G15¶
The DRAFT tied HI4/G22 to G15 because the old "must not fire" framing required a stall or enforcement mechanism whose timing was unresolved. Allowing stale-fold predictions removes that mechanism. With nothing to enforce, G22 is no longer a correctness gate on bp_cluster integration. G15 reduces to a performance measurement: the accuracy cost of predicting on a stale fold in the rollback cycle.
5.4 Performance cost (accepted, quantify later)¶
Decision: predictions are not blocked during the one-cycle recompute. No handshake, no backpressure, no stall. The predictor reads the old fold values that cycle and produces a lower-quality prediction for that one fetch. This is an accepted performance cost, taken to avoid the control complexity a block would add.
Action item, detailed performance analysis: quantify how often a prediction lands in the recompute cycle and its accuracy cost. Revisit only if it is material.
6. Fold Definition (Canonical)¶
This section is the authoritative definition of every folded history bp_history produces. It is stated in the project's own terms so that the RTL (fold_ghr / fold_step), the testbench reference, and any downstream producer/consumer check derive expected fold values from THIS document, not from an external source. Origin is recorded in section 6.6; the definition here is the contract.
A folded history compresses an H-bit window of the global history register (GHR) into a W-bit value by XOR. Each consuming table selects its own (H, W): H = history length, W = folded width. The per-table (H, W) values are package localparams (section 8: TAGE_TBL_HIST/FH/FH1/FH2, IT_TBL_HIST/FH/FH1/FH2, SC_TBL_HIST). This section defines the mapping, not the values.
6.1 Age indexing¶
Index the H in-window history bits by AGE, not by buffer
position. Age i = 0 is the NEWEST bit (the most recently written
branch outcome); age i = H-1 is the OLDEST bit still in the
window. Aging is independent of how the GHR buffer is addressed:
the buffer-walk that maps age to a physical ghr_mem index is a
pointer-model concern (section 2.2), not part of this definition.
The fold is a function of the H-bit age-ordered history alone.
6.2 Position mapping (full recompute)¶
The bit of age i contributes, by XOR, to folded output position
posmap(i) = (i + W - 1) mod W
Equivalently:
- The newest bit (age 0) lands at the high end, position W-1.
- Each older bit sits one position HIGHER, modulo W: age 1 wraps
to position 0, age 2 to 1, and so on (a left rotate per age
step, as 6.3 applies it).
- Age i and age i + W land on the same position and XOR-overlap;
this overlap is the compression.
This read "one position lower", against the formula, the
parenthetical, 6.3 and the 6.5 example, and said wrapped ages
overlap "onto lower positions". Session-072.
The folded value is
fold = XOR over i in [0, H-1] of
( history_bit(age i) << posmap(i) )
with all arithmetic in W bits. A history bit of 0 contributes
nothing; a bit of 1 toggles its mapped position. This is the
full recompute; bp_history uses it on rollback (fold_ghr).
6.3 Window eviction (incremental form)¶
The incremental form advances the fold by one new bit per branch
without rescanning the window (fold_step). One step:
1. Left-rotate the W-bit fold by 1 (each occupied position p
moves to (p+1) mod W).
2. XOR the new (age-0) bit in at position W-1.
3. XOR OUT the bit that has just left the H-deep window -- the
bit now at age H -- at position
posmap(H) = (H - 1) mod W.
Step 3 removes the contribution the departing bit made when it
entered: after H-1 rotations that contribution now sits at
(H-1) mod W. Without step 3 the fold would accumulate bits older
than the window. The departing bit is read from the GHR at the
age-H position (RTL: ghr_mem[write_addr - H], section 2.2).
6.4 Equivalence invariant¶
The full recompute (6.2) and the incremental form (6.3) MUST
produce the same fold for the same H-bit history:
recompute(history) == incremental(history)
for every history and every (H, W) in use -- including H = W (no
compression; SC ST1-ST3) and H > W (compression; the TAGE/ITTAGE
tag folds fh1/fh2). bp_history uses the incremental form on the
prediction path and the full recompute on rollback (section 2.2);
this invariant is what makes the two paths interchangeable. For
a dual-slot bundle the incremental form is applied twice, slot 0
then slot 1 (section 3.3), and must still equal the recompute
over both new bits. TD #74 proves the invariant in simulation
(tb_bp_history).
6.5 Worked example (checkable)¶
TAGE T1 index fold, H = W = 8 (TAGE_TBL_HIST[1] = TAGE_TBL_FH[1]
= 8). This is the BP-073 TC14 anchor; the result below is the
committed test literal, so this example and tb_bp_history agree
by construction.
Drive eight single-slot branches, oldest first, taken pattern
p0..p7 = 1,1,0,0,1,0,1,1. p0 is written first (oldest), p7 last
(newest), giving ghr[7:0] = 0xD3 and the age-ordered history:
age i: 0 1 2 3 4 5 6 7
bit: 1 1 0 1 0 0 1 1 (age 0 = p7, newest)
posmap(i) = (i + 7) mod 8, taking only the set bits:
age 0 (1) -> pos 7
age 1 (1) -> pos 0
age 3 (1) -> pos 2
age 6 (1) -> pos 5
age 7 (1) -> pos 6
Set positions {7, 6, 5, 2, 0} -> 1110_0101 = 0xE5.
So bp_history.folded.tage_t1_idx_fh == 0xE5 for this history,
matching tb_bp_history TC14. The ITTAGE IT1 anchor (0x9, H=W=4,
sub-window) and the SC ST3 anchor (0xC000_0000_0000_0000,
H=W=64, wrapped) in TC15/TC16 follow the same definition at
their (H, W).
6.6 Origin¶
The geometry above is the standard folded-history compression of the O-GEHL and TAGE predictors (newest bit folded in at the high end, leaving bit removed at (H-1) mod W, one definition shared by update and recompute). This section is the project's own contract; it cites no external implementation. An earlier revision credited one implementation and left its commit and date as placeholders; both were removed session-078 (Jeff, TD#83).
7. Checkpoint¶
The checkpoint array (ckpt_gptr / ckpt_pptr, internal) stores the GHR pointer (8b) + PHR pointer (5b) per FTQ ENTRY, 13 bits per entry, indexed by FTQ index. Folds are NOT stored per entry; they are recomputed on rollback from buffer contents at the restored pointer (section 5, G15 framing). "Per FTQ slot" here and in 3.4 meant per entry; corrected 2026-09-17.
Write: ckpt_wr_en writes the POST-advance internal pointer pair (the next-write address for the cycle after this bundle) into ckpt_wr_idx, and exposes it on ckpt_ghist_ptr / ckpt_phist_ptr for FTQ entry construction.
Checkpoint timing is POST-advance (ratified -- see History 2026-06-26). The rollback anchor needs only the pointer. Storing the post-advance pointer puts the newest history bit of the bundle at ckpt - 1 whether the bundle held one branch or two, so the rollback recompute anchors uniformly at ckpt - 1 (section 2.2). A pre-advance snapshot would require also storing the slot count to locate the newest bit. This supersedes the earlier pre-advance wording in this section and matches bp_history_interfaces.md (Checkpoint Timing).
THE CHECKPOINT ALSO STORES A BUNDLE SIZE, ckpt_nb, since BP-121: the corrected rollback needs the bundle's FIRST bit, which is the checkpoint minus ckpt_nb (3.5). This paragraph read "The checkpoint carries a pointer only, not num_branches", true for the anchor and untrue of the entry since BP-121. Corrected session-078.
Read (rollback): the rollback index selects ckpt_gptr[idx] / ckpt_pptr[idx]; the module loads the live pointer from it and recomputes folds (section 2.2, section 5). No pointer value is driven in. Since BP-121 the rollback also carries a correction: the pointer goes to the bundle's first bit, the corrected bits are written and the checkpoint is rewritten (3.5).
Contamination model (unchanged from BP-002 TC8): ghr_mem and phr_mem are not cleared on rollback. Entries written after the checkpoint remain in the buffer but are unreachable via the restored pointer. This is accepted.
Checkpoint slot reclaim (when a slot is safe to reuse) and the no-branch-flush target case (section 3.4) are FTQ concerns. BOTH ARE NOW ANSWERED. The no-branch-flush case is closed in 3.4. The reclaim is closed by G23: the checkpoint is a FIELD of the FTQ entry, so a slot is reclaimed with the entry at commit and there is no separate protocol (ftq_decisions.md 5.8 and 5.3). HI5 closed session-070, section 9.
8. Parameters¶
Defined in bp_defines_pkg.sv / bp_structs_pkg.sv. Do not use numeric literals.
GHR_WIDTH = 256 GHR buffer depth, bits.
PHR_WIDTH = 32 PHR buffer depth, bits.
GHIST_PTR_BITS = 8 pointer into GHR buffer.
PHIST_PTR_BITS = 5 pointer into PHR buffer.
FTQ_DEPTH = 64 checkpoint slots.
FTQ_IDX_BITS = 6 checkpoint index.
Fold widths and per-table history lengths (TAGE_TBL_HIST, TAGE_TBL_FH/FH1/FH2, IT_TBL_HIST, IT_TBL_FH/FH1/FH2, SC_TBL_HIST, and the *_MAX_FH cast widths) are package localparams consumed by the fold functions (section 6). They are not restated here; bp_history.sv reads them from the package.
The folded output is bp_folded_hist_t (bp_structs_pkg.sv): one idx + two tag folds per TAGE T1-T4 and ITTAGE IT1-IT5, one idx fold per SC ST1-ST3. SC ST0 (hist=0) and SC ST4 (BrIMLI index, not a hashed fold) have no folds.
9. Open Items¶
HI1: RESOLVED (this document, section 3). Dual-slot update is
combined slot-0-then-slot-1 in one cycle, bundle-
granularity checkpoint. The interface doc port list must be
reconciled to pred_taken[1:0] / pred_pc[2] / num_branches.
HI3: RESOLVED (section 4). Rollback wins; mutually exclusive
with normal update. Interface doc obligation relaxed from
"must not assert both" to "rollback wins if both asserted."
HI4: RESOLVED (section 5). Stale-fold predictions allowed;
"must not fire" obligation withdrawn; decoupled from G15.
HI2: OPEN. PHR contribution to fold index/tag hashing. All folds
are GHR-derived today. It was deferred to the TAGE/ITTAGE
hashing work; that work is done, both units are Complete, and
the question was not answered there. It has no scheduled
home (bp_cluster.md History Module, fe_decisions.md FE-U4).
Session-072.
HI5: CLOSED session-070 by G23. Checkpoint slot reclaim -- when
a slot is safe to reuse. It was deferred here "at FTQ
implementation", and the FTQ has now answered it: the
checkpoint is a FIELD of the FTQ entry, so a slot is
reclaimed with the entry at commit and there is no separate
protocol (ftq_decisions.md 5.8 and 5.3, PROJECT_STATUS G23).
G23 has read RESOLVED while this entry read DEFERRED.
(The no-branch-flush concern raised earlier
is closed in section 3.4, but not for the reason first
given: restore is NOT mispredict-only, and the bundle
granularity means every entry has a checkpoint, so any
named entry resolves.)
G15: REFRAMED (section 5.3). No longer a correctness gate; now a
performance measurement (stale-fold accuracy cost in the
rollback cycle).
HI6: OPEN, and NOT OWNED HERE. IT5 fold generation is missing
in bp_history.sv: ittage.sv wires it_t5_idx_fh / tag_fh1 /
tag_fh2 to outputs that are never driven, so IT5 indexes on
PC alone. = TD#102. Opened in bp_history_interfaces.md
session-064 and listed here 2026-09-17 so this file is not
read as holding the whole HI registry.
HI7: CLOSED by BP-129 (session-078). The ports are sized by
NUM_PRED_SLOTS and PRED_CNT_BITS; the correction ports are
RB_CORR_BITS / RB_CNT_BITS (BP-130). It read: ports use
literal [1:0] and [2] where other modules use
NUM_PRED_SLOTS, deferred, INFRA-011.
HI8: CLOSED session-076 by ruling: the history is corrected on
a redirect (3.5, BP-121 decision 8), so the cost below is
no longer paid. The text that follows is the record.
PERFORMANCE MEASUREMENT, not a correctness gate and not
technical debt (section 3.5, session-069). The accuracy
cost of the imprecise GHR across a redirect: two wrong bits
surviving H predictions after every mispredict. Measure
against the alternative in 3.5, which corrects the bit at
the cost of a rollback port change. Same standing as G15.
RENUMBERED FROM G24, 2026-09-17. G24 was already allocated,
in the PROJECT_STATUS BP Cluster Open TBDs table, to the FTB
flush protocol (ftb_flush_px), which BP-105 closed by
decision. Every other citation of G24 in this tree --
PROJECT_STATUS, fe_decisions.md, ftq_decisions.md,
ftq_backend_interfaces.md, ras_decisions.md -- means that
FTB item and none of them means this one. HI8 was taken
because HI6 and HI7 were already issued in
bp_history_interfaces.md and never mirrored into this
file's section 9, which is what made HI6 look free.
THE HI REGISTRY IS SHARED between this document and bp_history_interfaces.md. Check BOTH before issuing a number.
RTL + interface change (module-owned pointer, section 2).
DELIVERED BY BP-069 and no longer open. The pointer is internal
and advances by num_branches; ghist_ptr and phist_ptr are
registered outputs; rollback supplies rollback_ckpt_idx and the
module reads its own checkpoint array. bp_history_interfaces.md
carries the delivered port list and PROJECT_STATUS records
bp_history.sv as module-owned.
SECTION 2 STILL READS AS THOUGH THIS IS PENDING. It says the
decision "diverges from the as-built RTL" and that the RTL and
port list "change to match (section 9)". That was true when
session-054 wrote it and has not been true since BP-069. Read
section 2 as the DECISION and its rationale; the divergence it
describes is closed. Noted 2026-09-17.
Interface reconciliation, also DELIVERED. The DRAFT-vs-as-built
deltas below were applied; they are kept as the record of what
moved, not as work:
- rollback_en -> rollback_valid
- ckpt_idx -> ckpt_wr_idx
- pred_taken / pred_pc scalar -> [1:0] / [2]
- add num_branches, ghr_buf, phr_buf
- DRAFT obligation "must not assert rollback + pred together"
relaxed to "rollback wins" (section 4)
RTL fix (section 3.6): DONE by BP-129 (session-078), one loop
over branches. It read: convert the slot cases to if / else-if,
directed, apply at TD #74.
Downstream tasks (not doc edits, sequenced after this doc):
- TD #74: dual-slot directed test. Proves the section 3.3
incremental-vs-recompute equivalence against the canonical
fold definition (section 6). Proven (BP-072).
- TD #69 / #70: TAGE / ITTAGE rollback + history-recompute
test. Was blocked on G20/G21/G22; this document unblocks
it. NO LONGER GATED ON STIMULUS: tb_bp_cluster E1 and E2
drive checkpoint and rollback through the cluster
(PROJECT_STATUS TD#69). This read "Still gated on the
cluster providing the rollback stimulus path".
Session-070.
- Producer/consumer fold check: drive a known GHR, take the
bp_history fold output, run it through the actual TAGE/
ITTAGE table index hash, confirm the resulting index against
an independently-known value. End-to-end format agreement
between bp_history and its consumers; needs cluster stimulus.
Distinct from the BP-073 unit anchor (which proves the fold
value against section 6, not the index the table derives).
- Performance item (section 5.4): stale-fold cost at SPEC.
10. Interactions With Other Planning Documents¶
bp_history_interfaces.md
-- bp_history interface contract: port list,
timing, producer/consumer obligations. Carries
the port reconciliation listed in section 9.
bp_cluster.md -- the cluster reads the exposed pointer for FTQ
entry construction and supplies rollback
stimulus (the checkpoint index); it does NOT
own or drive the pointer. Pointer ownership is
module-internal (section 2). Also: rollback
stimulus path, FTQ entry contents, GHR 256b /
PHR 32b, folds recomputed on rollback.
tage_table_hash_rules.md / ittage_table_hash_rules.md
-- consume the folded outputs for index/tag
hashing. They define fold CONSUMPTION (the
index/tag hash given fh/fh1/fh2); the fold
COMPUTATION is defined here (section 6). HI2
(PHR mixing) lands in the hash docs.
bp_defines_pkg.sv / bp_structs_pkg.sv
-- GHR_WIDTH, PHR_WIDTH, pointer/FTQ widths,
per-table history and fold widths,
bp_folded_hist_t.
11. Document History¶
2026-06-25 session-054. Created. Resolves G20/G21/G22
(= HI1/HI3/HI4). Decisions: dual-slot combined
slot-0-then-slot-1 update with bundle-granularity
checkpoint (section 3); rollback wins, mutually
exclusive with update (section 4); stale-fold
predictions allowed, G22 decoupled from G15
(section 5). Pointer model ruled module-owned:
internal pointer, sequential-only advance, internal
checkpoint, rollback by index (section 2). This
diverges from the as-built RTL (caller-owned input
pointer) and changes both bp_history.sv and the
interface port list (section 9). Sequential-only
advance confirmed against Alpha 21264 and IBM GHV
recovery practice; no surveyed design needs a
non-sequential pointer. Restore applies to every
redirect that names an entry (section 3.4, corrected
session-069): RC_MISPREDICT, RC_TRAP and RC_REPLAY
per ftq_backend_interfaces.md D1. Bundle granularity
gives every entry a checkpoint, so no no-branch
restore case exists.
Open: the module-owned RTL/port edit and
TD #74 / #69 / #70 sequencing (section 9).
2026-06-26 session-055 (fold-definition capture). Added section
6, the canonical Fold Definition: age indexing,
position mapping posmap(i) = (i+W-1)%W, window
eviction, the recompute == incremental invariant, and
a checkable worked example tied to the BP-073 TC14
anchor (history 0xD3 -> fold 0xE5). demoted
to an origin footnote (section 6.6) with a captured
commit/date placeholder. Section 2.2 now cites section
6 as the geometry authority rather than "the BP-071
convention." Old sections 6-10 renumbered to
7-11; all "section N>=6" cross-references updated. No
RTL or behavior change -- this captures the frozen,
externally-anchored (BP-073) geometry in the project's
own terms. A verification pass confirming the RTL still
matches the reworded authority is the follow-on task.
2026-06-26 session-055 (BP-072). Root cause found: session-054 left
BP-069 (module-owned pointer interface) and BP-071 (fold
geometry) in SEPARATE files -- BP-069 only in
versions/bp_history.sv, BP-071 only in the active rtl/
file -- so no single file held both, and the pointer-to-
fold addressing for an incrementing module-owned pointer
was never written or tested. handoff-054 and
PROJECT_STATUS recorded both as landed and lint-clean;
that was inaccurate. BP-072 merged the two into the
active rtl/ file and wrote that addressing for the first
time: with the pointer INCREMENTING (section 2.1) the
recompute walks the GHR downward (anchor - i) and
fold_step fetches its leaving bit at write_addr - H. The
BP-071 geometry (posmap, high-end insertion, (H-1)%W
eviction) is UNCHANGED; this was an addressing
reconciliation, not a geometry change, and no table-
consumed fold value moved. While writing it, the
checkpoint-timing inconsistency between this doc (section
7, pre-advance) and bp_history_interfaces.md (post-
advance) surfaced; resolved to POST-advance (ratified)
for the num_branches-independent anchor reason in section
7. recompute == incremental proven in simulation (TD #74,
tb_bp_history): 13 directed cases, 19224 golden
comparisons, incl. single-slot, dual-slot, GHR-boundary
wrap, SC ST3 (H=W=64). External fold-value anchor against
the canonical definition added in BP-073 (TC14-TC16);
the hash-rule docs were found to define fold consumption
only, which motivated the section 6 capture above.
2026-09-17 audit_v6, interactive. Five corrections, all of them
this document disagreeing with documents that had
already settled the point.
3.2: pred_pc is the BRANCH PC, not the fetch-block
PC. bp_history_interfaces.md, ftq_bpu_interfaces.md 9
and BP-092a have said so since session-064 and the
PHR fold arithmetic in 3.2 is the reason.
3.4: cited "the fixed bundle split (G8/G17)", which
session-063 superseded. The bundle-granularity
conclusion does not rest on it and is restated
without it.
3.4 and 7: "per FTQ slot" meant per FTQ ENTRY. The
prediction slot is a different concept (FE-10).
Section 9: G24 RENUMBERED HI8. G24 was already the
FTB flush protocol in the PROJECT_STATUS TBD table,
closed by BP-105, and every other citation in the
tree means that item. HI6 and HI7 were already
issued in bp_history_interfaces.md and are now
listed here, because their absence from this file's
section 9 is what made HI6 look free.
Section 9: the module-owned pointer RTL and port
change was DELIVERED by BP-069 and is no longer
open. Section 2 still describes the divergence as
live and is annotated rather than rewritten.
Header STATUS set to DRAFT per the PROJECT_CORE
convention; the field is decorative.
2026-09-19 session-071. 3.2: pred_pc is the block START plus
pos << POS_OFFSET_BITS; "block base" had been read as
the aligned base (TD#125).
2026-09-20 session-072. 6.2: "each older bit sits one position
lower" contradicted the formula; older is higher. HI2
no longer deferred to the completed TAGE/ITTAGE work.
2026-09-20 session-072. E22: Document History sorted into date order;
newer entries had been appended at the wrong end.
2026-10-08 session-076, PA-direct correction recording BP-121.
3.5 REVERSED: the history is corrected on a redirect,
with the checkpoint rewritten, and stops at the first
taken slot (decision 8, D14, D16). HI8 closed. 3.2:
the aligned-base note brought to BP-110 (TD#125). 7:
the rollback read notes the correction.
2026-10-09 session-076, recording BP-122. 3.5: the correction
ports named; rollback_n locates the first bit.
2026-10-12 session-078, after BP-128 to BP-130. 3, 3.1: the
ports sized by NUM_PRED_SLOTS (BP-129), one loop over
branches. 3.5: the first bit is located from the stored
bundle size ckpt_nb, not from rollback_n (the
2026-10-09 reading was wrong); the correction is at most
two bits at either slot count (ruled, built by BP-130).
3.6 done (BP-129). 7: ckpt_nb recorded. 9: HI7 and the
3.6 item closed. 6.6: the external implementation
citation and its placeholders removed (Jeff, TD#83).
bp_history_interfaces.md
planning/interfaces/bp_history_interfaces.md on GitHub
bp_history Interface Specification¶
FILE: bp_history_interfaces.md
SOURCE: various
STATUS: DRAFT
UPDATED: 2026-10-12
CONTACT: Jeff Nye
Overview¶
bp_history owns all branch history state for the BP cluster: the GHR (Global History Register), the PHR (Path History Register), the GHR/PHR pointers, the per-slot checkpoint array, and all folded histories consumed by TAGE, ITTAGE, and SC. It is owned by BPC (branch predictor cluster), not by rename or dispatch. It contains no SRAM -- purely registered state.
Types are defined in bp_structs_pkg.sv and parameters in bp_defines_pkg.sv. (bp_pkg.sv was split session-008 and deleted; earlier revisions of this file named it.) This document describes port semantics, timing contracts, and consumer/producer obligations.
The G20/G21/G22 resolutions and the module-owned pointer decision (bp_history_decisions.md) are reflected here and are IMPLEMENTED in bp_history.sv. The module-owned pointer landed in BP-069; earlier revisions of this file described the as-built RTL as caller-owned-pointer and single-rollback-pointer and named this document the target the implementation would close to. That gap is closed. The RTL is now the reference; where this document and the RTL disagree, this document is corrected.
Module Parameters¶
None. All widths and depths are localparams from bp_defines_pkg.sv.
GHR_WIDTH = 256 -- circular buffer depth in bits
PHR_WIDTH = 32 -- circular buffer depth in bits
GHIST_PTR_BITS = 8 -- pointer into GHR buffer
PHIST_PTR_BITS = 5 -- pointer into PHR buffer
FTQ_DEPTH = 64 -- number of checkpoint slots
FTQ_IDX_BITS = 6 -- index into checkpoint array
NUM_PRED_SLOTS = 2 -- prediction slots, 1 or 2 (BP-128);
branches per update 0 to NUM_PRED_SLOTS
PRED_CNT_BITS = 2 -- $clog2(NUM_PRED_SLOTS + 1); 1 at one
slot. Width of num_branches (BP-129)
RB_CORR_BITS = 2 -- bits of a history correction, 2 at
either slot count, not derived from
NUM_PRED_SLOTS (BP-130, session-078)
RB_CNT_BITS = 2 -- $clog2(RB_CORR_BITS + 1). Width of
rollback_n and of the stored bundle
size (BP-130)
Port List¶
clk : input logic -- rising edge
rstn : input logic -- active low
-- Prediction update (one bundle per cycle, indexed by BRANCH
-- number, not by slot number)
num_branches : input logic [PRED_CNT_BITS-1:0] -- 0 to NUM_PRED_SLOTS
pred_taken : input logic [NUM_PRED_SLOTS-1:0] -- bit n = branch n
pred_pc : input logic [VA_WIDTH-1:0]
[NUM_PRED_SLOTS] -- per-branch PC
-- Checkpoint write
ckpt_wr_en : input logic -- write enable
ckpt_wr_idx : input logic [FTQ_IDX_BITS-1:0] -- FTQ ENTRY index
-- Rollback (redirect recovery, by checkpoint index)
rollback_valid : input logic -- restore enable
rollback_ckpt_idx : input logic [FTQ_IDX_BITS-1:0]
-- Rollback history correction (BP-121, D14; declared by BP-122;
-- widths BP-130)
rollback_corr : input logic -- corrected bundle
rollback_n : input logic [RB_CNT_BITS-1:0] -- bits, 0 to 2
rollback_tkn : input logic [RB_CORR_BITS-1:0] -- their directions
rollback_pbit : input logic [RB_CORR_BITS-1:0] -- their path bits
At NUM_PRED_SLOTS = 2 every width above is the former [1:0] or
[2]. At 1 the three prediction-update ports are one entry wide
and the four correction ports keep their two-bit width (BP-129,
BP-130).
-- Current pointer outputs (module-owned, for FTQ construction)
ghist_ptr : output logic [GHIST_PTR_BITS-1:0]
phist_ptr : output logic [PHIST_PTR_BITS-1:0]
-- Checkpoint snapshot outputs (value written this cycle)
ckpt_ghist_ptr : output logic [GHIST_PTR_BITS-1:0]
ckpt_phist_ptr : output logic [PHIST_PTR_BITS-1:0]
-- Raw buffer outputs
ghr_buf : output logic [GHR_WIDTH-1:0]
phr_buf : output logic [PHR_WIDTH-1:0]
-- Folded history output (consumed by TAGE, ITTAGE, SC)
folded : output bp_folded_hist_t
Note: ghist_ptr / phist_ptr are OUTPUTS. The pointer is owned and advanced inside bp_history (module-owned pointer, bp_history_decisions.md section 2). No pointer value is driven into the module; rollback supplies an INDEX, not a pointer.
Note: the three prediction-update ports are indexed by branch number. The cluster compacts its valid prediction slots down before presenting them, so a bundle whose only branch is in slot 1 presents that branch at index 0. See "Prediction Update Interface" below.
Pointer Ownership¶
bp_history owns the live GHR and PHR pointers as internal registers and advances them itself. The pointer advances by num_branches each cycle (0 to NUM_PRED_SLOTS), modulo buffer width. The advance is sequential only: reset and checkpoint-restore are the only events that load a non-incremented value. There is no external pointer-load path.
The current pointer is exposed as a registered output (ghist_ptr / phist_ptr) for FTQ entry construction. The cluster reads it; it does not drive it.
See bp_history_decisions.md section 2 for rationale (sequential- only advance, rollback by index, FTQ visibility vs ownership).
Prediction Update Interface¶
Producer: BP cluster (one bundle per cycle, up to NUM_PRED_SLOTS¶
branches)¶
Consumer: bp_history (GHR/PHR advance, folds update)¶
Timing¶
num_branches, pred_taken, pred_pc are sampled on rising clk.
GHR, PHR, the pointer, and the folds advance synchronously.
Updated folds are available at the start of the next cycle.
Semantics¶
num_branches = 0 -- no branch this cycle. GHR, PHR, pointer,
and folds HOLD. No write, no advance.
num_branches = 1 -- branch 0 only. One bit into GHR at the
pointer, one path bit into PHR, one
incremental fold step per table. Pointer
advances by 1.
num_branches = 2 -- branch 0 then branch 1. Branch 0 writes at
the pointer, branch 1 at pointer+1 (modulo
width). Each fold takes two incremental
steps, branch 0 first. Pointer advances
by 2.
num_branches = 2 exists only at NUM_PRED_SLOTS = 2. A count above
NUM_PRED_SLOTS is undefined: 3 at two slots; at one slot the port
is one bit and cannot carry one. The RTL writes branches 0 to
num_branches - 1 in one loop over branch number (BP-129).
GHR write (per active branch n):
ghr_mem[ptr_n] <= pred_taken[n]
where ptr_n is the GHR pointer for branch 0, pointer+1 for
branch 1.
PHR write (per active branch n):
phr_mem[pptr_n] <= pred_pc[n][2] ^ pred_pc[n][3]
Fold update (incremental, branch 0 then branch 1, per tagged
table): each active branch applies one fold step in branch
order. The two-step result for num_branches=2 must equal the
full recompute over the same two new bits walked linearly from
the bundle-start pointer. Branch-0-first is that order. This
equivalence is the dual-slot correctness property (proven by
the dual-slot directed test, TD #74).
Producer obligations¶
- Drive num_branches to the count of branches in the bundle
(0 to NUM_PRED_SLOTS), counting up to and including the first
taken branch and none after it: a branch after a taken one is
off the path. Do not drive a count above NUM_PRED_SLOTS. The stop at the first taken branch
was BUILT by BP-121 (D16); before it the p1 bundle counted a
branch past a taken one.
- pred_taken[n] / pred_pc[n] valid for each branch n <
num_branches. The index is the branch number after
compaction, not the prediction slot number.
- pred_pc is the BRANCH PC: the block START plus that branch's
in-block position, TWO bytes per position, pos counted from the
block start. Not the 32-byte-aligned base, which bp_cluster.sv
used until BP-110 removed it (TD#125, closed). It is not the
prediction block
PC. This read "four bytes per position", which
BP-099 superseded when POS_OFFSET_BITS went to 1 for the C
extension; the granularity note below, ftq_bpu_interfaces.md
7.4 and 9 and ftq_entry_formats.md 2 all say two.
Session-070.
An earlier revision of this file stated the opposite. It was
wrong, and the fold arithmetic here is why: the PHR write
above consumes pred_pc bits [3] and [2] only. With the branch
PC, pred_pc[3:2] is simply bits [3:2] OF THE BRANCH PC and the
path bit varies as it should. It is NOT a function of the
in-block position alone: the branch PC is block start + 2*pos
and the start is unaligned, so no pos-only identity holds. An
earlier revision said pred_pc[3:2] "carries the low two bits
of the branch's in-block position". Corrected session-070.
THE REASON GIVEN FOR IT WAS ALSO WRONG, session-069. It said a
fetch block PC is FTB_BLOCK_BYTES aligned so bits [4:0] are
zero by construction. Prediction blocks are NOT aligned: a
block begins at the lookup PC, which is a taken branch target
and so any 2-byte address (ftq_decisions.md 4.7,
ifu_decisions.md IFU-6). The conclusion survives without that
premise. THE REPLACEMENT PREMISE WAS ALSO WRONG. It read "a
block start is 2'b00 in bits [3:2] whenever it is a
fall-through from an aligned predecessor, which is most of
them", which is the same alignment assumption one step
removed: blocks are unaligned, so a fall-through inherits its
predecessor's low bits, and even from an aligned start the
fall-through is 2'b00 there only when the block length is a
multiple of 16 bytes. No alignment claim is needed. A block
start moves only when the block boundary moves, while the
branch PC moves with every branch's in-block position, so the
block PC gives a nearly constant path bit and the branch PC
does not. Corrected session-070.
bp_cluster derives this value; see bp_cluster.sv
w_slot_pc_p1 (BP-092a).
Granularity note: the in-block position field addresses
two-byte slots (FTB_BR_POS_BITS = 4), so every RVC branch has
its own position and its own path bit. Until 2026-08-19 the
field was four-byte granular and two RVC branches in one
aligned word shared a position; that aliasing is gone.
- Do not drive a pointer; the module owns it.
Checkpoint Interface¶
Producer: BP cluster (writes on each accepted bundle)¶
Consumer: bp_history (stores pointer snapshot per FTQ ENTRY)¶
Timing¶
ckpt_wr_en and ckpt_wr_idx are sampled on rising clk.
The checkpoint captures the post-advance pointer values for the
bundle (the pointer after this cycle's prediction advance).
Semantics¶
ckpt_wr_en = 0 -- no checkpoint write this cycle.
ckpt_wr_en = 1 -- write the current ghist_ptr and phist_ptr
into checkpoint slot ckpt_wr_idx, and expose
them on ckpt_ghist_ptr / ckpt_phist_ptr.
Checkpoint stores: GHR pointer (8b) + PHR pointer (5b), and
the bundle size ckpt_nb (RB_CNT_BITS), the number of history
bits the entry holds: num_branches at the write, rollback_n
after a corrected rollback. The corrected rollback finds the
bundle's first bit as the checkpoint minus ckpt_nb. ckpt_nb has
been stored since BP-121; this line read "pointer only" until
session-078. Folded histories are NOT stored per checkpoint
slot. On rollback, folds are recomputed from buffer contents at
the restored pointer (G15).
Granularity is the bundle: one checkpoint per accepted
prediction bundle, not per branch. There is no checkpoint
position between branch 0 and branch 1 of one bundle.
Producer obligations¶
- ckpt_wr_idx must be a valid FTQ ENTRY index (0 to FTQ_DEPTH-1).
"Slot" is the prediction slot, a different concept
(bp_history_decisions.md, fe_decisions.md TD-FE-5); these three
sites read "FTQ slot". Session-072.
- ckpt_wr_en should be asserted in the same cycle as the bundle
prediction update (num_branches > 0) it checkpoints.
- Producer must not write the same ckpt_wr_idx twice without an
intervening rollback or FTQ slot reclaim.
Rollback Interface¶
Producer: BP cluster: its own p2/p3 redirects and the FTQ rollback¶
Consumer: bp_history (restore pointer by index, recompute folds)¶
Timing¶
rollback_valid and rollback_ckpt_idx are sampled on rising clk.
Pointer restore and fold recompute are synchronous.
Restored folds are available at the start of the next cycle.
Semantics¶
rollback_valid = 0 -- no rollback this cycle.
rollback_valid = 1 -- read the checkpoint at rollback_ckpt_idx,
load the live pointer from it (ckpt_gptr /
ckpt_pptr), and recompute all folds from
ghr_mem and phr_mem at the restored
pointer positions.
Rollback supplies an INDEX, not a pointer. The module restores
the pointer from its own checkpoint array.
HISTORY CORRECTION, since BP-121 (D14; bp_history_decisions.md
3.5, ruled session-075). The rollback also carries a correction.
The module restores the pointer to the FIRST bit of the named
bundle rather than past its last, writes the corrected bits, and
rewrites that entry's checkpoint. The correction comes from
ftq_npc for a backend redirect (from bkend_ftq_redir_pos and
bkend_ftq_redir_taken) and from the cluster for its own p2 and
p3 redirects; the cluster muxes one onto the ports:
rollback_corr = 1 -- restore to the bundle's first bit, write
rollback_n bits (directions rollback_tkn,
bit 0 oldest; path bits rollback_pbit into
the PHR), advance, rewrite the checkpoint.
rollback_corr = 0 -- restore past the bundle, as above.
THE CORRECTION IS AT MOST TWO BITS, at either slot count (Jeff,
session-078; built by BP-130): at most one not-taken bit for a
branch of the entry before the redirecting one, then the
redirecting branch's resolved bit. At one slot a backend
mispredict of a branch held in no slot (BP-128 D2) gives two
bits for an entry whose prediction wrote one; both are written
and ckpt_nb becomes 2. BP-129 had limited the correction to
NUM_PRED_SLOTS bits, provisionally; BP-130 replaced that. The
cluster's own p2 / p3 corrections are at most NUM_PRED_SLOTS
bits and are zero-extended to RB_CORR_BITS.
Scope: rollback (checkpoint-restore) applies to RC_MISPREDICT,
RC_TRAP and RC_REPLAY -- every backend redirect cause that names
an FTQ entry (bp_history_decisions.md 3.4,
ftq_backend_interfaces.md 5 D1). A mispredict target is the
mispredicted branch's bundle, which always carries a checkpoint,
so the index always resolves.
THIS READ "applies only to branch-mispredict redirects" with
exceptions and interrupts reinitializing history instead.
Corrected session-070; 3.4 is the owner and covers all three
causes.
ghr_mem and phr_mem are NOT cleared on rollback. Entries written
after the checkpoint remain in the buffer but are unreachable via
the restored pointer. This is the accepted contamination model
(BP-002 TC8).
Priority: if rollback_valid and num_branches > 0 are asserted in
the same cycle, ROLLBACK WINS. The prediction update (both
branches and the checkpoint write) is dropped for that cycle.
The two are mutually exclusive in the update logic; no merge
occurs. (This relaxes the BP-002 obligation "producer must not
assert both" -- the module now defines the outcome.)
Producer obligations¶
- rollback_ckpt_idx must be a previously written checkpoint slot.
- Use this path for every backend redirect that names an FTQ
entry: RC_MISPREDICT, RC_TRAP and RC_REPLAY. This read
"branch-mispredict redirects only ... route exception/interrupt
redirects through the history reinit path". Session-070.
- bp_cluster drives rollback from the derived redirect and from
the FTQ (ftq_rollback_val / ftq_rollback_idx, which outrank
both cluster arms; ftq_bpu_interfaces.md 9). When both stages
redirect in the same cycle the p3 index wins, matching the
supersession rule.
- Present the history correction with every rollback that has
one (BP-121).
Folded History Output Interface¶
Producer: bp_history¶
Consumer: TAGE (T1-T4 index and tag folds),¶
ITTAGE (IT1-IT5 index and tag folds),¶
SC (ST1-ST3 index folds)¶
Timing¶
folded is a registered output.
Valid one cycle after the prediction update that caused the
advance (same timing as ghist_ptr output).
On rollback: folded reflects the recomputed state one cycle
after rollback_valid is asserted. During the rollback cycle the
fold outputs hold their prior (pre-rollback) values -- see
staleness note below.
Semantics¶
folded is a bp_folded_hist_t packed struct. All fields are
GHR-derived. PHR does not contribute to any fold in the current
implementation (deferred -- see Known Gaps).
TAGE folds (one set of three per tagged table T1-T4):
tage_t<N>_idx_fh -- index fold for T<N>
tage_t<N>_tag_fh1 -- tag fold 1 for T<N>
tage_t<N>_tag_fh2 -- tag fold 2 for T<N>
ITTAGE folds (one set of three per table IT1-IT5):
it_t<N>_idx_fh -- index fold for IT<N>
it_t<N>_tag_fh1 -- tag fold 1 for IT<N>
it_t<N>_tag_fh2 -- tag fold 2 for IT<N>
IT5 HAS REAL FOLDED HISTORY: IT_TBL_HIST[5]=32, FH=9, FH1=9,
FH2=8, per bp_defines_pkg.sv. An earlier revision of this file
stated "IT5 has no folds (BrIMLI table)"; that was a
copy-paste artifact from SC's real BrIMLI table (ST4) and was
removed session-061.
bp_history.sv GENERATES the IT5 folds since BP-126 (TD#102,
HI6 closed): in the rollback and corrected-rollback recompute
and in both steps, as for IT1-IT4, so a rollback restores them
and a redirect corrects them by the same recompute. Before it
ittage.sv read IT5 fold outputs that were never driven, and IT5
indexed on PC alone.
SC folds (one index fold per table with history, ST1-ST3):
sc_t1_idx_fh -- width = SC_TBL_FH[1] = 4b
sc_t2_idx_fh -- width = SC_TBL_FH[2] = 16b
sc_t3_idx_fh -- width = SC_TBL_FH[3] = 64b
These read SC_T2_HIST = 10b and SC_T3_HIST = 16b. Neither
parameter exists; bp_defines_pkg.sv has
SC_TBL_FH[0:4] = '{0, 4, 16, 64, 0}, which bp_cluster.md
Folded Histories and bp_history_decisions.md 6.4/6.5 both
match. Corrected session-070. ST1 read SC_T1_HIST, which does
not exist either; session-072.
ST0 (hist=0) and ST4 (BrIMLI) have no folds.
bp_cluster stages the three SC index folds from p0 to p2
before presenting them to sc, alongside the SC prediction PC
and phr (BP-090). This module presents them live; the staging
is the consumer's.
Staleness on rollback (stale, not invalid)¶
The fold registers are NOT cleared or driven X on rollback. They
hold their current (pre-rollback, wrong-path) values during the
rollback cycle and present the recomputed values from the next
cycle. The value visible in the rollback cycle is stale, not
undefined.
Predictions are NOT blocked during the one-cycle recompute. The
cluster may issue a prediction that cycle; it reads the stale
folds and produces a lower-quality prediction for that one fetch.
This is an accepted performance cost, taken to avoid the control
complexity of a stall or handshake. It never corrupts
architectural state: a stale fold yields a weak/wrong prediction
a later redirect corrects, and because rollback and update are
mutually exclusive, the stale value is never fed back into an
incremental fold step.
Cost to be quantified at detailed performance analysis (G15).
Consumer obligations¶
- Consumers must not cache or register folded outputs
independently. Read folded directly each cycle.
- No must-not-fire obligation in the rollback cycle. Stale folds
are a permitted, lossy input, not an error condition. (This
withdraws the BP-002 "must treat folded as invalid / must not
fire" obligation.)
Pointer Output Interface¶
Producer: bp_history¶
Consumer: BP cluster (FTQ entry construction)¶
ghist_ptr : current GHR pointer (module-owned, registered
output). Post-advance value: reflects the advance
from the most recent num_branches > 0.
phist_ptr : current PHR pointer. Same timing as ghist_ptr.
ckpt_ghist_ptr / ckpt_phist_ptr : the pointer pair written into
the checkpoint array on the most recent ckpt_wr_en.
The cluster reads these to build the FTQ entry. It does not drive
any pointer into bp_history.
Known Gaps and Deferred Items¶
| ID | Item | Status |
|---|---|---|
| HI1 | Dual-slot prediction update | RESOLVED |
| (NUM_PRED_SLOTS=2). Combined branch-0- | session-054. | |
| then-branch-1, bundle-granularity | bp_history_ | |
| checkpoint. = G20. | decisions.md s3. | |
| HI2 | PHR contribution to fold index and tag | OPEN. The TAGE / |
| hashing. Currently all folds are GHR- | ITTAGE sessions | |
| derived only. PHR mixing TBD. | it was deferred | |
| to are done; | ||
| no home. S-072. | ||
| HI3 | rollback_valid + prediction same-cycle | RESOLVED |
| priority. Rollback wins; mutually | session-054. | |
| exclusive with update. = G21. | decisions.md s4. | |
| HI4 | Folded output stale (not invalid) in the | RESOLVED |
| rollback cycle. Predictions permitted on | session-054. | |
| stale folds; cost deferred to perf | decisions.md s5. | |
| analysis (G15). = G22. | ||
| HI5 | Checkpoint slot reclaim. When is a | CLOSED |
| checkpoint slot safe to reuse? At entry | session-070 by | |
| commit: the checkpoint is a FIELD of the | G23. | |
| FTQ entry, reclaimed with it. No separate | ftq_decisions.md | |
| protocol. | 5.8, 5.3. | |
| HI6 | IT5 fold generation missing in | CLOSED BP-126. |
| bp_history.sv. IT5 has real history but | TD#102 closed. | |
| its three fold outputs are never driven. | ||
| HI7 | Ports used literal [1:0] and [2] where | CLOSED BP-129 |
| other modules use NUM_PRED_SLOTS. | (session-078). | |
| Correction ports | ||
| RB_CORR_BITS, | ||
| BP-130. |
See bp_history_decisions.md for the full resolution of HI1/HI3/HI4 and the module-owned pointer decision.
Document history¶
2026-08-09 PA-direct correction, session-064. Producer obligation
corrected: pred_pc is the BRANCH PC, not the fetch
block PC, with the PHR fold arithmetic recorded as
the reason (BP-092a binding decision 1). Port list
and prediction-update semantics restated in terms of
branch number rather than slot number, matching the
cluster's compaction. bp_pkg.sv references corrected
to bp_defines_pkg.sv / bp_structs_pkg.sv. The
caller-owned-pointer target-state note retired: the
module-owned pointer is implemented (BP-069). The
"IT5 has no folds (BrIMLI table)" claim removed and
replaced with the real IT5 geometry plus the TD#102
generation gap. SC fold staging note added (BP-090).
HI6 and HI7 opened.
2026-09-19 session-071. Producer obligations: pred_pc is block
START plus position, not the aligned base (TD#125).
The 2026-08-09 entry was labelled INFRA-012, a task
that did not exist then; it was a PA-direct
correction.
2026-09-20 session-072. E15: the history code fence, open
since the section was written, is closed.
2026-10-08 session-076, PA-direct correction recording BP-121.
Port List and Rollback Interface: the history
correction on rollback (D14); its ports not yet
recorded. Producer obligations:
num_branches stops at the first taken branch (D16);
the FTQ rollback arm named; the aligned-base note
brought to BP-110 (TD#125).
2026-10-09 session-076, recording BP-122. Port List and Rollback
Interface: rollback_corr/_n/_tkn/_pbit declared, as
built.
2026-10-10 session-077, after BP-126. IT5 folds generated
(TD#102); HI6 closed.
2026-10-12 session-078, after BP-128 to BP-130. Module
Parameters: NUM_PRED_SLOTS 1 or 2; PRED_CNT_BITS,
RB_CORR_BITS, RB_CNT_BITS. Port List: the prediction
ports sized by NUM_PRED_SLOTS (BP-129), the correction
ports two bits at either slot count (BP-130). The
correction is at most two bits (ruled session-078).
Checkpoint: the stored bundle size ckpt_nb, there since
BP-121, recorded; it read "pointer only". HI7 closed.
uBTB¶
Status: RTL complete, interim documentation
The micro BTB, the single-cycle p1 predictor that starts fetch before the slower predictors respond.
Specification: ubtb_interfaces.md, bp_cluster.md, bp_arb_spec.md, bpu_port_inventory.md (in the Overview above)
Related: IA tasks: BP-003, BP-018, BP-086; Frontend demo: fd02_steady: Steady-State Prediction and Fetch
TAGE¶
Status: RTL complete, interim documentation
The TAGE direction predictor, its tagged tables, provider selection, allocation and use_alt_on_na.
Specification: tage_cntrl_decisions.md, tage_cntrl_alloc_rules.md, tage_cntrl_ctr_update_rules.md, tage_cntrl_uaon_update_rules.md, tage_cntrl_use_update_rules.md, tage_table_entry_formats.md, tage_table_hash_rules.md, tage_interfaces.md, tage_table_interfaces.md, bp_cluster.md, bp_arb_spec.md, bpu_port_inventory.md (in the Overview above)
Related: Blog: TAGE -- Architecture and the Decomposition Problem; Blog: TAGE Implementation; Blog: TAGE Verification; Blog: TAGE Arbitration and Integration; Blog: TAGE Coverage Methodology and Closure; IA tasks: BP-056, BP-081; Frontend demo: fd09_tage: TAGE Provider, Allocation and use_alt_on_na
Statistical Corrector¶
Status: RTL complete, interim documentation
The statistical corrector, its tables and thresholds, and when it reverses the TAGE direction at p3.
Specification: sc_decisions.md, sc_table_hash_rules.md, sc_interfaces.md, sc_table_interfaces.md, bp_cluster.md, bp_arb_spec.md, bpu_port_inventory.md (in the Overview above)
Related: Blog: The Statistical Corrector: Design Choices at p3; IA tasks: BP-075, BP-078, BP-079; Frontend demo: fd05_p3_override: p3 Override; Frontend demo: fd22_sc_slot1: SC Reversing Slot 1
Fetch Target Buffer¶
Status: RTL complete, interim documentation
The fetch target buffer, its entry format, PLRU replacement and the confidence override at p2.
Specification: ftb_decisions.md, ftb_confidence_override_rules.md, ftb_interfaces.md, bp_cluster.md, bp_arb_spec.md, bpu_port_inventory.md (in the Overview above)
Related: Blog: The RAS and the FTB: Design Choices at p2; IA tasks: BP-065, BP-066, BP-067; Frontend demo: fd04_p2_override: p2 Override; Frontend demo: fd12_training: Predictor Training
Loop Predictor¶
Status: RTL complete, interim documentation
The loop predictor, how it counts iterations at p1 and when its prediction is trusted over the other predictors.
Specification: loop_pred_interfaces.md, bp_cluster.md, bp_arb_spec.md, bpu_port_inventory.md (in the Overview above)
Related: Blog: Iteration Counting at s1: The Loop Predictor; IA tasks: BP-004, BP-091; Frontend demo: fd06_loop_pred: Loop Predictor
ITTage¶
Status: RTL complete, interim documentation
The ITTAGE indirect target predictor, its tables, allocation and update rules.
Specification: ittage_cntrl_decisions.md, ittage_cntrl_alloc_rules.md, ittage_cntrl_ctr_update_rules.md, ittage_cntrl_uaon_update_rules.md, ittage_cntrl_use_update_rules.md, ittage_table_entry_formats.md, ittage_table_hash_rules.md, ittage_interfaces.md, ittage_table_interfaces.md, bp_cluster.md, bp_arb_spec.md, bpu_port_inventory.md (in the Overview above)
Related: Blog: ITTAGE Design and Planning; Blog: ITTAGE -- Table, Controller, Wrapper, and First Integrated Testbench; IA tasks: BP-034, BP-050, BP-055; Frontend demo: fd08_indirect: Indirect Jump
Return Address Stack¶
Status: RTL complete, interim documentation
The return address stack, its push and pop on calls and returns, and its repair after a redirect.
Specification: ras_decisions.md, ras_interfaces.md, bp_cluster.md, bp_arb_spec.md, bpu_port_inventory.md (in the Overview above)
Related: Blog: The RAS and the FTB: Design Choices at p2; IA tasks: BP-062, BP-063, BP-064; Frontend demo: fd07_calls_returns: Calls and Returns
History Module¶
Status: RTL complete, interim documentation
The branch history the predictors index with, its speculative update, and its correction after a redirect.
Specification: bp_history_decisions.md, bp_history_interfaces.md, bp_cluster.md, bpu_port_inventory.md (in the Overview above)
Related: Blog: Branch History and the First Prediction; IA tasks: BP-069, BP-074, BP-130
Dual Prediction¶
Status: RTL complete, interim documentation
The two branch slots, br0 and br1, predicted from one 32-byte block lookup, and how a taken branch ends the block.
Specification: fe_decisions.md, bp_cluster.md (in the Overview above)
Related: IA task: BP-128; Frontend demo: fd03_two_branch: Two Branches in One Block; Frontend demo: fd22_sc_slot1: SC Reversing Slot 1; Frontend demo: fd24_call_slot1: A Call in Slot 1