The simplified DLX The datapath control story What

  • Slides: 35
Download presentation
The simplified DLX The datapath & control story: What happens in each control state.

The simplified DLX The datapath & control story: What happens in each control state.

The Datapath consists of several environments, buses, registers and multiplexers. At the right there

The Datapath consists of several environments, buses, registers and multiplexers. At the right there is a general scheme of the entire Datapath (no drivers, only muxes). datapath. pdf

What is RTL? RTL = Register Transfer Language The RTL describes the operations done

What is RTL? RTL = Register Transfer Language The RTL describes the operations done in each Control’s state in terms of “what is written to the registers”. Note: This description is just of the functionality and not of the way of implementation. Examples: • IR=M[PC] • A=RS 1 • B=RS 2 • PC=PC+1

The Control is a state machine that consists of 20 states. The Control’s signals

The Control is a state machine that consists of 20 states. The Control’s signals control the data flow. fsd_idlx. pdf

What happens during Fetch state? Din Reminder… Memory Env. Dout IR IR Env. 1)

What happens during Fetch state? Din Reminder… Memory Env. Dout IR IR Env. 1) The PC register contains the address. Adr W Busy PC MR Was the mission completed? Control Sample! 2) The desired functionality: IR M[PC] 3) The memory is very slow. It announces: “I’m busy” after getting a read / write request. When busy, no new requests are allowed. As Dout stablizes, the memory announces: “I’m done”. Only then the control asks the IR Env. to sample Dout’s value and update the IR register. Fetch The Control usually stays in fetch state for more than one clock cycle

The Control (Cont. ) In our explanation about the different states we also describe

The Control (Cont. ) In our explanation about the different states we also describe the RTL instructions that correspond to each state of the Control. Let’s start: 1) Fetch. RTL Instruction: IR=M[PC] Action: The instruction pointed to by the PC is read from the memory and is stored to the IR register. The Fetch state might last more than one clock cycle. The DLX stays in this state as long the “busy” signal is active. Memory Read Active Control Signals: IRce, PCAOdoe, MR IR’s Clock Enable The PC Env. address out’s driver is enabled

The Control (Cont. ) 2) Decode. RTL Instructions: A=RS 1 B=RS 2 PC=PC+1 The

The Control (Cont. ) 2) Decode. RTL Instructions: A=RS 1 B=RS 2 PC=PC+1 The ALU’s output value’s (PC+1) driver is enabled Actions: The contents of the RS 1 and RS 2 (if needed) registers are stored in the A and B registers (that are located in the GPR Env. ) and the PC’s register value is incremented by 1 (to point to the next instruction). PC’s clock enable (for storing the new PC) Active Control Signals: Ace, Bce, PCS 1 doe, 1 S 2 doe, ALUDINTdoe, Add, PCce PC’s value’s driver is enabled and the PC is outputted to S 1 1’s const value’s driver is enabled and this value is outputted to S 2

What happens during Execute state (Cont. )? : A. Arithmetic/Logic instructions Reminder… C Cce

What happens during Execute state (Cont. )? : A. Arithmetic/Logic instructions Reminder… C Cce GPR Env. A IR Env. B Sext (Imm. ) 1 ALU Env. Result 0 ITYPE ALU Control signals

The Control (Cont. ) 3) ALU. RTL Instruction: C=A op B Action: An arithmetic

The Control (Cont. ) 3) ALU. RTL Instruction: C=A op B Action: An arithmetic operation is done on the arguments (which are the contents of the A and B registers). The result is stored in the C register in the GPR Env. Active Control Signals: AS 1 doe, BS 2 doe, OPALU, ALUDINTdoe, Cce The A register’s value’s driver is enabled and its value is outputted to S 1 The B register’s value’s driver is enabled and its value is outputted to S 2 The name of a group of signals

The Control (Cont. ) 4) ALUI (Add). RTL Instruction: C=A + imm. Action: The

The Control (Cont. ) 4) ALUI (Add). RTL Instruction: C=A + imm. Action: The sum of the addition of the value of the A register in the GPR Env. and the immediate’s value is stored in the C register in the GPR Env. Active Control Signals: AS 1 doe, IRS 2 doe, OPALU, ALUDINTdoe, Cce The IR register’s value’s driver is enabled and its value (=immediate) is outputted to S 2

The Control (Cont. ) 5) Shift. I. RTL Instruction: C=Shift. Left A / Shift.

The Control (Cont. ) 5) Shift. I. RTL Instruction: C=Shift. Left A / Shift. Right A Action: The value of the A register is being shifted one step right or left. The direction is determined by IR[1]. Active Control Signals: AS 1 doe, Cce, shift (left or right). In a general shifter: the shift amount is coded in IR…

What happens during Execute state (Cont. )? Reminder… : B. Test&Set instructions Sgri: RD

