+ All Categories
Home > Documents > ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... ·...

ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... ·...

Date post: 22-Jan-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
71
ECE 550D Fundamentals of Computer Systems and Engineering Fall 2016 Storage and Clocking Tyler Bletsch Duke University Slides are derived from work by Andrew Hilton (Duke)
Transcript
Page 1: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

ECE 550D Fundamentals of Computer Systems and Engineering

Fall 2016

Storage and Clocking

Tyler Bletsch

Duke University

Slides are derived from work by Andrew Hilton (Duke)

Page 2: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

2

VHDL: Behavioral vs Structural

• A few words about VHDL

• Structural:

• Spell out at (roughly) gate level

• Abstract piece into entities for abstraction/re-use

• Very easy to understand what synthesis does to it

• Behavioral:

• Spell out at higher level

• Sequential statements, for loops, process blocks

• Can be difficult to understand how it synthesizes

• Difficult to resolve performance issues

Page 3: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

3

Last time…

• Who can remind us what we did last time?

• Add

• Substract

• Bit shift

• Floating point

Page 4: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

4

So far…

• We can make logic to compute “math”

• Add, subtract,… (we’ll see multiply/divide later)

• Bitwise: AND, OR, NOT,…

• Shifts

• Selection (MUX)

• …pretty much anything

• But processors need state (hold value)

• Registers

• …

Page 5: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

5

Memory Elements

• All the circuits we looked at so far are combinational circuits: the output is a Boolean function of the inputs.

• We need circuits that can remember values (registers, memory)

• The output of the circuit is a function of the input and a function of a stored value (state)

• Circuits with storage are called sequential circuits

• Key to storage: feedback loops from outputs to inputs

Page 6: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

6

Ideal Storage – Where We’re Headed

• Ultimately, we want something that can hold 1 bit and we want to control when it is re-written

• However, instead of just giving it to you as a magic black box, we’re going to first dig a bit into the box

“flip flop” =

device that

holds one

bit (0 or 1)

bit to be written bit currently being held

bit to control

when we write

Page 7: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

7

Building up to the D Flip-Flop and beyond

SR Latch

Q

Q

R

S D

E

Q

Q

R

S

D Latch

D

latch

D Q

E Q

D

latch

D Q

E

D

latch

D Q

E !Q !Q

Q D

C

DFF

D Q

E Q

D Flip-Flop

32 bit reg

D Q

E Q

Register

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

(too awkward) (bad timing) (okay but only one bit) (nice!)

Page 8: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

8

FF Step #1: NOR-based Set-Reset (SR) Latch

R

S

Q

Q

0

1 0

1 0

0

R

S

Q

Q

0

0 1

0 1

0

R S Q

0 0 Q

0 1 1

1 0 0

1 1 - Don’t set both S & R to 1.

Seriously, don’t do it.

Page 9: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

9

R

S

Q

Q

0

1 0

1 0

0

R

S

Q

Q

0

0 1

0 1

1

Set-Reset Latch (Continued)

Time

S 0

1

R 0

1

Q 0

1

Page 10: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

10

R

S

Q

Q

0

1 0

1 0

0

R

S

Q

Q

0

0 1

0 1

1

Set-Reset Latch (Continued)

Time

S 0

1

R 0

1

Q 0

1

Set Signal Goes High

Output Signal Goes High

Page 11: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

11

R

S

Q

Q

0

1 0

1 0

0

R

S

Q

Q

0

0 1

0 1

1

Set-Reset Latch (Continued)

Time

S 0

1

R 0

1

Q 0

1

Set Signal Goes Low

Output Signal Stays High

Page 12: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

12

R

S

Q

Q

0

1 0

1 0

0

R

S

Q

Q

0

0 1

0 1

1

Set-Reset Latch (Continued)

Time

S 0

1

R 0

1

Q 0

1

Until Reset Signal

Goes High

Then Output Signal Goes Low

Page 13: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

13

SR Latch

• Downside: S and R at once = chaos

• Downside: Bad interface

• So let’s build on it to do better

Page 14: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

14

Building up to the D Flip-Flop and beyond

SR Latch

Q

Q

R

S D

E

Q

Q

R

S

D Latch

D

latch

D Q

E Q

D

latch

D Q

E

D

latch

D Q

E !Q !Q

Q D

C

DFF

D Q

E Q

