34
1 Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David August

Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

1

Lecture 7: Datapath

COS / ELE 375

Computer Architecture and Organization

Princeton University Fall 2015

Prof. David August

Page 2: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

5

Datapath

Datapath �The component of the processor that performs arithmetic operations� – P&H

Datapath

The collection of state elements, computation elements, and interconnections that together provide a conduit for the flow and transformation of data in the processor during execution. - DIA

Page 3: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

6

Page 4: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

7

Datapath - Part of the Microarchitecture

Architecture •  The ISA - the programmer�s view of the machine •  Implementation independent, an interface

Microarchitecture •  The lower-level implementation of the ISA •  Design specific, an implementation

Example use of terminology •  Architectural state: Register r5 •  Microarchitectural state: Carry bit on the 5th 1-bit ALU

Page 5: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

8

Datapath Elements

•  ALUs are just one datapath building block •  What about the other elements?

Computational Elements •  Combination Circuits •  Outputs follow inputs •  Familiar Example: ALU

State Elements •  Sequential Circuits •  Outputs change on clock edge •  Familiar Example: A Register

Page 6: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

•  Combinational - you had better know how to design it by now!!! •  Refine for MIPS

•  Zero equality test on all results - why? •  Set on less than for slt instruction

Computation Element: ALU

A L U c o n t r o l 3

ALU Result Zero

ALU Control Function 000 AND 001 OR 010 add 110 subtract 111 set on less than

Page 7: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

•  16 à 32 bit Sign extender •  Why is this necessary in MIPS?

•  Hint:

Computation Element: Sign Extender

1 6 3 2 S i g n

E x t e n d

Implementation?

Page 8: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

•  Not an ALU, just add •  Why would we need this in MIPS to execute instructions?

Computation Element: Adder

A d d S u m

Page 9: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

12

Computational Element: The Magical Mux

•  Mux is short for Multiplexer (Think: selector) •  n input lines (of any common width) •  m control wires to select •  n = 2m

M u x

Control

in0

inn

out

m

Implementation?

Page 10: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

•  Microarchitecture to implement architectural state •  Built using D flip-flops •  MIPS:

•  Need to be able to read two operands at once •  2 source operands per instruction

State Element: Register File

R e g W r i t e

R e g i s t e r s W r i t e r e g i s t e r

R e a d d a t a 1

R e a d d a t a 2

R e a d r e g i s t e r 1 R e a d r e g i s t e r 2

W r i t e d a t a D a t a

D a t a R e g i s t e r n u m b e r s 5

5

5

5-bits? 2 Reads? 1 Write?

Page 11: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

14

State Element: Register File Register Implementation

Falling edge triggered D flip-flop

D latch

Page 12: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

State Element: Register File Read Implementation

R e g W r i t e

R e g i s t e r s W r i t e r e g i s t e r

R e a d d a t a 1

R e a d d a t a 2

R e a d r e g i s t e r 1 R e a d r e g i s t e r 2

W r i t e d a t a D a t a

D a t a R e g i s t e r n u m b e r s 5

5

5

Page 13: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

State Element: Register File Write Implementation

R e g W r i t e

R e g i s t e r s W r i t e r e g i s t e r

R e a d d a t a 1

R e a d d a t a 2

R e a d r e g i s t e r 1 R e a d r e g i s t e r 2

W r i t e d a t a D a t a

D a t a R e g i s t e r n u m b e r s 5

5

5

Know decoders

Page 14: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

17

State Element: Data and Instruction Memory

•  Microarchitectural element to hold the architectural memory state

•  See Appendix B for implementation details

M e m R e a d

M e m W r i t e

D a t a m e m o r y W r i t e

d a t a R e a d d a t a A d d r e s s

I n s t r u c t i o n m e m o r y

I n s t r u c t i o n a d d r e s s

I n s t r u c t i o n

Page 15: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

18

State Element: The Program Counter

•  To hold the architectural PC state •  Just like a single register

P C

Page 16: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

Our Complete Line of Products! There may be others, but this is good for MIPS

A L U c o n t r o l

R e g W r i t e

R e g i s t e r s W r i t e r e g i s t e r

R e a d d a t a 1

R e a d d a t a 2

R e a d r e g i s t e r 1 R e a d r e g i s t e r 2

W r i t e d a t a

A L U r e s u l t A L U

D a t a D a t a

R e g i s t e r n u m b e r s Z e r o 5

5

5 3

P C I n s t r u c t i o n

m e m o r y

I n s t r u c t i o n a d d r e s s

I n s t r u c t i o n A d d S u m

1 6 3 2 S i g n

e x t e n d

M e m R e a d

M e m W r i t e

D a t a m e m o r y W r i t e

d a t a

R e a d d a t a A d d r e s s

M u x

Control

in0

inn

out

m

Page 17: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

21

Fetching Instructions (no branching)

Page 18: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

22

The ALU (R-Type) Instructions

Consider: r1 = r2 - r3

Page 19: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

23

Load and Store Instructions

Consider: r1 = M[ r2 - 3 ]

Page 20: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

24

Composition of Memory and R-Type Datapath The Magic of the Mux

Page 21: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

25

Recall Fetch

Page 22: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

26

Now Add Instruction Fetch

Page 23: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

27

Now Add Instruction Fetch (ALU + MEM + Fetch)

Data and Instruction memory?

Page 24: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

28

Branch Instructions

Consider: Branch r1 == 0, TARGET

Why shift left by 2?

Page 25: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

29

Add Branch to Datapath (ALU + MEM + Fetch + Branch)

What will zero be connected to?

Page 26: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

30

MIPS Instruction Quirk •  The Destination Register may be in different locations

•  11-15: Loads use rt •  16-20: All R-Types use rd

Page 27: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

31

Again, The Magic of the Mux!

Page 28: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

32

Ugh, what is going on here!?!

Page 29: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

33

Control vs. Datapath (Blurring the Line)

Page 30: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

34

What is Control?

Control �The component of the processor that commands the datapath, memory, and I/O devices according to the instructions of the program.� – P&H

Control

The component of the processor that commands the datapath, memory, and I/O devices according to the instructions of the program. - DIA

Page 31: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

35

Full Datapath with Control

Page 32: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

36

Page 33: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

37

Summary and Next Steps

•  The book doesn�t define datapath well •  Computation and State elements compose datapath •  Look for reuse across instruction types •  Build minimal HW datapath with the magic of the mux

Next Steps •  Need to define control •  Understand Timing

•  Single cycle •  Multi-cycle

•  Understand how to implement control

Page 34: Lecture 7: Datapath - Princeton University Computer Science · Lecture 7: Datapath COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David

38

For Next Time

•  Review finite state machines: