600 likes | 612 Views
Implementing addi, jal, and lui instructions in the MIPS lite design. Update Register Transfer Sequences and Control Units.
E N D
CSE 3322 Computer Architecture Additional Assignments for Chapter 5 Due Mon Oct 25 1. We wish to add the MIPS instruction addi ( add immediate) to the MIPS lite design we did in class. a. Write the Register Transfer Sequences that would implement this instruction. b. Modify, if required, the ALU Control to implement this instruction c. Give the modified truth table for the ALU control signals and the States 2. We wish to add the MIPS instruction jal (jump and link) to the MIPS lite design we did in class. a. Write the Register Transfer Sequences that would implement this instruction. b. Modify, if required, the PC Control to implement this instruction c. Give the modified truth table for the PC control signals and the States 3. We wish to add the MIPS instruction lui (load upper immediate) to the MIPS lite design we did in class. a. Write the Register Transfer Sequences that would implement this instruction. b. Modify, if required, the Register File Control to implement this instruction c. Give the modified truth table for the Register File control signals and the States
Multicycle Implementation I n s t r u c t i o n r e g i s t e r D a t a P C A d d r e s s IR A R e g i s t e r # I n s t r u c t i o n A L U A L U O u t M e m o r y R e g i s t e r s o r d a t a R e g i s t e r # M e m o r y d a t a B D a t a r e g i s t e r R e g i s t e r # MDR
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S S2 A + sign_ext(IR[15-0]) ALUOut, ‘LW’S3 + ‘SW’S5 S
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S S2 A + sign_ext(IR[15-0]) ALUOut, ‘LW’S3 + ‘SW’S5 S S3 M[ ALUOut] MDR, S4 S
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S S2 A + sign_ext(IR[15-0]) ALUOut, ‘LW’S3 + ‘SW’S5 S S3 M[ ALUOut] MDR, S4 S S4 MDR R[ IR[20-16]], S0 S
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S S2 A + sign_ext(IR[15-0]) ALUOut, ‘LW’S3 + ‘SW’S5 S S3 M[ ALUOut] MDR, S4 S S4 MDR R[ IR[20-16]], S0 S S5 B M[ ALUOut], S0 S
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S S2 A + sign_ext(IR[15-0]) ALUOut, ‘LW’S3 + ‘SW’S5 S S3 M[ ALUOut] MDR, S4 S S4 MDR R[ IR[20-16]], S0 S S5 B M[ ALUOut], S0 S S6 A op B ALUOut, S7 S
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S S2 A + sign_ext(IR[15-0]) ALUOut, ‘LW’S3 + ‘SW’S5 S S3 M[ ALUOut] MDR, S4 S S4 MDR R[ IR[20-16]], S0 S S5 B M[ ALUOut], S0 S S6 A op B ALUOut, S7 S S7 ALUOut R[IR[15-11]], S0 S
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S S2 A + sign_ext(IR[15-0]) ALUOut, ‘LW’S3 + ‘SW’S5 S S3 M[ ALUOut] MDR, S4 S S4 MDR R[ IR[20-16]], S0 S S5 B M[ ALUOut], S0 S S6 A op B ALUOut, S7 S S7 ALUOut R[IR[15-11]], S0 S S8 Zero PC + Zero ALUOut PC, S0 S
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S S2 A + sign_ext(IR[15-0]) ALUOut, ‘LW’S3 + ‘SW’S5 S S3 M[ ALUOut] MDR, S4 S S4 MDR R[ IR[20-16]], S0 S S5 B M[ ALUOut], S0 S S6 A op B ALUOut, S7 S S7 ALUOut R[IR[15-11]], S0 S S8 Zero PC + Zero ALUOut PC, S0 S S9 PC[31-28] : shlt2(IR[25-0]) PC, S0 S
MEMORY CONTROL M[PC] IR M[ ALUOut] MDR B M[ ALUOut] Addr Read Data Write Data
MEMORY CONTROL M[PC] IR M[ ALUOut] MDR B M[ ALUOut] MemRead Addr Read Data Write Data MemWrite
MEMORY CONTROL M[PC] IR M[ ALUOut] MDR B M[ ALUOut] IorD MemRead PC 0 1 Addr Read Data ALUOut Write Data MemWrite
MEMORY CONTROL M[PC] IR M[ ALUOut] MDR B M[ ALUOut] IRWrite IorD MemRead IR PC 0 1 Addr Read Data ALUOut Write Data B MDR MemWrite
IorD IRWrite MemRead MemWrite S0 M[PC] IR S3 M[ ALUOut] MDR S5 B M[ ALUOut] IRWrite IorD MemRead IR PC 0 1 Addr Read Data ALUOut Write Data B MDR MemWrite
IorD IRWrite MemRead MemWrite S0 M[PC] IR 0 1 1 0 S3 M[ ALUOut] MDR S5 B M[ ALUOut] IRWrite IorD MemRead IR PC 0 1 Addr Read Data ALUOut Write Data B MDR MemWrite
IorD IRWrite MemRead MemWrite S0 M[PC] IR 0 1 1 0 S3 M[ ALUOut] MDR 1 0 1 0 S5 B M[ ALUOut] IRWrite IorD MemRead IR PC 0 1 Addr Read Data ALUOut Write Data B MDR MemWrite
IorD IRWrite MemRead MemWrite S0 M[PC] IR 0 1 1 0 S3 M[ ALUOut] MDR 1 0 1 0 S5 B M[ ALUOut] 1 0 0 1 IRWrite IorD MemRead IR PC 0 1 Addr Read Data ALUOut Write Data B MDR MemWrite
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S S2 A + sign_ext(IR[15-0]) ALUOut, ‘LW’S3 + ‘SW’S5 S S3 M[ ALUOut] MDR, S4 S S4 MDR R[ IR[20-16]], S0 S S5 B M[ ALUOut], S0 S S6 A op B ALUOut, S7 S S7 ALUOut R[IR[15-11]], S0 S S8 Zero PC + Zero ALUOut PC, S0 S S9 PC[31-28] : shlt2(IR[25-0]) PC, S0 S
REGISTER FILE CONTROL R[IR[25-21]] A, R[IR[20-16]] B MDR R[ IR[20-16]], ALUOut R[IR[15-11]], Read Reg 1 Data 1 Read Reg 2 Write Reg Data 2 Write Data
R[IR[25-21]] A, R[IR[20-16]] B MDR R[ IR[20-16]], ALUOut R[IR[15-11]], IR[25-21] Read Reg 1 A Data 1 IR[20-16] Read Reg 2 Write Reg B Data 2 Write Data
R[IR[25-21]] A, R[IR[20-16]] B MDR R[ IR[20-16]], ALUOut R[IR[15-11]], RegWrite IR[25-21] Read Reg 1 A Data 1 IR[20-16] Read Reg 2 0 1 Write Reg B Data 2 IR[15-11] RegDst Write Data ALUOut 0 1 MDR MemtoReg
RegDst MemtoReg RegWrite S1 R[IR[25-21]] A, R[IR[20-16]] B S4 MDR R[ IR[20-16]], S7 ALUOut R[IR[15-11]], RegWrite IR[25-21] Read Reg 1 A Data 1 IR[20-16] Read Reg 2 0 1 Write Reg B Data 2 IR[15-11] RegDst Write Data ALUOut 0 1 MDR MemtoReg
RegDst MemtoReg RegWrite S1 R[IR[25-21]] A, R[IR[20-16]] B x x 0 S4 MDR R[ IR[20-16]], S7 ALUOut R[IR[15-11]], RegWrite IR[25-21] Read Reg 1 A Data 1 IR[20-16] Read Reg 2 0 1 Write Reg B Data 2 IR[15-11] RegDst Write Data ALUOut 0 1 MDR MemtoReg
RegDst MemtoReg RegWrite S1 R[IR[25-21]] A, R[IR[20-16]] B x x 0 S4 MDR R[ IR[20-16]], 0 1 1 S7 ALUOut R[IR[15-11]], RegWrite IR[25-21] Read Reg 1 A Data 1 IR[20-16] Read Reg 2 0 1 Write Reg B Data 2 IR[15-11] RegDst Write Data ALUOut 0 1 MDR MemtoReg
RegDst MemtoReg RegWrite S1 R[IR[25-21]] A, R[IR[20-16]] B x x 0 S4 MDR R[ IR[20-16]], 0 1 1 S7 ALUOut R[IR[15-11]], 1 0 1 RegWrite IR[25-21] Read Reg 1 A Data 1 IR[20-16] Read Reg 2 0 1 Write Reg B Data 2 IR[15-11] RegDst Write Data ALUOut 0 1 MDR MemtoReg
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S S2 A + sign_ext(IR[15-0]) ALUOut, ‘LW’S3 + ‘SW’S5 S S3 M[ ALUOut] MDR, S4 S S4 MDR R[ IR[20-16]], S0 S S5 B M[ ALUOut], S0 S S6 A op B ALUOut, S7 S S7 ALUOut R[IR[15-11]], S0 S S8 Zero PC + Zero ALUOut PC, S0 S S9 PC[31-28] : shlt2(IR[25-0]) PC, S0 S
PC + 4 PC PC + shlt2[sign_ext(IR[15-0])] ALUOut A + sign_ext(IR[15-0]) ALUOut A op B ALUOut Zero PC + Zero ALUOut PC PC Zero ALU ALUOut ALU Control IR[0-5] ALUOp
ALU Control INSTRUCTION OP FUNCT ALUOp ALU Action ALU control add 0 32 10 add 010 subtract 0 34 10 subtract 110 AND 0 36 10 and 000 OR 0 37 10 or 001 set on less than 0 42 10 slt 111 load word 35 na 00 add 010 store word 43 na 00 add 010 branch equal 4 na 01 subtract 110 ALUOp = 10 if the operation depends on the funct field 00 if add 01 if subtract
PC + 4 PC PC + shlt2[sign_ext(IR[15-0])] ALUOut A + sign_ext(IR[15-0]) ALUOut A op B ALUOut Zero PC + Zero ALUOut PC PC Zero ALU ALUOut ALU Control IR[5-0] ALUOp
PC + 4 PC PC + shlt2[sign_ext(IR[15-0])] ALUOut A + sign_ext(IR[15-0]) ALUOut A op B ALUOut Zero PC + Zero ALUOut PC PC PC 0 1 A Zero ALUSrcA ALU ALUOut ALU Control IR[5-0] ALUOp
PC + 4 PC PC + shlt2[sign_ext(IR[15-0])] ALUOut A + sign_ext(IR[15-0]) ALUOut A op B ALUOut Zero PC + Zero ALUOut PC PC PC 0 1 A Zero ALUSrcA ALU B 0 1 2 3 ALUOut 4 sign_ext(IR[15-0]) shlt2 ALU Control ALUSrcB IR[5-0] ALUOp
ALUSrcA ALUSrcB S0 PC + 4 PC S1 PC + shlt2[sign_ext(IR[15-0])] ALUOut S2 A + sign_ext(IR[15-0]) ALUOut S6 A op B ALUOut S8 Zero PC + Zero ALUOut PC PC PC 0 1 A Zero ALUSrcA ALU B 0 1 2 3 ALUOut 4 sign_ext(IR[15-0]) shlt2 ALU Control ALUSrcB IR[5-0] ALUOp
ALUSrcA ALUSrcB S0 PC + 4 PC 0 01 S1 PC + shlt2[sign_ext(IR[15-0])] ALUOut S2 A + sign_ext(IR[15-0]) ALUOut S6 A op B ALUOut S8 Zero PC + Zero ALUOut PC PC PC 0 1 A Zero ALUSrcA ALU B 0 1 2 3 ALUOut 4 sign_ext(IR[15-0]) shlt2 ALU Control ALUSrcB IR[5-0] ALUOp
ALUSrcA ALUSrcB S0 PC + 4 PC 0 01 S1 PC + shlt2[sign_ext(IR[15-0])] ALUOut 0 11 S2 A + sign_ext(IR[15-0]) ALUOut S6 A op B ALUOut S8 Zero PC + Zero ALUOut PC PC PC 0 1 A Zero ALUSrcA ALU B 0 1 2 3 ALUOut 4 sign_ext(IR[15-0]) shlt2 ALU Control ALUSrcB IR[5-0] ALUOp
ALUSrcA ALUSrcB S0 PC + 4 PC 0 01 S1 PC + shlt2[sign_ext(IR[15-0])] ALUOut 0 11 S2 A + sign_ext(IR[15-0]) ALUOut 1 10 S6 A op B ALUOut S8 Zero PC + Zero ALUOut PC PC PC 0 1 A Zero ALUSrcA ALU B 0 1 2 3 ALUOut 4 sign_ext(IR[15-0]) shlt2 ALU Control ALUSrcB IR[5-0] ALUOp
ALUSrcA ALUSrcB S0 PC + 4 PC 0 01 S1 PC + shlt2[sign_ext(IR[15-0])] ALUOut 0 11 S2 A + sign_ext(IR[15-0]) ALUOut 1 10 S6 A op B ALUOut 1 00 S8 Zero PC + Zero ALUOut PC PC PC 0 1 A Zero ALUSrcA ALU B 0 1 2 3 ALUOut 4 sign_ext(IR[15-0]) shlt2 ALU Control ALUSrcB IR[5-0] ALUOp
ALUSrcA ALUSrcB S0 PC + 4 PC 0 01 S1 PC + shlt2[sign_ext(IR[15-0])] ALUOut 0 11 S2 A + sign_ext(IR[15-0]) ALUOut 1 10 S6 A op B ALUOut 1 00 S8 Zero PC + Zero ALUOut PC 1 00 PC PC 0 1 A Zero ALUSrcA ALU B 0 1 2 3 ALUOut 4 sign_ext(IR[15-0]) shlt2 ALU Control ALUSrcB IR[5-0] ALUOp
ALUOp S0 PC + 4 PC 00 add S1 PC + shlt2[sign_ext(IR[15-0])] ALUOut 00 add S2 A + sign_ext(IR[15-0]) ALUOut 00 add S6 A op B ALUOut 10 funct S8 Zero PC + Zero ALUOut PC 01 sub PC PC 0 1 A Zero ALUSrcA ALU B 0 1 2 3 ALUOut 4 sign_ext(IR[15-0]) shlt2 ALU Control ALUSrcB IR[5-0] ALUOp
State Register Transfers S0 M[PC] IR, PC + 4 PC, S1 S S1 R[IR[25-21]] A, R[IR[20-16]] B, PC + shlt2[sign_ext(IR[15-0])] ALUOut, (‘LW’+’SW’)S2 + ‘R’S6 + ‘BEQ’S8 + ‘J’S9 S S2 A + sign_ext(IR[15-0]) ALUOut, ‘LW’S3 + ‘SW’S5 S S3 M[ ALUOut] MDR, S4 S S4 MDR R[ IR[20-16]], S0 S S5 B M[ ALUOut], S0 S S6 A op B ALUOut, S7 S S7 ALUOut R[IR[15-11]], S0 S S8 Zero PC + Zero ALUOut PC, S0 S S9 PC[31-28] : shlt2(IR[25-0]) PC, S0 S
PC + 4 PC Zero PC + Zero ALUOut PC PC[31-28] : shlt2(IR[25-0]) PC PC PCWrite + PCWriteCond * Zero
PC + 4 PC Zero PC + Zero ALUOut PC PC[31-28] : shlt2(IR[25-0]) PC ALU Result 0 1 2 PC PCWrite + PCWriteCond * Zero PCSource
PC + 4 PC Zero PC + Zero ALUOut PC PC[31-28] : shlt2(IR[25-0]) PC ALU Result 0 1 2 ALUOut PC PCWrite + PCWriteCond * Zero PCSource
PC + 4 PC Zero PC + Zero ALUOut PC PC[31-28] : shlt2(IR[25-0]) PC ALU Result 0 1 2 ALUOut PC PC[31-28] : shlt2(IR[25-0]) PCWrite + PCWriteCond * Zero PCSource
PCSource PCWrite PCWriteCond S0 PC + 4 PC S8 Zero PC + Zero ALUOut PC S9 PC[31-28] : shlt2(IR[25-0]) PC ALU Result 0 1 2 ALUOut PC PC[31-28] : shlt2(IR[25-0]) PCWrite + PCWriteCond * Zero PCSource
PCSource PCWrite PCWriteCond S0 PC + 4 PC 00 1 x S8 Zero PC + Zero ALUOut PC S9 PC[31-28] : shlt2(IR[25-0]) PC ALU Result 0 1 2 ALUOut PC PC[31-28] : shlt2(IR[25-0]) PCWrite + PCWriteCond * Zero PCSource
PCSource PCWrite PCWriteCond S0 PC + 4 PC 00 1 x S8 Zero PC + Zero ALUOut PC 01 0 1 S9 PC[31-28] : shlt2(IR[25-0]) PC ALU Result 0 1 2 ALUOut PC PC[31-28] : shlt2(IR[25-0]) PCWrite + PCWriteCond * Zero PCSource