Simple Controller continued
Last Edit October 10, 1996; May 1, 1999; July 9, 2001
Conditional Branch
It is sometimes desirable to terminate a microroutine in one of
several different ways depending on one or more conditions. For
example, the conditions tested could be the various status bit outputs
of the ALU based on the result of an operation. Status outputs can
include
- Z=1 if ACC=0
- S=1 if ACC < 0
- Cout=1 if | ACC | > range
- OVR (overflow)=1 if error
- on the result of a compare operation
Only one condition is testable at a time. Hardware could be used to
combine a number of conditions to supply one test bit if that combination
is expected to occur frequently. A program Flow diagram for a conditional
branch is shown in Figure 2-12.
Figure 2-12 Conditional Branch Flow Diagram. "IF-THEN-ELSE"
- the conditional branch (CJP, conditional jump)
The ability to test a condition and to branch if the condition
is TRUE is provided by adding a MUX at the counter load control.
The load control filed in the microword is changed to a branch condition
select, which selects
- ground (count; no branch)
- condition 1 or condition 2 (load branch address into counter
if TRUE)
- Vcc (unconditional branch, load counter).
The CCU is shown in Figure 2-13, with its microword format
shown in Figure 2-14.
Figure 2-13 CCU with Conditional Branch Capability
Figure 2-14 Microword Format for Conditional Branch (A) Detail
of Load Control MUX (B) Detail
of Microword Format
A sample piece of microcode is shown in Figure 2-15 that
has both unconditional and conditional branches. As with most programming
languages, if a conditional test fails (FALSE), execution continues
sequentially, as shown in statements at addresses 30 and 31. The
branch condition select field is 2 bits wide in this example. A
wider field would allow a larger MUX and therefore would allow more
conditions to be tested.
Figure 2-15 Microcode, Demonstrating Conditional Jumps
|