Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR...

83
15 COUNTERS Page 1 ECE238L © 2006 Midterm 2 - Review

Transcript of Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR...

Page 1: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 1

ECE238L © 2006

Midterm 2 - Review

Page 2: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 2

ECE238L © 2006

LATCH

StorageBi-stability

Latches

Page 3: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 3

ECE238L © 2006

Sequential Circuits

• The output of a Combinatorial Circuit depends only on the current inputs

• The output of a Sequential Circuit can remember something about the past

Page 4: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 4

ECE238L © 2006

Bi-Stability = Key to Memory

1 00

0 11

This is a stable state –it will sit like this forever

This is also a stable state –it will sit like this forever

There are 2 stable states -a bi-stable circuit…

Page 5: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 5

ECE238L © 2006

SR Latch – A Bi-Stable Circuit

S

RQ

Q’

0

0

1

0

S

RQ

Q’

0

0

0

1

This is a stable state –it will sit like this forever

This is also a stable state –it will sit like this forever

Page 6: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 6

ECE238L © 2006

SR Latch Transition TableS R Q Q+

0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 11 0 1 11 1 0 N/A1 1 1 N/A

No change

Reset it

Set it

S

R

Q

Q’

Page 7: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 7

ECE238L © 2006

Symbology

S

R

Q

Q’

R Q

S Q’

Page 8: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 8

ECE238L © 2006

GLATCH

Gated Latches

Page 9: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 9

ECE238L © 2006

The Gated SR LatchR

S

Q

Q’

GATE

GS

GR When GATE=‘0’ GR=GS=‘0’

latch cannot be modified

When GATE=‘1’GR=R, GS=S

works like an SR latch

A Latch

The GATE signal allows us to controlwhen

the latch will be loaded with a new value

Page 10: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 10

ECE238L © 2006

Gated SR Latch

• Sometimes known as a loadable SR latch– Can be loaded with new value

R

S

Q

Q’

GATE

GS

GR

Page 11: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 11

ECE238L © 2006

The Gated D LatchD

Q’

Q

GATE

GATE D Q Q+

0 0 0 00 0 1 10 1 0 00 1 1 11 0 0 01 0 1 01 1 0 11 1 1 1Q+ = GATE•D + GATE’•Q

When GATE=‘1’ Q follows D (storage)When GATE=‘0’ Q retains old value (retention)

Page 12: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 12

ECE238L © 2006

Gated D Latches

• Sometimes called a transparent latch– When GATE=‘1’:

• Q follows D• D is reflected on Q output

• Allows us to control when to store new data into latch– D = data to be stored– GATE = control signal

Page 13: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 13

ECE238L © 2006

Symbology

D Q

Gate

D

Q

GATE

D Q

Load

or…

Page 14: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 14

ECE238L © 2006

MSFF

Master/Slave Flip Flops

Page 15: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 15

ECE238L © 2006

A Master/Slave Flip Flop (D Type)Gated D latch(master) Gated D latch (slave)

D Q

Gate

D Q

Gate

D

GATE

QQ1

Either:The master is loading (the master in on)

orThe slave is loading (the slave is on)

But never both at the same time…

Page 16: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 16

ECE238L © 2006

Alternative Flip Flops

TJK

Page 17: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 17

ECE238L © 2006

Toggle Flip Flop

T Q Q+

0 0 00 1 11 0 11 1 0

NoAction

Toggle

T Q

CLK

QT

Q+ = T’•Q + T•Q’ = T + Q

Clock edge is assumedin this transition table…

Page 18: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 18

ECE238L © 2006

JK Flip Flop

J K Q Q+

0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 11 0 1 11 1 0 11 1 1 0

No Change

Reset

Set

Toggle

J QK

CLK

QJK

Q+ = K’•Q + J•Q’Kind of a cross betweena SR FF and a T FF

Page 19: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 19

ECE238L © 2006

Why Alternative FF’s?

• With discrete parts (TTL family)– JK or T FF’s could reduce gate count for the

input forming logic – Extensively used

• With VLSI IC’s and FPGA’s– JK or T FF’s must be built from DFF+gates– Larger, slower than a DFF– Not used

Page 20: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 20

ECE238L © 2006

Flip Flops With Additional Control Inputs

Page 21: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 21

ECE238L © 2006

D

CLK

Q

Q’

What is this?

Enable

A falling edge triggered, D-type FF with enable

Master only loads when CLK=Enable=‘1’

Page 22: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 22

ECE238L © 2006

D

CLK

Q

Q’

What is this?

Set

