Latches and Flip

advertisement
CEC 220 Digital Circuit Design
Latches and Flip-Flops
Friday, March 07
CEC 220 Digital Circuit Design
Slide 1 of 14
Lecture Outline
•
•
•
•
D Flip-Flop review
VHDL code for a D Flip-Flop
S-R, J-K, T Flip-Flops
Registers
Friday, March 07
CEC 220 Digital Circuit Design
Slide 2 of 14
Latches and Flip-Flops
Example with a Gated D-Latch
• Complete the timing diagram below for a gated D latch
 Assume that Q begins at 0
Friday, March 07
CEC 220 Digital Circuit Design
Slide 3 of 14
Latches and Flip-Flops
• An edge triggered D Flip-Flop from gated D Latches
P & Q are
initially ‘0’
Master
Slave

𝐶𝑘
P
Q
Friday, March 07
CEC 220 Digital Circuit Design
Slide 4 of 14
Latches and Flip-Flops
VHDL Code for a D Flip-Flop
• VHDL architecture code is concurrent except for code
inside a “PROCESS” statement
process (CLK)
–- If clock changes
begin
if (CLK’event and CLK=‘1’) then –- Rising edge
Q <= D;
-- Q and QNot
QN <= not D; Statements in here
are “Sequential”
end if;
end process;
Friday, March 07
CEC 220 Digital Circuit Design
Slide 5 of 14
Latches and Flip-Flops
VHDL Code for a D Flip-Flop
Friday, March 07
CEC 220 Digital Circuit Design
Slide 6 of 14
Latches and Flip-Flops
The J-K Flip-Flop
J
0
0
1
1
• The J-K Flip-Flop
Inputs
State
Next State
J(t) K(t) Q(t) Q(t+t)
0
0
0
0
Hold
0
0
1
1
0
1
0
0
Reset
0
1
1
0
1
0
0
1
Set
1
0
1
1
1
1
0
1
Toggle
1
1
1
0
Friday, March 07
Q(t+t)
J(t)
0
1
00
0
1
01
1
1
11
0
0
10
0
1
K(t)Q(t)
Q  J Q  K Q
CEC 220 Digital Circuit Design
K
Q
0 Hold
1 Reset
0
Set
1 Toggle
Slide 7 of 14
Latches and Flip-Flops
The J-K Flip-Flop
• An example with the J-K Flip-Flop
 Assume initially Q=0
Set
Reset
Toggle
Q
Friday, March 07
CEC 220 Digital Circuit Design
Slide 8 of 14
Latches and Flip-Flops
The Toggle Flip-Flop
• The T Flip-Flop
Input
Hold
Toggle
Friday, March 07
State
Next State
T(t) Q(t) Q(t+t)
0
0
0
1
0
1
1
1
0
0
1
1
CEC 220 Digital Circuit Design
Q  T Q  T Q
Slide 9 of 14
Latches and Flip-Flops
The Toggle Flip-Flop
• An example with the T Flip-Flop
 Assume initially Q=0
Hold
Toggle
Hold
Toggle
Q
Friday, March 07
CEC 220 Digital Circuit Design
Slide 10 of 14
Latches and Flip-Flops
Flip-Flop Summary
Flip-Flop
Name
S-R
J-K
D
Flip-Flop
Symbol
S
Q
R
Q
Clk
J
Q
K
Q
Clk
Q
D
Clk
T
Q
T
Clk
Friday, March 07
Q
Q
Characteristic
Table
S R
Q++
0
0
1
1
Q
0
1
NA
0
1
0
1
J K
Q++
0
0
1
1
0
1
0
1
Q
0
1
Q
D
Q++
0
1
0
1
T
Q++
0
1
Q
Q
Hold
Reset
Set
NA
Hold
Reset
Set
Toggle
Reset
Set
Hold
Toggle
Characteristic
Equations
Q+ = S + R Q
Q++ = J Q + K Q
Q++ = D
Q++ = T Q + T Q
CEC 220 Digital Circuit Design
Excitation
Table
Q Q++
S R
0
0
1
1
0
1
0
X
0
1
0
1
X
0
1
0
Q Q++
J K
0
0
1
1
0
1
0
1
0
1
X
X
Q Q++
D
0
0
1
1
0
1
0
1
0
1
0
1
Q Q++
T
0
0
1
1
0
1
1
0
0
1
0
1
X
X
1
0
Slide 11 of 14
Latches and Flip-Flops
• Build a T Flip-Flop from a J-F Flip-Flop
Excitation Table:
T
0
0
Q
0
1
Q+
1
1
0
1
1
0
0
1
J
0
X
K
X
0
1
X
X
1
Q
Q+
SR
JK
T
D
0
0
0X
0X
0
0
0
1
10
1X
1
1
1
0
01
X1
1
0
1
1
X0
X0
0
1
T type FF
J T
K T
Friday, March 07
Q
J
K
CEC 220 Digital Circuit Design
Clk
Q
Slide 12 of 14
Latches and Flip-Flops
• Fill in the timing diagram for a falling-edge triggered
S-R flip-flop.
 Assume Q begins at 0
Friday, March 07
CEC 220 Digital Circuit Design
Slide 13 of 14
Next Lecture
• Shift registers
• Counters
• State Graphs
Friday, March 07
CEC 220 Digital Circuit Design
Slide 14 of 14
Download