Академический Документы
Профессиональный Документы
Культура Документы
Generic Implementation:
We need an ALU
We have already designed that
We need memory to store inst and data
Instruction memory takes address and supplies inst
Data memory takes address and supply data for lw
Data memory takes address and data and write into memory
We need to manage a PC and its update mechanism
We need a register file to include 32 registers
We read two operands and write a result back in register file
Some times part of the operand comes from instruction
We may add support of immediate class of instructions
We may add support for J, JR, JAL
Simple Implementation
Instruction
address
MemWrite
PC
Instruction
Add Sum
Instruction
memory
Address
Write
data
a. Instruction memory
5
Register
numbers
5
5
Data
b. Program counter
Read
register 2
Registers
Write
register
Write
data
Data
memory
ALU control
Read
data 1
Sign
extend
32
MemRead
a. Data memory unit
Data
16
c. Adder
Read
register 1
Read
data
Zero
ALU ALU
result
Read
data 2
b. Sign-extension unit
RegWrite
a. Registers
b. ALU
Data
Register #
PC
Address
Instruction
Instruction
memory
Registers
ALU
Address
Register #
Data
memory
Register #
Data
cycle time
rising edge
26 25
21 20
REG 1
LW
31
26 25
21 20
31
26 25
31
21 20
26 25
R-TYPE
31
26 25
31
26 25
JUMP
DST
16 15
JUMP
OFFSET
0
OFFSET
SHIFT AMOUNT
11 10
ADD/AND/OR/SLT
IMMEDIATE DATA
REG 2
21 20
11 10
BRANCH ADDRESS
REG 2
REG 1
11 10
16 15
21 20
5
OFFSET
11 10
16 15
21 20
STORE ADDRESS
REG 2
REG 1
I-TYPE
16 15
REG 2
REG 1
BEQ/BNE/J
11 10
LOAD ADDRESS
REG 2
REG 1
SW
16 15
16 15
11 10
6
ADDRESS
Add
Add ALU
result
4
Shift
left 2
PC
Read
address
Instruction
Instruction
memory
Registers
Read
register 1
Read
Read
data 1
register 2
Write
register
Write
data
RegWrite
16
ALUSrc
Read
data 2
Sign
extend
M
u
x
ALU operation
Zero
ALU ALU
result
MemWrite
MemtoReg
Address
Read
data
Data
memory
Write
data
M
u
x
32
MemRead
Add
ALU
Add result
4
RegWrite
Instruction [2521]
PC
Read
address
Instruction
[310]
Instruction
memory
Instruction [2016]
1
M
u
Instruction [1511] x
0
RegDst
Instruction [150]
Read
register 1
Read
register 2
Read
data 1
Read
Write
data 2
register
Write
data Registers
16
Sign 32
extend
1
M
u
x
0
Shift
left 2
MemWrite
ALUSrc
1
M
u
x
0
ALU
control
Zero
ALU ALU
result
MemtoReg
Address
Read
data
Write Data
data memory
1
M
u
x
0
MemRead
Instruction [50]
ALUOp
SW:
1. READ INST
R/I/S-Type:
1. READ INST
BR-Type:
1. READ INST
JMP-Type:
1. READ
INST
READ REG 2
READ REG 2
READ REG 2
4. WRITE MEM 4.
5. WRITE REG2 5.
5. WRITE DST
4.
5.
3.
4.
5.
10
A
D
D
M
U
X
ADD
Shift
Left 2
M
U
X
AND
jmp
25-00
zero br
25-21
PC
IA
INST
MEMORY
20-16
INST 31-00
M
15-11 U
X
RA1
RD1
RA2 REG
FILE
WA WD RD2
WE
RDES
Sign
15-00
Ext
05-00
31-26
ALU
DATA
MEMORY
M
U
X
ALU
SRC
MA
WD
MD
MR MW
ALU
CON
ALUOP
M
U
X
Memreg
CONTROL
11
We wait for everything to settle down, and the right thing to be done
ALU might not produce right answer right away
we use write signals along with clock to determine when to write
State
element
1
Combinational logic
State
element
2
Clock cycle
12
Control Points
4
A
D
D
M
U
X
ADD
Shift
Left 2
M
U
X
AND
jmp
25-00
zero br
25-21
PC
IA
INST
MEMORY
20-16
INST 31-00
M
15-11 U
X
RA1
RD1
RA2 REG
FILE
WA WD RD2
WE
RDES
Sign
15-00
Ext
05-00
31-26
ALU
DATA
MEMORY
M
U
X
ALU
SRC
MA
WD
MD
MR MW
ALU
CON
ALUOP
M
U
X
Memreg
CONTROL
13
LW Instruction Operation
4
A
D
D
M
U
X
ADD
Shift
Left 2
M
U
X
AND
jmp
25-00
zero br
25-21
PC
IA
INST
MEMORY
20-16
INST 31-00
M
15-11 U
X
RA1
RD1
RA2 REG
FILE
WA WD RD2
WE
RDES
Sign
15-00
Ext
05-00
31-26
ALU
DATA
MEMORY
M
U
X
ALU
SRC
MA
WD
MD
MR MW
ALU
CON
ALUOP
M
U
X
Memreg
CONTROL
14
SW Instruction Operation
4
A
D
D
M
U
X
ADD
Shift
Left 2
M
U
X
AND
jmp
25-00
zero br
25-21
PC
IA
INST
MEMORY
20-16
INST 31-00
M
15-11 U
X
RA1
RD1
RA2 REG
FILE
WA WD RD2
WE
RDES
Sign
15-00
Ext
05-00
31-26
ALU
DATA
MEMORY
M
U
X
ALU
SRC
MA
WD
MD
MR MW
ALU
CON
ALUOP
M
U
X
Memreg
CONTROL
15
A
D
D
M
U
X
ADD
Shift
Left 2
M
U
X
AND
jmp
25-00
zero br
25-21
PC
IA
INST
MEMORY
20-16
INST 31-00
M
15-11 U
X
RA1
RD1
RA2 REG
FILE
WA WD RD2
WE
RDES
Sign
15-00
Ext
05-00
31-26
ALU
DATA
MEMORY
M
U
X
ALU
SRC
MA
WD
MD
MR MW
ALU
CON
ALUOP
M
U
X
Memreg
CONTROL
16
BR-Instruction Operation
4
A
D
D
M
U
X
ADD
Shift
Left 2
M
U
X
AND
jmp
25-00
zero br
25-21
PC
IA
INST
MEMORY
20-16
INST 31-00
M
15-11 U
X
RA1
RD1
RA2 REG
FILE
WA WD RD2
WE
RDES
Sign
15-00
Ext
05-00
31-26
ALU
DATA
MEMORY
M
U
X
ALU
SRC
MA
WD
MD
MR MW
ALU
CON
ALUOP
M
U
X
Memreg
CONTROL
17
A
D
D
M
U
X
ADD
Shift
Left 2
M
U
X
AND
jmp
25-00
zero br
25-21
PC
IA
INST
MEMORY
20-16
INST 31-00
M
15-11 U
X
RA1
RD1
RA2 REG
FILE
WA WD RD2
WE
RDES
Sign
15-00
Ext
05-00
31-26
ALU
DATA
MEMORY
M
U
X
ALU
SRC
MA
WD
MD
MR MW
ALU
CON
ALUOP
M
U
X
Memreg
CONTROL
18
Control
Example:
add $8, $17, $18 Instruction Format:
000000 10001 10010 01000 00000 100000
op
rs
rt
rd
shamt
funct
19
Control
Instruction
memory
Shift
left 2
RegDst
Branch
MemRead
MemtoReg
ALUO p
MemWrite
ALUSrc
RegWrite
Read
register 1
Read
address
Instruction
[31 0]
ALU
result
0
M
u
x
1
Read
data 1
Read
register 2
Registers Read
Write
data 2
register
Zero
0
M
u
x
1
Write
data
ALU
ALU
result
Address
Write
data
Instruction [15 0]
16
Sign
extend
Read
data
Data
memory
1
M
u
x
0
32
ALU
control
Instruction [5 0]
20
ALU Control
35
op
rs
rt
16 bit offset
100
AND
OR
add
subtract
set-on-less-than
21
F5
X
X
X
X
X
X
X
Funct field
F4 F3 F2 F1
X X X X
X X X X
X 0 0 0
X 0 0 1
X 0 1 0
X 0 1 0
X 1 0 1
Operation
F0
X
X
0
0
0
1
0
010
110
010
110
000
001
111
22
Implementation of Control
ALUOp
Op3
Op2
Op1
ALUcontrol block
ALUOp0
Op0
ALUOp1
Outputs
F3
F2
F(50)
Operation1
Operation
Iw
sw
beq
RegDst
ALUSrc
MemtoReg
RegWrite
F1
Operation0
F0
R-format
Operation2
MemRead
MemWrite
Branch
ALUOp1
ALUOpO
23
24
25
Add
ALU
Add result
4
RegWrite
Instruction [25 21]
PC
Read
address
Instruction
[31 0]
Instruction
memory
Read
register 1
Read
register 2
Read
data 1
Read
Write
data 2
register
Write
Registers
data
16
Sign 32
extend
1
M
u
x
0
Shift
left 2
MemWrite
ALUSrc
1
M
u
x
0
ALU
control
Zero
ALU ALU
result
MemtoReg
Address
Read
data
Data
Write
memory
data
1
M
u
x
0
MemRead
Instruction [5 0]
ALUOp
26
Design a data path for our machine specified in the next 3 slides
Single Cycle Problems:
what if we had a more complicated instruction like floating point?
wasteful of area
One Solution:
use a smaller cycle time and use different numbers of cycles
for each instruction using a multicycle datapath:
Instruction
register
PC
Address
Data
A
Memory
Data
Register #
Instruction
or data
Memory
data
register
ALU
Registers
Register #
ALUOut
B
Register #
27
Machine Specification
28
Instruction
29
30
Performance
31
Airplane
Passengers
Boeing 737-100
Boeing 747
BAC/Sud Concorde
Douglas DC-8-50
101
470
132
146
598
610
1350
544
32
Throughput
How many jobs can the machine run at once?
What is the average execution rate?
How much work is getting done?
33
Execution Time
Elapsed Time
counts everything (disk and memory accesses, I/O , etc.)
a useful number, but often not good for comparison purposes
CPU time
doesn't count I/O or time spent running other programs
can be broken up into system time, and user time
Our focus: user CPU time
time spent executing the lines of code that are "in" our program
34
Clock Cycles
program program
cycle
time
35
program program
cycle
So, to improve performance (everything else being equal) you can either
36
...
6th
5th
4th
3rd instruction
2nd instruction
time
37
time
Important point: changing the cycle time often changes the number of
cycles required for various instructions (more later)
38
39
Performance
40
# of Instructions Example
41
MIPS example
Two different compilers are being tested for a 100 MHz. machine with
three different classes of instructions: Class A, Class B, and Class
C, which require one, two, and three cycles (respectively). Both
compilers are used to produce code for a large piece of software.
The first compiler's code uses 5 million Class A instructions, 1
million Class B instructions, and 1 million Class C instructions.
The second compiler's code uses 10 million Class A instructions, 1
million Class B instructions, and 1 million Class C instructions.
42