Single Cycle Processor Design Guide
Single Cycle Processor Design Guide
Computer Architecture and Assembly Language ❖ The Main Controller and ALU Controller
0 zero
A
Instruction memory where instructions are stored ALU, Adder 16
Extend
32 m
u L
32
ALU result
x U overflow
Data memory where data is stored
32
Immediate extender 1
ExtOp select ALU control
❖ Registers Multiplexers
32 × 32-bit general purpose registers, R0 is always zero ❖ Storage Elements Instruction
32
Data
32
Memory
32 32 32
Read source register Rs
PC
Address Address
Instruction memory 32 Data_out
32
Instruction
Read source register Rt Data memory Memory
Data_in
RegWrite 32
MIPS Register File RW RA RB
Instruction and Data Memories
❖ Register File consists of 32 × 32-bit registers ❖ Instruction memory needs only provide read access
BusA and BusB: 32-bit output busses for reading 2 registers Because datapath does not write instructions
BusW: 32-bit input bus for writing a register when RegWrite is 1 Behaves as combinational logic for read 32
Address Instruction
32
Two registers read and one written in a cycle Address selects Instruction after access time Instruction
Register Memory
❖ Registers are selected by: 5
RA File BusA 32
❖ Data Memory is used for load and store
5
RA selects register to be read on BusA 5
RB
32 MemRead: enables output on Data_out Data
BusB
RW
RB selects register to be read on BusB ▪ Address selects the word to put on Data_out Memory
32 32
Clock
RW selects the register to be written BusW MemWrite: enables writing of Data_in 32
Address Data_out
Data_in
▪ Address selects the memory word to be written
❖ Clock input RegWrite
32
Clock
▪ The Clock synchronizes the write operation
The clock input is used ONLY during write operation
During read, register file behaves as a combinational logic block ❖ Separate instruction and data memories MemRead MemWrite
▪ RA or RB valid => BusA or BusB valid after register file’s access time Later, we will replace them with caches
RegWrite
RegWrite
ALUCtrl
+1
ALUCtrl
30
+1
30 Instruction Registers 32
Instruction Registers 32
Rs 5
Rs 5 30 Memory RA BusA
Memory 32 A
00
30 RA BusA 32
32 A Instruction
L
00
32 5
Instruction 32
32
Rt 5
RB
L 32 RB
BusB U
U Address 32
PC
Address BusB 32 Rt 5
PC
Rd 5 RW ALU result
RW ALU result BusW
BusW
ExtOp
32
Instruction Rt 5
RB
32 L 30 32
32
Address
BusB 0
m U source register Instruction Rs 5
RA BusA Data
PC
0 Memory
m u Rt data on BusB 30 32 Registers A 32
Memory 0
00
u RW BusW x m 32
Instruction
Rd x 1 or the extended 32
Rt 5
RB
L Address
32
u
x
1 32 BusB 0 U
ExtOp ALUSrc Address Data_out
immediate 1
PC
5 0 m
m u
A mux selects RW RegDst ALU result u RW BusW x Data_in
as either Rt or Rd Extender Rd x 1
32
Imm16 1
5
RegDs
RegWrite
❖ Control signals t
ALU calculates data memory address A 3rd mux selects data on BusW as
ALUCtrl is derived from either the Op or the funct field
either ALU result or memory data_out
RegWrite enables the writing of the ALU result ❖ Additional Control signals
MemRead for load instructions BusB is connected to Data_in of Data
ExtOp controls the extension of the 16-bit immediate
Memory for store instructions
RegDst selects the register destination as either Rt or Rd MemWrite for store instructions
ALUSrc selects the 2nd ALU source as BusB or extended immediate MemtoReg selects data on BusW as ALU result or Memory Data_out
+1
PCSrc +1 Imm16
zero
30 32 Instruction Rs 5
Data
Instruction Rs 5
Data RA BusA
RA BusA Memory Memory 0
30 Memory Memory 0 30 32 Registers A
00
32 A Ext m 32
Registers 32 Instruction
00
m 32 0 Rt 5 L Address u
Instruction
32
Rt 5
RB
L Address
32
u
x m RB BusB 0 U 32 x
BusB 0 U u Address Data_out 1
PC
0 m
Address Data_out 1
PC
0 m x m u
m u 1 u x Data_in
u x Data_in RW BusW
RW BusW Rd x 1
Rd x 1 1
1 32
5
5
RegDst RegWrite RegDst RegWrite
RegDst = ‘0’ selects Rt =0 =1 ALUSrc ALUCtrl J, Beq, Bne
as destination register MemRead = ‘1’ to read data memory
❖ Additional Control Signals Next PC computes
ALUSrc = ‘1’ selects extended immediate as MemtoReg = ‘1’ places the data read jump or branch target
second ALU input from memory on BusW
J, Beq, Bne for jump and branch instructions
instruction address
Zero condition of the ALU is examined
ALUCtrl = ‘ADD’ to calculate data memory RegWrite = ‘1’ to write the memory For Branch, ALU does
address as Reg(Rs) + sign-extend(Imm16) data on BusW to register Rt PCSrc = 1 for Jump & taken Branch a subtraction
Next J, Beq, Bne All instructions take as much time as the slowest
Imm26
PC ALU result
PCSrc +1 Imm16
zero ALU Instruction Fetch Reg Read ALU Reg Write
Instruction Rs 5
BusA Data
RA
30
Memory
32 A Memory 0 longest delay
Registers
00
Ext m 32
Instruction
0 Rt 5
RB
L Address
32
u
x Load Instruction Fetch Reg Read ALU Memory Read Reg Write
m 0
u Address
BusB U Data_out 1
PC
0 m
x m u
1 u x Data_in
RW BusW
Rd x 1
1 Store Instruction Fetch Reg Read ALU Memory Write
5
First 2 steps are the same for all instructions Source registers always in same place
Immediates are of same size and same location
Instruction # cycles Instruction # cycles
Operations are always on registers/immediates
ALU & Store 4 Branch 3
Load 5 Jump 2 ❖ Single cycle datapath => CPI=1, but Long Clock Cycle