L6 MIPS Datapath
L6 MIPS Datapath
op rs rt offset I-Format
6 bits 26 bits
op address J-Format
Implementing MIPS: the
Fetch/Execute Cycle
• High-level abstract view of fetch/execute implementation
– use the program counter (PC) to read instruction address
– fetch the instruction from memory and increment PC
– use fields of the instruction to select registers to read
– execute depending on the instruction
– repeat…
Data
Register #
PC Address Instruction Registers ALU Address
Instruction Register #
memory Data
Register # memory
Data
Overview: Processor Implementation
Single Cycle
– perform each instruction in 1 clock cycle
– clock cycle must be long enough for slowest instruction; therefore,
– disadvantage: only as fast as slowest instruction
Multi-Cycle
– break fetch/execute cycle into multiple steps
– perform 1 step in each clock cycle
– advantage: each instruction uses only as many cycles as it needs
Pipelined
– execute each instruction in multiple steps
– perform 1 step / instruction in each clock cycle
– process multiple instructions in parallel – assembly line
For the load word instruction, we need to read only one register,
but most other instructions require that we need two registers.
Instruction
address
Add
PC
Instruction Add Sum
Instruction
4
memory
PC Read
address
a. Instruction memory b. Program counter c. Adder
Instruction
Instruction
Three elements used to store memory
PC
ADDR
Memory
RD Instruction
Datapath: R-Type Instruction
RegWrite
a. Registers b. ALU
5 5 5 Operation
3
RN1 RN2 WN
RD1
Register File ALU Zero
WD
RD2
RegWrite
Datapath: Load/Store Instruction
3 ALU operation
Read
MemWrite register 1 Read MemWrite
Read data 1
Instruction register 2 Zero
Registers ALU ALU
Address Read Write result Address Read
data 16 32 register data
Sign Read
extend Write data 2
Data data Data
Write
data memory memory
RegWrite Write
data
16 32
Sign MemRead
MemRead
extend
lw rt, offset(rs)
R[rt] MEM[R[rs] + s_extend(offset)];
Animating the Datapath
sw rt, offset(rs)
MEM[R[rs] + sign_extend(offset)] R[rt]
Datapath: Branch Instruction
ALU operation
Read 3
Instruction register 1 Read
Read data 1
register 2 To branch
Registers ALU Zero
Write control logic
register Read
Write data 2
data
RegWrite
16 32
Sign
extend
Datapath
Animating the Datapath
PC +4 from
op rs rt offset/immediate instruction
16 datapath ADD
5 5 Operation
<<2
RN1 RN2 WN
RD1
Register File ALU Zero
WD
RD2
RegWrite
16
E
X 32
beq rs, rt, offset
T
N if (R[rs] == R[rt]) then
D
PC PC+4 + s_extend(offset<<2)