XC2200 Derivatives
System Units (Vol. 1 of 2)
Central Processing Unit (CPU)
User’s Manual
4-7
V2.1, 2008-08
CPUSV2_X, V2.2
4.2.1
Branch Detection and Branch Prediction Rules
The Branch Detection Unit preprocesses instructions and classifies detected branches.
Depending on the branch class, the Branch Prediction Unit predicts the program flow
using the following rules:
4.2.2
Correctly Predicted Instruction Flow
shows the continuous execution of instructions, assuming a 0-waitstate
program memory. In this example, most of the instructions are executed in one CPU
cycle while instruction I
n+6
takes two CPU cycles (general example for multicycle
instructions). The diagram shows the sequential instruction flow through the different
pipeline stages.
shows the corresponding program memory section.
The instructions for the processing pipeline are fetched from the Instruction FIFO while
the IFU prefetches the next instructions to fill the FIFO. As long as the instruction flow is
correctly predicted by the IFU, both processes are independent.
In this example with a fast Internal Program Memory, the Prefetcher is able to fetch more
instructions than the processing pipeline can execute. In T
n+4
, the FIFO and prefetch
buffer are filled and no further instructions can be prefetched. The PMU address stays
Table 4-1
Branch Classes and Prediction Rules
Branch Instruction Classes Instructions
Prediction Rule (Assumption)
Inter-segment branch
instructions
JMPS seg, caddr
CALLS seg, caddr
The branch is always taken
Branch instructions with
user programmable branch
prediction
JMPA- xcc, caddr
JMPA+ xcc, caddr
CALLA- xcc, caddr
CALLA+ xcc, caddr
User-specified
1)
via bit 8 (‘a’) of
the instruction long word:
…+: branch ‘taken’ (a = 0)
…-: branch ‘not taken’ (a = 1)
1) This bit can be also set/cleared automatically by the Assembler for generic JMPA and CALLA instructions
depending on the jump condition (condition is cc_Z: ‘not taken’, otherwise: ‘taken’).
Indirect branch instructions
JMPI cc, [Rw]
CALLI cc, [Rw]
Unconditional: branch ‘taken’
Conditional: ‘not taken’
Relative branch instructions
with condition code
JMPR cc, rel
Unconditional or backward:
branch ‘taken’
Conditional forward: ‘not taken’
Relative branch instructions
without condition code
CALLR rel
The branch is always taken
Branch instructions with bit-
condition
JB(C) bitaddr, rel
JNB(S) bitaddr, rel
Backward: branch ‘taken’
Forward: ‘not taken’
Return instructions
RET, RETP
RETS, RETI
The branch is always taken