Professional Documents
Culture Documents
CO - MODULE - 2 (B) - Basic-Processing-Unit
CO - MODULE - 2 (B) - Basic-Processing-Unit
and Architecture
Carl Hamacher, Zvonko Vranesic, Safwat Zaky,
Computer Organization, 5th Edition,
Tata McGraw Hill, 2002.
Module-2
BASIC PROCESSING UNIT
Overview
Instruction Set Processor (ISP) – executes
machine instructions and coordinates the
activities of other cells.
Also called Central Processing Unit (CPU)
A typical computing task consists of a series
of steps specified by a sequence of machine
instructions that constitute a program.
An instruction is executed by carrying out a
sequence of more rudimentary operations.
Some Fundamental
Concepts
Fundamental Concepts
Processor fetches one instruction at a time and
performs the operation specified.
Instructions are fetched from successive memory
locations until a branch or a jump instruction is
encountered.
Processor keeps track of the address of the memory
location containing the next instruction to be fetched
using Program Counter (PC).
After fetching an instruction, the contents of the PC are
updated to point to the next instruction in the sequence.
A branch instruction may load a different value into the PC.
Steps in Executing an
Instruction
Fetch the contents of the memory location pointed to by
the PC. The contents of this location are loaded into the
instruction register IR (fetch phase).
IR ← [[PC]]
Assuming that the memory is byte addressable, increment
the contents of the PC by 4 (fetch phase).
PC ← [PC] + 4
Carry out the actions specified by the instruction in the
IR (execution phase).
Processor Organization Internal processor
bus
C
o
PC n
t
r
o Instruction
Address l decoder and
lines
MAR control logic
MDR HAS s
Memory i
TWO INPUTS bus g
AND TWO n
MDR a
OUTPUTS Data l
lines s IR
Datapath
Y
Constant 4 R0
Select MUX
Add
A B
ALU Sub R n - 1
control ALU
lines
Carry-in
XOR TEMP
Ri
Riout
Y in
Constant 4
Select MUX
A B
ALU
Z in
Z out
Figure 7.2. Input and output gating for the registers in Figure 7.1.
Register Transfers..
Suppose that we wish to transfer the contents of
register R1 to register R4.
This can be accomplished as follows:
Enable the output of register R1 by setting R1out to 1. This
places the contents of R1 on the processor bus.
Enable the input of register R4 by setting R4in to 1. This
loads data from the processor bus into register R4.
All operations and data transfers within the processor
take place within time periods defined by the
processor clock.
Register Transfers..
An implementation for one bit of register Ri is
shown in Figure 7.3 as an example.
A two-input multiplexer is used to select the data
applied to the input of an edge-triggered D flip- flop.
When the control input Riin is equal to 1, the
multiplexer selects the data on the bus.
This data will be loaded into the flip-flop at the rising
edge of the clock.
When Riin is equal to 0, the multiplexer feeds back
the value currently stored in the flip-flop.
Register Transfers..
The Q output of the flip-flop is connected to the
bus via a tri-state gate.
When Riout is equal to 0, the gate's output is in
the high-impedance (electrically disconnected)
state.
This corresponds to the open-circuit state of a switch.
When Riout = 1, the gate drives the bus to 0 or 1,
depending on the value of Q.
Register Transfers..
Bus
D Q
1
Q
Riiout
Riin
Clock
Figure 7.3. Input and output gating for one register bit.
Performing an Arithmetic or
Logic Operation
The ALU is a combinational circuit that has no
internal storage.
It performs arithmetic and logic operations on the two
operands applied to its A and B inputs.
ALU gets the two operands from MUX and bus.
The result is temporarily stored in register Z.
The sequence of operations to add the contents of
register R1 to those of R2 and store the result in R3.
1.
R1out, Yin
2. R2out, SelectY, Add, Zin
3.
Zout, R3in
Performing an Arithmetic or
Logic Operation..
The signals whose names are given in any step are
activated for the duration of the clock cycle
corresponding to that step.
All other signals are inactive.
In step 1, the output of register R1 and the input of
register Y are enabled, causing the contents of RI to
be transferred over the bus to Y.
Performing an Arithmetic or
Logic Operation..
In step 2, the multiplexer's Select signal is set to
SelectY, causing the multiplexer to gate the contents
of register Y to input A of the ALU.
At the same time, the contents of register R2 are gated
onto the bus and, hence, to input B.
The Add line is set to 1, causing the output of the ALU to be
the sum of the two numbers at inputs A and B.
This sum is loaded into register Z because its input
control signal is activated.
In step 3, the contents of register Z are transferred to
the destination register, R3.
Fetching a Word from
Memory
To fetch a word of information from memory, the
processor has to specify the address of the memory
location where this information is stored and request
a Read operation.
The information to be fetched may be an instruction
in a program or an operand specified by an
instruction.
The processor transfers the required address to the
MAR, whose output is connected to the address
lines of the memory bus.
Fetching a Word from
Memory..
At the same time, the processor uses the control
lines of the memory bus to indicate that a Read
operation is needed.
When the requested data are received from the
memory they are stored in register MDR,
From MDR, they can be transferred to other
registers in the processor.
Fetching a Word from
Memory..
MDR
MDRinE MDRin
Timing Clock
MR
MDR inE
Data
MDR out
Load MDR from the memory bus
R2 ← [MDR]
PC
Register
file
Constant 4
MUX
ALU R
B
Instruction
decoder
IR
MDR
MAR
Memory b us Address
data lines lines
Multiple-Bus Organization..
All general-purpose registers are combined into a
single block called the register file.
Implemented in the form of an array of memory cells.
The register file in Figure 7.8 is said to have
three ports.
There are two outputs, allowing the contents of two
different registers to be accessed simultaneously and
have their contents placed on buses A and B.
The third port allows the data on bus C to be loaded into
a third register during the same clock cycle.
Multiple-Bus Organization..
Buses A and B are used to transfer the source
operands to the A and B inputs of the ALU, where
an arithmetic or logic operation may be performed.
The result is transferred to the destination over bus
C.
If needed, the ALU may simply pass one of its
two input operands unmodified to bus C.
We will call the ALU control signals for such an
operation R=A or R=B.
Multiple-Bus Organization..
The Incrementer unit is used to increment the PC
by 4.
Using the Incrementer eliminates the need to add 4 to the
PC using the main ALU.
The source for the constant 4 at the ALU input
multiplexer is still useful.
It can be used to increment other addresses, such as the
memory addresses in LoadMultiple and StoreMultiple
instructions.
Multiple-Bus Organization..
Consider the three-operand instruction Add R4, R5, R6
Multiple-Bus Organization..
In step 1, the contents of the PC are passed through
the ALU, using the R=B control signal, and loaded
into the MAR to start a memory read operation.
At the same time the PC is incremented by 4.
In step 2, the processor waits for MFC and loads
the data received into MDR, then transfers them to
IR in step 3.
Finally, the execution phase of the instruction
requires only one control step to complete, step 4.
Hardwired Control
Overview
To execute instructions, the processor must
have some means of generating the control
signals needed in the proper sequence.
Two categories:
Hardwired control
Microprogrammed control
Hardwired system can operate at high speed;
but with little flexibility.
Hardwired Control – Control
Unit Organization
Consider the sequence of control signals
given in Figure 7.6.
Each step in this sequence is completed in one
clock period.
A counter may be used to keep track of the
control steps, as shown in Figure 7.10.
Each state, or count, of this counter
corresponds to one control step.
Control Unit Organization
CLK Control step
Clock counter
External
inputs
Decoder/
IR
encoder
Condition
codes
Control signals
Figure 7.10. Control unit organization.
Control Unit Organization..
The required control signals are determined by
the following information:
Contents of the control step counter
Contents of the instruction register
Contents of the condition code flags
External input signals, such as MFC and interrupt
requests
Control Unit Organization..
The decoder/encoder block in Figure 7.10 is a
combinational circuit that generates the required
control outputs, depending on the state of all its
inputs.
By separating the decoding and encoding
functions, we obtain the more detailed block
diagram in Figure 7.11.
Control Unit Organization -
Detailed Block Description
CLK
Clock Control step Reset
counter
Step decoder
T 1 T2 T
n
INS 1
INS External
2 inputs
Instruction
IR decoder Encoder
Condition
codes
INS m
Run End
Control signals
Instruction Data
cache cache
Bus interface
Processor
System bus
Main Input/
memory Output
MDRout
WMFC
MAR in
Micro -
Select
PCout
Read
R1out
R3out
instruction
Zout
End
Add
R1in
PCin
IRin
Yin
Zin
1 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0
2 1 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0
3 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
4 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0
5 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0
6 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1