Professional Documents
Culture Documents
CSE305 L9 11 10 11 Tues
CSE305 L9 11 10 11 Tues
Lecture – 9
A Branch instruction replaces the contents of
PC with the Branch Target Address.
This address is determined by adding an offset
value, X, to the updated value of the PC which
is given in the branch instruction.
Following is an example of implementing
unconditional Branch Instruction.
The first 3 steps which constitutes the Fetch
Phase is same for all instructions.
So, the first 3 steps are same as the previous :
1. PCout, MARin, Read, Select4, Add, Zin
2. Zout, PCin, Yin ,WMFC
3. MDRout, IRin
The fetch phase ends when the fetched
instruction is loaded into IR.
Then the branch instruction is taken to decoding
circuit, where the offset value is extracted from
the instruction.
While finding out the offset, the decoding
circuit also performs sing extension, if
necessary.
Step 4 :
4. Offset-field-of-IRout, Add, Zin
▪ In step 4, the updated value of PC is already available in
the register Y.
▪ The offset, X is gated on to the bus from decoding
circuit.
▪ The offset value is added with the updated value of PC
and temporarily stored in Z.
Step 5 :
Zout, PCin, End.
▪ In final step, the branch target address, which is found
from the addition is taken from Z and loaded into PC.
How Offset address is calculated :
Normally, the difference between target address
and the address of the instruction which
immediately follows the branch instruction is said
as the Offset value.
Let, the instructions are byte addressable and each
instruction consists of 4 bytes.
Assume, the branch instruction is at address 2000.
And, the target address is 2050.
During the fetch phase of the Branch instruction
located at 2000, the PC is updated with the
address of the instruction that follows the branch
instruction, which is 2004
So, the offset value is : 2050 – 2004 = 46.
Now consider an conditional Branch
instruction.
Here, we have to check the status of the
condition codes before loading the new value
into the PC.
And, here, the condition is if the status is
negative then branching is performed,
otherwise consecutive instructions are
performed.
So, we call it Branch-on-negative instruction.
We denote, the status as N.
So, N = 1 means condition is true, then
branching happens and the PC is loaded with
the new value.
And when N = 0 means condition is false, and
the program ends, that is, returns to step 1.
For this instruction, also the Fetch phase is
same.
So the Fetch phase :
1. PCout, MARin, Read, Select4, Add, Zin
2. Zout, PCin, Yin ,WMFC
3. MDRout, IRin
The Execution Phase :
4. Offset-field-of-IRout, Add, Zin, if N = 0 then End
5. Zout, PCin, End
This if N = 0, the processor returns to step 1
immediately after step 4.
If N = 1, step 5 is performed to a new value
into the PC, the performing the branch
operation.
In the beginning we have learned an
organization of processor which consists of
only one inter processor bus.
But a problem is with this single bus
organization, for performing one instruction
lots of control step is needed, that is the
control sequence becomes long.
The reason for this, there is only one path for
the transfer of the data.
To reduce the number of steps, processors can
have multiple internal buses in different way.
This provides several paths for data transfer,
so multiple transfer takes place in parallel.
Here, we will explain a three-bus organization
processor's structure use to connect the
registers and the ALU.
But other different organization is also
possible.
Important components of three-bus(A, B & C)
structure of the processor :
Register File
▪ All general purpose registers are combined into a single
block, called Register File.
▪ The number of register is implemented in the form of an
array of memory cells.
▪ Here, the register file has three ports.
▪ There are two outputs, so that the contents of two
different registers can be accessed simultaneously.
▪ Because of having the two outputs, the content of two
registers can be placed on the buses A and B.
▪ The third port is used to load the data of Bus C into
another register during the same clock cycle.
▪ So, data transfer from or to three registers can be
performed simultaneously.
ALU
▪ Bus A and B provides the two operands to two inputs A
and B of the ALU.
▪ Of this, the contents of Bus A passes through a
Multiplexer.
Bus A Bus B Incrementer Bus C
PC
IR
MDR
MAR