13 j-k ff, counters, debouncing - university of florida j-k ff, counters, debouncing.pdfflip-flops...

24
28-May-20—4:54 PM 1 University of Florida, EEL 3701 – File 13 © Drs. Schwartz & Arroyo J-K FF, Counters EEL3701 1 University of Florida, EEL 3701 – File 13 © Drs. Schwartz & Arroyo Menu • Clocks and Master-Slave Flip-Flops • J-K and other Flip-Flops • Truth table & excitation table • Adders (see [Lam: pg 130]) • Counters Look into my ... EEL3701 2 University of Florida, EEL 3701 – File 13 © Drs. Schwartz & Arroyo Master-Slave Flip-Flop Complex Circuit t c = time when signals change t w = digital systems do their work here, others finish their work in this phase Most digital systems expect their inputs to be stable very early in the t c phase of the clock. As drawn, it is possible for S and/or R to “change” while CLK = 1 (during t c ). Master-Slave Latch/Flip-Flop Q (active-high and -low) may change during time t c even though other hardware expect them to be stable!! CLK t c t w S R Q Q E CLK

Upload: others

Post on 16-Jul-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

1University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

1University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Menu

• Clocks and Master-Slave Flip-Flops• J-K and other Flip-Flops• Truth table & excitation table• Adders (see [Lam: pg 130])• Counters

Look into my ...

EEL3701

2University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Master-Slave Flip-Flop

Complex Circuit

tc = time when signals changetw = digital systems do their

work here, others finish their work in this phase

Most digital systems expect their inputs to be stable very early in the tc phase of the clock. As drawn, it is possible for S and/or R to “change” while CLK = 1 (during tc).

Master-Slave Latch/Flip-Flop

Q (active-high and -low) may change during time tc

even though other hardware expect them to be stable!!

CLK

tc

tw

S

RQ

Q

E

CLK

Page 2: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

2University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

3University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Master-Slave Flip-Flop• Q: How do we solve this problem?• A: Use 2 latch’s, one master, one slave. Signals do not change

during tc. (This is a digital-only solution; the 3rd option discussed earlier.)

• Q: Why?• A: Now {Q(H), Q(L)} will not change until tw. Hence, inputs to

other systems are stable during tc.

Master Slave

S

R Q

Q

E

S

R Q

Q

ECLK

tc

tw

CLK

tc

tw

Master-Slave S-R Flip-Flop

EEL3701

4University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Master-Slave JK FF

Gated S-R Latch Q(L)

Q(H)

S(H)

E(H)

Pre-Clear

Pre-Set

R(H)

S

RQ

Q

E

LogicWorks

> With master-slave FFs we have a completely digital solution to the “stable” input problem. No oscillation occurs!!!!

JK_from_M-S_SR*.cct

Master-Slave J-K FF(Falling Edge Clock)

R Q

E

R QE

Master Slave

Q QS SK

J

J-K FF withfalling edge-clock

J

KQ

QS

R

Page 3: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

3University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

5University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Flip-FlopsMaster-Slave J-K FF(Rising Edge Clock) J-K FF with

rising edge-clock

JK

Q

QK QE

K QE

Master Slave

Q QJ J

T-FF using JK D-FF using JK

TJK

Q

Q D JK

Q

Q

D-FF using SR

D SR

Q

Q

How about constructing a JK with a D?Hint: D = J /Q + /K Q

S

R

S

R

S

R

S

R

J-K FF withfalling edge-clock

J

KQ

QS

R

EEL3701

6University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

D-FF using Two MUXs• Designed by Alex Kagioglu, a UF EEL 4712 student, 2008

10Sel

Y

2-input MUX 01Sel

Y

2-input MUXQ(H)

D(H)CLK

CLK

d-ff_mux.bdf d-ff_mux.vwf

mux2to1.vwf

Page 4: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

4University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

7University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K Flip-Flop

Next State Truth Table for J-K FF

K-Map gives

Q+ = J /Q + /K Q

(Q+ = S + /R Q)

Abbreviated Next State Truth Table

for J-K FF

Excitation Table for J-K FF

Abbreviated Excitation Table for J-K FF

