Flip-Flops and Latches: Elektronik
Flip-Flops and Latches: Elektronik
Before starting the exercise answer the following questions and carry out the following tasks:
• Draw a RS latch with NAND gates
• Write the function table of a RS latch
• Modify the RS latch such as it remembers the value if a signal ENABLE is set. (Hint: use AND gates between the
enable and the S/R inputs).
• Modify the RS latch with ENABLE such as to obtain a D latch with enable. (Hint: the S and R inputs should be
complementary. Use a NOT gate.)
• What is the difference between a latch and a flip-flop ?
• How are the edge sensitive signals drawn in schematics ?
• Write down the function table of a J-K flip-flop.
• Draw a D-Type Positive-Edge-Triggered Flip-Flop. Use a D flip-flop with enable (as a circuit) with two outputs Q
and Q̄ and an RS latch with enable at the output.
• What is the difference between the types bit and std logic ?
• Which libraries are opened by default ?
D flip-flop
Table 1 describes the ports of a D flip flop. The input d is remembered at the rising edge of the clock signals clk.
Figure 1 shows the behavioural description of a D flip-flop.
1
31000 - Electronics. Tutorial Flip-flops and Latches
library IEEE;
use IEEE.std_logic_1164.all;
begin
end rtl;
• How would you detect the rising edge of a signal in VHDL without using the function rising edge ?
• Is the use of the function rsing edge necessary in the case of the code in Fig. 1 ?
• Simulate the VHDL model by giving the following input signals:
wave /*
force clk 0 0, 1 60 -repeat 120
force d 0 0, 1 100, 0 200
run 400
library IEEE;
use IEEE.std_logic_1164.all;
begin
end rtl;
Fig. 3 shows the behavioural model of the D flip-flop. When is the process called ? Notice that the check for an active
RESET signal is done prior to the check for a rising edge of the clock signal. Is the use of the function rising edge
necessary in this code ? Explain.
Simulate the VHDL model by choosing suitable excitations such as to get the result shown in Fig. 4
Directions:
1. Use the model of the D flip-flop shown in the previous assignment
2. After the check for a rising edge, add a check for the signal ena. Use a separate
if-then-else construct for the latter.
Register
Table 4: Description of the ports of an 8 bit register with asynchronous RESET and ENABLE.
Directions:
1. The register is just a couple of D flip-flops with common RESET and ENABLE
signals.
2. Use the model of the D flip-flop developed in the previous assignment.
R-S flip-flop
The description of the ports of a R-S flip-flop are given in Table 5. The changes in the state of the flip-flop is at the rising
edge of clk.
1. Use the model of the D flip-flop from the first assignment as a base.
2. After checking for a rising edge of the clock, use an if-then-else operator for
Directions: checking the conditions:
3. In order to preserve the pre condition, it sufficient that the condition R = ’0’ and
S = ’0’ is not checked in the if condition
4. In order to assign an undefined output to the flip-flop, use the value ’X’.
wave /*
force clk 0 0, 1 50 -repeat 100
force r 1 0, 0 100, 1 400
force s 0 0, 1 200, 0 300, 1 400
run 500
D latch
Table 6 shows the description of the ports of a D latch. While ena is high (=’1’) the output q follows the input d. When
ena=’0’ the output q remembers the last value and is not influenced by the input d.
Figure 8 gives the VHDL model of a D latch. Pay attention of the condition in the if operator. It is not fully specified,
i.e. the output q is not given for all values of ena. What are the missing values of ena ?
Simulate the VHDL model of D latch. Choose the input signals such as to get a result like the one in Fig. 9.
library IEEE;
use IEEE.std_logic_1164.all;
begin
end rtl;