coreblocks
coreblocks copied to clipboard
Add support for branch speculation
To use whole potential of out-of-order execution we need a speculation over jumps. As for now we stall whole pipeline till branch is retired. Instead of that we should:
- have a branch predictor
- check in fetch if fetched instruction is jump - if yes:
- use branch predictor to get next_pc
- make a checkpoint of current CPU state
- on mispredicted branch CPU state from before speculation should be restored and execution should be started from that point
Comments:
- first branch predictor can be very easy e.g. always
current_pc+4
- if this will make a task easier we can assume speculation depth = 1