Professional Documents
Culture Documents
Datapath & Control Design: We Will Design A Simplified MIPS Processor The Instructions Supported Are
Datapath & Control Design: We Will Design A Simplified MIPS Processor The Instructions Supported Are
Datapath & Control Design: We Will Design A Simplified MIPS Processor The Instructions Supported Are
1
What blocks we need
• 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
2
Simple Implementation
ALU control
5 Read 3 MemRead
register 1
Read
Register 5 data 1 a. Data memory unit b. Sign-extension unit
Read
numbers register 2 Zero
Registers Data ALU ALU
5 Write result
register
Read Why do we need this stuff?
Write data 2
Data data
RegWrite
a. Registers b. ALU
3
More Implementation Details
Data
Register #
PC Address Instruction Registers ALU Address
Register #
Instruction
memory Data
Register # memory
Data
4
Managing State Elements
falling edge
cycle time
rising edge
5
MIPS Instruction Format
31 26 25 21 20 16 15 11 10 6 5 0
31 26 25 21 20 16 15 11 10 6 5 0
31 26 25 21 20 16 15 11 10 6 5 0
31 26 25 21 20 16 15 11 10 6 5 0
31 26 25 21 20 16 15 11 10 6 5 0
31 26 25 21 20 16 15 11 10 6 5 0
6
Building the Datapath
PCSrc
M
Add u
x
4 Add ALU
result
Shift
left 2
Registers
Read 3 ALU operation
MemWrite
Read register 1 ALUSrc
PC Read
address Read data 1 MemtoReg
register 2 Zero
Instruction ALU ALU
Write Read Address Read
register M result data
data 2 u M
Instruction u
memory Write x Data x
data memory
Write
RegWrite data
16 32
Sign
extend MemRead
7
A Complete Datapath for R-Type Instructions
1
Add M
u
x
4 ALU 0
Add result
RegWrite Shift
left 2
Instruction [5–0]
ALUOp
8
What Else is Needed in Data Path
9
Operation for Each Instruction
10
Data Path Operation
4 A M
D U M
D ADD X U
Shift X
Left 2
AND
jmp
25-00
zero br
25-21 RA1
PC INST RD1
IA
MEMORY 20-16 RA2 REG
INST 31-00 FILE ALU MA
M DATA
WA WD RD2 M MEMORY
15-11 U U
X WE WD MD
X
MR MW M
RDES
ALU U
15-00 Sign ALU
SRC X
Ext CON
05-00 ALUOP Memreg
31-26
CONTROL
11
Our Simple Control Structure
State State
element Combinational logic element
1 2
Clock cycle
4 A M
D U M
D ADD X U
Shift X
Left 2
AND
jmp
25-00
zero br
25-21 RA1
PC INST RD1
IA
MEMORY 20-16 RA2 REG
INST 31-00 FILE ALU MA
M DATA
WA WD RD2 M MEMORY
15-11 U U
X WE WD MD
X
MR MW M
RDES
ALU U
15-00 Sign ALU
SRC X
Ext CON
05-00 ALUOP Memreg
31-26
CONTROL
13
LW Instruction Operation
4 A M
D U M
D ADD X U
Shift X
Left 2
AND
jmp
25-00
zero br
25-21 RA1
PC INST RD1
IA
MEMORY 20-16 RA2 REG
INST 31-00 FILE ALU MA
M DATA
WA WD RD2 M MEMORY
15-11 U U
X WE WD MD
X
MR MW M
RDES
ALU U
15-00 Sign ALU
SRC X
Ext CON
05-00 ALUOP Memreg
31-26
CONTROL
14
SW Instruction Operation
4 A M
D U M
D ADD X U
Shift X
Left 2
AND
jmp
25-00
zero br
25-21 RA1
PC INST RD1
IA
MEMORY 20-16 RA2 REG
INST 31-00 FILE ALU MA
M DATA
WA WD RD2 M MEMORY
15-11 U U
X WE WD MD
X
MR MW M
RDES
ALU U
15-00 Sign ALU
SRC X
Ext CON
05-00 ALUOP Memreg
31-26
CONTROL
15
R-Type Instruction Operation
4 A M
D U M
D ADD X U
Shift X
Left 2
AND
jmp
25-00
zero br
25-21 RA1
PC INST RD1
IA
MEMORY 20-16 RA2 REG
INST 31-00 FILE ALU MA
M DATA
WA WD RD2 M MEMORY
15-11 U U
X WE WD MD
X
MR MW M
RDES
ALU U
15-00 Sign ALU
SRC X
Ext CON
05-00 ALUOP Memreg
31-26
CONTROL
16
BR-Instruction Operation
4 A M
D U M
D ADD X U
Shift X
Left 2
AND
jmp
25-00
zero br
25-21 RA1
PC INST RD1
IA
MEMORY 20-16 RA2 REG
INST 31-00 FILE ALU MA
M DATA
WA WD RD2 M MEMORY
15-11 U U
X WE WD MD
X
MR MW M
RDES
ALU U
15-00 Sign ALU
SRC X
Ext CON
05-00 ALUOP Memreg
31-26
CONTROL
17
Jump Instruction Operation
4 A M
D U M
D ADD X U
Shift X
Left 2
AND
jmp
25-00
zero br
25-21 RA1
PC INST RD1
IA
MEMORY 20-16 RA2 REG
INST 31-00 FILE ALU MA
M DATA
WA WD RD2 M MEMORY
15-11 U U
X WE WD MD
X
MR MW M
RDES
ALU U
15-00 Sign ALU
SRC X
Ext CON
05-00 ALUOP Memreg
31-26
CONTROL
18
Control
op rs rt rd shamt funct
19
Adding Control to DataPath
0
M
u
x
Add ALU 1
result
Add Shift
RegDst left 2
4 Branch
MemRead
Instruction [31– 26] MemtoReg
Control ALUO p
MemWrite
ALUSrc
RegWrite
Instruction [5– 0]
•
35 2 1 100
op rs rt 16 bit offset
000 AND
001 OR
010 add
110 subtract
111 set-on-less-than
21
Other Control Information
Inputs
Op5
Op4
ALUOp Op3
Op2
ALUcontrol block
Op1
ALUOp0 Op0
ALUOp1
Outputs
ALUOpO
23
A Complete Datapath with Control
24
Datapath with Control and Jump Instruction
25
Timing: Single Cycle Implementation
1
Add M
u
x
4 ALU 0
Add result
RegWrite Shift
left 2
ALUOp
26
Where we are headed
• 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
Data
PC Address
A
Register #
Instruction
Memory or data Registers ALU ALUOut
Memory Register #
data B
Data register Register #
27
Machine Specification
28
Instruction
29
Instruction bits needed
30
Performance
31
Which of these airplanes has the best performance?
32
Computer Performance: TIME, TIME, TIME
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
34
Clock Cycles
time
35
How to Improve Performance
So, to improve performance (everything else being equal) you can either
36
How many cycles are required for a program?
2nd instruction
3rd instruction
1st instruction
4th
5th
6th
...
time
Why? hint: remember that these are machine instructions, not lines of C code
37
Different numbers of cycles for different instructions
time
• Important point: changing the cycle time often changes the number of
cycles required for various instructions (more later)
38
Now that we understand cycles
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.
42