What happens during Execute state (Cont. )? Reminder… : B. Test&Set instructions Sgri: RD (RS 1 > Sext(Imm) ? 1 : 0) C Cce GPR Env. A IR Env. B (. Sext (Imm 1 Alway s 0/1 Result ALU Env. ITYPE 0 TEST Two stages: 1) execute C (RS 1 > RS 2 ? 1: 0) 2) writeback RD C In this way the period time is shorter.

The Control (Cont. ) 6) Test. I RTL Instruction: C=A rel imm. Action: A

The Control (Cont. ) 6) Test. I RTL Instruction: C=A rel imm. Action: A logic operation is done on the arguments (which are the contents of the A register and the immediate value that is supplied by co in the IR Env. ). The result is stored in the C register in the GPR Env. Active Control Signals: AS 1 doe, IRS 2 doe, Cce, ALUDINTdoe, test Comparison to be conducted: can be extracted from last 3 bits in the opcode.

What happens during Execute state (Cont. )? 3) Jump instructions: Reminder… A. Unconditional jump:

What happens during Execute state (Cont. )? 3) Jump instructions: Reminder… A. Unconditional jump: Jump Reg (jr): PC A No direct path from A to PC. Instead: GPR Env. IR Env. A 0 ALU Env. ADD PC PC Env. Cce

The Control (Cont. ) 8) JR. RTL Instruction: PC=A Action: In this state that

The Control (Cont. ) 8) JR. RTL Instruction: PC=A Action: In this state that deals with jumping, the PC register gets the address of the instruction to jump to. This address is stored in the A register in the GPR Env. Active Control Signals: AS 1 doe, 0 S 2 doe, add, ALUDINTdoe, PCce

What happens during Execute state (Cont. )? C. Calling a routine: ”Jump, remember your

What happens during Execute state (Cont. )? C. Calling a routine: ”Jump, remember your address so it will be possible to get back to this address” jalr: R 31 PC+1 PC RS 1 We use two Control states in order to execute this instruction because we want to avoid a collision in the buses (to be elaborated). Reminder…

What happens during Execute state (Cont. )? Reminder… State I: Copying the PC (2

What happens during Execute state (Cont. )? Reminder… State I: Copying the PC (2 clock cycles) Clock cycle 1 (save. PC): C PC PC Env. GPR Env. Cce Clock cycle 2 (like in the Write-Back state): C GPR Env. R 31 !Write The address=31

What happens during Execute state (Cont. )? State II (JALR): Calculating the jump address

What happens during Execute state (Cont. )? State II (JALR): Calculating the jump address Cce PC PC Env. Reminder… GPR Env. IR Env. 0 A ALU Env. ADD

The Control (Cont. ) 9) Save. PC. RTL Instruction: C=PC Action: The PC is

The Control (Cont. ) 9) Save. PC. RTL Instruction: C=PC Action: The PC is stored in the C register in the GPR Env. Active Control Signals: PCS 1 doe, 0 S 2 doe, add, ALUDINTdoe, Cce

The Control (Cont. ) 17) JALR. RTL Instructions: PC=A R 31=C (=old PC) Actions:

The Control (Cont. ) 17) JALR. RTL Instructions: PC=A R 31=C (=old PC) Actions: In this state that deals with jumping, the PC’s current value is stored in the 31’st register in the GPR and the address of the instruction we jump to is stored in the PC and comes from the A register in the GPR. Active Control Signals: AS 1 doe, 0 S 2 doe, ALUDINTdoe, add, PCce, GPR_WE, Jlink

What happens during Execute state (Cont. )? Reminder… B. Branch: “Jump only if a

What happens during Execute state (Cont. )? Reminder… B. Branch: “Jump only if a condition is satisfied” beqz: PC PC+1+(RS 1=0 ? Sext (Imm. ) : 0) bnez: PC PC+1+(RS 1=0 ? 0 : Sext (Imm. )) : We’ll demonstrate the beqz instruction. Two states are needed State I - Branch: Check the condition – RS 1=0 ? Sext (Imm. ) : 0 GPR Env. IR Env. A 0 ALU Env. TEST Comparison result To the Control

The Control (Cont. ) 10) Branch. RTL Instruction: Branch taken? Active Control Signals: AS

The Control (Cont. ) 10) Branch. RTL Instruction: Branch taken? Active Control Signals: AS 1 doe, 0 S 2 doe, test Action: In the Beqz and Bnez instructions, when reaching this state, a check of the A register’s value is done. According to this check, a path to continue with is determined.

What happens during Execute state (Cont. )? The next state Reminder… o N um