A falling edge triggered, D-type FF with an asynchronous set

If Set=1 then Q=>1, regardless of CLK or D

Page 23: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 23

ECE238L © 2006

D

CLK

Q

Q’

What is this?

A falling edge triggered, D-type FF with a synchronous set

If Set=1 then Q=>1 on the next falling edge of the clock, regardless of D

Set

Page 24: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 24

ECE238L © 2006

Flip Flops With Additional Control Inputs

• A variety of FF’s have been made over the years

• They contain combinations of these inputs:– Enable– Set– Reset

• The Set and Reset can be either:– Asynchronous (independent of CLK)– Synchronous (work only on CLK edge)

Page 25: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 25

ECE238L © 2006

Flip Flop Timing Characteristics

Page 26: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 26

ECE238L © 2006

Clock-to-Q Time (tCLK Q)

D

CLK

Q

Q’

tCLK Q = tNOT + tAND + 2 x tNOR

The output does not change instantaneously…

Why 2 x tNOR?

Page 27: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 27

ECE238L © 2006

Setup Time (tsetup)D

CLK

Q

Q’

tsetup = tNOT + tAND + 2 x tNOR

The input has to get there early enoughto set the master latch before

the clock turns off…

Page 28: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 28

ECE238L © 2006

D

CLK

Q

Q’

Same setup time as before

Clock is delayed through the NOT gate

Rising Edge FF Setup Time (tSETUP)

Page 29: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 29

ECE238L © 2006

Falling Edge Hold Time (thold)D

CLK

Q

Q’

thold = 0ns (AND gates turn off immediately)

You have to keep the old D value there until the ANDgates are shut off… (but no longer)

Page 30: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 30

ECE238L © 2006

Rising Edge Hold Time (thold)D

CLK

Q

Q’

thold = tNOT

You have to keep the old D value there until the ANDgates are shut off…

Page 31: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 31

ECE238L © 2006

Timing of a Synchronous System

CLK

D Q

CLK

D QInputFormingLogic

InputFormingLogic

time

Q D

CLK

Q

D

tCLK Q tIFL tSETUP

tCYCLE >= tCLK Q + tIFL + tSETUP

Page 32: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 32

ECE238L © 2006

D QD QD Q

Example of a Synchronous System

D Q+1

Circuit

4

CLK

4 4CNT = 0000

0001001000110100…11110000…One transition per clock edge…

Page 33: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 33

ECE238L © 2006

General Sequential Systems

D QD Q

CurrentStateState

MemoryInputForming

Logic

NextState

Page 34: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 34

ECE238L © 2006

A Sequential Counter

CLK

NextState 01 10 11 00 01

CurrentState 00 01 10 11 00

The current stateloads the nextstate values inresponse to the clock edge.

IFL reacts after some gate delaysto produce a newnext state.

Clock edges…D QD Q

CurrentStateState

Memory+1 Next

State

2

Master Master MasterMaster MasterSlave Slave Slave Slave

Page 35: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 35

ECE238L © 2006

Transition Table for 2-Bit Counter

CurrentState

NextState

00 0101 1010 1111 00

It is the truth table for the input forming logic…

It describes what the next state values are as a functionof the current state(clock is assumed)

Q1 Q0 N1 N0

0 0 0 10 1 1 01 0 1 11 1 0 0

CurrentState

NextState

Page 36: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 36

ECE238L © 2006

General Counter Design Procedure

• Write transition table for counter– Use X’s as appropriate

• Reduce each Nx variable to an equation• Implement input forming logic (IFL) using

gates• Draw schematic using FF’s + IFL

Page 37: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 37

ECE238L © 2006

Counters With Outputs

Outputs

D QD Q

CurrentState

InputForming

Logic

NextState

StateMemory

OutputForming

Logic

Outputs = f(CurrentState)

Page 38: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 38

ECE238L © 2006

Combined Transition TableQ2 Q1 Q0 N2 N1 N0 Z

0 0 0 0 0 1 10 0 1 0 1 0 00 1 0 0 1 1 00 1 1 1 0 0 11 0 0 1 0 1 01 0 1 1 1 0 01 1 0 1 1 1 11 1 1 0 0 0 0

Current state Next state Output

Z = Q2’Q1’Q0’ + Q2’Q1Q0 + Q2Q1Q0’

(implement OFL with gates)

Page 39: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 39

ECE238L © 2006

State Graphs

Page 40: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 40

ECE238L © 2006

Binary Counter State Graph

00

10

0111

Q1 Q0 N1 N0

0 0 0 10 1 1 01 0 1 11 1 0 0

