160 likes | 273 Views
Laundry Model. Washer Drier Store Basket Wardrobe. running. idle. time. idle. running. time. Process Steps. 9.00. 10.00. 11.00. Load the washer at 9.00 Done at 10, load the drier Drier Done at 11. Wash then Dry 1 load takes 2 hours. 0.5. time.
E N D
Laundry Model Washer Drier Store Basket Wardrobe Comp 3014 The Nature of Computing
running idle time idle running time Process Steps 9.00 10.00 11.00 • Load the washer at 9.00 • Done at 10, load the drier • Drier Done at 11 Wash then Dry 1 load takes 2 hours 0.5 Comp 3014 The Nature of Computing
time Sequential Process 13.00 15.00 9.00 11.00 • Load washer at 9.00 • Done at 10, load drier • Drier Done at 11 • Reload washer at 11 • Done at 12, load drier • Drier done at 13 • Reload washer at 13 • Done at 14, load drier • Done at 15 3 loads takes 6 hours 0.5 Comp 3014 The Nature of Computing
time Overlapping Process 13.00 15.00 9.00 11.00 • Load washer at 9.00 • Done at 10, load drier reload washer • Both Done at 11. Reload drier reload washer • Both done at 12. Reload drier • Drier done at 13 From 10.00 till 11.00 both washer and dryer running concurrently 3 loads takes 4 hours 0.75 Comp 3014 The Nature of Computing
time Washing Pipeline Filling 9.00 11.00 13.00 15.00 17.00 18.00 • 5 Cycles !!! • Get washing • Wash • Dry • Store • Put away 5 loads in 9 hours 0.55 Comp 3014 The Nature of Computing
time Washing Pipeline Full 9.00 11.00 13.00 15.00 17.00 Pipe Full gives 1 load per hour 1.0 Comp 3014 The Nature of Computing
Instruction reg X Y 0 X r0 1 Y r1 Code Memory r2 mdr W Data Memory ALU mar 7 W Can we Pipeline SAM ? 1.Fetch 2.Dec/Reg 3.ALU 4.Mem 5.RW Comp 3014 The Nature of Computing
Pipelined Sam4 0 1 X Y X r0 Y r1 r2 Code Memory W Data Memory 7 time W 1.Fetch 2.Dec/Reg 3.ALU 4.Mem 5.RW Buffer Comp 3014 The Nature of Computing
Mem Mem Reg Reg ALU time 5 Stages in Pipeline 1.Fetch 3.ALU 4.Mem 5.RW 2.Dec/Reg r1,r2 r3 add r3,r1,r2 add Let’s take the instruction add r3,r1,r2 and show which stage is needed for each part of the instruction. Comp 3014 The Nature of Computing
ld add Mem r3 r4 r0 r1,r2 ALU time Two Instructions r0 ld r3,[r0+2] 2 add r4,r1,r2 Two instructions into the pipeline Comp 3014 The Nature of Computing
Mem Mem Mem Mem Mem Mem Mem Mem Mem Mem Reg Reg Reg Reg Reg Reg Reg Reg Reg Reg ALU ALU ALU ALU ALU Structural Hazard Write (store) Here we are being asked to read from memory and write to it simultaneously. Impossible! st r0,[5] Solution – Use separate code and data memories add r4,r1,r2 Read (fetch) Comp 3014 The Nature of Computing
time Hazardous Washing 9.00 11.00 13.00 15.00 17.00 18.00 Washing basket containes both clean and dirty washing! Comp 3014 The Nature of Computing
Mem Mem Reg Reg ALU Mem Mem Reg Reg ALU Mem Mem Reg Reg ALU Mem Mem Reg Reg ALU Mem Mem Reg Reg ALU Code and Data Memories Comp 3014 The Nature of Computing
add add r3 r4 r1,r2 r1,r3 time Data Hazard r3 set here add r3,r1,r2 add r4,r1,r3 but need r3 here EARLIER ! Comp 3014 The Nature of Computing
Mem Mem Mem Mem Mem Mem Mem Mem Mem Mem Reg Reg Reg Reg Reg Reg Reg Reg Reg Reg ALU ALU ALU ALU ALU Data Hazard Need value of r3 for second instruction before the first is complete. add r3,r1,r2 add r4,r1,r3 Comp 3014 The Nature of Computing
Mem Reg Reg ALU Mem Mem Mem Mem Mem Mem Mem Mem Reg Reg Reg Reg Reg Reg Reg Reg ALU ALU ALU ALU Pipeline Stalls add r3,r1,r2 Stall Mem Stall add r4,r1,r3 Resolve Hazard – Insert delay into second instruction stream. ‘Stall’ Cycles. But this needs extra electronics on the chip. Complex and Costly. Comp 3014 The Nature of Computing