D Flip-Flop

32 bit reg

D Q

E Q

Register

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

(too awkward) (bad timing) (okay but only one bit) (nice!)

Page 15: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

15

FF Step #2: Data Latch (“D Latch”)

Starting with SR Latch

Q

Q

R

S

Page 16: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

16

Data Latch (D Latch)

Starting with SR Latch

Change interface to

Data + Enable (D + E)

If E=0, then R=S=0.

If E=1, then S=D and R=!D

Data

Enable

Q

Q

R

S

Page 17: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

17

Data Latch (D Latch)

Data

Enable

Q

Q

D E Q

0 1 0

1 1 1

- 0 Q

Time

D 0

1

E 0

1

Q 0

1

E goes high

D “latched”

Stays as output

R

S

Page 18: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

18

Data Latch (D Latch)

Data

Enable

Q

Q

D E Q

0 1 0

1 1 1

- 0 Q

Time

D 0

1

E 0

1

Q 0

1

Does not

affect Output

E goes low

Output unchanged

By changes to D

R

S

Page 19: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

19

Data Latch (D Latch)

Data

Enable

Q

Q

D E Q

0 1 0

1 1 1

- 0 Q

Time

D 0

1

E 0

1

Q 0

1

E goes high

D “latched”

Becomes new output

R

S

Page 20: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

20

Data Latch (D Latch)

Data

Enable

Q

Q

D E Q

0 1 0

1 1 1

- 0 Q

Time

D 0

1

E 0

1

Q 0

1

Slight Delay

(Logic gates take time)

R

S

Page 21: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

21

Logic Takes Time

• Logic takes time:

• Gate delays: delay to switch each gate

• Wire delays: delay for signal to travel down wire

• Other factors (not going into them here)

• Need to make sure that signals timing is right

• Don’t want to have races or wacky conditions..

Page 22: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

22

Clocks

• Processors have a clock:

• Alternates 0 1 0 1

• Like the processor’s internal metronome

• Latch logic latch in one clock cycle

• 3.4 GHz processor = 3.4 Billion clock cycles/sec

One clock cycle

Page 23: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

23

FF Step #3: Using Level-Triggered D Latches

• First thoughts: Level Triggered

• Latch enabled when clock is high

• Hold value when clock is low

D

latch

D Q

E Q

D

latch

D Q

E Q

Logic

Clk

3 3

This slide describes how D-latches can malfunction because they were level triggered. Real D-flip-flops are edge-triggered, and we’re showing you why that’s important.

Page 24: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

24

Strawman: Level Triggered

• How we’d like this to work

• Clock is low, all values stable

D

latch

D Q

E Q

D

latch

D Q

E Q

Logic

Clk

3 3

010 111 100 001

0

Clk

This slide describes how D-latches can malfunction because they were level triggered. Real D-flip-flops are edge-triggered, and we’re showing you why that’s important.

Page 25: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

25

Strawman: Level Triggered

• How we’d like this to work

• Clock goes high, latches capture and xmit new val

D

latch

D Q

E Q

D

latch

D Q

E Q

Logic

Clk

3 3

010 010 100 100

0

Clk

This slide describes how D-latches can malfunction because they were level triggered. Real D-flip-flops are edge-triggered, and we’re showing you why that’s important.

Page 26: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

26

Strawman: Level Triggered

• How we’d like this to work

• Signals work their way through logic w/ high clk

D

latch

D Q

E Q

D

latch

D Q

E Q

Logic

Clk

3 3

010 010 100 100

0

Clk

This slide describes how D-latches can malfunction because they were level triggered. Real D-flip-flops are edge-triggered, and we’re showing you why that’s important.

Page 27: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

27

Strawman: Level Triggered

• How we’d like this to work

• Clock goes low before signals reach next latch

D

latch

D Q

E Q

D

latch

D Q

E Q

Logic

Clk

3 3

010 010 100 100

0

Clk

This slide describes how D-latches can malfunction because they were level triggered. Real D-flip-flops are edge-triggered, and we’re showing you why that’s important.

Page 28: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

28

Strawman: Level Triggered

• How we’d like this to work

• Clock goes low before signals reach next latch

D

latch

D Q

E Q

D

latch

D Q

E Q

Logic

Clk

3 3

111 010 000 100

0

Clk

