Sequential Circuits: Latches &...

30
Sequential Circuits: Latches & Flip-Flops

Transcript of Sequential Circuits: Latches &...

Page 1: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Sequential Circuits:Latches & Flip-Flops

Page 2: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Sequential Circuits

• Combinational Logic:– Output depends only on current input– Able to perform useful operations

(add/subtract/multiply/encode/decode/select[mux]/etc…)

– Require cascading of many structures– Costly and inflexible

Chapter 4: Sequential Circuits (4.1 -- 4.3)

213-Dec-12

Page 3: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Sequential Circuits (cont.)

• Sequential Logic:– Output depends not only on current input but

also on past input values– Store information between operations– Need some type of memory (Register) to

remember the past input values. (Commonly use D type Flip Flops as Registers)

Chapter 4: Sequential Circuits (4.1 -- 4.3)

313-Dec-12

Page 4: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Define Schematic Terminology

Chapter 4: Sequential Circuits (4.1 -- 4.3)

413-Dec-12

I/Ps O/Ps4 4

5

D(3:0)

Dout(3:0)

P(P,Dout(3:0))

D(3)

D(2)

D(1)

D(0)

D(3:0)

Not a short circuit!Signals merge into a

Bus or Vector

Page 5: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Sequential Circuits (cont.)

Chapter 4: Sequential Circuits (4.1 -- 4.3)

513-Dec-12

Information StoringCircuits – Registers(Flip Flops)

Timed “States”Probably more than 1 bit if >2 states

Page 6: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Sequential Logic: Concept

• Sequential Logic circuits remember past inputs and past circuit state.

• Outputs from the system are“fed back” as new inputs.

• The storage elements are circuits that are capable of storing binary information: memory.

Chapter 4: Sequential Circuits (4.1 -- 4.3)

613-Dec-12

Page 7: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Synchronous vs. Asynchronous machines

There are two types of sequential circuits:• Synchronous sequential circuit: the behavior

can be defined from knowledge of its signal at discrete instants of time. This type of circuits achieves synchronization by using a timing signal called the clock.

• Asynchronous (fundamental mode) sequential circuit: the behavior is dependent on the order of input signal changes over continuous time, and output can change at any time (clockless).

Chapter 4: Sequential Circuits (4.1 -- 4.3)

713-Dec-12

Page 8: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Clock Signal

Chapter 4: Sequential Circuits (4.1 -- 4.3)

813-Dec-12

Different duty cycles

Clock generator: Periodic train of clock pulses

Rising Clock Edge

Falling Clock Edge

Page 9: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Circuits:Flip flops as state

memory

Chapter 4: Sequential Circuits (4.1 -- 4.3)

913-Dec-12

The flipThe flip--flops receive their inputs from the flops receive their inputs from the combinational circuit and also from a clock signal combinational circuit and also from a clock signal with edges (rising or falling) that occur at fixed with edges (rising or falling) that occur at fixed intervals of time, as shown in the timing diagram.intervals of time, as shown in the timing diagram.

Page 10: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Chapter 4: Sequential Circuits (4.1 -- 4.3)

1013-Dec-12

Buffers

Inverters

Storing Elements

Can’t change the stored value!

Page 11: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

SR latch (NOR version)

Chapter 4: Sequential Circuits (4.1 -- 4.3)

1113-Dec-12

---- SR: “setSR: “set--reset”, bistable element with two extra reset”, bistable element with two extra inputs; note the “undefined” output for S=R=1. inputs; note the “undefined” output for S=R=1.

---- Reading the logic:Reading the logic:

Q = (R+Q’)’; P = (S+Q)’Q = (R+Q’)’; P = (S+Q)’Illegal state

Page 12: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

R=S=1 ??

• Illegal output, because– When S=R=1, both outputs go to zero.– If both inputs now go to 0, the state of the SR

flip flop is depends on which input remains a 1 longer before making transition to 0.

– Hence, “undefined” state. MUST be avoided.

Chapter 4: Sequential Circuits (4.1 -- 4.3)

1213-Dec-12

Page 13: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

S’R’ Latch (NAND version)

Chapter 4: Sequential Circuits (4.1 -- 4.3)

1313-Dec-12

S’

R’

Q

Q’

0 00 11 01 1

S’ R’ Q Q’0

1

1

0

1 0 Set

0 0 10 1 11 0 11 1 0

X Y NAND

Page 14: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

S’R’ Latch (NAND version)

Chapter 4: Sequential Circuits (4.1 -- 4.3)

1413-Dec-12

S’

R’

Q

Q’

0 00 11 01 1

S’ R’ Q Q’1

1

1

0 1 0 Hold

0 0 10 1 11 0 11 1 0

X Y NAND

1 0 Set

Page 15: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

S’R’ Latch (NAND version)

Chapter 4: Sequential Circuits (4.1 -- 4.3)

1513-Dec-12

S’

R’

Q

Q’

0 00 11 01 1

S’ R’ Q Q’1

0

0

1

0 0 10 1 11 0 11 1 0

X Y NAND

1 0 Hold

1 0 Set0 1 Reset

Page 16: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

