Académique Documents
Professionnel Documents
Culture Documents
Opérations programmeur
élémentaires
(lecture,…)
Programme en microprogramme
Instructions
langage machine
(A = B + C,…) compilateur
Programme en
langage évolué
Architecture des ordinateurs, M. Eleuldj, EMI, Février 2008 Ch.IV. 2
Taille des programmes
…
…
… OpSel
…
A=B+C
… {
MOV
ADD
…
{ RegSel
…
enALU
…
STORE
Programme en …
langage évolué
Programme en
langage machine
microprogramme
Architecture des ordinateurs, M. Eleuldj, EMI, Février 2008 Ch.IV. 3
Instructions MIPS
Quelques instructions
add a, b, c # a (b) + (c)
sub a, b, c # a (b) – (c)
lw a,b # a (b)
sw a,b # b (a)
beq a,b,L # si (a) = (b) aller à l’étiquette (Label) L
bnq a,b,L # si (a) = (b) aller à L
j L # aller à L
f = (g + h) – (i + j);
et variables f, g, h, i et j affectées aux registres $s0, $s1, $s2, $s3 et $s4
⇒ add $t0, $s1, $s2 # $t0 (g) + (h)
add $t1, $s3, $s4 # $t1 (i) + (j)
sub $s0, $t0, $t1 # $s0 ($t0) - ($t1)
Architecture des ordinateurs, M. Eleuldj, EMI, Février 2008 Ch.IV. 5
Exercices (1/2)
a) Opérande en mémoire
g = h + A[3];
A est un tableau de 100 éléments
e) Sélection binaire
if (i == j)
f=g+h;
else f = g – h;
f) Boucle
Loop : g = g + A[i];
i = i + j;
if (i!= j) goto Loop;
b) A[5] = h + A[3];
lw $t0, 12($s3) # $t0 (A[3])
add $t0, $s2, $t0 # g (h) + (A[3])
sw $t0, 20($s3) # A[5] (g)
c ) g = h + A[i];
add $t1, $s4, $s4 # $t1 2 * (i)
add $t1, $t1, $t1 # $t1 4 * (i)
add $t1, $t1, $s3 # $t1 A[i]
lw $t0, 0($t1) # $t0 (A[i])
add $s1, $s2, $t0 # g h + A[i]
e) if (i == j)
f=g+h;
else f = g – h;
g) While (B[i] == h) i = i + j;
Loop :add $t1, $s3, $s3 # $t1 2 * (i)
add $t1, $t1, $t1 # $t1 4 * (i)
add $t1, $t1, $s6 # $t1 B[i]
lw $t0, 0($t1) # $t0 (B[i])
bne $t0, $s2, Exit # if B[i] ≠ h sortir de la boucle
add $s3, $s3, $s4 # i (i) + (j)
j Loop # aller au début de la boucle
Architecture des ordinateurs, M. Eleuldj, EMI, Février 2008 Ch.IV. 10
Exit :
1
Microprogramming
Arvind
M.I.T.
6.823 L4- 2
Arvind
– CISC ⇒ microcoded
microarchitectural style
Controller control
status points
lines
Data
path
op conditional
code flip-flop
Next state
µ address
Matrix A Matrix B
Decoder
Control lines to
ALU, MUXs, Registers
September 21, 2005
6.823 L4- 5
Arvind
Microcoded Microarchitecture
Datapath
Data Addr
• Processor State
6 5 5 16
Mem opcode rs rt displacement M[(rs) + displacement]
6 5 5 16
opcode rs offset BEQZ, BNEZ
6 5 5 16
opcode rs JR, JALR
6 26
opcode offset J, JAL
31(Link)
rd
2 rt
rs
RegSel MA
rd 3
IR rt A B addr addr
rs
32 GPRs
ExtSel + PC ... Memory
Imm ALU MemWrt
RegWrt
2 Ext control ALU 32-bit Reg enReg
enImm enALU data data enMem
Bus 32
Microinstruction: register to register transfer (17 control signals)
MA ← PC means RegSel = PC; enReg=yes; ldMA= yes
B ← Reg[rt] means RegSel = rt; enReg=yes; ldB = yes
September 21, 2005
6.823 L4- 9
Arvind
Memory Module
addr busy
Write(1)/Read(0)
RAM we
Enable
din dout
bus
Assumption: Memory operates asynchronously
and is slow as compared to Reg-to-Reg transfers
September 21, 2005
6.823 L4- 10
Arvind
Instruction Execution
Execution of a MIPS instruction involves
1. instruction fetch
2. decode and register fetch
3. ALU operation
4. memory operation (optional)
5. write back to register file (optional)
+ the computation of the
next instruction address
Microprogram Fragments
instr fetch: MA ← PC
A ← PC can be
IR ← Memory treated as
PC ← A + 4 a macro
dispatch on OPcode
ALU: A ← Reg[rs]
B ← Reg[rt]
Reg[rd] ← func(A,B)
do instruction fetch
ALUi: A ← Reg[rs]
B ← Imm sign extension ...
Reg[rt] ← Opcode(A,B)
do instruction fetch
LW: A ← Reg[rs]
B ← Imm
MA ← A + B
Reg[rt] ← Memory
do instruction fetch
JumpTarg(A,B) =
J: A ← PC
{A[31:28],B[25:0],00}
B ← IR
PC ← JumpTarg(A,B)
do instruction fetch
beqz: A ← Reg[rs]
If zero?(A) then go to bz-taken
do instruction fetch
bz-taken: A ← PC
B ← Imm << 2
PC ← A + B
do instruction fetch
Opcode
zero? 6
Busy (memory)
latching the inputs µPC (state)
may cause a How big
s
one-cycle delay is “s”?
addr s
ROM size ?
µProgram ROM
= 2(opcode+status+s) words
Word size ? data
= control+s bits next
state
fetch0 * * * MA ← PC fetch1
fetch1 * * yes .... fetch1
fetch1 * * no IR ← Memory fetch2
fetch2 * * * A ← PC fetch3
fetch3 * * * PC ← A + 4 ?
fetch3 ALU * * PC ← A + 4 ALU0
addr / s
data
Control signals / c
MIPS Controller V2
Jump Logic
next ⇒ µPC+1
fetch ⇒ absolute
dispatch ⇒ op-group
fetch0 MA ← PC next
fetch1 IR ← Memory spin
fetch2 A ← PC next
fetch3 PC ← A + 4 dispatch
...
ALU0 A ← Reg[rs] next
ALU1 B ← Reg[rt] next
ALU2 Reg[rd]←func(A,B) fetch
Branches: MIPS-Controller-2
Jumps: MIPS-Controller-2
6.823 L4- 26
Implementing Complex
Arvind
Instructions
RegSel MA
3
rd
IR rt A B addr addr
rs
32 GPRs
ExtSel + PC ... Memory
Imm ALU MemWrt
RegWrt
2 Ext control ALU 32-bit Reg enReg
enImm enALU data data enMem
Bus 32
rd ← M[(rs)] op (rt)
Reg-Memory-src ALU op
M[(rd)] ← (rs) op (rt)
Reg-Memory-dst ALU op
M[(rd)] ← M[(rs)] op M[(rt)]
Mem-Mem ALU op
September 21, 2005
6.823 L4- 27
MIPS-Controller-2
Mem-Mem ALU op M[(rd)] ← M[(rs)] op M[(rt)]
ALUMM6 fetch
Performance Issues
Microprogrammed control
⇒ multiple cycles per instruction
Cycle time ?
tC > max(treg-reg, tALU, tµROM, tRAM)
Given complex control, tALU & tRAM can be broken
into multiple cycles. However, tµROM cannot be
broken down. Hence
tC > max(treg-reg, tµROM)
Suppose 10 * tµROM < tRAM
Good performance, relative to the single-cycle
hardwired implementation, can be achieved
even with a CPI of 10
September 21, 2005
6.823 L4- 29
Arvind
# µInstructions
• Nanocoding
– Tries to combine best of horizontal and vertical µcode
September 21, 2005
6.823 L4- 30
Arvind
Nanocoding
Exploits recurring
µPC (state)
µcode
control signal patterns
next-state
in µcode, e.g.,
µaddress
µcode ROM
ALU0 A ← Reg[rs]
...
nanoaddress
ALUi0 A ← Reg[rs]
...
nanoinstruction ROM
data
• Microcoding now
Datapath 8 16 32 64
width (bits)
µinst width 50 52 85 87
(bits)
µcode size 4 4 2.75 2.75
(K minsts)
µstore CCROS TCROS BCROS BCROS
technology
µstore cycle 750 625 500 200
(ns)
memory 1500 2500 2000 750
cycle (ns)
Rental fee 4 7 15 35
($K/month)
Microcode Emulation
Seventies
• Significantly faster ROMs than DRAMs were
available
• For complex instruction sets, datapath and
controller were cheaper and simpler
• New instructions , e.g., floating point, could
be supported without datapath modifications
• Fixing bugs in the controller was easier
• User-WCS failed
– Little or no programming tools support
– Difficult to fit software into small space
– Microcode control tailored to original ISA, less useful for
others
– Large WCS part of processor state - expensive context
switches
– Protection difficult if user can change microcode
– Virtual memory required restartable microcode
September 21, 2005
6.823 L4- 36
Arvind
Modern Usage
• Microprogramming is far from extinct
Thank you !