0% found this document useful (0 votes)
7 views11 pages

6multicycle Datapath

The multicycle approach breaks down instructions into steps, with each step taking one clock cycle and balancing the workload across cycles. It utilizes shared functional units and introduces internal registers for data storage between cycles, allowing for efficient execution of MIPS instructions. The process includes five main steps: instruction fetch, decode/register fetch, execution/address computation, memory access, and memory read completion.

Uploaded by

jaydipshiroya12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views11 pages

6multicycle Datapath

The multicycle approach breaks down instructions into steps, with each step taking one clock cycle and balancing the workload across cycles. It utilizes shared functional units and introduces internal registers for data storage between cycles, allowing for efficient execution of MIPS instructions. The process includes five main steps: instruction fetch, decode/register fetch, execution/address computation, memory access, and memory read completion.

Uploaded by

jaydipshiroya12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Multicycle Approach

 Break up the instructions into steps


 each step takes one clock cycle
 balance the amount of work to be done in each step/cycle so that
they are about equal
 restrict each cycle to use at most once each major functional unit
so that such units do not have to be replicated
 functional units can be shared between different cycles within one
instruction
 Between steps/cycles
 At the end of one cycle store data to be used in later cycles of the
same instruction
 need to introduce additional internal (programmer-invisible)
registers for this purpose
 Data to be used in later instructions are stored in programmer-
visible state elements: the register file, PC, memory
Multicycle Approach
PCSrc

M
Add u
x
4 Add ALU
result
Shift
left 2
Registers
Read 3 ALU operation
MemWrite
Read register 1 ALUSrc
PC Read
 Note particularities of address

Instruction
Read
register 2
data 1
Zero
ALU ALU
MemtoReg

multicyle vs. single-


Write Read Address Read
register M result data
data 2 u M
Instruction u
memory Write x Data x
diagrams data
RegWrite
Write memory
data
 single memory for data 16
Sign
extend
32
MemRead

and instructions
 single ALU, no extra adders Single-cycle datapath
 extra registers to
hold data between
Instruction
clock cycles PC Address
register
Data
A
Register #
Instruction
Memory or data Registers ALU ALUOut
Memory Register #
data B
Data register Register #

Multicycle datapath (high-level view)


Multicycle Datapath
PC 0 0
M Instruction Read
[25– 21] register 1 M
u Address u
x Read x
Instruction Read A
1 Memory Zero
[20– 16] register 2 data 1 1
0 ALU ALU ALUOut
MemData Registers
Instruction M Write result
Read
[15– 0] Instruction u register data 2 B 0
Write [15– 11] x
Instruction Write 4 1 M
data 1 u
register data 2 x
Instruction 0 3
[15– 0] M
u
x
Memory 1
data 16 32
Sign Shift
register
extend left 2

Basic multicycle MIPS datapath handles R-type instructions and load/stores:


new internal register in red ovals, new multiplexors in blue ovals
Breaking instructions into steps

 Our goal is to break up the instructions into steps so that


 each step takes one clock cycle
 the amount of work to be done in each step/cycle is about equal
 each cycle uses at most once each major functional unit so that
such units do not have to be replicated
 functional units can be shared between different cycles within
one instruction
 Data at end of one cycle to be used in next must be stored !!
Breaking instructions into steps
 We break instructions into the following potential execution steps
– not all instructions require all the steps – each step takes one
clock cycle
1. Instruction fetch and PC increment (IF)
2. Instruction decode and register fetch (ID)
3. Execution, memory address computation, or branch completion (EX)
4. Memory access or R-type instruction completion (MEM)
5. Memory read completion (WB)

 Each MIPS instruction takes from 3 – 5 cycles (steps)


Step 1: Instruction Fetch &
PC Increment (IF)
 Use PC to get instruction and put it in the instruction register.
Increment the PC by 4 and put the result back in the PC.

 Can be described succinctly using RTL (Register-Transfer Language):


IR = Memory[PC];
PC = PC + 4;
Step 2: Instruction Decode and
Register Fetch (ID)
 Read registers rs and rt in case we need them.
Compute the branch address in case the instruction is a branch.

 RTL:
A = Reg[IR[25-21]];
B = Reg[IR[20-16]];
ALUOut = PC + (sign-extend(IR[15-0]) << 2);
Step 3: Execution, Address
Computation or Branch Completion
(EX)
 ALU performs one of four functions depending on instruction
type
 memory reference:
ALUOut = A + sign-extend(IR[15-0]);
 R-type:
ALUOut = A op B;
 branch (instruction completes):
if (A==B) PC = ALUOut;
 jump (instruction completes):
PC = PC[31-28] || (IR(25-0) << 2)
Step 4: Memory access or R-type
Instruction Completion (MEM)
 Again depending on instruction type:
 Loads and stores access memory
 load
MDR = Memory[ALUOut];
 store (instruction completes)
Memory[ALUOut] = B;

 R-type (instructions completes)


Reg[IR[15-11]] = ALUOut;
Step 5: Memory Read
Completion (WB)
 Again depending on instruction type:
 Load writes back (instruction completes)
Reg[IR[20-16]]= MDR;

Important: There is no reason from a datapath (or control) point


of view that Step 5 cannot be eliminated by performing
Reg[IR[20-16]]= Memory[ALUOut];
for loads in Step 4. This would eliminate the MDR as well.

The reason this is not done is that, to keep steps balanced in


length, the design restriction is to allow each step to contain
at most one ALU operation, or one register access, or one
memory access.
Summary of Instruction Execution

Step Action for R-type Action for memory-reference Action for Action for
Step name instructions instructions branches jumps
1: IF Instruction fetch IR = Memory[PC]
PC = PC + 4
Instruction A = Reg [IR[25-21]]
2: ID decode/register fetch B = Reg [IR[20-16]]
ALUOut = PC + (sign-extend (IR[15-0]) << 2)
Execution, address ALUOut = A op B ALUOut = A + sign-extend if (A ==B) then PC = PC [31-28] II
3: EX computation, branch/ (IR[15-0]) PC = ALUOut (IR[25-0]<<2)
jump completion
Memory access or R-type Reg [IR[15-11]] = Load: MDR = Memory[ALUOut]
4: MEM completion ALUOut or
Store: Memory [ALUOut] = B
5: WB Memory read completion Load: Reg[IR[20-16]] = MDR

You might also like