S’R’ Latch (NAND version)

Chapter 4: Sequential Circuits (4.1 -- 4.3)

1613-Dec-12

S’

R’

Q

Q’

0 00 11 01 1

S’ R’ Q Q’1

1

0

1

0 0 10 1 11 0 11 1 0

X Y NAND

0 1 Hold

1 0 Set0 1 Reset1 0 Hold

Page 17: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

S’R’ Latch (NAND version)

Chapter 4: Sequential Circuits (4.1 -- 4.3)

1713-Dec-12

S’

R’

Q

Q’

0 00 11 01 1

S’ R’ Q Q’0

0

1

1

0 0 10 1 11 0 11 1 0

X Y NAND

0 1 Hold

1 0 Set0 1 Reset1 0 Hold

1 1 Disallowed

Page 18: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Chapter 4: Sequential Circuits (4.1 -- 4.3)

1813-Dec-12

SR Latches

Page 19: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Chapter 4: Sequential Circuits (4.1 -- 4.3)

1913-Dec-12

SR Latch Simulation (Timing Diagram)

Page 20: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Chapter 4: Sequential Circuits (4.1 -- 4.3)

2013-Dec-12

SR Latch with Clock signal

Latch is sensitive to input changes ONLY when C=1Latch is sensitive to input changes ONLY when C=1

CLK

CLK

Page 21: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

SR Latch with Clock signal (cont.)

Chapter 4: Sequential Circuits (4.1 -- 4.3)

2113-Dec-12

S’

R’

Q

Q’

S

R

CLK

S R CLK S’ R’ Q Q’0 0 1 1 1 Q0 Q0’ Store 0 1 1 1 0 0 1 Reset1 0 1 0 1 1 0 Set1 1 1 0 0 1 1 DisallowedX X 0 1 1 Q0 Q0’ Store

Page 22: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

D Latch

• One way to eliminate the undesirable indeterminate state in the RS flip flop is to ensure that inputs S and R are never 1 simultaneously. This is done in the D latch:

Chapter 4: Sequential Circuits (4.1 -- 4.3)

2213-Dec-12

CLK

Page 23: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

D Latch (cont.)

Chapter 4: Sequential Circuits (4.1 -- 4.3)

2313-Dec-12

D

S R CLK Q Q’0 0 1 Q0 Q0’ Store 0 1 1 0 1 Reset1 0 1 1 0 Set1 1 1 1 1 DisallowedX X 0 Q0 Q0’ Store

0 1 0 11 1 1 0X 0 Q0 Q0’

D CLK Q Q’

S’

R’

Q

Q’

S

R

CLK

Page 24: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Latches: Behaviour & Issues

• Level triggered• Latches are “transparent” (= any change on the

inputs is seen at the outputs immediately).• This causes synchronization problems! (not

recommended for use in synchronous designs)• Solution: use latches to create flip-flops that can

respond (update) ONLY on SPECIFIC times (instead of ANY time).

Chapter 4: Sequential Circuits (4.1 -- 4.3)

2413-Dec-12

Page 25: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Alternatives in FF choice

• Edge triggered (rising or falling edge of clk) used in synchronous design

• Various types exist:– RS– D– JK

Chapter 4: Sequential Circuits (4.1 -- 4.3)

2513-Dec-12

Page 26: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

SR Flip Flop

Chapter 4: Sequential Circuits (4.1 -- 4.3)

2613-Dec-12

–– Enables edgeEnables edge--triggered behaviortriggered behavior

––This is This is NOTNOT a latch (even though it is a latch (even though it is built from latchesbuilt from latches

Master Slave

CLK CLK

CLK

CLK

Page 27: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Chapter 4: Sequential Circuits (4.1 -- 4.3)

2713-Dec-12

S R CLK Q Q’

0 0 Q0 Q0’ Store 0 1 0 1 Reset1 0 1 0 Set1 1 1 1 DisallowedX X 0 Q0 Q0’ Store

•When C=1, master is enabled andstores new data, slave stores olddata.•When C=0, master’s state passesto enabled slave (Q=Y), master notsensitive to new data (disabled).

SR Flip Flop (contd.)SR Flip Flop (contd.)

CLK CLK CLK

Page 28: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Chapter 4: Sequential Circuits (4.1 -- 4.3)

2813-Dec-12

Master-Slave J-K Flip-Flop

CLK CLK CLK

CLK

Page 29: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Positive Edge-triggered D Flip-Flops

• Attach level-triggered D latch to level-triggered SR latch, using complemented clocks.

• D-Type Positive Edge-Triggered Flip-Flop:

13-Dec-12

29Chapter 4: Sequential Circuits (4.1 -- 4.3)

CLK CLK

CLK

Page 30: Sequential Circuits: Latches & Flip-Flopsmaulana.lecture.ub.ac.id/files/2012/04/Flip-Flop-dan-Latch.pdf · Latches: Behaviour & Issues • Level triggered • Latches are “transparent”

Chapter 4: Sequential Circuits (4.1 -- 4.3)

3013-Dec-12

Positive Edge-Triggered J-K Flip-Flop

CLK

CLK

CLK