Professional Documents
Culture Documents
Computer Architecture vs. Instruction Set Architecture
Computer Architecture vs. Instruction Set Architecture
COMPUTER ARCHITECTURE
VS. INSTRUCTION SET
ARCHITECTURE
CMSC 411 - 1 2
CS252 S05
Instruction Set Architecture: Critical Interface
software
instruction set
hardware
Example: MIPS
r0 0
Programmable storage Data types ?
r1
° 2^32 x bytes Format ?
° 31 x 32-bit GPRs (R0=0)
° Addressing Modes?
r31 32 x 32-bit FP regs (paired DP)
PC PC
Arithmetic logical
Add, AddU, Sub, SubU, And, Or, Xor, SLT, SLTU,
AddI, AddIU, SLTI, SLTIU, AndI, OrI, XorI,
SLL, SRL, SRA
Memory Access
LB, LBU, LH, LHU, LW,
SB, SH, SW
Control 32-bit instructions on word boundary
J, JAL, JR, JALR
BEq, BNE, BLEZ,BGTZ,BLTZ,BGEZ
CMSC 411 - 1 4
CS252 S05
Instruction Set Architecture (ISA)
“... the attributes of a [computing] system as seen by
the programmer, i.e. the conceptual structure and
functional behavior, as distinct from the organization
of the data flows and controls the logic design, and
the physical implementation.”
– Amdahl, Blaauw, and Brooks, 1964
SOFTWARE
-- Organization of Programmable
Storage
-- Data Types & Data Structures:
Encodings & Representations
-- Instruction Formats
-- Instruction (or Operation Code) Set
-- Modes of Addressing and Accessing Data Items and Instructions
-- Exceptional Conditions
CMSC 411 - 1 5
CMSC 411 - 1 6
CS252 S05
Computer Architecture Is An Integrated Approach
CMSC 411 - 1 7
Creativity
Cost /
Performance
Analysis
Good Ideas
Mediocre Ideas
Bad Ideas CMSC 411 - 1 8
CS252 S05
MIPS INSTRUCTION SET
ARCHITECTURE
CMSC 411 - 1 9
CS252 S05
Example: MIPS
Register-Register
31 26 25 21 20 16 15 11 10 6 5 0
op rs rt rd opx
rd ← rs OP rt
Register-Immediate
31 26 25 21 20 16 15 0
op rs rt immediate
rt ← rs OP immed
Jump / Call
31 26 25 0
op target
Next SEQ PC
4 RS
Zero?
MUX MUX
Address
Memory
Reg File
RT
Inst
ALU
Memory
RD L
Data
M
MUX
D
Sign
IR ← mem[PC]; Imm Extend
PC ← PC + 4
WB Data
Reg[IRrd] ← Reg[IRrs] opIRop Reg[IRrt]
CS252 S05
5 Steps of MIPS Datapath
Instruction Instr. Decode Execute Memory Write
Fetch Reg. Fetch Addr. Calc Access Back
Next PC
MUX
Next SEQ PC Next SEQ PC
Adder
4 RS
Zero?
MUX MUX
MEM/WB
Address
Memory
EX/MEM
Reg File
RT
ID/EX
IF/ID
ALU
Memory
Data
MUX
IR ← mem[PC];
WB Data
Sign
PC ← PC + 4 Imm
Extend
A ← Reg[IRrs];
RD RD RD
B ← Reg[IRrt]
rslt ← A opIRop B
WB ← rslt
Reg[IRrd] ← WB
CMSC 411 - 4 (from Patterson) 13
IR ← mem[PC]; Ifetch
PC ← PC + 4
A ← Reg[IRrs]; opFetch-DCD
B ← Reg[IRrt]
br jmp LD
RR RI
r ← A opIRop B r ← A opIRop IRim r ← A + IRim
if bop(A,b) PC ← IRjaddr
PC ← PC+IRim
WB ← r WB ← r WB ← Mem[r]
CS252 S05
Visualizing Pipelining
Time (clock cycles)
ALU
Reg
n Ifetch Reg DMem
s
t
r.
ALU
Ifetch Reg DMem Reg
O
r
ALU
Ifetch Reg DMem Reg
d
e
r
ALU
Ifetch Reg DMem Reg
CS252 S05
One Memory Port/Structural Hazards
ALU
I Load Ifetch Reg DMem Reg
n
s
ALU
t
Instr 1 Ifetch Reg DMem Reg
r.
ALU
Ifetch Reg DMem Reg
Instr 2
O
r
ALU
Ifetch Reg DMem Reg
d Instr 3
e
ALU
r Instr 4 Ifetch Reg DMem Reg
n
s
ALU
t
Instr 1 Ifetch Reg DMem Reg
r.
ALU
e
ALU
CS252 S05
Speed Up Equation for Pipelining
CS252 S05
Data Hazard on R1
Time (clock cycles)
IF ID/RF EX MEM WB
ALU
add r1,r2,r3 Ifetch Reg DMem Reg
n
s
ALU
t sub r4,r1,r3 Ifetch Reg DMem Reg
r.
ALU
Ifetch Reg DMem Reg
O and r6,r1,r7
r
d
ALU
Ifetch Reg DMem Reg
e or r8,r1,r9
r
ALU
Reg
xor r10,r1,r11 Ifetch Reg DMem
I: add r1,r2,r3
J: sub r4,r1,r3
CS252 S05
Three Generic Data Hazards
I: sub r1,r4,r3
J: add r1,r2,r3
K: mul r6,r1,r7
• Called an “output dependence” by compiler writers
This also results from the reuse of name “r1”.
• Can’t happen in MIPS 5 stage pipeline because:
– All instructions take 5 stages, and
– Writes are always in stage 5
• Will see WAR and WAW in more complicated pipes
CS252 S05
Forwarding to Avoid Data Hazard
Time (clock cycles)
I
n
ALU
add r1,r2,r3 Ifetch Reg DMem Reg
s
t
r.
ALU
sub r4,r1,r3 Ifetch Reg DMem Reg
O
r
ALU
Ifetch Reg DMem Reg
d and r6,r1,r7
e
r
ALU
Ifetch Reg DMem Reg
or r8,r1,r9
ALU
Ifetch Reg DMem Reg
xor r10,r1,r11
NextPC
mux
Registers
MEM/WR
EX/MEM
ALU
ID/EX
Data
mux
Memory
mux
Immediate
CS252 S05
Forwarding to Avoid LW-SW Data Hazard
Time (clock cycles)
I
n
ALU
add r1,r2,r3 Ifetch Reg DMem Reg
s
t
r.
ALU
lw r4, 0(r1) Ifetch Reg DMem Reg
O
r
ALU
Ifetch Reg DMem Reg
d sw r4,12(r1)
e
r
ALU
Ifetch Reg DMem Reg
or r8,r6,r9
ALU
Ifetch Reg DMem Reg
xor r10,r9,r11
n
s
ALU
r.
ALU
r
d
e
ALU
r
or r8,r1,r9
CS252 S05
Data Hazard Even with Forwarding
ALU
s lw r1, 0(r2) Ifetch Reg DMem Reg
t
r.
ALU
Ifetch Reg Bubble DMem Reg
sub r4,r1,r6
O
r
d
ALU
Ifetch Bubble Reg DMem Reg
e and r6,r1,r7
r
ALU
Bubble Ifetch Reg DMem
or r8,r1,r9
CS252 S05