State

Transition

State graphs are graphicalrepresentations of TT’s

They contain the same information:no more, no less

Page 41: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 41

ECE238L © 2006

State Graphs for Counters With Inputs

00

10

0111

INC

INCINC

INC

INC’

INC’

INC’

INC’

INC Q1 Q0 N1 N0

0 0 0 0 00 0 1 0 10 1 0 1 00 1 1 1 11 0 0 0 11 0 1 1 01 1 0 1 11 1 1 0 0

There is a one-to-onecorrespondence betweenthe rows of the TT andthe arcs in the SG

INC controls whether transitionis taken or not…

Page 42: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 42

ECE238L © 2006

Transition Table SimplificationCLR INC Q1 Q0 N1 N0

0 0 0 0 0 00 0 0 1 0 10 0 1 0 1 00 0 1 1 1 10 1 0 0 0 10 1 0 1 1 00 1 1 0 1 10 1 1 1 0 01 0 0 0 0 01 0 0 1 0 01 0 1 0 0 01 0 1 1 0 01 1 0 0 0 01 1 0 1 0 01 1 1 0 0 01 1 1 1 0 0

CLR INC Q1 Q0 N1 N0

0 0 0 0 0 00 0 0 1 0 10 0 1 0 1 00 0 1 1 1 10 1 0 0 0 10 1 0 1 1 00 1 1 0 1 10 1 1 1 0 01 - 0 0 0 01 - 0 1 0 01 - 1 0 0 01 - 1 1 0 0

These are input don’t cares. They are a shorthand for the TT on the leftThis TT exactly matches SG on previous page

CLR INC Q1 Q0 N1 N0

0 0 0 0 0 00 0 0 1 0 10 0 1 0 1 00 0 1 1 1 10 1 0 0 0 10 1 0 1 1 00 1 1 0 1 10 1 1 1 0 01 - - - 0 0

Page 43: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 43

ECE238L © 2006

Simplified Transition Tables With Input Don’t Cares

• Contain exactly same information as original– Shorthand way of writing

• Should be able to easily convert back/forth

Page 44: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 44

ECE238L © 2006

Design Procedure Using State Graphs

1. Draw the state graph

2. Create an equivalent transition table

3. If transition table contains input don’t cares, - unfold it to a full transition table

4. Complete the design using KMaps, gates, FF’s

Page 45: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 45

ECE238L © 2006

Cascaded Counters

Page 46: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 46

ECE238L © 2006

A Mod4 Counter With a Rollover Signal

CLR INC Q1 Q0 N1 N0 Rollover

0 0 0 0 0 0 00 0 0 1 0 1 00 0 1 0 1 0 00 0 1 1 1 1 00 1 0 0 0 1 00 1 0 1 1 0 00 1 1 0 1 1 00 1 1 1 0 0 11 - - - 0 0 0

00

10

0111

CLR’ • INCCLR’ • INC’

CLR

CLR’ • INCCLR’ • INC

CLR’ • INC/Rollover

CLR’ • INC’

CLR’ • INC’

Signal Rollover can be used to tellother circuitry that counter isrolling over to all 0’s

Mealy output CLR’ • INC’

Page 47: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 47

ECE238L © 2006

Cascading 2 Mod4 Counters

0001020310111213202122233031323300

Count sequence

Mod4 Counter

2

INCRollover0

Digit0

Increment higherdigit’s counterwhen lower digit’scounter is rollingover

Digit1 Digit0

CLRMod4

Counter

2

Rollover1

Digit1

CLR

clk clk

Page 48: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 48

ECE238L © 2006

3 Digits’ Worth

Mod4 Counter

2

INCRollover0

Digit0

CLRMod4

Counter

2

Rollover1

Digit1

CLRMod4

Counter

2

Rollover2

Digit2

CLR

Increment higherdigit’s counterwhen lower digit’scounter is rollingover

Can do this with anycounter that has a Rollover outputCould build a digital watch

or clock circuit this way withMod60 and Mod24 counters

clkclkclk

Page 49: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 49

ECE238L © 2006

Cascading Counters

• A counter will increment only when– The counter below it is at its terminal count

and it is being incremented• That is the definition of the Rollover signal

• Some people try to tie Rollover to the clkinput of the next higher counter– Bad idea… Very bad idea…– Violates our Globally Synchronous policy– Doesn’t work as intended

Page 50: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 50

ECE238L © 2006

Ripple Counters

• When you tie a rollover-like signal to a clock on the next higher digit ripple counter

