MIPS Single-Cycle CPU
MIPS Single-Cycle CPU
Group 22B
Nguyễn Bình Nam
Hồ Anh Trang
Nguyễn Bảo Trung
MIPS Single-Cycle CPU
• design a simple 32-bit MIPS Single-Cycle
CPU.
• The design includes support for execution of:
- memory-reference instructions: lw, sw
- arithmetic-logical instructions: add, sub,
slt,xori
- control flow instructions: bne, j, jr
MIPS Single-Cycle CPU
- CPU executes each instruction in only one
clock cycle time.
- a clock cycle time must be chosen such that
the longest instruction can be executed in one
clock cycle.
- Require 2 memories( data and instruction).
MIPS Single-Cycle CPU
• Generic implementation
- Use the program counter (PC) to supply
instruction address.
- Get the instruction from memory.
- Read registers.
- Use the instruction to decide exactly what to
do.
MIPS Single-Cycle CPU
Building
Blocks
MIPS Single-Cycle CPU
MIPS Single-Cycle CPU
• R-Type: op=0
• 31:26 • 25:21 • 20:16 • 15:11 • 10:6 • 5:0
• op • rs • rt • rd • shamt • funct
• Load/Store: op=35 or 43
• 31:26 • 25:21 • 20:16 • 15:0
• op • rs • rt • address
• Jump: op=2
• 31:26 • 25:0
• op • target
MIPS Single-Cycle CPU Design
- Data memory.
- Instructions memory.
- Register file.
- ALU.
- PC Block.
- Control block.
- Extend-sign block and shift-left2 block.
MIPS Single-Cycle CPU Design
- Data memory.
- Instructions memory.
- Register file.
- ALU.
PC Block.
- Control block.
- Extend-sign block and shift-left2 block.
PC block
Fetching instructions:
• ADD, SUB, SLT, XORI, LW, SW:
PC’ = PC +4
• BNE:
PC’ = PC + 4 + offset x 4
• J:
PC’ = PC[32-28]_26bit target_00
• Jr:
PC’ = rs x 4
PC block
MIPS Single-Cycle CPU Design
- Data memory.
- Instructions memory.
- Register file.
- ALU.
- PC Block.
Control block.
- Extend-sign block and shift-left2 block.
Control block
- Select the registers to be read (always read
two)
- Select the 2nd ALU input
- Select the operation to be performed by ALU
- Select if data memory is to be read or written
- Select what is written and where in the register
file
- Select what goes in PC
Control block
Control block
Control block
Control block
module Control(Opcode, //Input
RegDst,Jump,Branch,MemRead,MemtoReg, //Output
ALUOp,MemWrite,ALUSrc,RegWrite,Extend //Output
);
input [5:0] Opcode;
output RegDst, Jump, Branch, MemRead, MemtoReg, MemWrite, ALUSrc, RegWrite, Extend;
output [1:0] ALUOp;
reg RegDst1,Jump1,Branch1,MemRead1,MemtoReg1,MemWrite1,ALUSrc1,RegWrite1,Extend1;
reg [1:0] ALUOp1;
Simulation