latches and flip-flops
DESCRIPTION
Latches and Flip-Flops. Discussion D6.1. Latches and Flip-Flops. Latches SR Latch D Latch Flip-Flops D Flip-Flop JK Flip-Flop T Flip-Flop. Sequential Logic. Combinational Logic Output depends only on current input Sequential Logic - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/1.jpg)
Latches and Flip-Flops
Discussion D6.1
![Page 2: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/2.jpg)
Latches and Flip-Flops
• Latches– SR Latch– D Latch
• Flip-Flops– D Flip-Flop– JK Flip-Flop– T Flip-Flop
![Page 3: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/3.jpg)
Sequential Logic
• Combinational Logic– Output depends only on current input
• Sequential Logic– Output depends not only on current input but
also on past input values– Need some type of memory to remember the
past input values
![Page 4: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/4.jpg)
Cross-coupled Inverters
0
1
1
0
State 1 State 2
![Page 5: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/5.jpg)
Latches and Flip-Flops
• Latches– SR Latch– D Latch
• Flip-Flops– D Flip-Flop– JK Flip-Flop– T Flip-Flop
![Page 6: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/6.jpg)
SR Latch
0 00 11 01 1
S' R' Q Q'1
1
0
1 0 1
0 0 10 1 11 0 11 1 0
X Y nand
S’
R’
Q
Q’
Q
![Page 7: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/7.jpg)
0 00 11 01 1
0
1
0
1 0 1
0 0 10 1 11 0 11 1 0
X Y nand
S’
R’
Q
Q’
Q
SR Latch
S' R' Q Q'
![Page 8: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/8.jpg)
0 00 11 01 1
0
1
1
1 0 1
0 0 10 1 11 0 11 1 0
X Y nand
S’
R’
Q
Q’
Q
SR Latch
S' R' Q Q'
![Page 9: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/9.jpg)
0 00 11 01 1
0
1
1
0 0 1
0 0 10 1 11 0 11 1 0
X Y nand
1 0 Set
S’
R’
Q
Q’
Q
SR Latch
S' R' Q Q'
![Page 10: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/10.jpg)
0 00 11 01 1
1
1
1
0 0 1
0 0 10 1 11 0 11 1 0
X Y nand
1 0 Set
1 0 Store
S’
R’
Q
Q’
Q
SR Latch
S' R' Q Q'
![Page 11: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/11.jpg)
0 00 11 01 1
1
0
1
0 0 1
0 0 10 1 11 0 11 1 0
X Y nand
1 0 Set
1 0 Store
S’
R’
Q
Q’
Q
SR Latch
S' R' Q Q'
![Page 12: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/12.jpg)
0 00 11 01 1
1
0
1
1 0 1
0 0 10 1 11 0 11 1 0
X Y nand
1 0 Set
1 0 Store
S’
R’
Q
Q’
Q
SR Latch
S' R' Q Q'
![Page 13: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/13.jpg)
0 00 11 01 1
1
0
0
1 0 1
0 0 10 1 11 0 11 1 0
X Y nand
1 0 Set
1 0 Store0 1 Reset
S’
R’
Q
Q’
Q
SR Latch
S' R' Q Q'
![Page 14: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/14.jpg)
0 00 11 01 1
1
1
0
1 0 1
0 0 10 1 11 0 11 1 0
X Y nand
1 0 Set
1 0 Store0 1 Reset
S’
R’
Q
Q’
Q
SR Latch
S' R' Q Q'
![Page 15: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/15.jpg)
0 00 11 01 1
0
0
1
1 0 1
0 0 10 1 11 0 11 1 0
X Y nand
1 0 Set
1 0 Store0 1 Reset
1 1 Disallowed
Q0 Q0'
S’
R’
Q
Q’
Q
SR Latch
S' R' Q Q'
![Page 16: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/16.jpg)
0 00 11 01 1
1
1
0
1 0 1
0 0 10 1 11 0 11 1 0
X Y nand
1 0 Set
1 0 Store0 1 Reset
1 1 Disallowed
Q0 Q0'
To close or lock with or as if with a latch, To catch or fasten
S’
R’
Q
Q’
Q
SR Latch
S' R' Q Q'
![Page 17: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/17.jpg)
SR Latch with EnableS'
R'
Q
Q'
S
R
EN
S R EN 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 18: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/18.jpg)
RS Latch
RS LatchR
S
Q
Q is set to 1 when S is asserted, and remains unchanged when S is disasserted.
Q is reset to 0 when R is asserted, and remains unchanged when R is disasserted.
Assertions can be active HIGH or active LOW
![Page 19: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/19.jpg)
library IEEE;use IEEE.STD_LOGIC_1164.all;
entity rslatch is port(
R : in STD_LOGIC; S : in STD_LOGIC; Q : out STD_LOGIC
);end rslatch;
architecture rslatch of rslatch isbegin
process(R,S)begin if S = '1' and R = '0' then
Q <= '1'; elsif S = '0' and R = '1' then
Q <= '0'; end if;end process;
end rslatch;
RS LatchR
S
Q
Active HIGH
![Page 20: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/20.jpg)
RS Latch -- Active High
![Page 21: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/21.jpg)
library IEEE;use IEEE.STD_LOGIC_1164.all;
entity rslatch is port(
R : in STD_LOGIC; S : in STD_LOGIC; Q : out STD_LOGIC
);end rslatch;
architecture rslatch of rslatch isbegin
process(R,S)begin if S = '0' and R = '1' then
Q <= '1'; elsif S = '1' and R = '0' then
Q <= '0'; end if;end process;
end rslatch;
RS LatchR
S
Q
Active LOW
![Page 22: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/22.jpg)
RS Latch -- Active Low
![Page 23: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/23.jpg)
How can you make this RS latch from gates?
RS LatchR
S
Q
Q is set to 1 when S is asserted, and remains unchanged when S is disasserted.
Q is reset to 0 when R is asserted, and remains unchanged when R is disasserted.
Assertions can be active HIGH or active LOW
![Page 24: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/24.jpg)
R S Q Q0 0 0 00 0 1 10 1 0 10 1 1 11 0 0 01 0 1 01 1 0 01 1 1 1
RS LatchR
S
Q
Q is set to 1 when S is asserted (1), and remains unchanged when S is disasserted (0).
Q is reset to 0 when R is asserted (1), and remains unchanged when R is disasserted (0).
RSQ
00 01 11 10
0
1
Q = R'Q + R'S + SQ
1 1
1
1store
set
reset
store
![Page 25: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/25.jpg)
Q
S
RR S Q Q0 0 0 00 0 1 10 1 0 10 1 1 11 0 0 01 0 1 01 1 0 01 1 1 1
store
set
reset
store
RS LatchR
S
Q
RS Latch
Q = R'Q + R'S + SQ
![Page 26: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/26.jpg)
library IEEE;use IEEE.STD_LOGIC_1164.all;
entity rslatchgates is port(
R : in STD_LOGIC; S : in STD_LOGIC; Q : out STD_LOGIC
);end rslatchgates;
architecture rslatchgates of rslatchgates is signal Q1: std_logic;
begin
Q1 <= (not R and Q1) or (not R and S) or (S and Q1); Q <= Q1;
end rslatchgates;
Q
S
R Q1
![Page 27: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/27.jpg)
Q
S
R
![Page 28: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/28.jpg)
Latches and Flip-Flops
• Latches– SR Latch– D Latch
• Flip-Flops– D Flip-Flop– JK Flip-Flop– T Flip-Flop
![Page 29: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/29.jpg)
D Latch
D LatchD
EN
Q
Q follows D when EN is high, and remains unchanged when EN is low..
![Page 30: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/30.jpg)
library IEEE;use IEEE.STD_LOGIC_1164.all;
entity dlatch is port(
D : in STD_LOGIC; EN : in STD_LOGIC; Q : out STD_LOGIC
);end dlatch;
architecture dlatch of dlatch isbegin
process(D,EN)begin if EN = '1' then
Q <= D; end if;end process;
end dlatch;
D LatchD
EN
Q
![Page 31: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/31.jpg)
D Latch
![Page 32: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/32.jpg)
D Latch
Q
Q'
EN
D S'
R'
S
R S R EN 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 EN Q Q'
![Page 33: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/33.jpg)
D Latch
0 1 0 11 1 1 0X 0 Q0 Q0'
D EN Q Q' Note that Q follows Dwhen EN in high,and is latched when EN goes to zero.
Q
Q'
EN
D S'
R'
S
R
![Page 34: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/34.jpg)
Latches and Flip-Flops
• Latches– SR Latch– D Latch
• Flip-Flops– D Flip-Flop– JK Flip-Flop– T Flip-Flop
![Page 35: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/35.jpg)
D Flip-Flop
0 0 11 1 0X 0 Q0 Q0'
D clk Q Q'
D gets latched to Q on the rising edge of the clock.
Positive edge triggered
if rising_edge(clk) then Q <= D;end if;
Behavior
clk
D Q
Q'
![Page 36: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/36.jpg)
library IEEE;use IEEE.STD_LOGIC_1164.all;
entity dflipflop is port(
D : in STD_LOGIC; clk : in STD_LOGIC; Q : out STD_LOGIC; NotQ : out STD_LOGIC
);end dflipflop;
architecture dflipflop of dflipflop issignal QS: STD_LOGIC;begin
process(D,clk)begin if rising_edge(clk) then
QS <= D; end if;end process;Q <= QS;NotQ <= not QS;
end dflipflop;
clk
D Q
Q'
![Page 37: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/37.jpg)
D Flip-Flop
![Page 38: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/38.jpg)
library IEEE;use IEEE.STD_LOGIC_1164.all;
entity dflipflop is port(
D : in STD_LOGIC; clk : in STD_LOGIC; Q : out STD_LOGIC; NotQ : out STD_LOGIC
);end dflipflop;
architecture dflipflop of dflipflop issignal QS: STD_LOGIC;begin
process(D,clk)begin if clk'event and clk = '1' then
QS <= D; end if;end process;Q <= QS;NotQ <= not QS;
end dflipflop;
clk
D Q
Q'
![Page 39: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/39.jpg)
D Flip-Flop
![Page 40: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/40.jpg)
Master Slave
D D
EN EN
clk
QMQD
Master-Slave D Flip-Flop
![Page 41: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/41.jpg)
Master-Slave D Flip-Flop
Master Slave
D D
EN EN
clk
QMQD
![Page 42: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/42.jpg)
Recall the SR Latch
0 00 11 01 1
0
0
1
1 0 1
0 0 10 1 11 0 11 1 0
X Y nand
1 0 Set
1 0 Store0 1 Reset
1 1 Disallowed
Q0 Q0'
S’
R’
Q
Q’
Q S' R' Q Q'
![Page 43: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/43.jpg)
Edge-triggered D Flip-flop
0 1
1
1 0
1
S’
R’
Q
Q’
1
2
3
4
5
6
CLK
D
F1
F2
F3
F4
F5
F6
![Page 44: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/44.jpg)
Edge-triggered D Flip-flop
1
0
1 0
1
1 0
1
S’
R’
Q
Q’
1
2
3
4
5
6
CLK
D
F1
F2
F3
F4
F5
F6
![Page 45: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/45.jpg)
Edge-triggered D Flip-flop
1
0
1 0
1
0 1
1
S’
R’
Q
Q’
1
2
3
4
5
6
CLK
D
F1
F2
F3
F4
F5
F6
![Page 46: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/46.jpg)
Edge-triggered D Flip-flop
1
0
0 1
1
0 1
0
S’
R’
Q
Q’
1
2
3
4
5
6
CLK
D
F1
F2
F3
F4
F5
F6
![Page 47: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/47.jpg)
Edge-triggered D Flip-flop
1 1
0
0 1
0
0
1
S’
R’
Q
Q’
1
2
3
4
5
6
CLK
D
F1
F2
F3
F4
F5
F6
![Page 48: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/48.jpg)
Edge-triggered D Flip-flop
1 1
0
1 1
0
0
1
S’
R’
Q
Q’
1
2
3
4
5
6
CLK
D
F1
F2
F3
F4
F5
F6
![Page 49: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/49.jpg)
Edge-triggered D Flip-flop
0 1
1
1 0
1
0
1
S’
R’
Q
Q’
1
2
3
4
5
6
CLK
D
F1
F2
F3
F4
F5
F6
![Page 50: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/50.jpg)
![Page 51: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/51.jpg)
Spartan 3 CLB slices
![Page 52: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/52.jpg)
Latches and Flip-Flops
• Latches– SR Latch– D Latch
• Flip-Flops– D Flip-Flop– JK Flip-Flop– T Flip-Flop
![Page 53: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/53.jpg)
J-K Flip-flops
Qnext = JQ' + K'Q
J K Qnext
0 0 Q0 1 01 0 11 1 Q'
CLK
D Q
Q’
J
K
CLK
QQ’
![Page 54: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/54.jpg)
J-K Flip-flopsJ K Qnext
0 0 Q0 1 01 0 11 1 Q'
J
CLK
Q
Q’K
0 0 Q0 Q’00 1 0 11 0 1 01 1 TOGGLEX X 0 Q0 Q’0
J K CLK Q Q’
![Page 55: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/55.jpg)
Latches and Flip-Flops
• Latches– SR Latch– D Latch
• Flip-Flops– D Flip-Flop– JK Flip-Flop– T Flip-Flop
![Page 56: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/56.jpg)
T Flip-flops
CLK
D Q
Q’
CLK
QQ’
T
nextQ T Q T Qnext
0 Q1 Q'
![Page 57: Latches and Flip-Flops](https://reader036.vdocuments.us/reader036/viewer/2022062316/56815e25550346895dcc7fcd/html5/thumbnails/57.jpg)
T Flip-flopsT Qnext
0 Q1 Q'
T
CLK
Q
Q’
0 Q Q’ 1 Q’ Q
T CLK Q Q’