This slide describes how D-latches can malfunction because they were level triggered. Real D-flip-flops are edge-triggered, and we’re showing you why that’s important.

Page 29: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

29

Strawman: Level Triggered

• How we’d like this to work

• Everything stable before clk goes high

D

latch

D Q

E Q

D

latch

D Q

E Q

Logic

Clk

3 3

111 010 000 100

0

Clk

This slide describes how D-latches can malfunction because they were level triggered. Real D-flip-flops are edge-triggered, and we’re showing you why that’s important.

Page 30: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

30

Strawman: Level Triggered

• How we’d like this to work

• Clk goes high again, repeat

D

latch

D Q

E Q

D

latch

D Q

E Q

Logic

Clk

3 3

111 111 000 000

0

Clk

This slide describes how D-latches can malfunction because they were level triggered. Real D-flip-flops are edge-triggered, and we’re showing you why that’s important.

Page 31: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

31

Strawman: Level Triggered

• Problem: What if signal reaches latch too early?

• I.e., while clk is still high

D

latch

D Q

E Q

D

latch

D Q

E Q

Logic

Clk

3 3

111 111 101 000

0

Clk

This slide describes how D-latches can malfunction because they were level triggered. Real D-flip-flops are edge-triggered, and we’re showing you why that’s important.

Page 32: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

32

Strawman: Level Triggered

• Problem: What if signal reaches latch too early?

• Signal goes right through latch, into next stage..

D

latch

D Q

E Q

D

latch

D Q

E Q

Logic

Clk

3 3

111 111 101 101

0

Clk

This slide describes how D-latches can malfunction because they were level triggered. Real D-flip-flops are edge-triggered, and we’re showing you why that’s important.

Page 33: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

33

That would be bad…

• Getting into a stage too early is bad

• Something else is going on there corrupted

• Also may be a loop with one latch

• Consider incrementing counter (or PC)

• Too fast: increment twice? Eeek…

D

latch

D Q

E Q

+1

3

001

010

This slide describes how D-latches can malfunction because they were level triggered. Real D-flip-flops are edge-triggered, and we’re showing you why that’s important.

Page 34: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

34

Building up to the D Flip-Flop and beyond

SR Latch

Q

Q

R

S D

E

Q

Q

R

S

D Latch

D

latch

D Q

E Q

D

latch

D Q

E

D

latch

D Q

E !Q !Q

Q D

C

DFF

D Q

E Q

D Flip-Flop

32 bit reg

D Q

E Q

Register

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

(too awkward) (bad timing) (okay but only one bit) (nice!)

Page 35: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

35

FF Step #4: Edge Triggered

• Instead of level triggered

• Latch a new value at a clock level (high or low)

• We use edge triggered

• Latch a value at an clock edge (rising or falling)

Falling Edges

Rising Edges

Page 36: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

36

Our Ultimate Goal: D Flip-Flop

• Rising edge triggered D Flip-flop

• Two D Latches w/ opposite clking of enables

D

latch

D Q

E

D

latch

D Q

E Q Q

Q D

C

Page 37: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

37

D Flip-Flop

• Rising edge triggered D Flip-flop

• Two D Latches w/ opposite clking of enables

• On Low Clk, first latch enabled (propagates value)

• Second not enabled, maintains value

D

latch

D Q

E

D

latch

D Q

E Q Q

Q D

C

Page 38: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

38

D Flip-Flop

• Rising edge triggered D Flip-flop

• Two D Latches w/ opposite clking of enables

• On Low Clk, first latch enabled (propagates value)

• Second not enabled, maintains value

• On High Clk, second latch enabled

• First latch not enabled, maintains value

D

latch

D Q

E

D

latch

D Q

E Q Q

Q D

C

Page 39: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

39

D Flip-Flop

• No possibility of “races” anymore

• Even if I put 2 DFFs back-to-back…

• By the time signal gets through 2nd latch of 1st DFF

1st latch of 2nd DFF is disabled

• Still must ensure signals reach DFF before clk rises

• Important concern in logic design “making timing”

D

latch

D Q

E

D

latch

D Q

E Q

D

C

D

latch

D Q

E

D

latch

D Q

E Q

C

Page 40: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

40

Making Timing

• Making timing is important in a design • If you don’t make timing, your logic won’t compute right

• Synthesis tool (Quartus) tells you what max freq • Running above this your logic doesnt “finish” in time

