csee 3827: fundamentals of computer systems, spring...
TRANSCRIPT
![Page 1: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/1.jpg)
CSEE 3827: Fundamentals of Computer Systems, Spring 2011
9. Single Cycle MIPS Processor
Prof. Martha Kim ([email protected])Web: http://www.cs.columbia.edu/~martha/courses/3827/sp11/
![Page 2: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/2.jpg)
Outline (H&H 7.2-7.3)
2
• Single Cycle MIPS Processor
• Datapath (functional blocks)
• Control (control signals)
• Single Cycle Performance
![Page 3: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/3.jpg)
Microarchitecture
• Microarchitecture: an implementation of a particular architecture
• Multiple implementations for a single architecture
• Single-cycle: Each instruction executes in a single cycle
• Multi-cycle: Each instruction is broken up into a series of shorter steps
• Pipelined: Each instruction is broken up into a series of steps; Multiple instructions execute at once
3
Copyright © 2007 Elsevier
![Page 4: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/4.jpg)
Our MIPS Processor
• We consider a subset of MIPS instructions:
• R-type instructions: and, or, add, sub, slt
• Memory instructions: lw, sw
• Branch instructions: beq
• Later consider adding addi and j
4
Copyright © 2007 Elsevier
![Page 5: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/5.jpg)
Instruction Execution
• PC → instruction memory, fetch instruction
• Register numbers → register file, read registers
• Depending on instruction class:
• Use ALU to calculate:
• Arithmetic or logical result
• Memory address for load/store
• Branch target address
• Access data for load/store
• PC ← target address or PC + 4
5
![Page 6: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/6.jpg)
MIPS State Elements
• Architectural state determines everything about a processor: PC, 32 registers, memory
6
Copyright © 2007 Elsevier
![Page 7: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/7.jpg)
Single-Cycle Datapath: lw fetch
• First consider executing lw
• STEP 1: Fetch instruction
7
Copyright © 2007 Elsevier
![Page 8: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/8.jpg)
Single-Cycle Datapath: lw register read
• STEP 2: Read source operands from register file
8
Copyright © 2007 Elsevier
![Page 9: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/9.jpg)
• STEP 3: Sign-extend the immediate
Single-Cycle Datapath: lw immediate
9
Copyright © 2007 Elsevier
![Page 10: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/10.jpg)
• STEP 4: Compute the memory address
Single-Cycle Datapath: lw address
10
Copyright © 2007 Elsevier
![Page 11: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/11.jpg)
• STEP 5: Read data from memory and write it back to register file
Single-Cycle Datapath: lw memory read
11
Copyright © 2007 Elsevier
![Page 12: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/12.jpg)
• STEP 6: Determine the address of the next instruction
Single-Cycle Datapath: lw PC increment
12
Copyright © 2007 Elsevier
![Page 13: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/13.jpg)
• Write data in rt to memory
Single-Cycle Datapath: sw
13
Copyright © 2007 Elsevier
![Page 14: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/14.jpg)
• Read from rs and rt
• Write ALUResult to register file
• Write to rd (instead of rt)
Single-Cycle Datapath: R-type instructions
14
Copyright © 2007 Elsevier
![Page 15: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/15.jpg)
• Determine whether values in rs and rt are equal
• Calculate branch target address: BTA = (sign-extended immediate)x4 + (PC+4)
Single-Cycle Datapath: beq
15
Copyright © 2007 Elsevier
![Page 16: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/16.jpg)
Complete Single-Cycle Processor
16
Copyright © 2007 Elsevier
![Page 17: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/17.jpg)
Control Unit
17
Copyright © 2007 Elsevier
![Page 18: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/18.jpg)
ALU Interface and Implementation
18
F2:0 Function0 0 0 A & B
0 0 1 A | B
0 1 0 A + B
0 1 1 not used
1 0 0 A & ~B
1 0 1 A | ~B
1 1 0 A - B
1 1 1 SLT
Copyright © 2007 Elsevier
![Page 19: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/19.jpg)
Control Unit: ALU Decoder
19
ALUOp1:0 Meaning0 0 Add0 1 Subtract1 0 Look at Funct1 1 not used
ALUOp1:0 Funct ALUControl2:0
0 0 x 010 (Add)
x 1 x 110 (Subtract)
1 x 100000 (add) 010 (Add)
1 x 100010 (sub) 110 (Subtract)
1 x 100100 (and) 000 (And)
1 x 100101 (or) 001 (Or)
1 x 101010 (slt) 111 (SLT)Copyright © 2007 Elsevier
![Page 20: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/20.jpg)
Control Unit: Main Decoder
20
Instruction Op5:0 RegWrite RegDst AluSrc Branch MemWrite MemToReg ALUOp1:0
R-type 0 0 0 0 0 0
lw 1 0 0 0 1 1
sw 1 0 1 0 1 1
beq 0 0 0 1 0 0
Copyright © 2007 Elsevier
![Page 21: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/21.jpg)
Single-Cycle Datapath Example: or
21
Copyright © 2007 Elsevier
![Page 22: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/22.jpg)
Extended Functionality: addi
• No change to datapath
22
Instruction Op5:0 RegWrite RegDst AluSrc Branch MemWrite MemToReg ALUOp1:0
R-type 0 0 0 0 0 0 1 1 0 0 0 0 1 0
lw 1 0 0 0 1 1 1 0 1 0 0 1 0 0
sw 1 0 1 0 1 1 0 x 1 0 1 x 0 0
beq 0 0 0 1 0 0 0 x 0 1 0 x 0 1
addi 0 0 1 0 0 0 1 0 1 0 0 0 0 0Copyright © 2007 Elsevier
![Page 23: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/23.jpg)
Extended Functionality: j
23
Copyright © 2007 Elsevier
![Page 24: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/24.jpg)
Control Unit: Main Decoder with j
24
Instruction Op5:0 RegWrite RegDst AluSrc Branch MemWrite MemToReg ALUOp1:0 Jump
R-type 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0
lw 1 0 0 0 1 1 1 0 1 0 0 1 0 0 0
sw 1 0 1 0 1 1 0 x 1 0 1 x 0 0 0
beq 0 0 0 1 0 0 0 x 0 1 0 x 0 1 0
addi 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0
j 0 0 0 0 1 0 0 x x x 0 x x x 1
Copyright © 2007 Elsevier
![Page 25: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/25.jpg)
Review: Processor Performance
25
=Instructions
ProgramClock cyclesInstruction
SecondsClock cycle
x xSecondsProgram
![Page 26: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/26.jpg)
Single-Cycle Performance
• Seconds/cycle (or TC) is limited by the critical path (lw)
26
Copyright © 2007 Elsevier
![Page 27: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/27.jpg)
Single-Cycle Performance
• Single-cycle critical path:
Tc = tpcq_PC + tmem + max(tRFread, tsext + tmux) + tALU + tmem + tmux + tRFsetup
• In most implementations, limiting paths are:
• memory, ALU, register file
• Tc = tpcq_PC + 2tmem + tRFread + tmux + tALU + tRFsetup
27
Copyright © 2007 Elsevier
![Page 28: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/28.jpg)
Single-Cycle Performance Example
28
Element Parameter Delay (ps)
Register clock-to-Q tpcq_PC 30
Register setup tsetup 20
Multiplexer tmux 25
ALU tALU 200
Memory read tmem 250
Register file read tRFread 150
Register file setup tRFsetup 20
Tc = tpcq_PC + 2tmem + tRFread + tmux + tALU + tRFsetup = [30 + 2(250) + 150 + 25 + 200 + 20] ps = 925 ps
Copyright © 2007 Elsevier
![Page 29: CSEE 3827: Fundamentals of Computer Systems, Spring …martha/courses/3827/sp11/slides/9_singleCycl… · CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9. Single Cycle](https://reader034.vdocuments.site/reader034/viewer/2022042801/5a78ce137f8b9ae6228d3bcc/html5/thumbnails/29.jpg)
Single-Cycle Performance Example
• For a program with 100 billion instructions executing on a single-cycle MIPS processor,
Execution Time = # instructions x CPI x TC
= (100 × 109)(1)(925 × 10-12 s)
= 92.5 seconds
29
Copyright © 2007 Elsevier