Unit3-Control-Unit-1
Unit3-Control-Unit-1
Control Unit
Introduction
• Fetch the contents of the memory location pointed to by the PC. The
contents of this location are loaded into the 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
Control signals
PC
Instruction
Address
decoder and
lines
MAR control logic
Memory
bus
MDR
Data
lines IR
Constant 4 R0
Select MUX
Add
A B
ALU Sub R n - 1
control ALU
lines
Carry-in Datapath
XOR TEMP
• ALU
• Registers for temporary storage
• Various digital circuits for executing different micro operations.(gates,
MUX , decoders , counters).
• Internal path for movement of data between ALU and registers.
• Driver circuits for transmitting signals to external units.
• Receiver circuits for incoming signals from external units.
• PC:
Keeps track of execution of a program
Contains the memory address of the next instruction to be fetched and
executed.
• MAR:
Holds the address of the location to be accessed.
I/P of MAR is connected to Internal bus and an O/p to external bus.
• MDR:
Contains data to be written into or read out of the addressed location.
IT has 2 inputs and 2 Outputs.
Data can be loaded into MDR either from memory bus or from internal
processor bus.
The data and address lines are connected to the internal bus via MDR and MAR
Registers:
The processor registers R0 to Rn-1 vary considerably from one processor to
another.
Registers are provided for general purpose used by programmer.
Special purpose registers-index & stack registers.
Registers Y,Z &TEMP are temporary registers used by processor during the
execution of some instruction.
Multiplexer:
Select either the output of the register Y or a constant value 4 to be provided as
input A of the ALU.
Constant 4 is used by the processor to increment the contents of PC.
ALU:
Used to perform arithmetic and logical operation.
Data Path:
The registers, ALU and interconnecting bus are collectively referred to as the data
path.
Register Transfers Internal processor
bus
Constant 4
Riout Is set to 0 – the bus can be used for
Select MUX
transferring data from other registers .
A B
ALU
Z in
Z out
Figure 7.2. Input and output gating for the registers in Figure 7.1.
Data transfer between two registers
EX:
Transfer the contents of R1 to R4.
1. Enable output of register R1 by setting R1out=1. This places the contents of R1 on
the processor bus.
2. Enable input of register R4 by setting R4in=1. This loads the data from the
processor bus into register R4.
Performing an Arithmetic or Logic Operation
The ALU is a combinational circuit that has no internal storage.
ALU gets the two operands from MUX and bus. Internal processor
bus
Riin
The result is temporarily stored in register Z.
Ri
The sequence of operations to add the contents of register R1 to
those of R2 and store the result in R3 is:
Riout
1. R1out, Yin
Yin
2. R2out, Select Y, Add, Zin
3. Zout, R3in Y
Constant 4
• All operations and data transfers are controlled by the processor clock.
Bus
D Q
1
Q
Riout
Ri in
Clock
Figure7.3.
Figure 7.3.Input
Input
andand output
output gating
gating for register
for one one register
bit. bit.
Fetching a Word from Memory
• Address into MAR; issue Read operation; data into MDR.
Memory-b us Internal processor
data lines MDRoutE MDRout bus
MDR
The response time of each memory access varies (cache miss, memory-mapped I/O,…).
To accommodate this, the processor waits until it receives an indication that the
requested operation has been completed (Memory-Function-Completed, MFC).
Move (R1), R2
MAR ← [R1]
Start a Read operation on the memory bus
Wait for the MFC response from the memory
Load MDR from the memory bus
R2 ← [MDR]
Timing
Step 1 2 3
Clock
MARin
Assume MAR
is always available Address
on the address lines
of the memory bus. Read
MR
MDR out
Internal processor
Add (R3), R1 bus
MDR
Add (R3), R1 Data
lines IR
Step Action
Y
Constant 4 R0
1 PC out , MAR in , Read,Select4,Add, Zin
2 Zout , PC in , Y in , WMF C Select MUX
3 MDR out , IR in
Add
4 R3out , MAR in , Read Sub
A B
R n - 1
ALU
control
5 R1out , Y in , WMF C lines
ALU
Carry-in
6 MDR out , SelectY,Add, Zin XOR TEMP
StepAction
StepAction
Hardwired system can operate at high speed; but with little flexibility.
External
inputs
Decoder/
IR
encoder
Condition
codes
Control signals
CLK
Clock Control step Reset
counter
Step decoder
T 1 T2 Tn
INS 1
External
INS 2 inputs
Instruction
IR Encoder
decoder
Condition
codes
INSm
Run End
Control signals
Generating Zin
• Zin = T1 + T6 • ADD + T4 • BR + …
Branch Add
T4 T6
T1
Figure 7.12. Generation of the Zin control signal for the processor in Figure 7.1.
I/P signals to encoder are combined to generate individual control signals i.e. End signal
This end signal starts a new instruction fetch cycle by resetting the control step counter to its starting value.
Another RUN signal is used when set=1, causes counter to be incremented by 1 at the end of every clock cycle,
When RUN=0 the counter stops counting, this used when WMFC is issued
Generating End Signal
T7 T5 T4 T5
End
Instruction Data
cache cache
Bus interface
Processor
System bus
Main Input/
memory Output
MDRout
WMFC
MAR in
Select
PCout
Micro -
R1out
R3out
Read
PCin
R1 in
Add
End
Z out
IRin
Yin
instruction
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
Step Action
Starting
• One function
Control store IR address
generator cannot be carried
out by this simple
organization.
Clock P C
Control
store CW
Address
Microinstruction
Starting and
branch address Condition
IR codes
generator
Clock m PC
Control
store CW
F1 F2 F3 F4 F5
0000: No transfer 000: No transfer 000: No transfer 0000: Add 00: No action
0001: PCout 001: PCin 001: MARin 0001: Sub 01: Read
0010: MDRout 010: IRin 010: MDRin 10: Write
0011: Zout 011: Z in 011: TEMP in
0100: R0out 100: R0in 100: Y in 1111: XOR
0101: R1out 101: R1in
0110: R2out 110: R2 in 16 ALU
functions
0111: R3 out 111: R3 in
1010: TEMPout
1011: Offset out
F6 F7 F8
11 10 8 7 4 3 0
Address Microinstruction
(octal)
External Condition
Inputs codes
Decoding circuits
AR
Control store
Microinstruction decoder
Control signals
F0 F1 F2 F3
F4 F5 F6 F7
F8 F9 F10
0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0
0 0 1 0 0 0 0 0 0 1 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0
0 0 2 0 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0
1 2 1 0 1 0 1 0 0 1 0 1 0 0 01 1 0 0 1 0 0 0 0 01 1 0 0 0 0
1 2 2 0 1 1 1 1 0 0 0 0 1 1 10 0 0 0 0 0 0 0 0 00 0 1 0 0 1
1 7 0 0 1 1 1 1 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0
1 7 1 0 1 1 1 1 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
1 7 2 0 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 7 3 0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Decoder
Decoder
IR Rsrc Rdst
InstDecout
External
inputs ORmode
Decoding
circuits
Condition ORindsrc
codes
AR
Control store
Rdst out
Rdst in
Microinstruction
decoder
Rsrc out
Rsrc in