Lec04 - Control Unit Operation
Lec04 - Control Unit Operation
Lec04 - Control Unit Operation
Lec04
Control Unit Operation
Topics for discussion
2
Micro-Operations
Program Execution
Consists of the sequential execution of instructions
subdivided into various instruction cycles
Instruction Cycle
divided into subtasks
Fetch, indirect, execute and interrupt with fetch and execute always occurring
Micro-operations
Each cycle made up of a sequence of more fundamental operations
called micro-operations.
The prefix micro means that each step is very simple and accomplishes very
little.
Functional, or atomic operations of a processor
micro-operations may involve
- transfer between registers
- between registers and external bus
- a simple ALU operation 3
Constituent Elements of Program Execution
4
Control Unit Tasks
Two tasks performed by the control unit of a processor:
Causes the processor to execute micro-ops in the proper sequence
determined by the program being executed
Generates the control signals that cause each micro-op to be executed.
5
Techniques for implementing Control Unit
Hard-wired Implementation:
The Control Unit is a combinatorial circuit.
Its input logic signals, governed by the current machine instruction, are
transferred into a set of output control signals
Microprogrammed Implementation/Control (MI):
The logic of the Control Unit is specified by a microprogram
Each machine language instruction is translated into a sequence of
lower-level control unit instructions
• Called microinstructions
• Process of translation is called microprogramming
A microprogram consists of a sequence of instructions in a
microprogramming language
6
Micro-Operations – Fetch Cycle (1)...
7
Micro-Operations – Fetch Cycle (2)...
- Data Flow
8
Micro-Operations – Fetch Cycle (3)...
- Sequence
Or
11
Micro-Operations – Fetch Cycle (6)
- Rules to follow
Note:
PC <- (PC) +I involves addition
Use ALU
May need additional micro-operations
12
Micro-Operations - Indirect Cycle (1)...
14
Micro-Operations - Interrupt cycle (1)...
15
Micro-Operations - Interrupt Cycle (2)
16
Micro-Operations - Execute Cycle (1)…
The fetch, indirect, and interrupt cycles are simple and predictable.
Each involves a small, fixed sequence of micro-ops that are
repeated each time
The execute cycle is different for each Opcode
machine with n different opcodes - n different sequences of micro-operations
Example 1:
ADD R1, X - add the contents of location X to Register R1
Suppose IR contains the ADD instruction
t1: MAR (IRaddress) (The address portion of IR is loaded into MAR)
t3: R1 R1 + (MBR) (The content of R1 and MBR are added by the ALU)
Example 2:
ISZ X (Increment and Skip if Zero)
(The contents of location X is incremented by 1.
If the result is 0, the next instruction is skipped)
t1: MAR (IRaddress)
t2: MBR Memory
t3: MBR (MBR) +1
t4: Memory (MBR)
If ((MBR)=0) then (PC (PC) + 1)
Test and action - implemented as one micro-operation
updated value storage and test and action can be performed
during the same time unit
18
Micro-Operations - Execute Cycle (3)
Example 3:
BSA X ( Branch and Save address)
(Subroutine Call Instruction - Address of instruction that
follows the BSA instruction saved in location X and execution
starts from location X+I)
t1: MAR (IRaddress)
MBR (PC)
t2: PC (IRaddress)
Memory (MBR)
t3: PC (PC)+I
19
Flowchart for Instruction Cycle (1)...
– Complete Sequence of micro-operations
Assume a new 2-bit reg. called instruction cycle code (ICC)
Instruction cycle code (ICC) designates which part of cycle
processor is in
ICC : 00=Fetch, 01=Indirect, 10= Execute,11=Interrupt
Indirect cycle - always followed by execute cycle
Interrupt cycle- always followed by fetch cycle
Fetch cycle- depends upon the state - indirect addressing used
or not
Execute cycle - depends upon whether the enabled interrupt has
occurred or not
Summary: Operation of the processor is defined as the
performance of a sequence of micro-operations
20
Flowchart for Instruction Cycle (2)
– Complete Sequence of micro-operations
21
Functional Requirements of the Control Unit
Behavior or functioning of the CPU was decomposed into
elementary operations called micro-operations.
Define the functional requirements of the Control Unit (those
functions that the Control Unit must perform)
Basis for the design and implementation of the control unit
Three-step process that leads to a characterization of the CU:
Define the basic elements of the processor
Describe micro-operations that the processor performs
Determine the functions that the CU must perform to cause a micro-op
to be performed
22
Basic Elements of Processor
Execution of a program consists of operations involving the
following processor elements
ALU
• Essential functional unit of the CPU
Registers
• Store data internal to the CPU
• e.g. status information to manage instruction sequencing (program status word); data
that go to or come from the ALU, memory and I/O modules
Internal data paths
• Used to move data between registers, and between registers and ALU
External data paths
• Link registers to memory and I/O modules (system bus)
Control Unit
• Causes operation to happen within the CPU
23
Types of Micro-operation Categories
Operations involving processor elements consists of a sequence
of micro-operations
Categories of micro-operations
Transfer data between registers
Transfer data from register to an external interface
• e.g. system bus
Transfer data from an external interface to a register
Perform arithmetic or logical operations, using registers for input and
output.
24
Functions of Control Unit (CU)
25
Model of Control Unit (1)...
Model of Control Unit (2)...
- Control Signals (Input)
Clock
One micro-instruction (or set of parallel micro-instructions) per clock
cycle
Instruction register
Op-code and addressing mode of current instruction
Determines which micro-operations to perform
Flags
To determine the status of CPU
Results of previous operations
Example: ISZ (Increment-and-skip-if-zero) instruction
• Control unit will increment the PC if the zero flag is set
Control Signals from control bus
Interrupts
Acknowledgements
27
Model of Control Unit (3)
Control Signals - output
28
Example Control Signal Sequence - Fetch
30
Data Paths and Control Signals (2)...
- An example
Control Unit
Receives inputs from clock, instruction register, and flags
Generate a sequence of control signals that causes micro-operations to
occur.
Uses clock pulse to time the sequence of events
Control signals go to
data paths to control the internal flow of data
ALU to activate various logic circuits and gates
Control lines of system bus
31
Data Paths and Control Signals (3)
- An example
Micro-Operations and Control Signals
Micro-operations Active Control
Signals
t1: MAR ← (PC) C2
33
CPU with Internal Bus (2)...
35
END