EEL3701

8University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Rising edge triggered JK-FF Timing Diagram

Lam: Figure 5.2

JK

Q

Q

Page 5: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

5University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

9University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Rising edge triggered D-FF Timing Diagram

Lam: Figure 5.2

DQQ

EEL3701

10University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

• Q1: Is addition sequential?

Adder Circuits using Memory

> In this circuit a 1-bit FA with a D-FF can be used to add an arbitrary N-bit number (e.g., a 32 bit number). But a 32 bit adder without memory requires, for example, eight 74’283 4-bit parallel adders.

CLR

Q

D

SA

BCi

Ci+1

Xi (H)

Yi (H)

CLK

SUMi(H)

Ci+1 (H)

FAR

• A1: No. (At least not from what we previously learned.) It can be implemented with a combinational circuit.

• But we CAN make a sequential adder:

Page 6: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

6University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

11University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Adder Circuits using Memory

CLR

Q

D

SABCi

Ci+1

Xi (H)Yi (H)

CLK

SUMi(H)

Ci+1 (H)

FAR

Lam: Figure 5.5 (Ex 5.1)

EEL3701

12University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

• Q2: How big can N be? What is the cost?• A2: As big as you want --- same (IC) cost.• Observations:

>We can often realize complex combinational logic with simple sequential logic

>We can realize impossible combinational functions with sequential logic (e.g., counting)

>The trade-off is parallel (combinational) vs. sequential circuits, and time vs. hardware complexity– Parallel circuits obtain a sum in 1 clock tick; serial circuits

require N clock ticks.

N-bit Adder (Using Memory and 1-bit FA)

Page 7: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

7University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

13University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

• Recall we mentioned in lecture #2 that “counting” requires memory. In the next few page we will design a 3-input (8 state or 23) counter.

• There are several steps in the design of sequential circuits:> Develop a state diagram> Make a next state truth table (NSTT)> If not D-FFs, pick FFs and get excitation info to NSTT> Add outputs to NSTT> Get equations for FFs inputs > Design circuits based on the equations

• A counter turns out to have very simple steps! We will show that some of the steps above are trivial

• Assumption: A clock pulse “P” is used to clock the counter> (example/analogy) A car counter used by the road department

Steps for Counter Design

EEL3701

14University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Counter Design: State Diagram

Design a counter that counts the following sequence:Q2Q1Q0 = 100, 010, 111, 110, 011, 000, 101, 001,100,...

100

001

101

000 011

010

111

110

PP

P

P

P

P

P

PStart

Note the strange counting sequence:

4, 2, 7, 6, 3, 0, 5, 1, 4, 2, 7, …

Page 8: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

8University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

15University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Counter Design: Truth Table

• 3-bit counter (with 23=8 states) needs 3 FF’s• From the desired counter sequence, for Q2

+

(the next state for Q2) we obtain the sequence, 0 1 1 0 0 1 0 1, i.e., column Q2 of the counter sequence but delayed (starting in row 2) by 1 row> Q1

+: 1 1 1 1 0 0 0 0> Q0

+: 0 1 0 1 0 1 1 0> Put this in a next state truth table (NSTT)

• For each FF, we develop state equations > For D-FFs Qi

+ = Di , i.e., what comes in goes out immediately after the clock

• Notice that the counting order truth table (shown here) is preferred

P

100

001

101000 011

010

111

110

P

P

P

P

P

P

PStart

Q2 Q1 Q0 Q2+ Q1

+ Q0+

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

Current Next

EEL3701

16University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Counter Design: FF Next State Equations

/Q2/Q0

Q2Q1Q0

Q2+ = /Q2/Q0 + /Q2/Q1 + Q2Q1Q0

= D2

QQ2D

Q2+

CLR

/Q2/Q1

Using these sequences, we fill 3 K-maps, one for each of Q2+, Q1

+, & Q0+.

Current NextQ2 Q1 Q0 Q2

+ Q1+ Q0

+

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

D2 D1 D0

Page 9: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

9University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

17University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Counter Design: FF Next State Equations

Q2/Q0

Q1/Q0