Page 41: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

41

D Flip-flops (continued…)

• Could also do falling edge triggered

• Switch which latch has NOT on clk

• D Flip-flop is ubiquitous

• Typically people just say “latch” and mean DFF

• Which edge: doesn’t matter

• As long as consistent in entire design

• We’ll use rising edge

Page 42: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

42

D flip flops

• Generally don’t draw clk input

• Have one global clk, assume it goes there

• Often see > as symbol meaning clk

• Maybe have explicit enable

• Might not want to write every cycle

• If no enable signal shown, implies always enabled

• Get output and NOT(output) for “free”

DFF

D Q

E Q

DFF

D Q

Q

DFF

D Q

> Q

Page 43: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

43

DFFs in VHDL

x: dffe port map (

clk => clk, --the clock

d => someInput, --the input is d

q => theOutput, --the output is q

ena => en, --the enable

clrn => '1', --clear

prn => '1'); --set

Also, comes in “dff” with no enable

Page 44: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

44

A word of advice

signal x_q : std_logic;

signal x_d: std_logic;

x : dffe port map (…, d=> x_d, q=>x_q,…);

• Use naming convention: x_d, x_q

• Write x_d, read x_q

• Remember new value shows up next cycle

x x_d x_q

Page 45: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

45

A few words about timing

• Homework 2: VGA Controller

• Requires certain clock frequency

• Else won’t control monitor properly

• Quartus will tell you what timing you make

• Fmax : how fast can this be clocked

• Tells you your worst timing paths

• From which dff to which dff

• Can see in schematic viewer (usually)

• Homework 2

• Should be plenty of slack

• But if not…

Page 46: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

46

Fixing timing misses

• Typical approach: reduce logic (gate delays)

• Better adder?

• Rethink approach?

• Change “don’t care” behavior?

• Fix high fanout

• Duplicate high FO/simple logic

• Also, feel free to ask for help from me/TAs

• Quartus’s tools to help you fix them aren’t the best

Page 47: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

47

Building up to the D Flip-Flop and beyond

SR Latch

Q

Q

R

S D

E

Q

Q

R

S

D Latch

D

latch

D Q

E Q

D

latch

D Q

E

D

latch

D Q

E !Q !Q

Q D

C

DFF

D Q

E Q

D Flip-Flop

32 bit reg

D Q

E Q

Register

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

(too awkward) (bad timing) (okay but only one bit) (nice!)

Page 48: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

48

Stick a bunch of DFFs together to make a register

32 bit reg

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

in0

in1

in2

in31

. . .

out0

out1

out2

out31

enable

Page 49: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

49

Next evolution: multiple registers

32 bit reg

D Q

E Q

Register

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

DFF

D Q

E Q

(nice!)

En0

En1

En30

En31

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

WrData

En0

En1

En30

En31

Register File (Tremendous!)

Page 50: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

50

Register File

• Can store one value… How about many?

• Register File

• In processor, holds values it computes on

• MIPS, 32 32-bit registers

• How do we build a Register File using D Flip-Flops?

• What other components do we need?

Page 51: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

51

Register File: Interface

• 4 inputs

• 3 register numbers (5 bit): 2 read, 1 write

• 1 register write value (32 bits)

• 2 outputs

• 2 register values (32 bits)

Register File

rnumA

rnumB

rnumW Wval

Aval

Bval

Page 52: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

52

Register file strawman

• Use a mux to pick read ?

• 32 input mux = slow

• (other regs not pictured)

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

… …

Page 53: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

53

Register File Design

• Two problems: write and read

• Writing the registers

• Need to pick which reg

• Have reg num (e.g., 19)

• Need to make En19=1

• En0, En1,… = 0

• Read: Use a mux to pick?

• 32-input mux = slow

• Need a better method…

• Let’s talk about writing first.

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

… … WrData

En0

En1

En30

En31

Page 54: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

54

First: A Decoder

• First task: convert binary number to “one hot”

• Saw this before

• Take register number

Decoder

3

101

0 0

0

0 0

1 0

0

Page 55: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

55

Register File

• Now we know how to write:

• Use decoder to convert reg # to one hot

• Send write data to all regs

• Use one hot encoding of reg # to enable right reg

• Still need to fix read side

• 32 input mux (the way we’ve made it) not realistic

