Control Unit

Download Report

Transcript Control Unit

Control Unit Operation and
Microprogramming
Chap 16 & 17 of CO&A
Dr. Farag
1
Introduction
• Internal processor organization for single bus
architecture (See following slide)
• Main components of the CPU
• Special Registers (Y and Z)
• The two cycles (fetch and execute phases)
• The basic functions of CU
– Sequencing: stepping through microinstructions
– Execution: executing microinstructions
• CU block diagram
– Inputs (IR, flags, clock, & control signals from system bus)
– Outputs (control signals to system and internal buses)
2
ALU
control
lines
R n - 1
Sub
ALU
Carry -in
XOR
TEMP
Z
Figure 7.1. Single-bus organization of the datapath inside a processor.
Introduction
3
Introduction
CLK
Clock
Control step
counter
External
inputs
Decoder/
IR
encoder
Condition
codes
Control signals
4
Basic Operations
• Four basic operations can be used to construct
more complex ones
–
–
–
–
Register transfer (LOAD MQ)
Performing an arithmetic or logic operation
Fetching a word from memory (Load M(100))
Storing a word into memory (Store M(100))
• Complete example: Write the control steps for
executing IAS assembly instruction: ADD
M(3000)
5
Control Unit Implementation
• Two Main techniques to implement CU:
– Hardwired implementation
– Microprogrammed implementation
• In hardwired implementations the CU is
considered as a combinational logic circuit that
produces its outputs (control signals) based on
its inputs (IR, flags, step counter, etc.)
• Ex: To derive a logical expression for Zin:
• Zin = T1. (fetch phase) + T6 . Add + ………
6
Control Unit Implementation (Cont.)
• All control steps for each instruction should be
specified then the logical expression for each
control signal is derived.
• This process becomes very complex with the
increase in processor complexity (there are
solutions)
• An
alternative
is
microprogrammed
implementation.
• The idea of microprogramming is to consider
each instruction as a sequence of much simpler
steps called microinstructions.
7
Control Unit Implementation (Cont.)
• Each microinstruction basically activates a number
of control signals.
• Microinstructions can be stored into memory
locations as control words.
• Each control word contains a number of bits equals
to the number of CPU & bus control signals in
addition to an address field and a jump condition
field.
• For those active control signals in a
microinstruction corresponding bits will be set
otherwise all other bits store zero.
8
Control Unit Implementation (Cont.)
• The previously described technique is called
horizontal microinstruction.
• To execute such instructions:
– Issue control signals for active bits
– If condition is false, execute the following instruction
– Otherwise, execute the instruction whose address is
stored in the address field
• Another form of structuring the microinstruction is
called vertical organization where the system bus
and the internal CPU control signals are coded.
• Think of the pros and cons
9
Control Unit Implementation (Cont.)
• Now the components of a microprogrammed CU
are :
– Decoder: to decode the IR
– Sequencing logic: to determine the address Of the next
microinstruction to be executed
– Control address register: to hold the above address
– Control memory: to store control words
– Control buffer register: to store the currently read
microinstruction
– Decoder: to decode microinstructions if need
10
Advantages and Disadvantages
• Simplicity
– Cheaper
– Less error-prone
• Flexibility: The content of the control memory can
be modified or even replaced to update the
instruction set architecture of the computer.
• This is impossible in case of Hardwired control.
• The principle disadvantage of microprogramming is
performance. Despite this, it is the dominant
technique to implement CUs in CISC processors.
• RISC processors usually use Hardwired control.
11
Microprogramming Applications
• Realization of CUs.
• Emulation.
• Operating system support: Implement primitives
that replace important portions of OS S/W.
• HLL support: various functions and data type that
can be implemented directly in firmware.
• Monitoring, detecting, isolating, and repairing
system errors (microdiagnostics).
• User tailoring: Enable the user to write to the
control memory by implementing it using RAM.
12