Professional Documents
Culture Documents
PRACTICAL TRAINING
TO THE LECTURE
FCE 1
Experiment 3
Flip-flops,
Design of a counter
Name: Matriculation-Number:
Tutor: Date:
All questions marked with Q1 to Qn must be answered before the lab begins.
All tasks marked with T1 till Tn must be completed to finish the lab.
Introduction
In the preceding experiments you learned how to simulate and analyze simple logical circuits.
The most important functions of OrCAD Capture were introduced and applied. The acquired
knowledge should now be used to understand the basics of flip-flops, digital counting and
combinatorial circuits. All the logic circuits we have worked on so far are purely
"combinatorial" circuits, also called switching networks. These kinds of circuits consist only
of pure logic gates without feedback, what means the output signals of switching networks are
always only dependent on the current input signals.
In contrast, "sequential" circuits are circuits whose output signals are no longer exclusively
dependent on the input signals of the circuit, but also on the internal states of the circuit.
These, in turn, depend on the "sequence" of the preceding input signals. But if we want to
keep inner states, this means that we have to be able to "store" states. Memory devices fulfill
this requirement.
Memory devices can be divided into the asynchronous and synchronous elements. The main
difference is that asynchronous memory devices can change their state at any time, while
synchronous memory devices can only change their state at specific time intervals or at
specific times. Synchronous memory devices therefore have a clock line (CLK).
1. Flip-flops (FFs)
Flip-flops are the most common and basic memory devices used for information storage in
sequential circuits. A flip-flop can stay in one of two logical states. To change its state we
need a new input signal. This makes the flip-flop a 1 bit memory device.
In case of clocked FFs, a distinction is made between the clock-state-controlled FF and the
clock-edge-controlled FF. Clock-controlled FFs are also called latches and are distinguished
by the fact that during the active clock phase (eg. high signal), any change in the input
immediately switches to the output. On the other hand, in the case of the clock-edge-controlled
FF, the output is only changed during a clock edge (ie, when switching from 0-> 1 and / or
from 1-> 0).You can find all flip-flops in the 74LS.OLB and 7400.OLB libraries.
2/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
S R Qn Qn+1 Functionality
The most common realizations of RS FFs are based on NOR or NAND gates. Fig. 1.1.1 shows
a typical NOR-gate core circuit of an RS FF and Fig. 1.1.2 shows its gate symbol. Take notice
that flip-flops usually provide the complement of their state as a second output Q n .
Q
S Q
__
R Q
Q
Fig. 1.1.3 and Fig. 1.1.4 respectively, illustrate the gate circuit and gate symbol of a NAND
type RS FF with clock state control.
The signals at S and R only affect the circuit when a positive level is present at the CLK input
(CLK = 1). In order in order to set the FF output in a well defined state the low active inputs
signal CLR (Clear) und PRE (Preset) can be used asynchronous (what means regardless of
the clock signal state).
When CLR = 0, PRE = 1, so Q = 0, when CLR = 1, PRE = 0 so Q = 1. CLR and PRE =
0 has to be avoided because it leads to Q = = 1 , which is, on the one hand, illogical with
regard to the names of the outputs, but can also lead to unpredictable subsequent states. With
CLR = 1 and PRE = 1, the circuit operates as a clock state-controlled RS-FF.
3/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
___
PRE
Q ____
S PRE Q
CLK
__ ___
Q R CLR Q
___
CLR
Fig. 1.1.4
Fig. 1.1.3: clock-state-controlled RS FF with pre-set and clear
Inputs Qn Qn+1
0 0 0 0 0 X 0
0 0 1 1 1 X 1
0 1 0 0 0 0 X
0 1 1 0 0 0 X
1 0 0 1 1 1 X
1 0 1 1 1 1 X
1 1 0 1 X X 1
1 1 1 0 X X 0
Table 1.2.1
4/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
n +1 n n
The characteristic equations for the JK FF is Q = K Q + J Q . We can derive from the
truth table (Table 1.2.1) the equations and inputs of other flip-flop types, which can be
construct from JK FF.
As the name implies the purpose of a D FF is to temporary store (or delay) a single bit. A
signal of 0 or 1 present at the input D is transferred to the output Q whenever the clock CLK is
set to 1. Fig. 1.3.1 shows the gate symbol of a D flip-flop.
If we look closely at the truth table (Table 1.2.1) again we will see that it is quite simple to
construct a D FF out of a JK FF. A delay flip-flop uses only the situations where the J and K
inputs are different. This would make a D FF truth table only 2 lines. So how can we get rid of
the other two lines in a JK FF truth table? We make sure they do not occur by connecting a
NOT gate between the inputs J and K, as shown in Fig. 1.3.2. This way J and K will always be
different.
D Q D J Q
CLK CLK
Q K Q
As the construct in Fig. 1.3.2 implies, the equation for a D FF built from JK FF would be:
D=J =K
5/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
Q1: Fig. 1.1 illustrates two flip-flops. Which flip-flop functions as a D FF and why?
Fig. 1.1
6/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
Q4: Some flip-flops have additional inputs, such as clear and pre-set. What function do these
inputs serve?
2. Registers
A register is a circuit that can store whole data words. It is constructed by connecting several
flip-flops; hence an n-bit register consists of at least n flip-flops. The following example
shown in Fig. 2.1 illustrates a 4-bit shift register built with D flip-flops.
Fig. 2.1
Q6: Define a series of input impulses D to store the pattern (D3 D2 D1 D0) = (1010) into the
4-bit register illustrated in Fig. 2.1.
7/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
Q8: How would you modify the circuit in Fig. 2.1 in order to turn it into a ring-register?
Explain your answer and add your modifications to the figure.
3. Designing a counter
Before we knew flip-flops we could only design combinatorial circuits. The output of a
combinational circuit depends on the current input signal only. If X n are the inputs of such
circuit at cycle n, the characteristic equation is of the type:
Qn = f ( X n )
The output of a circuit containing flip-flops depends not only on the current input, but on the
previous inputs as well, making it a sequential circuit. Therefore, the according characteristic
equation must match:
Q n = f ( X n , Q n1 )
One of the most typical applications for sequential circuits is counters. In this part of the
experiment we want to design a counter that has no inputs apart from the clock pulse.
Therefore, the circuits state will depend only on the preceding state:
Q n = f (Q n1 )
8/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 1 0 0
4 0 1 0 1
5 1 0 0 0
6 1 0 0 1
7 1 0 1 0
8 1 1 0 0
9 1 1 0 1
Table 3.1.1
A 5-3-2-1 code is just another 4-bit binary code, but with different decimal values assigned to
each bit.
Example:
Decimal number: 7
4-bit binary code: 0111 = 023 + 122 + 121 + 120 = 7
4-bit 5-3-2-1 code: 1010 = 15 + 03 + 12 + 01 = 7
9/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
Q n + 1 = K Q n + J Q n
a a a
we have to find by comparison the equations for the inputs J and K for every flip-flop:
J a = f (Qb , Qc , Qd ) K a = f (Qb , Qc , Qd )
For this task we set up a KV-diagram representing the formerly given truth table (Table 3.1.1).
Q2
X
Q1
Q3
8 3
2 7
Q4
Fig. 3.2.1: KV-diagram of a 5-3-2-1 code
10/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
Be aware that when looking for a simplified expression for Qan+1 we have to find one that
contains Qan to be able to compare coefficients!
Following this principle the equations for J1, K1 and J2, K2 are:
n +1
Q1 = Q1 Q2 (follows if we consider the previous states 0,3,5,8)
J1 = Q2
K1 = K1 = 0 K1 = 1
J2 = Q1 Q3
K2 = K2 = 0 K2 = 1
Q10: Find the functions for the inputs J4, K4 of the fourth flip-flop. Do not make use of the
Dont care states!
Q4n+1 =
J4 =
K4 =
Q11: Is it possible to simplify the expressions for J and K even further? If yes, how?
11/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
Q12: Complete the circuit in Fig. 3.2.2 using the equations for K3 , J4 und K4.
12/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
S1 S1 S1 S1 S1
S3
S3
S3
S3
S3
S2
S2
S2
S2
S2
S1
S4 S4 S4 S4 S4
S5
S5
S5
S6
S6
S6
S6
S6
S5
S5
S3
S2
S7 S7 S7 S7 S7
S4
S1 S1 S1 S1 S1
S5
S6
S3
S3
S3
S3
S2
S2
S2
S3
S2
S2
S4 S4 S4 S4 S4
S7
S5
S5
S5
S5
S5
S6
S6
S6
S6
S6
S7 S7 S7 S7 S7
Fig. 4.1
Q14: Complete the truth table shown below:
Number Q4 Q3 Q2 Q1 S7 S6 S5 S4 S3 S2 S1
0 0 0 0 0 0 0 0 1 0 0 0
1 0 0 0 1 1 0 1 1 0 1
2 0 0 1 0 0 1 0 1 0 0
3 0 1 0 0 1 0 0 1 0 0
4 0 1 0 1 1 0 0 0 0 1
5 1 0 0 0 1 0 0 0 1 0
6 1 0 0 1 0 0 0 0 1 1
7 1 0 1 0 1 0 1 1 0 0
8 1 1 0 0 0 0 0 0 0 0
9 1 1 0 1 1 0 0 0 0 0
Table 4.1: Truth table for the 7-segment-display controller
13/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
From the truth table we get the equations for S1,...,S6 in disjunctive normal form:
S5= (Q 1Q2 Q 3 Q 4 )
S6= (Q1 Q 2 Q 3 Q 4 ) + (Q1 Q 2 Q3 Q 4 ) + (Q1 Q 2 Q3 Q 4 ) + (Q1 Q 2 Q 3Q4 ) + (Q1Q2 Q 3Q4 ) + (Q1 Q 2 Q3Q4 )
S7=_________________________________________________________________
Simplifying the functions for S1,...,S6 (with KV-Diagramms and boolean Algebra) leads to:
S2= (Q 2 Q 3Q4 )
S5= (Q 1Q2 Q 3 Q 4 )
Q16: Simplify the functions for S7 from Q15 with the help of KV-diagrams and write down
the simplified equation.
S7=_________________________________________________________________
Q17: Complete the circuit for the display controller (see next page)!
14/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
Fig. 4.2
16/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
Click OK to close the Place Hierarchical Block dialog box. Now you can draw the hierarchical
block using the mouse by pressing the left button and dragging the mouse to draw a rectangle.
If you have entered the names of the schematic page and folder correctly then your block
should appear with already set-up pins and pin names.
T1: Create a new Analog or Mixed A/D project named Lab2. Rename SCEMATIC1 to Lab2
and PAGE1 to Lab2Circuit. This will be your complete circuit schematic page and folder.
T2: Create a new schematic folder and name it Counter. In it create a new schematic page
named CounterCircuit. Create the circuit you drew in question Q12 (Fig. 3.2.2) in the
CounterCircuit schematic page and place, and name ports at the inputs and outputs.
T3: Create a hierarchical block in the Lab2Circuit schematic page, which refers to your
counter circuit.
T4: Create and run a simulation of the hierarchical block counter with an appropriate input to
test its functionality.
T5: Create a new schematic folder named Controller and a new schematic page in it, named
ControllerCircuit.
T6: Design the 7-segment-display controller from Q17 (Fig. 4.2) in the ControllerCircuit
schematic page and place, and name ports at the inputs and outputs.
T7: Create a hierarchical block in the Lab2Circuit schematic page, which refers to your
controller circuit. Connect the controller hierarchical block to the counter one.
17/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
T8: Create and run a simulation with an appropriate input to test the functionality of both
blocks.
18/19
FCE1 Lab Experiment 3: Flip-flops, Design of a counter
Digital Components
19/19