Q1+ = Q2/Q0 + Q1/Q0 + Q2Q1

= D1

QQ1D

Q1+

CLR

Q2Q1

Using these sequences, we fill 3 K-maps, one for each of Q2+, Q1

+, & Q0+.

Q2 Q1 Q0 Q2+ Q1

+ Q0+

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

Current NextD2 D1 D0

EEL3701

18University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Counter Design: FF Next State Equations

Q1/Q0

Q0+ = /Q2/Q0 + Q1/Q0 + Q2/Q1Q0

= D0

QQ0D

Q0+

CLR

Q2/Q1Q0/Q2/Q0

Using these sequences, we fill 3 K-maps, one for each of Q2+, Q1

+, & Q0+.

Q2 Q1 Q0 Q2+ Q1

+ Q0+

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

Current NextD2 D1 D0

Page 10: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

10University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

19University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Counter Design: Realization (Designing the Circuit)

Q2+ = /Q2/Q0 + Q2Q1Q0 + /Q2/Q1

= f2(Q2, Q1, Q0) = D2

Q1+ = Q2/Q0 + Q1/Q0 + Q2Q1

= f0(Q2, Q1, Q0) = D1

Q0+ = /Q2/Q0 + Q1/Q0 + Q2/Q1Q0

= f0(Q2, Q1, Q0) = D0

Q Q2D

Q Q1D

Q Q0D

Q2+

Q1+

Q0+

CLR

CLR

CLR

Comb2

Comb1

Comb0

Q2, Q1, Q0

Q2, Q1, Q0

Q2, Q1, Q0

CLKDone!

EEL3701

20University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Activation-Levels for State Bits• What if one (or more) of the state bits (Qi ) is

active-low?>As you may recall, when we first started discussing

circuits we feedback, I stated that with these types of circuits it is often easier to deal with voltages rather than with logic.

• Recommendations:>Design the next state circuits for counters (and other

state machines) with all active-high state-bits>Then design the output circuits using the appropriate

(specified) activation levels

Page 11: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

11University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

21University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

State Machine Design

Next State

Comb. Logic

Q’sFlip-Flops

Inputs

Clk

Output Comb. Logic

Q’s

Inputs

Outputs

• For Moore machines, there are no dashed line “Inputs”; Mealy machines have these inputs

• For counters, state bits (Q’s) are generally some of the outputs, but might be active-low or active-high

Q’sClk

EEL3701

22University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Another Counter Design: State Diagram

Design a counter that counts the following sequence:Q1Q2Q3 = 000, 001, 101, 100, 010, 110, 111, 011, 000,...

Observation: Simple!

Each bubble (node) is a state.

The only input is a pulse, P.000

011

111

110 010

001

101

100

PP

P

P

P

P

P

PStart

Note the counting sequence:0, 1, 5, 4, 2, 6, 7, 3, 0, 1, 5, …

Note that naming of the state bits (Q1 Q2 Q3) different than 1st example

Page 12: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

12University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

23University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Another Counter Design: Truth Table

• 3 bit counter (8 states or 23=8) 3 FF’s• From the desired counter sequence, for

Q1+ (the next state from Q1) we obtain the

sequence, 0 1 1 0 1 1 0 0, i.e., column Q1

of the counter sequence but delayed (starting in row 2) by 1 row.> Q2

+: 0 0 0 1 1 1 1 0> Q3

+: 1 1 0 0 0 1 1 0> Put this in a next state truth table (NSTT)

• For each FF, we develop state equations > For D-FFs Qi

+ = Di , i.e., what comes in goes out

Counting:0, 1, 5, 4, 2, 6, 7, 3, 0, 1, 5, …

Q1 Q2 Q3 Q1+ Q2

+ Q3+

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

EEL3701

24University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Q2Q3 Q2Q3

Q1Q2

Q1Q3Q2Q3

Q2+ = Q1Q2+Q1Q3+Q2Q3

= D2

Q1+ = Q2Q3+Q2Q3

= Q2 Q3

= D1

Q1Q2 Q1Q2

Q3+ = Q1Q2+Q1Q2

= (Q1 Q2)

= Q1 Q2

= D3

