Download presentation
Presentation is loading. Please wait.
1
Latches and Flip-Flops Discussion D4.1 Appendix J
2
Latches and Flip-Flops Latches –SR Latch –Clocked SR Latch –D Latch Flip-Flops –Edge-Triggered D Flip-Flop
3
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
4
Cross-coupled Inverters State 1 State 2
5
Latches and Flip-Flops Latches –SR Latch –Clocked SR Latch –D Latch Flip-Flops –Edge-Triggered D Flip-Flop
6
SR Latch 0 0 1 1 0 1 S' R' Q Q' 1 1 0 1 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand
7
0 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand SR Latch S' R' Q Q'
8
0 0 1 1 0 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand SR Latch S' R' Q Q'
9
0 0 1 1 0 1 0 1 1 0 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand 1 0 Set SR Latch S' R' Q Q'
10
0 0 1 1 0 1 1 1 1 0 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand 1 0 Set 1 0 Store SR Latch S' R' Q Q'
11
0 0 1 1 0 1 1 0 1 0 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand 1 0 Set 1 0 Store SR Latch S' R' Q Q'
12
0 0 1 1 0 1 1 0 1 1 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand 1 0 Set 1 0 Store SR Latch S' R' Q Q'
13
0 0 1 1 0 1 1 0 0 1 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand 1 0 Set 1 0 Store 0 1 Reset SR Latch S' R' Q Q'
14
0 0 1 1 0 1 1 1 0 1 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand 1 0 Set 1 0 Store 0 1 Reset SR Latch S' R' Q Q'
15
0 0 1 1 0 1 0 0 1 1 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand 1 0 Set 1 0 Store 0 1 Reset 1 1 Disallowed Q 0 Q 0 ' SR Latch S' R' Q Q'
16
0 0 1 1 0 1 1 1 0 1 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand 1 0 Set 1 0 Store 0 1 Reset 1 1 Disallowed Q 0 Q 0 ' To close or lock with or as if with a latch, To catch or fasten SR Latch S' R' Q Q'
17
R-S Latch R 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
18
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 is begin 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; R-S Latch R S Q Active HIGH
19
R-S Latch -- Active High
20
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 is begin 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; R-S Latch R S Q Active LOW
21
R-S Latch -- Active Low
22
How can you make this R-S latch from gates? R-S Latch R 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
23
R S Q Q 0 0 0 0 1 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 0 0 1 1 R-S Latch R 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). R SQ 00011110 0 1 Q = R'Q + R'S + SQ 11 1 1 store set reset store
24
R S Q Q 0 0 0 0 1 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 0 0 1 1 store set reset store R-S Latch R S Q RS Latch Q = R'Q + R'S + SQ
25
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; Q1
27
Latches and Flip-Flops Latches –SR Latch –Clocked SR Latch –D Latch Flip-Flops –Edge-Triggered D Flip-Flop
28
Clocked SR Latch S' R' Q Q' S R CLK S R CLK S' R' Q Q' 0 0 1 1 1 Q 0 Q 0 ' Store 0 1 1 1 0 0 1 Reset 1 0 1 0 1 1 0 Set 1 1 1 0 0 1 1 Disallowed X X 0 1 1 Q 0 Q 0 ' Store
29
Latches and Flip-Flops Latches –SR Latch –Clocked SR Latch –D Latch Flip-Flops –Edge-Triggered D Flip-Flop
30
D Latch D EN Q Q follows D when EN is high, and remains unchanged when EN is low..
31
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 is begin process(D,EN) begin if EN = '1' then Q <= D; end if; end process; end dlatch; D Latch D EN Q
32
D Latch
33
Q Q' EN D S' R' S R S R EN Q Q' 0 0 1 Q 0 Q 0 ' Store 0 1 1 0 1 Reset 1 0 1 1 0 Set 1 1 1 1 1 Disallowed X X 0 Q 0 Q 0 ' Store 0 1 1 1 1 0 X 0 Q 0 Q 0 ' D EN Q Q'
34
D Latch 0 1 1 1 1 0 X 0 Q 0 Q 0 ' D EN Q Q' Note that Q follows D when EN in high, and is latched when EN goes to zero. Q Q' EN D S' R' S R
35
Latches and Flip-Flops Latches –SR Latch –Clocked SR Latch –D Latch Flip-Flops –Edge-Triggered D Flip-Flop
36
D Flip-Flop 0 0 1 1 1 0 X 0 Q 0 Q 0 ' 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'
37
Master-Slave D Flip-Flop
39
Recall the SR Latch 0 0 1 1 0 1 0 0 1 1 0 1 0 0 1 0 1 1 1 0 1 1 1 0 X Y nand 1 0 Set 1 0 Store 0 1 Reset 1 1 Disallowed Q 0 Q 0 ' S' R' Q Q'
40
Edge-triggered D Flip-flop 0 1 1 1 0 1
41
1 0 1 0 1 1 0 1
42
1 0 1 0 1 0 1 1
43
1 0 0 1 1 0 1 0
44
1 1 0 0 1 0 0 1
45
1 1 0 1 1 0 0 1
46
0 1 1 1 0 1 0 1
47
Edge-triggered D Flip-flop with asynchronous set and reset 0 1 1 1 0 1
48
0 1 1 1 0 1 0 1 0 1
49
0 1 1 1 0 1 1 1 0 1
50
0 1 1 1 1 0 1 0 1 0
51
0 1 1 1 0 1 1 0 1 1
52
D Flip-Flop 0 0 1 1 1 0 X 0 Q 0 ~Q 0 D CLK Q ~Q D gets latched to Q on the rising edge of the clock. Positive edge triggered
53
Spartan 3 CLB slices
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.