Presentation is loading. Please wait.

Presentation is loading. Please wait.

Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.

Similar presentations


Presentation on theme: "Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data."— Presentation transcript:

1 Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data

2 Single Cycle Implementation Cycle Time  Unfortunately, though simple, the single cycle approach is not used because it is inefficient  Clock cycle must have the same length for every instruction  What is the longest path (slowest instruction)?  Calculate cycle time assuming negligible delays (for muxes, control unit, sign extend, PC access, shift left 2, wires) except:  Instruction and Data Memory (2ns)  ALU and adders (2ns)  Register File access (reads or writes) (1ns)  floating point operations even longer

3 Instruction Critical Paths Instr.I MemReg RdALU OpD MemReg WrTotal delay (ns) R-type load store beq jump 21216 212218 21227 2125 22

4  A floating point add.d = Instr. Fetch (2 ns)+ Reg. Read (1 ns)+ ALU add(8 ns)+ Reg. Write (1 ns)= 12 ns  Floating point load l.s =2+1+2(ALUop)+2(data mem)+1 (Reg.) = 8 ns  Floating point store s.s =2+1+2(ALU)+2(data mem) = 7 ns.  The longest instruction is floating point multiply mul = Inst. Fetch (2 ns)+Reg. Read (1 ns)+ALU multiply (16 ns)+ Reg. Write (1 ns) = 20 ns  Floating point branch = 5 ns, floating point jump=2 (fetch)  If clock period is variable in length, then we need to look at instruction frequency. For example Loads (31%), stores (21%), R- type (27%), beq(5%), j (2%), add.d, sub.d (7%), mult.d, div.d(7%).  Combining to compute the clock cycle=8x31%+7x21%+6x27%+5x5%+2x2%+20x7%+12x7%= 7 ns What about floating point operations?

5  Instead of a fixed cycle time, we allow cycle time to depend on instruction class.  We can then compare performance, considering that CPI will still be 1, and Instruction count does not change. Perf. CPU variable cycle time = CPU exec. time fixed cycle time Perf. CPU fixed cycle time CPU exec. time var. cycle time = Clock period fixed Clock period variable  because performance= _____________1______________ ) Instr. Count x CPI x Clock Period  Performance improvement = 20 ns (fixed cycle clock period) = 2.86 faster 7 ns (variable cycle clock period) What about variable cycle length?

6  Single cycle/instr. datapath is wasteful of area since some functional units must be duplicated since they can not be “shared” during an instruction execution  e.g., need separate adders to do PC update and branch target address calculations, as well as an ALU to do R- type arithmetic/logic operations and data memory address calculations Where We are Headed  Single cycle/instr. uses the clock cycle inefficiently – the clock cycle must be timed to accommodate the slowest instruction – we cannot make common case fast.  especially problematic for more complex instructions like floating point multiplications

7  Another approach  use a “smaller” cycle time  have different instructions take different number of cycles  a “multi-cycle” datapath Where We are Headed Address Read Data (Instr. or Data) Memory PC Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU Write Data IR MDR A B ALUout

8 Multicycle Implementation Overview  Each step in the execution of an instruction takes 1 clock cycle  An instruction takes more than 1 clock cycle to complete  Not every instruction takes the same number of clock cycles to complete  Multi-cycle implementations allow functional units to be used more than once per instruction as long as they are used on different clock cycles, as a result  we need only one memory  we need only one ALU/adder  We can have faster clock rates

9 The Multicycle Datapath – A High Level View PC Address Read Data (Instr. or Data) Memory Write Data A B ALU ALUout IR MDR Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 u Registers have to be added after every major functional unit to hold the intermediate output value until that intermediate result is used in a subsequent clock cycle

10 The Multicycle Datapath – A High Level View u All internal registers hold the intermediate output value until it is used in a subsequent clock cycle of that instruction, thus do not need a dedicated control signal.  The only exception is the Instruction Register (IR), which needs to hold the instruction bits for several cycles, until the instruction finishes its execution.  Thus it needs a control signal which allows it to be written into - IRWrite u Data used by subsequent instructions are stored in programmer visible elements (like Register File, PC or memory)

11 u Break up the instructions into steps where each step takes a cycle while trying to –balance the amount of work to be done in each step –restrict each cycle to use only one major functional unit u Thus each cycle can at most do one of the following operations – a memory access or – a register file access (two reads or one write), or – an ALU operation Multicycle Approach

12 Clocking the Multicycle Datapath Address Read Data (Instr. or Data) Memory PC Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU Write Data IR MDR A B ALUout System Clock MemWriteRegWrite clock cycle IRWrite simplified

13 u Reading/writing to any of the internal registers (except IR) or to the PC occurs (quickly) at the end of a clock cycle u reading/writing to the register file takes ~50% of a clock cycle since it has additional control and access overhead (reading can be done in parallel with instruction decode) u All operations occurring in one step occur in parallel within the same clock cycle u This limits us to one ALU operation, one memory access, and one register file access per step (per clock cycle) Multicycle Approach, continued

14 PC Address Read Data (Instr. or Data) Memory Write Data A B ALU ALUout IR MDR Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 The Multicycle Datapath – A High Level View u Need more multiplexors to direct the datapath to fewer logical units

15 Multiplexors used in multicycle datapath IorD  The first multiplexor determines whether memory address input comes from the PC (for instruction fetching) or from the ALU (for lw, sw instructions) 1 0 PC Address Read Data (Instr. or Data) Memory ALUOut u The second multiplexor determines whether input to the ALU first port is from internal register A (during R-type operations for example), or from the PC (to compute the next PC value). ALUSrcA ALU ALUout zero 1 0 PC A

16 Multiplexors used in multicycle datapath u The third multiplexor determines whether input to the ALU second port comes from Internal register B (for R-type instructions), a constant 4 (to increment the PC), the sign-extended Instruction [15-0] bits (for immediate operations), or those bits shifted left by 2 (for branch operations) ALUSrcB ALU zero 1 0 2 3 Sign Extend Instr[15-0] 32 Shift left 2 B 4 2

17 u The fourth multiplexor determines the address of the destination register in the Register File, whether input comes from Instr[20-16] bits or from Instr[15-11] bits (this is the same with the single- cycle/instruction datapath. u Another multiplexer determines whether data to be written in the Register File comes from the Memory Data Register or from ALUout.  Finally, there is a four-way multiplexor to determine what is written into the PC. Its control signal is PCSource Multiplexors used in multicycle datapath 1 0 2 PC PCWrite (PC+4)ALU result ALUout Shift left 2 Instr[25-0] PC[31-28] 28 PCWriteCond ALU zero output PCSouorce 2

18 The Complete Multicycle Data with Control Address Read Data (Instr. or Data) Memory IR MDR Read Addr 2 Read Addr 1 Register File Shift left 2 Read Data 1 Read Data 2 A B Write Data ALU control IRWrite MemtoReg MemWrite MemRead IorD PCWrite RegDst RegWrite ALUSrcA ALUSrcB ALUOp ALU ALUout zero PCSource 1 0 Write Data 1 0 Write Addr 1 0 1 0 2 1 0 2 3 4 Instr[5-0] Control Instr[31-26] 1 0 PC Sign Extend Instr[15-0] 32 Shift left 2 Instr[25-0] PC[31-28] 28 PCWriteCond


Download ppt "Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data."

Similar presentations


Ads by Google