Another Counter Design: Next State Equations

QQ1D

Q1+

CLR

Using these sequences we fill 3 K-maps, one for each of Q1+, Q2

+, & Q3+.

Page 13: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

13University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

25University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Another Counter Design: Realization (Designing the Circuit)

• Choose FF’s to realize Qi+, i=1,2,3.

• Choose D-FF because Qi+ = Di.

Simple!!!D1=Q1

+, D2=Q2+, and D3=Q3

+.

QQ1D

Q Q2D

Q Q3D

Q1+

Q2+

Q3+

CLR

CLR

CLR

• What are the output equations? O1=Q1, O2=Q2, and O3=Q3

Simple! • You could get the outputs from Qi

+, but the Qi’s are better with regard to a starting count

EEL3701

26University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Another Counter Design: Realization (Designing the

Circuit)• Realize using D-FF, T-FF, SR-FF or JK-FFs

CombinationalNetwork

Observation: This circuit contains feedback! Since the flip-flops are edge triggered, after the signal propagates through the combinational network, they do not feedback around to change the states.

CLK

Q1

Q2

Q1

Q2

Q1

/Q3

Q2

/Q3

Q2

Q3

GND

Reset

QQ1D

Q Q2D

Q Q3D

Q1+

Q2+

Q3+

CLR

CLR

CLR

Vcc

counter2.cct

Page 14: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

14University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

27University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Another Counter Design: Simulation

•Check it with LogicWorks>Build it>Simulate it

•BOUNCING!!

Counter2.cct

EEL3701

28University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Switch Bouncing

Page 15: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

15University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

29University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Switch Bouncing

EEL3701

30University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Digital Switch DebounceCircuit (with SPDT)

• The S-R latch should be made with NAND’s or NOR’s> S-R latch below is made with a D-FF used as an S-R latch

D

C

S

R

Q

Q

+5V

ON

OFF

CLN_IN(H)

CLN_IN(L)

Debounced_Switch.cct

Vcc

Page 16: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

16University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

31University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Bouncing with SPST

0ms 1ms 2ms

6V

4V

2V

0V

EEL3701

32University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Debounce Circuit Response

6V

4V

2V

0V

0ms 1ms 2ms

Page 17: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

17University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

33University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Wrong Time Scale for Bouncing with SPST

0ns 50ns 100ns 150ns 200ns

6V

4V

2V

0V

EEL3701

34University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Analog Switch DebounceCircuit (with SPST)

• Not a good solution, but one that will probably work for HC chips.

• Should use a Schmitt Trigger (74’14) with below

Debounced Switch.cct

Vcc

Page 18: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

18University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

35University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Q & AQ: Can we obtain a cheaper solution using other FF’s?A: Possibly. Some like to use JK FFs because you can make any FF

using JK.Q: But shouldn’t you use T or D -vs- JK because they are slightly faster?A: It is true that a master/slave JK is slightly slower. Typical tPD 20 ~

50 ns. Inverters (level shifters) have tPD 5-10 ns. Unless you have a very high frequency 20 ~ 50 ns (1 ns = 10-9 sec) it is still fast (50-20MHz)!

Q: You start the counter at 000. Anywhere else?A: Yes. The Qi’s are pre-cleared to start at 000. Any other state is

relatively simple to obtain using pre-clear/pre-set.Q:Who would build such a counter?

(i.e., to go 0 1 5 4 2 6 7 3 0)A: Nobody (probably). I wanted to show you that it can be designed

using any count sequence you wish. this is a pedagogical example!

EEL3701

36University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Procedure for Sequential State Machine Design

• Develop a state diagram> Use bubbles for states, arrows for transitions

• Create a next state truth table• Pick FF and add to NSTT• Add outputs to NSTT• Use K-maps to find equations to drive the FF inputs to

generate the required outputs• Design the circuit based on the equations

>Use selected FF’s and other logic gates

Page 19: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

19University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

37University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

State Machine Counter Design Steps

s0

000s1

001s2

101s3

100s4

010s5

110s6

111s7

011

Q1+ Q2

+ Q3+

(ex) When Q1Q2Q3=000, Q1+=0, Q2

