
This project is a miniaturized branch predictor loosely modeled on TAGE (TAgged GEometric history length predictors), built for a single Tiny Tapeout tile. It combines three predictors, arranged in priority order:
On a misprediction, the design allocates a fresh entry in the tagged table for that branch (protecting existing useful entries rather than evicting them outright), so the table gradually specializes to whichever branches actually need history to predict correctly.
The design operates in a trace-replay model: each clock cycle you supply
a branch address (pc) and its actual outcome, the predictor
combinationally produces the prediction it would have made from its
state as of the previous cycle, and then trains itself on the outcome
you gave it. This makes it possible to measure real prediction accuracy
against arbitrary branch traces directly on fabricated silicon, and to
compare it against a plain bimodal-only predictor to see how much the
tagged history table and loop predictor actually buy you.
Each cycle:
ui_in[6:0] with a 7-bit branch address and ui_in[7] with the
branch's actual outcome (1 = taken, 0 = not-taken).uio_in[0] high for one cycle to mark the input as valid.uo_out[0] before the next clock edge - it
reflects the predictor's state from before this cycle's training.uo_out[1] tells you whether that prediction was a misprediction.To read back cumulative statistics instead, set uio_in[1] high and
uio_in[4:2] to a register address (0 = correct count, 1 = mispredict
count, 7 = a fixed 0xA5 sanity byte) - the byte appears on uo_out.
Hold uio_in[0] low for about 40 cycles after reset before feeding real
data, since the internal tables sweep-clear themselves over that window.
A full worked example, including a cocotb test exercising an alternating
pattern, a fixed-trip-count loop, a pseudo-random LFSR sequence, and a
history-correlated pattern, is in test/test.py.
List external hardware used in your project (e.g. PMOD, LED display, etc), if any
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | pc[0] | final_pred | valid (in) |
| 1 | pc[1] | misp | readback_mode (in) |
| 2 | pc[2] | provider[0] | stat_reg_addr[0] (in) |
| 3 | pc[3] | provider[1] | stat_reg_addr[1] (in) |
| 4 | pc[4] | loop_conf_ok | stat_reg_addr[2] (in) |
| 5 | pc[5] | t1_hit | unused |
| 6 | pc[6] | unused (0) | unused |
| 7 | actual_taken | ghr[0] (debug) | unused |