• A ripple counter is an ASYNCHRONOUS counter– Transitions are not all synchronized to the clock– Different flip flops change at different times– Similar to gated clocks (seen earlier)

• Asynchronous circuits are an advanced topic

Page 51: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 51

ECE238L © 2006

Another Common Ripple Counter

CLK

T QQ’

‘1’T Q

Q’

‘1’T Q

Q’

‘1’T Q

Q’

‘1’

Q3 Q2 Q1 Q0

Sequence is:

00000001001000110100010101100111100010011010101111001101111011110000

So what is the problem?

Page 52: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 52

ECE238L © 2006

Mod4 Counter

Page 53: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 53

ECE238L © 2006

D Q

D Q

IFL

Inc

TerminalCount

RollOver

A Mod4 Counter

CountValue

The right way!

Clr

Page 54: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 54

ECE238L © 2006

A Mod4 Counter

MOD4

CountValue

RollOver

Clock

Clear

Increment

Page 55: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 55

ECE238L © 2006

Registers

Page 56: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 56

ECE238L © 2006

A 4-Bit RegisterCLK

D3

CLK

D2

CLK

D1

CLK

D0

Q3

Q2

Q1

Q0

D Q

CLK

D Q4 4

D Q

D Q

D Q

D Q

Could be called a parallel-in/parallel-outregister.

Why?

Page 57: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 57

ECE238L © 2006

A Shift Register

CLK

Serial-In D Q D Q D Q D Q

CLK CLK CLK

Q3 Q2 Q1 Q0

cycle 0 1 0 1 1cycle 1 0 1 0 1cycle 2 0 0 1 0cycle 3 0 0 0 1cycle 4 0 0 0 0

Called a serial-in, parallel-out shift register (SIPO)

Page 58: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 58

ECE238L © 2006

SIPO Register (Serial-In/Parallel-Out)

CLK

Serial-In D Q D Q D Q D Q

CLK CLK CLK

Q3 Q2 Q1 Q0

Parallel-Out

Page 59: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 59

ECE238L © 2006

SISO Register (Serial-In/Serial-Out)

CLK

Serial-In D Q D Q D Q D Q

CLK CLK CLK

Serial-Out

Useful for delaying a serial bit-stream some number of cycles…

Page 60: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 60

ECE238L © 2006

Gated Clocking

• Different flip flops load at different times– A form of clock skew– Makes doing timing analysis more difficult– Can lead to circuits which run more slowly– Can lead to circuits which fail at any clock rate

Page 61: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 61

ECE238L © 2006

Globally Synchronous Design

• One global clock• All registers load on that clock’s edge• Control over loading done via input forming logic (IFL)

• Simplifies timing analysis and requirements• Makes it possible for even novices to design large,

functioning circuits

• Multi-clock circuits next semester’s topic

Page 62: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 62

ECE238L © 2006

The Correct Way To Make A Loadable Register (1-Bit)

D Q0

1

CLKLOAD

DINQ

When LOAD=‘0’, FF loads old value

When LOAD=‘1’, FF loads DIN

Page 63: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 63

ECE238L © 2006

A Loadable Parallel-In, Parallel-Out Register

D Q0

1

CLKLOAD

DIN(3:0)Q(3:0)

4

4 4

PIPO ?

Page 64: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 64

ECE238L © 2006

MUX for Register Control

• Loadable register concept can be generalized– Provide any combination of inputs to register

Page 65: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 65

ECE238L © 2006

Uses of Shift Registers

• Collecting serial input data into a parallel word• Shifting out bits of a word• Delaying a serial stream by some # of cycles

Page 66: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 66

ECE238L © 2006

A Clearable Counter

CLR INC Q+0 0 Q0 1 Q+11 0 01 1 Q

D Q Q

CLKCLR INC

QQ+1

0Q

444

4

4

4

2

From there to here, from here to there, interesting circuits are everywhere…

(when you have a MUX and some flip flops)

Page 67: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 67

ECE238L © 2006

An Up/Down Counter

D Q Q

CLKUP/DN#

Q-144

0

1Q+1

How about an up/down counter + bi-directional shift register design?

Page 68: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 68

ECE238L © 2006

Up/Down Counter + Bi-Directional Shift Register

Control NextQ00 Q+101 Q-110 Q shifted left11 Q shifted right

D Q Q

CLKControl

Q+1Q-1

Q<<1Q>>1

444

4

4

4

2

Page 69: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 69

ECE238L © 2006

An Accumulator

D Q Q

CLKCLR

44

0

1

+AD Q Q

CLKCLR

44

0

1

+A

0

