Escolar Documentos
Profissional Documentos
Cultura Documentos
Introduction - Performance
The performance of a machine was determined by
three key factors:
Instruction Count
Clock Cycle Time
Clock Cycle per Instruction (CPI)
The compiler and the instruction set architecture
determine the instruction count required for a given
program.
Both the clock cycle time and CPI are determined
by the implementation of the processor.
Data
Register #
PC
Address
Instruction
Instruction
Registers
ALU
Address
Register #
Data
memory
memory
Register #
Data
State Elements
Unclocked vs. Clocked
Clocks used in synchronous logic
when should an element that contains state be
updated?
falling edge
cycle time
rising edge
10
11
Clocking Methodology
A clocking methodology defines when signals can be read
and when they can be written.
If a signal is written at the same time it is read, the value of
the read could correspond to the old value, the newly written
value, or even some mix of the two!
Assume an edge-triggered clocking methodology, which
means that any values stored in the machine are updated
only on a clock edge.
The state elements all update their internal storage on the
clock edge.
Because only state elements can store a data value, any
collection of combinational logic must have its inputs coming
from a set of state elements and its outputs written into a set
of state elements.
The inputs are values that were written in a previous clock
cycle, while the outputs are values that can be used in the
following clock cycle.
12
Our Implementation
An edge triggered methodology
Typical execution:
read contents of some state elements,
send values through some combinational logic
write results to one or more state elements
State
element
1
Combinational logic
State
element
2
Clock cycle
13
14
Building a Datapath
PC
Instruction
Add Sum
Instruction
memory
Address
a. Instructionmemory
5
Register
numbers
5
5
Data
b.Programcounter
Read
register 1
Read
register 2
Registers
Write
register
Write
data
c.Adder
Data
memory
16
Sign
extend
32
ALU control
Read
data 1
Data
Write
data
Read
data
Zero
ALU ALU
result
Read
data 2
MemRead
a. Data memory unit
b. Sign-extension unit
RegWrite
a. Registers
b. ALU
16
Add Sum
PC
Instruction
address
Instruction
Instruction
memory
18
Register File
R-format instructions (add, sub, slt, and, or) all
read two registers, perform an ALU operation on
the contents of the registers, and write the result.
The processors 32 registers are stored in a
structure called a register file.
A register file is a collection of registers in which
any register can be read or written by specifying
the number of the register in the file.
R-format instructions have 3 register operands, we
will need to read two data words from the register
file and write one data word into the register file for
each instruction.
19
Register File
For each data word to be read from the registers:
We need an input to the register file that
specifies the register number to be read
We need an output from the register file that will
carry the value that has been read from the
registers.
To write a data word, we need two inputs:
One to specify the register number to be written
One to supply the data to be written into the
register.
We need a total of 4 inputs (3 for register numbers
and 1 for data) and 2 outputs (both for data) as
shown in the next slide.
20
Register File
Readregister
number 1
Read register
number 1
Register 0
Register 1
Register n 1
M
u
x
Read data 1
Read
data1
Readregister
number 2
Register file
Register n
Write
register
Read register
number 2
M
u
x
Read data 2
Write
data
Read
data2
Write
21
Register File
R eg is te r n um be r
C
R e giste r 0
5 -to -32
de co d e r
30
R e giste r 1
D
31
C
R eg is te r 30
D
C
R e giste r 31
R e gister d ata
22
23
5
Register
numbers
5
5
Data
Read
register 1
Read
register 2
Registers
Write
register
Write
data
ALU control
Read
data 1
Data
Zero
ALU ALU
result
Read
data 2
RegWrite
a. Registers
b. ALU
24
L U
c o n t r o l
R e a d
re g is te r 1
R e a d
R e g is t e r
Instruction
d a ta 1
R e a d
Z
re g is te r 2
n u m b e rs
R e g is t e r s
5
D a ta
W r ite
L U
e r o
L U
r e s u l t
re g is te r
R e a d
d a ta 2
W r ite
D a ta
d a ta
R e g W rite
25
lw $t1, offset_value($t2)
sw $t1, offset_value($t2)
27
1 6
R e a d
A d d re s s
3 2
S
ig n
d a ta
e x t e n d
W rite
d a ta
D a ta
m e m o ry
M e m R e a d
a . D a ta
m e m o ry
u n it
b .
ig n - e x t e n s io n
u n it
28
29
c o n tr o l
R e ad
r e g ist e r 1
M em W rite
Read
R e g is te r
Instruction
d ata 1
R e ad
Z e ro
r e g ist e r 2
n u m b e rs
R e g is te r s
5
A L U
A L U
R ead
A ddre ss
W rite
r e s u lt
d ata
r e g ist e r
Read
d ata 2
W rite
D a ta
d a ta
W rite
D ata
da ta
m e m ory
R e g W rite
M em R ea d
1 6
S ig n
e x te n d
3 2
a. D ata m e m o ry un it
30
31
beq Instruction
There are two details in the definition of the branch
instruction (for details see chapter 3):
1. The instruction set architecture specifies that the base
for the branch address calculation is the address of the
instruction following the branch.
Since we compute PC+4 (address of next instruction), it
is easy to use this value as the base for computing the
branch target address.
2. The architecture states that the offset field is shifted
left 2 bits so that it is a word offset; this shift increase
the effective range of the offset field by a factor of four.
32
33
S um
Branch
target
Shift
left 2
A L U
R e ad
Instruction
c o n tr o l
r e g is te r 1
R e a d
d a ta 1
R e ad
r e g is te r 2
R e g is t e r s
A L U
W r ite
r e g is te r
R e a d
Z e ro
To
branch
control
logic
d a ta 2
W r ite
d a ta
R e g W r ite
16
S ig n
e x te n d
32
34
35
R ead
A L U o p e r a t io n
M e m W r ite
A L U S rc
re g is t e r 1
Load
R ead
R ead
M e m to R e g
d a ta 1
Z e ro
re g iste r 2
instruction
A LU A LU
W r ite
R ea d
re g is t e r
M
u
d a ta 2
r e s u lt
A d d re s s
d a ta
W r ite
D a ta
d a ta
W rite
R e g W r it e
32
16
R ead
Store
M
u
x
m e m ory
d a ta
S ig n
M em R ead
e x te n d
R-Type
R-Type or Load
36
Add
Sum
4
Registers
PC
Read
register 1
Instruction
address
Read
register 2
Instruction
Instruction
memory
Write
register
ALU operation
Read
data 1
Load
MemtoReg
Zero
Read
data 2
M
u
x
Write
data
ALU ALU
result
Address
Sign
32
Store
Read
data
Data
Write
RegWrite
16
MemWrite
ALUSrc
M
u
x
memory
data
MemRead
extend
R-Type
R-Type or Load
37
38
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
M
u
x
ALU operation
Zero
ALU ALU
result
MemtoReg
Address
Write
data
Sign
extend
MemWrite
Read
data
Data
memory
M
u
x
32
MemRead
39
40