MIPS流水线笔记

  • 非流水线下,指令的常规操作:
    • IF
      • IR<- Mem[PC]
      • NPC<- PC+4
    • ID-instruction decode and register fetch step
      • A<- Regs[IR6..10]
      • B<- Regs[IR11..16]
        • 可能读取的寄存器值没有用,但没关系;译码后如果没用,以后操作就不用
      • Imm<- ((IR16)16)##IR16-31
    • EX,根据译码结果分为四种情况
      • Memory reference
        • ALUOUTPUT<- A+(IR16)16 ## IR16..31---effective address
        • SMD<- B---data to be written if it is a store---SMD(MDR)
      • R-R ALU instruction
        • ALUOUTPUT<- A op B
      • R-I ALU instruction
        • ALUOUTPUT<- A op((IR16)16)## IR16..31
      • Branch/Jump
        • ALUOutput<- NPC+(IR16)16##IR16..31
        • cond <- A op 0;for conditional branches A's value is the condition base(for BEQZ);
    • MEM-memory access/branch completion
      • memory reference
        • LMD<- Mem[ALUOutput];if it's a load
        • Mem[ALUOutput]<- SMD;
      • branch
        • if (cond) then PC<- ALUOutput else PC<- NPC
    • WB
      • R-R ALU (这种指令没有访存)
        • Regs[IR16..20]<- ALUOutput
      • R-I ALU
        • Regs[IR11..15]<- ALUOutput
      • Load
        • Regs[IR11..15]<-LMD
  • 流水线正常工作的基本条件
    • 增加寄存器文件保存当前段传送到下一段的数据和控制信息
    • 存储器带宽是非流水的5倍
  • MIPS流水线笔记_第1张图片
    • IF

      IF/ID.IR<-MEM[PC];

      IF/ID.NPC,PC <- if((EX/MEM.opcode == branch) & EX/MEM.cond) then EX/MEM.ALUOutput else PC+4

      ID

      ID/EX.A<-Regs[IF/ID.IR[rs]];   ;ID/EX.B<- Regs[IF/ID.IR[rt]];

      ID/EX.NPC<-IF/ID.NPC;  ;ID/EX.IR<- IF/ID.IR

      ID/EX.Imm<- sign-extend(IF/ID.IR[immediate field]);

        ALU instruction LOAD or Store Branch instruction
      EX

      EX/MEM.IR<- ID/EX.IR;

      EX/MEM.ALUOutput<- ID/EX.A func ID/EX.B; or

      EX/MEM.ALUOutput<- ID/EX.A op ID/EX.Imm;

      EX/MEM.IR<- ID/EX.IR

      EX/MEM.ALUOutput<- ID/EX.A+ID/EX.Imm

      EX/MEM.B<- ID/EX.B

      EX/MEM.ALUOutput<- ID/EX.NPC+(ID/EX.Imm << 2);

      EX/MEM.cond<- (ID/EX.A == 0)

      MEM

      MEM/WB.IR<- EX/MEM.IR;

      MEM/WB.ALUOutput<- EX/MEM.ALUOutput;

      MEM/WB.IR<- EX/MEM.IR;

      MEM/WB.LMD<- Mem[EX/MEM.ALUOoutput];or

      Mem[EX/MEM.ALUOutput]<- EX/MEM.B;(store)

       
      WB

      Regs[MEM/WB.IR[rd]]<- MEM/WB.ALUOutput; or

      Regs[MEM/WB.IR[rt]]<- MEM/WB.ALUOutput;

      Regs[MEM/WB.IR[rt]]<- MEM/WB.LMD

      ;for load only

       
  • 三种类型的指令
    • I
    • J
    • R
  • 数据相关
    • 采用定向技术解决(将EX/MEM,MEM/WB寄存器都和ALU输入端相连)
    • MIPS流水线笔记_第2张图片
    • 定向源的判定
      • 定向源位R-R ALU操作的定向比较判断
      • MIPS流水线笔记_第3张图片
  • d
  • dd
  • d
  • d

 

你可能感兴趣的:(MIPS流水线笔记)