This one loads 0 when CLR=‘1’ This one loads A when CLR=‘1’

Both work, they just have different timings…

Values to be added are placed on A input, one per cycle. Register accumulates their sum.

4

4

Version A Version B

Page 70: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 70

ECE238L © 2006

Register Files

Small memories holding multiple words of data

Page 71: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 71

ECE238L © 2006

Typical Register File

DataIn

clk

Addr

regWE

RegFile

DataOut

n

n

m

Page 72: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 72

ECE238L © 2006

Building a Register File

Reg0

Reg1

Reg2

Reg3

Reg4

Reg5

Reg6

Reg7

WriteDecoder

Addr

regWE

Reg

iste

r writ

e si

gnal

s

DataIn clk8:

1 M

UX

DataOut

m=3 n

n

nn

nnn

n

nn

Page 73: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 73

ECE238L © 2006

Multi-Ported Register File

Reg0

Reg1

Reg2

Reg3

Reg4

Reg5

Reg6

Reg7

WriteDecoder

WAddrWE

Reg

iste

r writ

e si

gnal

s

DataIn clk

RAddr18:

1 M

UX

Raddr2

DataOut1

DataOut2

One write portTwo read ports

Can be reading fromtwo locations on samecycle you write to another location

Useful for microprocessor design

Page 74: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 74

ECE238L © 2006

Memories vs. Register Files

• Random Access Memory (RAM) is similar to a register file– Stores many multi-bit words for reading/writing

• RAM usually only single-ported• RAM usually much, much larger

– Mbytes instead of bytes• RAM implementation conceptually the same as

register file– Transistor-level implementation different due to

size/usage characteristics• RAM design beyond the scope of this class

Page 75: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 75

ECE238L © 2006

Finite State Machines

Page 76: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 76

ECE238L © 2006

State Machine Concepts

• State, current state, next state, state registers

• IFL, OFL, Moore outputs, Mealy outputs• Transition tables

– With output don’t cares (X’s)– With input don’t cares (-’s)

• State graphs– And their correspondence to TT’s

Page 77: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 77

ECE238L © 2006

State Machines

• A state machine is a sequential circuit which progresses through a series of states in reponse to inputs– The output values are usually significant– The state encodings are usually not significant

• Unlike with counters

Page 78: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 78

ECE238L © 2006

Implementing the Sequence Detector FSM

1. Create symbolic Transition Table2. Assign state encoding3. Create conventional Transition Table4. Do standard implementation steps

Xin CS NS Z

0 S0 S1 01 S0 S0 00 S1 S1 01 S1 S2 00 S2 S1 01 S2 S3 0- S3 S3 1

Xin Q1 Q0 N1 N0 Z

0 0 0 0 1 01 0 0 0 0 00 0 1 0 1 01 0 1 1 0 00 1 0 0 1 01 1 0 1 1 0- 1 1 1 1 1

Symbolic TT Conventional TTState Assignment

S0 = 00S1 = 01S2 = 10S3 = 11

Page 79: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 79

ECE238L © 2006

Sequence Detector Implementation

Q1

CLK

Q0

CLK

Q1

D Q

D Q

Q0N1

N0

Q1XinXinQ0

Xin’Q1

Z

N1 = Q1•Q0 + Xin•Q1 + Xin•Q0N0 = Xin’ + Q1Z = Q1•Q0

Page 80: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 80

ECE238L © 2006

Resetting State Machines

• Ability to reset the FSM is essential for testing most systems

• Always include a reset capability– Add CLR signal to state graph– Use flip flops with clear inputs

– Either method will work

Page 81: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 81

ECE238L © 2006

One-Hot EncodedFinite State Machines

Page 82: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 82

ECE238L © 2006

One-Hot - Observations

• Choosing a one-hot encoding results in many, many don’t cares in transition table

• Minimization results in simpler IFL and OFL

• Can do one-hot design by inspection– without using transition tables…

Page 83: Midterm 2 - Reviezbaker/ece238/slides/Review.pdf · 2007. 8. 14. · 2 Rollover0 INC Digit0 CLR Mod4 Counter 2 Rollover1 Digit1 CLR Mod4 Counter 2 Rollover2 Digit2 CLR Increment higher

15 COUNTERSPage 83

ECE238L © 2006

Other State Encoding Techniques

• You have learned the 2 extremes– Fully encoded (8 states 3 state bits)– One-hot encoded (8 states 8 state bits)

• A range of options exist in between

• A good choice of encoding– Can minimize IFL and OFL complexity– Algorithms have been developed for this…– Beyond the scope of this class