Control Unit:: Hardwired vs. Microprogrammed Approach
Control Unit:: Hardwired vs. Microprogrammed Approach
Datapath
Adders,
Control Unit
Controls
the data How data is stored? Where is it stored? When should data be available?
Control Unit
Correct sequencing of control signals Much like human brain controlling various parts of body Sequence and timing is the key
Any
Control Unit
Decode Unit Execute Execution Unit Write Back Write Back Unit
A Possible Implementation
Mod-3 Counter
2 to 4 Decoder
CLK
Timing Diagram
CLK
Fetch
Decode
Execute
Write Back
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
Hardwired vs Microprogrammed
Hardwired
Use
gates to generate signals Squeeze out the juice for performance Different logic styles possible
Microprogrammed
Store
the control signals in the sequence Just read from the memory every clock cycle
A Model Computer
(Richard Eckert, SIGCSE Bulletin, Vol. 20, No. 3, September 1988)
IP LP EP 8 PC 12 MAR 8 R W LD ED RAM 12 MDR Bus 12 12 Register B 12 IR 4 Control LB LI EI 12 ALU 12 LA EA S A EU Accumulator 12
LM
More Details
L = Load E = Copy to bus A,S = Add and Subtract Sign bit to control unit IP = Increment PC
IP LP EP
PC
ACC
LA EA
LM
MAR
ALU
A EU
R W LD ED
LB LI EI
Mnemonic Opcode
LD A
Load Accumulator
Action
A(Mem)
Register Transfers
1. MAR IR 2. MDR M(MAR) 3. A MDR 1. MAR IR 2.MDR A 3. M(MAR) MDR 1. AALU(Add) 1. AALU(Sub) 1. BA 1. PCIR
Active Controls
EI,LM R ED,LA EI,LM EA,LD W A,EU,LA S,EU,LA EA,LB EI,LP NF : EI,LP
STA
Store Accumulator
2 3 4 5 6 7
PC Mem 1. PCIR if NF is set If ve flag is set Stop Clock IR Next Instruction 1. MAR PC 2. MDR M(MAR) 3. IR MDR
HLT Fetch
8-15
EP,LM R ED,LI,IP
Hardwired Unit
IR Opcode
LDA STA ADD CLK
Ring Counter T1
T5
Decoder
Control Matrix
Halt
NF
Control Signals
Control Matrix
Implement using discrete gates Usually done using PLAs Large control matrices are implemented hierarchically
For
speed
An Alternate Implementation
4-bit opcode IR MAP Starting Address Generator 1* 01 00
CLK
&
CD + NF
uPC 32 x 24
Map 1 0
CD * 0
Meaning From IR Unconditional Branch within Microprogram NF=0 => Increment NF=1 => Conditional Branch
+1 Control Store
Instruction Op-Code
Fetch 0
uInstruction Address
00 01 02
Control Store
0011000000000000 0000100000000000 1000000110000000
Control Signals
CD
0 0 0
LDA
03 04 05
0001000001000000 0000100000000000 0000000100100000 0001000001000000 0000001000010000 0000010000000000 0000000000101010 0000000000100110 0000000000010001 0100000001000000 0000000000000000 0000000000000000 0100000001000000
0 0 0 0 0 0 0 0 0 0 1 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 0 0 0
04 05 00 07 08 00 00 00 00 00 0F 00 00
STA
06 07 08
3 4 5 6 7
09 0A 0B 0C 0D 0E 0F
Expansion
8-E
10-1E
Control Word
I P
L P
E P
L M
L D
E D
L I
E I
L A
E A
E U
L B
0 0 0
0 0 1
0 0 0
01 02 XX 0B 09
LDA
03 04 05
0001000001000000 0000100000000000 0000000100100000 0001000001000000 0000001000010000 0000010000000000 0000000000101010 0000000000100110 0000000000010001 0100000001000000 0000000000000000 0000000000000000 0100000001000000
0 0 0 0 0 0 0 0 0 0 1 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 0 0 0
04 05 00 07 08 00 00 00 00 00 0F 00 00
STA
06 07 08
3 4 5 6 7
09 0A 0B 0C 0D 0E 0F
Expansion
8-E
10-1E
ADD
I P
L P
E P
L M
L D
E D
L I
E I
L A
E A
E U
L B
CD
00 Fetch 0 01 02
0 0 0
0D
LDA
03 04 05
0001000001000000 0000100000000000 0000000100100000 0001000001000000 0000001000010000 0000010000000000 0000000000101010 0000000000100110 0000000000010001 0100000001000000 0000000000000000 0000000000000000 0100000001000000
0 0 0 0 0 0 0 0 0 0 1 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 0 0 0
04 05 00 07 08 00 00 00 00 00 0F 00 00
STA
06 07 08
3 4 5 6 7
09 0A 0B 0C 0D 0E 0F
Expansion
8-E
10-1E
I P
L P
E P
L M
L D
E D
L I
E I
L A
E A
E U
L B
CD
00 Fetch 0 01 02
0 0 0
0D
LDA
03 04 05
0001000001000000 0000100000000000 0000000100100000 0001000001000000 0000001000010000 0000010000000000 0000000000101010 0000000000100110 0000000000010001 0100000001000000 0000000000000000 0000000000000000 0100000001000000
0 0 0 0 0 0 0 0 0 0 1 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 0 0 0
04 05 00 07 08 00 00 00 00 00 0F 00 00
STA
06 07 08
3 4 5 6 7
09 0A 0B 0C 0D 0E 0F
Expansion
8-E
10-1E
What is Microcode?
Michael Slater's "Microprocessor Based Design" (pg.42): Microcode tells the processor every detailed step required to execute each machine language instruction. Microcode is thus at an even more detailed level than machine language, and in fact defines the machine language. In a standard microprocessor, the microcode is stored in a ROM or a programmable logic array (PLA) that is part of the microprocessor chip and cannot be modified by the user.'
Thought Experiment
Why is the design a little clumsy? What can we do about it?
Real Life
A little American Football Story Theory vs. Practice
In
theory, there is no difference between theory and practice In practice, theory and practice are two different things altogether
A General Approach
IR Starting and Branch Address Generator External Inputs Conditional Codes
uPC
Control Store
Control Word
Format of Microinstructions
Pick yours
Your One
What we did :
bit position per control signal Order of the bits ?
Dont matter
Can
Vertical
Microprogram
Vertical Microprogram
Encode the bits by grouping similar elements together General Idea :
Group
There can be only one source or destination register Read vs Write of memory
Some
Design Issues
Another Idea
Group concuurently active signals Every meaningful combination gets a code Complex decoder to interpret every code
Vertical vs Horizontal
Horizontal
Faster More
Vertical
Slower More
microinstructions
Microsequencing
Other ways to save on hardware Every instruction had its own microprogram sequence Also, instructions have several addressing modes
Only
Bit-ORing
Example Two instructions share some microcode Eventually, must branch The default branch (one instructions) is X0 The other branch is stored at X1 Change the least significant bit(s?) to get a new address Having two conditional branches Store two fields, one for each branch Both very unclean
Thought Experiment :
What if we provided explicit branch instead of storing next field in our microprogram? Typical instruction set will need a lot of branches Lot of time will be wasted on branching
Caution :
Microinstruction
Solution :
There
is no free lunch.
A neat idea :
Why wait till the current micro-op is over? Branch field gives next operation Get the next op External inputs and status flags may change the order What about interrupts?
Caveat :
Commonly used
Historical Perspectives
Hardwired Logic
Popular now
Microprogram
Popular in 70s
Memory was slower than CPU No on-chip cache Best way is to store the microcode
Now Depends on who you ask? Extremes of spectrum are harder to find nowadays
Shades of gray :
Hardwired
Any
Microcoding
Small
Hardwired vs Microcoding
Hardwired units are faster and smaller Emulation is easy with microcoding Hardwired design is complex if large Bugs in hardwired design cannot be fixed in field Hardwired control is not suited for loops
Looping
RISC
Simpler
Store
Difference :
Contents
are not fixed Advantage : Only load what you want on the I-Cache
Keeps size smaller as compared to Control Stores
Microprogram vs Software
process Error prone Many fetches repeatedly from memory for the given sequence of operations
Solution 2 : Microcode
Long
process too but designers not programmers Relatively error free more thorough design Requires many cycles but fetched and used locally
Emulation
Secret :
Designed to emulate the x86, 68K, and 6502 architectures Uses customizable microcode, among other techniques Went bust, never released
if you, a programmer, can write your own control store? Not a mad scientist thought
Implemented in
VAX
Current Trends
to IA32 microcode driver It decodes and sends new microcode to the kernel driver to be uploaded to Intel IA32 processors Update is volatile lost on reboots
Intel Said..
The Pentium(R) Pro processor and Pentium(R) II processor may contain design defects or errors known as errata that may cause the product to deviate from published specifications. Many times, the effects of the errata can be avoided by implementing hardware or software work-arounds, which are documented in the Pentium Pro Processor Specification Update and the Pentium II Processor Specification Update. Pentium Pro and Pentium II processors include a feature called "reprogrammable microcode", which allows certain types of errata to be worked around via microcode updates. The microcode updates reside in the system BIOS and are loaded into the processor by the system BIOS during the Power-On Self Test, or POST.
Current Trends
Hyperthreading in P4
A
Microcoding in P4
Two
pointers control flow independently Both processors share the ROM entries Access is alternated between the CPUs
Thank You