What happens during Execute state (Cont. )? The next state Reminder… o N um p Ju m J p BTaken Fetch State II - BTaken: Calculating the jump – PC PC+1+(Result of state I) PC Cce IR Env. PC Env. PC t( x e S (. ALU Env. Imm ADD

The Control (Cont. ) 18) BTaken. RTL Instruction: PC=PC+imm. Action: The PC gets the

The Control (Cont. ) 18) BTaken. RTL Instruction: PC=PC+imm. Action: The PC gets the address of the next instruction to be executed. The address is based on the Branch state’s result. The value to be added to the PC comes from the co output of the IR Env. Active Control Signals: PCS 1 doe, IRS 2 doe, add, ALUDINTdoe, PCce

The Control (Cont. ) 11) WBR. RTL Instruction: RD=C (R-type) Active Control Signal: GPR_WE

The Control (Cont. ) 11) WBR. RTL Instruction: RD=C (R-type) Active Control Signal: GPR_WE Action: The data which is stored in the C register in the GPR env. (after the arithmeticshift operations are done) is being assigned to the instruction’s target register.

The Control (Cont. ) 12) WBI. RTL Instruction: RD=C (I-type) Active Control Signals: GPR_WE,

The Control (Cont. ) 12) WBI. RTL Instruction: RD=C (I-type) Active Control Signals: GPR_WE, ITYPE Action: Copy the result stored in the C register in the GPR env. (after the arithmeticlogic operations are done) to the instruction’s target register.

Reading From Memory - Load Word (lw): RD M(Sext(imm. ) + RS 1) Reminder…

Reading From Memory - Load Word (lw): RD M(Sext(imm. ) + RS 1) Reminder… : Four states are needed for finishing the load instruction State I: Effective Address Computation – MAR A+C 0 GPR Env. IR Env. C 0. ) m t(im A x Se ALU Env. MAR ADD Sext(imm. ) + RS 1

The Control (Cont. ) 7) Address. Cmp. RTL Instruction: MAR=A+imm. Action: The memory address

The Control (Cont. ) 7) Address. Cmp. RTL Instruction: MAR=A+imm. Action: The memory address where a data should be written to is stored in the MAR register. The address itself is the sum of the immediate value supplied by the IR Env. and the A register in the GPR Env. Active Control Signals: AS 1 doe, IRS 2 doe, add, ALUDINTdoe, MARce.

Reading From Memory – Load (Cont. ) State II: Memory Access (Load). This state

Reading From Memory – Load (Cont. ) State II: Memory Access (Load). This state lasts till the value is returned – MDR M(MAR) Reminder… Memory Env. Busy Tells the Control when readung is over Adr Dout W MAR !Read MDR Notes: 1) Busy signal informs the Control when the operation is over (Dout is stable). 2) MDR samples Dout every clock cycle, no need to compute CE (Simplifies Control). 3) Dout must be logical even if its value is incorrect!

The Control (Cont. ) 13) Load. RTL Instruction: MDR=M[MAR] Active Control Signals: MR, MDRce,

The Control (Cont. ) 13) Load. RTL Instruction: MDR=M[MAR] Active Control Signals: MR, MDRce, Asel, MDRsel Action: Store M[MAR] in MDR

Reading From Memory – Load (Cont. ) State III (copy MDR to C): Writing

Reading From Memory – Load (Cont. ) State III (copy MDR to C): Writing MDR’s value to C in the GPR : C MDR Reminder… C GPR Env. State IV: Write-Back: RD C MDR Cce

The Control (Cont. ) 16) Copy. MDR 2 C. RTL Instruction: C=MDR Action: Copy

The Control (Cont. ) 16) Copy. MDR 2 C. RTL Instruction: C=MDR Action: Copy MDR contents to C register in the GPR. Active Control Signals: MDRS 1 doe, 0 S 2 doe, add, ALUDINTdoe, Cce.

Writing To Memory – Store (Cont. ) State II: Copying the B register’s (this

Writing To Memory – Store (Cont. ) State II: Copying the B register’s (this is RD) value to the MDR : MDR B Reminder… GPR Env. B MDR State III: Memory Access (Store) – M(MAR) MDR Memory Env. Busy Din MDR Adr MAR W !Write Tells the Control when writing is over

The Control (Cont. ) 15) Copy. GPR 2 MDR. RTL Instruction: MDR=B Active Control

The Control (Cont. ) 15) Copy. GPR 2 MDR. RTL Instruction: MDR=B Active Control Signals: MDRS 1 doe, BS 2 doe Action: The value to be next written to the memory is stored in this state in the MDR. The value itself comes from the B register in the GPR.

The Control (Cont. ) 14) Store. RTL Instruction: M(MAR)=MDR Active Control Signals: MARS 1

The Control (Cont. ) 14) Store. RTL Instruction: M(MAR)=MDR Active Control Signals: MARS 1 doe, MW Action: The instruction that is stored in the MDR is copied to the memory Env. The address in the memory Env. is taken from the MAR.