• To do this: expand our world from {1,0} to {1, 0, Z}

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

WrData

En0

En1

En30

En31

Page 56: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

56

Kind of like water in a pipe…

• To understand Z, let’s make an analogy

• Think of a wire as a pipe

• Has water = 1

• Has water = 0

• This wire is 0 (it has no water)

Page 57: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

57

Kind of like water in a pipe…

• To understand Z, let’s make an analogy

• Think of a wire as a pipe

• Has water = 1

• Has water = 0

• This wire is 1 (it is full of water)

Page 58: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

58

Kind of like water in a pipe…

• To understand Z, let’s make an analogy

• Think of a wire as a pipe

• Has water = 1

• Has water = 0

• Suppose a gate drives a 0 onto this wire • Think of it as sucking the water out

0

Page 59: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

59

Kind of like water in a pipe…

• To understand Z, let’s make an analogy

• Think of a wire as a pipe

• Has water = 1

• Has water = 0

• Suppose the gate now drives a 1 • Think of it as pumping water in

1

Page 60: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

60

So this third option: Z

• There is a third possibility: Z (“high impedance”)

• Neither pushing water in, nor sucking it out

• Just closed off/blocked

• Prevents electricity from flowing through

• Gate that gives us Z : Tri-state

D E Q

0 1 0

1 1 1

- 0 Z D

Q

E

Page 61: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

61

CMOS: Complementary MOS

• 2 inputs: E and D. What does this do?

• Write truth table for output

Vcc

Gnd

E Output

E

D

E D Output

0 0

0 1

1 0

1 1

Page 62: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

62

CMOS: Complementary MOS

• 2 inputs: E and D. What does this do?

• Write truth table for output

• When E =1, straightforward

Vcc

Gnd

E Output

E

D

E D Output

0 0

0 1

1 0 1

1 1 0

Page 63: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

63

CMOS: Complementary MOS

• 2 inputs: E and D. What does this do?

• Write truth table for output

• When E =1, straightforward

• When E= 0, no connection: Z

Vcc

Gnd

E Output

E

D

E D Output

0 0 Z

0 1 Z

1 0 1

1 1 0

Page 64: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

64

High Impedance: Z

• Z = High Impedance

• No path to power or ground

• “Gate” does not produce a 1 or a 0

• Previous slide: tri-state inverter

• More commonly drawn: tri-state buffer

• E = enable, D = data

D E Out

0 1 0

1 1 1

X 0 Z D

Out

E

X=“Don’t care”

Page 65: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

65

Remember this rule?

• Remember I told you not to connect two outputs?

• If one gate tries to drive a 1 and the other drives a 0

• One pumps water in.. The other sucks it out

• Except its electric charge, not water

• “Short circuit”—lots of current -> lots of heat

a b

c

d

BAD!

Page 66: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

66

We’ve had this rule one day… and you break it

It’s ok to connect multiple outputs together

Under one circumstance:

All but one must be outputting Z at any time

D0

E0

D1

E1

Dn-2

En-2

Dn-1

En-1

Page 67: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

67

Mux, implemented with tri-states

• We can build effectively a mux from tri-states

• Much more efficient for large #s of inputs (e.g., 32)

Decoder

5

11110

0

0

1

0

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

… …

… …

Page 68: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

68

En0

En1

En30

En31

Register File

• Now we can write and read in one clock cycle!

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

32 bit reg

D Q

E Q

WrData

En0

En1

En30

En31

Page 69: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

69

Ports

• What we just saw: read port

• Ability to do one read / clock cycle

• May want more: read 2 source registers per instr

• Maybe even more if we do many instrs at once

• This design: can just replicate port

• Another decoder

• Another set of tri-states

• Another output bus (wire connecting the tri-states)

• Earlier: write port

• Ability to do one write/cycle

• Could add more: need muxes to pick wr values

Page 70: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

70

Minor Detail

• FYI: This is not how a register file is implemented

• (Though it is how other things are implemented)

• Actually done with SRAM

• We’ll see how those work soon

Page 71: ECE 550D Fundamentals of Computer Systems and Engineering ...tkb13/courses/ece550-2016... · •Spell out at (roughly) gate level •Abstract piece into entities for abstraction/re-use

71

Summary

Can layout logic to compute things

Add, subtract,…

Now can store things

D flip-flops

Registers

Also understand clocks


Recommended