Control Unit design
MODULE 2
What is a Control Unit?
Part of the CPU that directs operations of the processor.
It issues control signals to:
◦ ALU
◦ Memory
◦ I/O Devices
Two types:
◦ Hardwired Control Unit : Uses combinational logic circuits to generate
control signals.
◦ Microprogrammed Control Unit : Uses Microinstructions stored in a Control
Memory (ROM) to generate control signals.
Micro-operations
Address Data Control
PC MAR
IR MBR
Control
GPRs
Unit
ALU
Memory and IO
Components
Micro-operation for Instruction Fetch
Micro-operations For Immediate
Addressing Mode
Mov R1, 25H
Micro-operations For Register Addressing
Mode
Mov R1, R2
Micro-operations For Direct Addressing
Mode
Mov R1, [2000H]
Micro-operations For Indirect Addressing
Mode
Mov R1, [R2]
Micro-operations For Implied Addressing
Mode
STC
Hardwired Control unit
Hardwired control unit Design
Uses combinational logic circuits to generate control signals.
Control Signals are produced by Hardware.
➢State Table Method
➢Delay Element Method
➢Sequence counter Method
Features :
Fast execution (no need to fetch microinstructions).
Difficult to modify or update.
Typically used in RISC architectures.
Control logic is implemented using:
◦ Gates
◦ Flip-flops
◦ Decoders
◦ Multiplexers
State Table Method
1. Most basic type of Hardwired Control Unit design.
2. Control unit behaviour is represented using a State Table.
3. Rows represent T-states (timing steps of execution).
4. Columns represent different instructions.
5. Each cell at the intersection defines the control signals for that instruction at
a specific T-state.
6. Based on each column, a separate logic circuit is designed for each
instruction.
Z1,1 : Control Signal to be produced in T-state (T1) of Instruction (I1)
Delay Element Method
•The behaviour of the control unit is represented as a flowchart.
•Each step in the flowchart corresponds to a control signal.
•Execution of all steps in the flowchart = Instruction completed.
•Each control signal performs a micro-operation, requiring one T-state.
•A delay element is needed between every two steps to maintain timing.
•The delay must be exactly one T-state.
•This delay is implemented using D Flip-Flops.
Delay Element Method
•D Flip-Flops are placed between consecutive control signals to ensure timing
control.
•Of all D Flip-Flops only one will be active at a time. So the method is also called
“One Hot Method”.
•In a multiple entry point, to combine two or more paths, we use an OR gate.
•A decision box is replaced by a set of two complementing AND gates
Sequence Counter Method
•Most popular form of hardwired control unit.
•Follows flowchart logic like the Delay Element Method — but avoids D Flip-Flops.
•Step 1: Create a flowchart representing control unit behavior.
•Step 2: Convert the flowchart into a logic circuit using AND and OR gates.
•A 1 T-state delay between control signals is required — and is achieved by this circuit.
•For k distinct control steps, we use:
◦ A mod-k counter A
◦ k-output decoder
•How it works:
◦ The counter starts at the beginning of the instruction.
◦ The clock, gated via an AND gate, ensures one count per T-state.
◦ The decoder activates one control signal per T-state.
•When the instruction completes, the counter is reset to prepare for the next instruction
Sequence Counter Method
General Drawbacks Of A Hardwired Control Unit
1) Since they are based on hardware, as the instruction set increases,
the circuit becomes more and more complex. For modern processors
having hundreds of instructions, it is virtually impossible to create
Hardwired Control Units.
2) Such large circuits are very difficult to debug.
3) As the processor gets upgraded, the entire Control Unit has to be
redesigned, due to the rigid nature of hardware design.
Microprogrammed control unit
Need:
Hardwired CU is complex, difficult to modify.
As instruction sets grew (CISC), hardwired CU became impractical.
Microprogramming simplifies control unit design by replacing complex
circuits with memory-based microinstructions.
If Intel adds a new instruction, how can they implement it without
redesigning the CPU hardware?
Answer: By updating the microcode in control memory.
Instructions Micro- Control
Program
1..n operations signals
Microprograms
- A program = set of instructions
- Each instruction = set of micro-operations
- Micro-operations are executed by control signals
- Control signals are generated by micro-instructions
Wilkes’ Original Microprogrammed Control Unit
Design (1951)
Introduce Maurice
Wilkes (Cambridge,
1951).
His idea: Replace
complex control circuits
with a ROM-based store
of microinstructions.
Wilkes’ Design For A Microprogrammed
Control Unit
Working: Instruction enters Instruction Register.
Instruction Decoder generates address of the starting microinstruction.
Control Memory (ROM) outputs microinstruction (control word).
Control word activates datapath signals (ALU, MAR, MDR, PC, etc.).
Next Address Logic decides which microinstruction to fetch next.
Example microinstruction fields (Wilkes’ design):
◦ Control signals for datapath.
◦ Next address for sequencing.
Limitation of Wilkes’ design:
◦ Microinstruction format not standardized.
◦ Large ROM required (inefficient).
◦ Sequencing was sometimes complex.
Typical Microprogrammed Control
Unit
1. An Instruction that is fetched from the main memory into the Instruction Register (IR).
2. The processor uses its unique “opcode” to identify the address of the first micro-
instruction.
3. That address is loaded into CMAR (Control Memory Address Register) also called µIR.
4. This address is decoded to identify the corresponding µ-instruction from the Control
Memory.
5. There is a big improvement over Wilkes’ design, to reduce the size of micro-
instructions.
6. Most micro-instructions will only have a Control field. The Control field Indicates the
control signals to be generated.
7. Most micro-instructions will not have an address field. Instead, µPC will simply get
incremented after every micro-instruction. This is as long as the µ-program is executed
sequentially.
8. If there is a branch µ-instruction only then there will be an address filed. If the branch
is unconditional, the branch address will be directly loaded into CMAR. For Conditional
branches, the Branch condition will check the appropriate flag. This is done using a
MUX which has all flag inputs. If the condition is true, then the MUX will inform CMAR
to load the branch address. If the condition is false CMAR will simply get incremented.
9. The control memory is usually implemented using FLASH ROM as it is writable yet non
volatile.
Microprogrammed Control
ADVANTAGES
1. The biggest advantage is flexibility.
2. Any change in the control unit can be performed by simply changing the
micro-instruction.
3. This makes modifications and up gradation of the Control Unit very easy.
4. Moreover, software can be much easily debugged as compared to a large
Hardwired Control Unit.
5. Since most micro-instructions are executed sequentially, they don’t need for
an address field.
6. This significantly reduces the size of micro-instructions, and hence the Control
Memory.
DRAWBACKS
1. Control memory has to be present inside the processor, increasing its size.
2. This also increases the cost of the processor.
Applications of Micro-programming
Development of Control Units – Handles large/complex instruction sets, easily
modified.
User Tailoring of Control Unit – Reprogrammable control memory (RAM/Flash).
Emulation – One processor can mimic another by reprogramming control memory.
◦ Example: Main CPU emulating a math co-processor.
Improving the Operating System – Enhances OS performance, efficiency & security
from viruses.
High-Level Language Support – Provides direct support for complex data types.
Micro-Diagnostics – Easier debugging, error detection, runtime substitute for failed
units.
Development of Specialized Processors – Ideal for DSPs, GPUs & constantly evolving
architectures
Micro-instruction Sequencing
Control Memory
CW1 Assume a CPU supports 8 distinct instructions and for
CW1 each instruction sequence of 4 micro-operations are
I1
CW1 required
Control Word
CW1
CW2 External I/P
Next Control Control
CW2 Address Address
Control
Data
I2 Generator Register
Memory
CW2 Register
CW2
Next Address info
CW3
CW3
…….
…….
Micro-instruction Sequencing
Method of determining the flow of the Microprogram
DUAL ADDRESS FIELD
➢micro-instructions are NOT executed in a sequential
manner.
➢The instruction register (IR) gives the address of the
first micro-instruction.
➢Each micro-instruction gives the address of the next
micro-instruction.
➢If it is a conditional micro-instruction, it will contain
two address fields. One for the condition to be true
and the other for false. Hence it is called dual address
field.
➢The multiplexer will decide the address the address
to be loaded into the control memory address register
(CMAR) based on the status flags.
Micro-instruction Sequencing
SINGLE ADDRESS FIELD
➢Micro-instructions are executed in a sequential manner.
➢The instruction register (IR) gives the address of the first
micro-instruction into CMAR.
➢Thereafter the address is simply incremented.
➢For an unconditional branch, the micro-instruction
contains the branch address.
➢This address will be loaded into CMAR. For a conditional
branch, the micro-instruction contains the branch address
for true condition. If the condition is false, the current
address in CMAR will be simply incremented. This means
even in the worst case, the micro-instruction will carry
only one address. Hence it is called single address field.
➢The multiplexer will decide the address the address to be
loaded into the control memory address register (CMAR)
based on the status flags.
Micro instruction format
A micro-instruction format defines how a micro-instruction is
represented inside the control memory. It specifies how different fields
(bits) are allocated to represent control signals, sequencing information,
and sometimes addresses of the next micro-instruction.
1) Horizontal Micro-instruction
Here every bit of the micro-instruction corresponds to a control signal.
Whichever bit is “1”, that particular control signal will be produced by the
micro-instruction.
Micro instruction format
2) Vertical Micro-instruction
Here bits of the micro-instruction have to be decoded. The decoded output
decides the control signal to be produced.
Nano-Programming
Horizontal µ-instructions → Multiple signals, but wide
(large memory).
Vertical µ-instructions → Compact, but slower (needs
decoding).
Nano-Programming = Combination of both.
Two-level control memory: µ-Control Memory (vertical) +
Nano-Control Memory (horizontal).
Process:
[Link] fetched → IR.
[Link] → loads µPC → fetch µ-instruction
(vertical).
[Link] output → loads nPC → fetch Nano-
instruction (horizontal).
[Link]-instruction directly generates control signals.
Advantages:
•Smaller control memory (vertical µ-instructions).
•Parallel control signals (horizontal nano-instructions).