Beruflich Dokumente
Kultur Dokumente
Main Objectives
Introduction to MIPS Architecture MIPS Architecture Based Single Cycle Processor Datapath Design Control Unit Design
Revision
Remember these Names ? Register File ALU Instruction Memory Data Memory Program Counter Instruction Set Architecture (ISA)
Design of Processor
1. Analyze the instruction set architecture 2. Select the datapath elements each instruction needs 3. Assemble the datapath 4. determine the controls required 5. Assemble the control logic
beq
Branch Equal
Jump
Registers in MIPS
Instruction Formats
R-Type Instruction Fromat(add,sub,or)
31-26 25-21 20-16 15-11 Write reg. 10-6 Not Used 5-0 To ALU Control
Opcode
To ctrl logic
RS
Read reg. A
RT
Read reg. B
RD ShAmt Function
Opcode
To ctrl logic
RS
Read reg. A
RT
Write reg./ Read reg. B
Immediate Data
Memory address or Branch Offset
Arithmetic/logical instr for operation execution lw/sw for address calculation beq for comparison lw/sw read or write to memory Arithmetic/logical instr write to register beq updates PC
13
14
15
16
Register File
Consists of a set of 32 registers that can be read and written has two read ports and one write port Register number are 5 bit long To write, you need three inputs:
a register number, the data to write, and a clock (not shown explicitly) that controls the writing into the register The register content will change on clock edge
5 5 5
17
R-format
31-26 opcode
25-21 rs
20-16 rt
15-11 rd
10-6 shamt
5-0 funct
18
19
Memory Unit
MemRead to be asserted to read MemWrite to be asserted to write Both MemRead and MemWrite not to be asserted in same clock cycle Memory is edge triggered for writes
Address
MemRead
ReadData
Write Data
MemWrite
20
I-format
31-26
opcode rs
rt
offset
I-format
31-26
opcode rs
offset
I-format
31-26
opcode rs
rs rt
31-26
C
25-21 rs
20-16 rt
15-0 C
24
opcode
If ($rs-$rt)=0, PC=PC+4+(C.4)
25
26
27
P C
Instruction Memory
28
29
30
ALU Operation
31
Instruction
RegDst
RegWrite
ALUSrc
MemRead
MemWrite
MemToReg
PCSrc
ALU operation
R-format
0000(and) 0001(or) 0010(add) 0110(sub) 0010 (add) 0010 (add) 0110 (sub)
lw sw beq
0 X x
1 0 0
1 1 0
1 0 0
0 1 0
1 X X
0 0 1 or 0
32
Control
We next add the control unit that generates
write signal for each state element control signals for each multiplexer ALU control signal
33
Control Unit
Divided into two parts
Main Control Unit
Input: 6-bit opcode Output: all control signals for Muxes, RegWrite, MemRead, MemWrite and a 2-bit ALUOp signal
34
Add
Add
Read reg. num A A reg num Read reg data A Read reg num B
PC
Registers
Instruction Memory
Zero Result 0 1
Data Memory
1 0
Write data
16
MemoryRead/Write/neither?
Control Signals
1. RegDst = 0 => Register destination number for the Write register comes from the rt field (bits 20-16) RegDst = 1 => Register destination number for the Write register comes from the rd field (bits 15-11) 2. RegWrite = 1 => The register on the Write register input is written with the data on the Write data input (at the next clock edge) 3. ALUSrc = 0 => The second ALU operand comes from Read data 2 ALUSrc = 1 => The second ALU operand comes from the signextension unit 4. PCSrc = 0 => The PC is replaced with PC+4 PCSrc = 1 => The PC is replaced with the branch target address 5. MemtoReg = 0 => The value fed to the register write data input comes from the ALU MemtoReg = 1 => The value fed to the register write data input comes from the data memory 6. MemRead = 1 => Read data memory 7. MemWrite = 1 => Write data memory
36
37
38
39
40
41