+=0, and Q3+=1

Q1Q2Q3=101, Q1+=1, Q2

+=0, and Q3+=0

Fill up K-Maps for Qi+ using the “original” order

{0 1 5 4 2 6 7 3 0}

Next state truth table just adds a Di=Qi+

EEL3701

38University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

State Machine Counter Design Steps

Since using D-FF (because Qi+ = Di) then

D1=Q1+, D2=Q2

+, and D3=Q3+.

D1 = Q2 Q3, D2 = Q1Q2+Q1Q3+Q2/Q3 , and D3= /(Q1 Q2)

Since the outputs are the Q’s, i.e., Oi=Qi (or Oi=Qi+)

O1=Q1, O2=Q2, and O3=Q3

Q+ = D

QD

CLR

SET

Q

Page 20: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

20University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

39University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

State Machine Counter Design w/ SR FF’s

Let’s do it with SR FF’s.

Q

QCLK

S

R

Since we only want to count, Oi=Qi

O1=Q1, O2=Q2, and O3=Q3.

EEL3701

40University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

State Machine Counter Design w/ SR FFs

S1 R1 S2 R2 S3 R3

Use Excitation Table to

Complete the Design

[Example] Design the counter{0 1 5 4 2 6 7 3 0}From the previous example we have:

Page 21: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

21University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

41University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

State Machine Counter Design w/ SR FFs

[Example] Design the counter{0 1 5 4 2 6 7 3 0}From the previous example we have:

EEL3701

42University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

State Machine Counter Design w/ SR FFs

R1 = /S1= /(Q2 Q3)

For R1 = f(Qi’s)

S1 = Q2 Q3

For S1 = f(Qi’s)

Each arrow is an entry in the K-map

Recall: Q1 goes 001101100

Q1+ goes 01101100

next

start

0 1 5 4 2 6 7 3 0

Page 22: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

22University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

43University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

State Machine Counter Design w/ SR FFs

Do you suppose that we can trivially obtain S2,R2 and

S3,R3 since we see a D-FF?This is

a D-FF!

Q Q1

CLK

S

R

Q2

Q3

Pulse

R1 = /S1= /(Q2 Q3)

For R1

S1 = Q2 Q3

For S1

Now do similar for Q2 and Q3

EEL3701

44University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Design an Up/Down CounterLet us design a more general Up/Down Counter

00

1011

01U

U

UUD

DD

D

This is a 2-input 4-state system.

* Inputs: D, U

* States: Q1,Q0

D = Down PulseU = Up Pulse

DU 1

D U Q1 Q0 Q1+ Q0

+

0 0 0 0 0 00 0 0 1 0 1… … … … … …

0 1 0 0 0 10 1 0 1 1 0… … … … … …

1 0 0 0 1 11 0 0 1 0 0… … … … … …

1 1 0 0 X X1 1 0 1 X X… … … … … …

Page 23: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

23University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

45University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Design an Up/Down Counter

00

1011

01U

U

UUD

DD

D

• Could add an output when the count is at a certain value> Modify NSTT> Get new equation

D = Down PulseU = Up Pulse

DU 1

Q0+

Q1+

EEL3701

46University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

Next State Truth Table• You can make a next state truth table

>Inputs: Q1 and Q0 (the state), U, D>Intermediate outputs: Q1

+ and Q0+ (the next state)

>Outputs depend on type of flip-flop(s) desired and will require use of excitation tables and use of Qi & Qi

+

– If using JK-FFs: Outputs: J1, K1 and J0, K0

– If using D-FFs Outputs: D1, D0

– If using one JK-FF for MSB and one D-FF for LSB Outputs: J1, K1 and D0

This option is very common in exams!

Page 24: 13 J-K FF, Counters, Debouncing - University of Florida J-K FF, Counters, Debouncing.pdfFlip-Flops Master-Slave J-K FF (Rising Edge Clock) J-K FF with rising edge-clock J K Q Q K Q

28-May-20—4:54 PM

24University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

J-K FF, Counters

EEL3701

47University of Florida, EEL 3701 – File 13

© Drs. Schwartz & Arroyo

The End!