Upload
ajiyakunhu
View
232
Download
0
Embed Size (px)
Citation preview
8/9/2019 Presentation Flip Flop
1/44
LatchesFlip-Flops
VHDL Descriptions
Latches and Flip-Flops
Dr DC Hendry
March 6, 2006
Dr DC Hendry Latches and Flip-Flops
http://find/8/9/2019 Presentation Flip Flop
2/44
LatchesFlip-Flops
VHDL Descriptions
1 LatchesSR LatchClocked SR LatchD LatchSchematic Symbols
2 Flip-Flops
3 VHDL Descriptions
The D LatchThe D Flip-FlopSet and Reset lines
Dr DC Hendry Latches and Flip-Flops
http://find/8/9/2019 Presentation Flip Flop
3/44
LatchesFlip-Flops
VHDL Descriptions
SR LatchClocked SR LatchD LatchSchematic Symbols
SR Latch
The basic SR latch can be constructed as:
Q
QR
S
Dr DC Hendry Latches and Flip-Flops
http://find/http://goback/8/9/2019 Presentation Flip Flop
4/44
LatchesFlip-Flops
VHDL Descriptions
SR LatchClocked SR LatchD LatchSchematic Symbols
SR Latch
The basic SR latch can be constructed as:
Q
QR
S
and exhibits the behaviour:
1 Setting S(Set) to 0 with Rat 1 causes Qto become1and Qto become 0.
Dr DC Hendry Latches and Flip-Flops
SR L h
http://find/8/9/2019 Presentation Flip Flop
5/44
LatchesFlip-Flops
VHDL Descriptions
SR LatchClocked SR LatchD LatchSchematic Symbols
SR Latch
The basic SR latch can be constructed as:
Q
QR
S
and exhibits the behaviour:
1 Setting S(Set) to 0 with Rat 1 causes Qto become1and Qto become 0.
2 Setting R(Reset) to 0 with Sat 1 causes Qto become 0and Qto become 1.
Dr DC Hendry Latches and Flip-Flops
SR L t h
http://find/8/9/2019 Presentation Flip Flop
6/44
LatchesFlip-Flops
VHDL Descriptions
SR LatchClocked SR LatchD LatchSchematic Symbols
SR Latch
The basic SR latch can be constructed as:
Q
QR
S
and exhibits the behaviour:
1 Setting S(Set) to 0 with Rat 1 causes Qto become1and Qto become 0.
2 Setting R(Reset) to 0 with Sat 1 causes Qto become 0and Qto become 1.
3 When S and Rare at 1 Q and Q retain their last values.
Dr DC Hendry Latches and Flip-Flops
SR Latch
http://find/http://goback/8/9/2019 Presentation Flip Flop
7/44
LatchesFlip-Flops
VHDL Descriptions
SR LatchClocked SR LatchD LatchSchematic Symbols
SR Latch
The basic SR latch can be constructed as:
Q
QR
S
and exhibits the behaviour:
1 Setting S(Set) to 0 with Rat 1 causes Qto become1and Qto become 0.
2 Setting R(Reset) to 0 with Sat 1 causes Qto become 0and Qto become 1.
3 When S and Rare at 1 Q and Q retain their last values.
4 S and Rshould not both be 0 at the same time.
Dr DC Hendry Latches and Flip-Flops
SR Latch
http://find/8/9/2019 Presentation Flip Flop
8/44
LatchesFlip-Flops
VHDL Descriptions
SR LatchClocked SR LatchD LatchSchematic Symbols
SR Latch Waveform
For an SR latch the following waveform applies. No logic delaysare shown in this diagram:
S
R
Dr DC Hendry Latches and Flip-Flops
SR Latch
http://find/8/9/2019 Presentation Flip Flop
9/44
LatchesFlip-Flops
VHDL Descriptions
SR LatchClocked SR LatchD LatchSchematic Symbols
SR Latch Waveform
For an SR latch the following waveform applies. No logic delaysare shown in this diagram:
S
R
Q
Q
Dr DC Hendry Latches and Flip-Flops
L hSR Latch
http://find/8/9/2019 Presentation Flip Flop
10/44
LatchesFlip-Flops
VHDL Descriptions
SR LatchClocked SR LatchD LatchSchematic Symbols
Clocked SR Latch
1 While the SR latch is used in some simple circuits, it isprimarily used as a building block for clocked latches.
Dr DC Hendry Latches and Flip-Flops
L t hSR Latch
http://find/8/9/2019 Presentation Flip Flop
11/44
LatchesFlip-Flops
VHDL Descriptions
Clocked SR LatchD LatchSchematic Symbols
Clocked SR Latch
1 While the SR latch is used in some simple circuits, it isprimarily used as a building block for clocked latches.
2 In a clocked latch, the S and R inputs are only obeyedwhenthe clock signal is active.
Dr DC Hendry Latches and Flip-Flops
LatchesSR Latch
http://find/8/9/2019 Presentation Flip Flop
12/44
LatchesFlip-Flops
VHDL Descriptions
Clocked SR LatchD LatchSchematic Symbols
Clocked SR Latch
1 While the SR latch is used in some simple circuits, it isprimarily used as a building block for clocked latches.
2 In a clocked latch, the S and R inputs are only obeyedwhenthe clock signal is active.
3 For a positivelatch the clock is considered active whenit is1, and 0 for a negative latch.
Dr DC Hendry Latches and Flip-Flops
LatchesSR Latch
http://find/8/9/2019 Presentation Flip Flop
13/44
LatchesFlip-Flops
VHDL Descriptions
Clocked SR LatchD LatchSchematic Symbols
Clocked SR Latch
1 While the SR latch is used in some simple circuits, it isprimarily used as a building block for clocked latches.
2 In a clocked latch, the S and R inputs are only obeyedwhenthe clock signal is active.
3 For a positivelatch the clock is considered active whenit is1, and 0 for a negative latch.
4 Schematic for a Clocked SR Latch:
Q
Q
R
S
ClkDr DC Hendry Latches and Flip-Flops
LatchesSR LatchC S
http://find/8/9/2019 Presentation Flip Flop
14/44
LatchesFlip-Flops
VHDL Descriptions
Clocked SR LatchD LatchSchematic Symbols
Waveform of Clocked SR Latch
Waveform (positive latch):
Clk
S
R
Q
Q
Dr DC Hendry Latches and Flip-Flops
Latches SR LatchCl k d SR L h
http://find/8/9/2019 Presentation Flip Flop
15/44
LatchesFlip-Flops
VHDL Descriptions
Clocked SR LatchD LatchSchematic Symbols
D Latch
1 By far the most important of the clockedlatches however isthe clocked D latch.
Dr DC Hendry Latches and Flip-Flops
Latches SR LatchCl k d SR L t h
http://find/http://goback/8/9/2019 Presentation Flip Flop
16/44
Flip-FlopsVHDL Descriptions
Clocked SR LatchD LatchSchematic Symbols
D Latch
1 By far the most important of the clockedlatches however isthe clocked D latch.
2 This latch has a single data line, D, as input.
Dr DC Hendry Latches and Flip-Flops
Latches SR LatchClocked SR Latch
http://find/http://goback/8/9/2019 Presentation Flip Flop
17/44
Flip-FlopsVHDL Descriptions
Clocked SR LatchD LatchSchematic Symbols
D Latch
1 By far the most important of the clockedlatches however isthe clocked D latch.
2 This latch has a single data line, D, as input.
3 The effect is that D is only copied to theoutput Q when the
clock is active.
Dr DC Hendry Latches and Flip-Flops
Latches SR LatchClocked SR Latch
http://find/8/9/2019 Presentation Flip Flop
18/44
Flip-FlopsVHDL Descriptions
Clocked SR LatchD LatchSchematic Symbols
D Latch
1 By far the most important of the clockedlatches however isthe clocked D latch.
2 This latch has a single data line, D, as input.
3 The effect is that D is only copied to theoutput Q when the
clock is active.
4
Q
Q
Clk
D
Dr DC Hendry Latches and Flip-Flops
LatchesFli Fl
SR LatchClocked SR Latch
http://find/http://goback/8/9/2019 Presentation Flip Flop
19/44
Flip-FlopsVHDL Descriptions
Clocked SR LatchD LatchSchematic Symbols
Waveforms for D Latch:
Clk
D
Q
Q
Dr DC Hendry Latches and Flip-Flops
LatchesFli Fl
SR LatchClocked SR Latch
http://find/8/9/2019 Presentation Flip Flop
20/44
Flip-FlopsVHDL Descriptions
Clocked SR LatchD LatchSchematic Symbols
Schematic Symbols
The schematic symbol for aclocked SR latch is:
Clk
Q
QR
S
For the basic SR latch, omit theClk terminal.
and the schematic symbol for aD latch is:
Clk
Q
Q
D
Dr DC Hendry Latches and Flip-Flops
LatchesFlip Flops
http://find/8/9/2019 Presentation Flip Flop
21/44
Flip-FlopsVHDL Descriptions
Master Slave Flip-Flop
The master-slave flip-flop is perhaps theeasiest to understand.The circuit diagram, build with two D latches is as follows:
Dr DC Hendry Latches and Flip-Flops
LatchesFlip Flops
http://find/8/9/2019 Presentation Flip Flop
22/44
Flip-FlopsVHDL Descriptions
Master Slave Flip-Flop
The master-slave flip-flop is perhaps theeasiest to understand.The circuit diagram, build with two D latches is as follows:
Clk
Q
Q
D
Clk
Q
Q
DD Q
Clk
Q
Q
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
http://find/8/9/2019 Presentation Flip Flop
23/44
Flip-FlopsVHDL Descriptions
D Flip-Flop Waveforms
Clk
Q
Q
D
Clk
Q
Q
DD Q
Clk
Q
Q
Clk
Clk
D
Q
Q
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
http://find/8/9/2019 Presentation Flip Flop
24/44
Flip FlopsVHDL Descriptions
Flip-Flop Schematic Symbols
The sampling nature of the flip-flop is denoted by asmalltriangle on the clock line of the device. The presence of anegation bubble indicates a negative edge triggered device.
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
http://goforward/http://find/http://goback/8/9/2019 Presentation Flip Flop
25/44
p pVHDL Descriptions
Flip-Flop Schematic Symbols
The sampling nature of the flip-flop is denoted by asmalltriangle on the clock line of the device. The presence of anegation bubble indicates a negative edge triggered device.
Symbol for a positive edgetriggered flip-flop:
Q
Q
D
Dr DC Hendry Latches and Flip-Flops
http://find/8/9/2019 Presentation Flip Flop
26/44
LatchesFlip-Flops
The D LatchThe D Flip-Flop
8/9/2019 Presentation Flip Flop
27/44
VHDL Descriptions Set and Reset lines
The D Latch
The following code describes a D latch. Note that bothof theinputs to the circuit, clk and D are in the sensitivity list of theprocess.
library ieee;use ieee.std logic 1164.all;
entity dlatch is
port( clk : in std logic;d : in std logic;
q : out std logic;qbar : out std logic);
end entity dlatch;
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
The D LatchThe D Flip-FlopS
http://find/8/9/2019 Presentation Flip Flop
28/44
VHDL Descriptions Set and Reset lines
The D Latch
The following code describes a D latch. Note that bothof theinputs to the circuit, clk and D are in the sensitivity list of theprocess.
library ieee;use ieee.std logic 1164.all;
entity dlatch is
port( clk : in std logic;d : in std logic;
q : out std logic;qbar : out std logic);
end entity dlatch;
architecture rtl of dlatch is
begin
dl : process (clk, d)begin
if clk = 1 thenq
8/9/2019 Presentation Flip Flop
29/44
VHDL Descriptions Set and Reset lines
The D Flip-flop
library ieee;use ieee.std logic 1164.all;
entity dff is
port(clk : in std logic;d : in std logic;q : out std logic;qbar : out std logic);
end entity dff;
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
VHDL D i ti
The D LatchThe D Flip-FlopS t d R t li
http://find/8/9/2019 Presentation Flip Flop
30/44
VHDL Descriptions Set and Reset lines
The D Flip-flop
library ieee;use ieee.std logic 1164.all;
entity dff is
port(clk : in std logic;d : in std logic;q : out std logic;qbar : out std logic);
end entity dff;
architecture rtl of dff is
begin
ff : process (clk)begin
if clkevent and clk = 1 thenq
8/9/2019 Presentation Flip Flop
31/44
VHDL Descriptions Set and Reset lines
Coding the D Flip-flop
Note the following points about this code:
1 The code clkevent and clk = 1 denotes a risingedge
on the clock signal.
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
VHDL Descriptions
The D LatchThe D Flip-FlopSet and Reset lines
http://find/8/9/2019 Presentation Flip Flop
32/44
VHDL Descriptions Set and Reset lines
Coding the D Flip-flop
Note the following points about this code:
1 The code clkevent and clk = 1 denotes a risingedge
on the clock signal.2 On a rising edge d is copied to q, and the inverse to qbar.
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
VHDL Descriptions
The D LatchThe D Flip-FlopSet and Reset lines
http://find/http://goback/8/9/2019 Presentation Flip Flop
33/44
VHDL Descriptions Set and Reset lines
Coding the D Flip-flop
Note the following points about this code:
1 The code clkevent and clk = 1 denotes a risingedgeon the clock signal.
2 On a rising edge d is copied to q, and the inverse to qbar.
3 Note that we must use qbar
8/9/2019 Presentation Flip Flop
34/44
VHDL Descriptions Set and Reset lines
Coding the D Flip-flop
Note the following points about this code:
1 The code clkevent and clk = 1 denotes a risingedgeon the clock signal.
2 On a rising edge d is copied to q, and the inverse to qbar.
3 Note that we must use qbar
8/9/2019 Presentation Flip Flop
35/44
p
Set and Reset Lines
Many flips-flops (and latches) need to beplaced into aspecificstart up state. When powered up a flip-flop or latch takes arandom state. Therefore many flip-flops include a setline, a reset
line, or both.
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
VHDL Descriptions
The D LatchThe D Flip-FlopSet and Reset lines
http://find/8/9/2019 Presentation Flip Flop
36/44
Set and Reset Lines
Many flips-flops (and latches) need to beplaced into aspecificstart up state. When powered up a flip-flop or latch takes arandom state. Therefore many flip-flops include a setline, a reset
line, or both.1 A setline when active causes the flip-flop qoutput togo to
1.
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
VHDL Descriptions
The D LatchThe D Flip-FlopSet and Reset lines
http://find/http://goback/8/9/2019 Presentation Flip Flop
37/44
Set and Reset Lines
Many flips-flops (and latches) need to beplaced into aspecificstart up state. When powered up a flip-flop or latch takes arandom state. Therefore many flip-flops include a setline, a reset
line, or both.1 A setline when active causes the flip-flop qoutput togo to
1.
2 A resetline when active causes the flip-flop qoutput togo to
0.
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
VHDL Descriptions
The D LatchThe D Flip-FlopSet and Reset lines
http://find/8/9/2019 Presentation Flip Flop
38/44
Set and Reset Lines
Many flips-flops (and latches) need to beplaced into aspecificstart up state. When powered up a flip-flop or latch takes arandom state. Therefore many flip-flops include a setline, a reset
line, or both.1 A setline when active causes the flip-flop qoutput togo to
1.
2 A resetline when active causes the flip-flop qoutput togo to
0.3 Such lines may be either synchronousorasynchronous.
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
VHDL Descriptions
The D LatchThe D Flip-FlopSet and Reset lines
http://find/http://goback/8/9/2019 Presentation Flip Flop
39/44
D Flip-Flop with Synchronous Set
The VHDL code for a D flip-flop with active low synchronous set:
library ieee;use ieee.std logic 1164.all;
entity dffs is
port(clk : in std logic;set n : in std logic;d : in std logic;q : out std logic;qbar : out std logic);
end entity dffs;
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
VHDL Descriptions
The D LatchThe D Flip-FlopSet and Reset lines
http://find/http://goback/8/9/2019 Presentation Flip Flop
40/44
D Flip-Flop with Synchronous Set
The VHDL code for a D flip-flop with active low synchronous set:
library ieee;use ieee.std logic 1164.all;
entity dffs is
port(clk : in std logic;set n : in std logic;d : in std logic;q : out std logic;qbar : out std logic);
end entity dffs;
architecture rtl of dffs is
begin
ff : process(clk)begin
if clkevent and clk = 1 theif set n = 0 then
q
8/9/2019 Presentation Flip Flop
41/44
Waveform for synchronous set
Clk
set n
q
Note that effect of the set n line does occur until the next activeedge of the clock signal.
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
VHDL Descriptions
The D LatchThe D Flip-FlopSet and Reset lines
http://find/8/9/2019 Presentation Flip Flop
42/44
D Flip-Flop with AsynchronousReset
The VHDL code for a D flip-flop with active low asynchronousreset:
library ieee;use ieee.std logic 1164.all;
entity dffr is
port(clk : in std logic;rst n : in std logic;d : in std logic;
q : out std logic;qbar : out std logic);end entity dffr;
Dr DC Hendry Latches and Flip-Flops
LatchesFlip-Flops
VHDL Descriptions
The D LatchThe D Flip-FlopSet and Reset lines
http://find/http://goback/8/9/2019 Presentation Flip Flop
43/44
D Flip-Flop with AsynchronousReset
The VHDL code for a D flip-flop with active low asynchronousreset:
library ieee;use ieee.std logic 1164.all;
entity dffr is
port(clk : in std logic;rst n : in std logic;d : in std logic;
q : out std logic;qbar : out std logic);end entity dffr;
architecture rtl of dffr is
begin
ff : process(clk, rst n)begin
if rst n = 0 thenq
8/9/2019 Presentation Flip Flop
44/44
Waveforms for asynchronous reset
Clk
rst n
q
For the asynchronous reset line, the effect is immediate.
Dr DC Hendry Latches and Flip-Flops
http://find/http://goback/