Computer Architecture
CISC
RISC
Stages
Millions of Instructions Per Second
Strongly pipelined architecture
DECs Alpha, HPs Precision
Registers
32 32-bit (word) registers
Arithmetic Operations
add a, b, c # a = b + c
add $t0, $s1, $s2
sub a, b, c # a = b c
sub $s0, $t0, $t1
Arithmetic operations occur only on
registers
Data Transfer
lw $t0, 8($s3) # load $t0 with data from memory
# base address in $s3, offset 8
sw $t0, 48($s3) # store word
12
101
110
10
1001
Addres
s
Memory
Byte 8 bits
Word 32 bits
Memory in words
Address to byte
level
5
MIPS Fields
Rtype
I-type
op
rs
rt
rd
shamt
funct
6 bits
5 bits
5 bits
5 bits
5 bits
6 bits
op
rs
rt
addres
s
rs
rt
rd
17
sham
t
0
func
t
32
18
19
18
19
17
34
op
rs
rt
35
18
17
100
lw $s1, 100($s2)
43
18
17
100
sw $s1,
100($s2)
address
#
#
#
#
#
10
Implement Instruction
Fetch
Add
4
P
C
Read
addres
s
Instructio
n
Instruction
memory
11
5
Instructio
n
Read
register
Read
1
data 1
Read
register
2
Registers
Write
register
Write
data
Read
data 2
32
Contro
l
ALU
Result 32
32
Reg_writ
e
12
Instructio Registe
ALU
n fetch
r read operatio
n
Memor
y
access
lw
sw
R-format
(add, sub)
Branch
Registe Total
r write time
1
8
7
6
5
13
lw $t1, 8($s1)
lw $t2,
16($s2)
lw $t3,
12($s3)
IF
ID ALU
1
0
1
2
1
4
1
6
1
8
MEM WB
ID ALU
IF
MEM WB
ID ALU
MEM WB
14
Pipeline Hazards
Situations when the next
instruction cannot execute in the
following clock cycle
Structural hazards
Control hazards
Data hazards
16
Structural Hazards
Hardware cannot support the
combined instructions that we want
to execute in the same clock cycle
Example: if there is only one
memory, then memory access and
instruction fetch cannot be
executed simultaneously
Solution: add hardware
17
Control Hazards
Decision-making depends on the result of
an instruction that has not been finished
Example: PC following a branch
instruction depends if branch is taken or
not
Solutions
Data Hazards
An instruction cannot be executed until a
data is available from another instruction
Example: add $s0, $t1, $t2
sub $t2, $s0, $t3
Solution: