coreblocks.frontend.bpu package

Submodules

coreblocks.frontend.bpu.bpu module

class coreblocks.frontend.bpu.bpu.BranchPredictionUnit

Bases: Elaboratable

Branch-prediction pipeline built from the configured predictor composition.

__init__(gen_params: GenParams) None
flush: PROVIDED: 1>]
request: PROVIDED: 1>]
update: PROVIDED: 1>]
write_fetch_target: REQUIRED: 2>]
write_prediction_details: REQUIRED: 2>]

coreblocks.frontend.bpu.component module

class coreblocks.frontend.bpu.component.BPUComponent

Bases: Elaboratable

Shared layouts and training interface for BPU components.

__init__(gen_params: GenParams, meta_width: int)
update: PROVIDED: 1>]

Train on a resolved CFI using this component’s prediction metadata.

class coreblocks.frontend.bpu.component.BPUComponentLayouts

Bases: object

Shared predictor layouts.

__init__(gen_params: GenParams, *, meta_width: int)
cfi_hints(candidate_count: int)
cfi_prediction(candidate_count: int)
class coreblocks.frontend.bpu.component.CfiPredictor

Bases: BPUComponent

Identify CFIs in S1 and provide their targets in S2 from an S0 request.

__init__(gen_params: GenParams, meta_width: int, candidate_count: int)
flush: PROVIDED: 1>]
request_s0: PROVIDED: 1>]
response_s1: PROVIDED: 1>]
response_s2: PROVIDED: 1>]
class coreblocks.frontend.bpu.component.DirectionPredictor

Bases: BPUComponent

Use an S0 request and S1 CFI hints to predict one taken bit per slot in S2.

__init__(gen_params: GenParams, meta_width: int, candidate_count: int)
accept_s1_hints: PROVIDED: 1>]
flush: PROVIDED: 1>]
request_s0: PROVIDED: 1>]
response_s2: PROVIDED: 1>]
class coreblocks.frontend.bpu.component.FastPredictor

Bases: BPUComponent

Predict a CFI and its target in S1 from an S0 request.

__init__(gen_params: GenParams, meta_width: int)
flush: PROVIDED: 1>]
request_s0: PROVIDED: 1>]
response_s1: PROVIDED: 1>]

coreblocks.frontend.bpu.micro_btb module

class coreblocks.frontend.bpu.micro_btb.MicroBTB

Bases: FastPredictor

A small, fully-associative, single-cycle branch target buffer (micro-BTB).

The micro-BTB maps a fetch block address to a predicted next-fetch PC and follows an “always-taken on hit” policy: a hit means the block is predicted to redirect fetch to the stored target. The lookup is fully associative and combinational over a registered request, so a prediction requested in one cycle is available in the next cycle.

Each entry carries a saturating usefulness counter: an entry is valid while its counter is non-zero. A correct, taken hit increases the counter; a not-taken hit or a hit with a different target decreases it. When the counter reaches zero the entry stops matching and becomes a replacement candidate. Replacement prefers any such not-useful entry, otherwise it falls back to tree-pseudo-LRU over the touched entries.

__init__(gen_params: GenParams, config: MicroBTBConfig)

coreblocks.frontend.bpu.ras module

class coreblocks.frontend.bpu.ras.RAS

Bases: Elaboratable

A simple return address stack.

It is only a best-effort prediction, so overflow and underflow are allowed. Wrong-path speculation can also corrupt the stack, as a checkpoint only recovers the top entry.

__init__(gen_params: GenParams, config: RASConfig)
peek: PROVIDED: 1>]

Return the address on top of the stack, if there is one.

recover: PROVIDED: 1>]

Restore a state previously returned by update.

update: PROVIDED: 1>]

Push and/or pop a return address. Returns the new state, to be saved in a checkpoint.

Module contents