Altera_Forum
Honored Contributor
16 years agoDynamic branch prediction info
Is there any information about how the dynamic branch prediction of the Nios II/f works?
We are looking to reduce the worst-case paths through some relatively short functions (less than 1k of code in total, compiled as a single function) and would rather have the static branch prediction of the II/s - but need the II/f to avoid all the pipeline stalls during memory transfers. I need to work out how to stop the branch predictor mispredicting branches. Consider, for example, a C 'if' statement with a lot of || cases. The worst case is the fallthrough - so you need to 'predict - not taken' all the branches, and take the 'hit' of one mis-predicted branch when acondition is true. The dynamic predictor might remember that several of the branches were taken the previous time they were executed - so getting into the conditional code may take several mispredicted branches. Even the idle loop (repeatedly reading a hardware register) has a branch that needs to be optimised for the unusual case!