Chapter One
Chapter One
College of Engineering
Department of Biomedical Engineering
DIGITAL ELECTRONICS II
Books:
Text Book:
   1. Thomas L. Floyd "Digital Fundamentals" , Eleventh Edition Global, Edition
      2015.
   2. M. Morris Mano, "Digital Design", 2015.
References:
    1. David Money and Harris' Sarah L. Harris "In Praise of Digital Design and
       Computer Architecture", British Library Cataloguing-in-Publication Data,
       2013.
    2. U.A. Bakshi and A.P Godse, "Analog and digital electronics", technical
       publications pune, first edition, 2009.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -1-
                                      CHAPTER One
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -2-
        Table (1.1) Comparison between Combinational and Sequential circuits.
1.2. Latches
The latch is a type of temporary storage device that has two stable states (bistable)
and is normally placed in a category separate from that of flip-flops. Latches are
similar to flip-flops because they are bistable devices that can reside in either of two
states using a feedback arrangement, in which the outputs are connected back to the
opposite inputs. The main difference between latches and flip-flops is in the method
used for changing their state.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -3-
                                 Figure (1.1) R-S latch circuit
To explain the operation of the latch, we will use the NAND gate 𝑆 − 𝑅 latch in
Figure 1(b). This latch is redrawn in Figure 2 with the negative-OR equivalent
symbols used for the NAND gates. This is done because LOWs on the 𝑆𝑎𝑛𝑑 𝑅 lines
are the activating inputs.
The latch in Figure 2 has two inputs, 𝑆𝑎𝑛𝑑 𝑅, and two outputs, Q and 𝑄. Let’s start
by assuming that both inputs and the Q output are HIGH, which is the normal latched
state.
Since the Q output is connected back to an input of gate G2, and the 𝑅 input is HIGH,
the output of G2 must be LOW. This LOW output is coupled back to an input of gate
G1, ensuring that its output is HIGH.
When the Q output is HIGH, the latch is in the SET state. It will remain in this state
indefinitely until a LOW is temporarily applied to the 𝑅 input. With a LOW on the 𝑅
input and a HIGH on 𝑆, the output of gate G2 is forced HIGH. This HIGH on the 𝑄
output is coupled back to an input of G1, and since the 𝑆 input is HIGH, the output of
G1 goes LOW.
This LOW on the Q output is then coupled back to an input of G2, ensuring that the
𝑄 output remains HIGH even when the LOW on the 𝑅 input is removed. When the Q
output is LOW, the latch is in the RESET state. Now the latch remains indefinitely in
the RESET state until a momentary LOW is applied to the 𝑆 input.
In normal operation, the outputs of a latch are always complements of each other.
When Q is HIGH, 𝑸 is LOW, and when Q is LOW, 𝑸 is HIGH.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -4-
An invalid condition in the operation of an active-LOW input 𝑆 − 𝑅 latch occurs
when LOWs are applied to both 𝑆 and 𝑅 at the same time. As long as the LOW levels
are simultaneously held on the inputs, both the Q and 𝑄 outputs are forced HIGH,
thus violating the basic complementary operation of the outputs. Also, if the LOWs
are released simultaneously, both outputs will attempt to go LOW. Since there is
always some small difference in the propagation delay time of the gates, one of the
gates will dominate in its transition to the LOW output state. This, in turn, forces the
output of the slower gate to remain HIGH. In this situation, you cannot reliably
predict the next state of the latch.
Figure 3 illustrates the active-LOW input 𝑆 − 𝑅 latch operation for each of the four
possible combinations of levels on the inputs. (The first three combinations are valid,
but the last is not.) Table 2 summarizes the logic operation in truth table form.
Operation of the active-HIGH input NOR gate latch in Figure 1(a) is similar but
requires the use of opposite logic levels.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -5-
   FIGURE 3 The three modes of basic 𝑆 − 𝑅 latch operation (SET, RESET, no-
                      change). and the invalid condition.
Logic symbols for both the active-HIGH input and the active-LOW input latches are
shown in Figure 4.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -6-
avoided because it results in an invalid mode of operation and is a major drawback
of any SET-RESET type of latch.
Example 1.
  1.2.2. An Application
  The Latch as a Contact-Bounce Eliminator
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -7-
An 𝑆 − 𝑅 latch can be used to eliminate the effects of switch bounce as shown in
Figure 6(b). The switch is normally in position 1, keeping the 𝑅 input LOW and the
latch RESET. When the switch is thrown to position 2, 𝑅 goes HIGH because of the
pull-up resistor to VCC, and 𝑆 goes LOW on the first contact. Although 𝑆 remains
LOW for only a very short time before the switch bounces, this is sufficient to set the
latch. Any further voltage spikes on the 𝑆 input due to switch bounce do not affect the
latch, and it remains SET. Notice that the Q output of the latch provides a clean
transition from LOW to HIGH, thus eliminating the voltage spikes caused by contact
bounce. Similarly, a clean transition from HIGH to LOW is made when the switch is
thrown back to position 1.
1.2.3. An Application
 Implementation: 𝑆 − 𝑅 Latch
Example 3.
Solution.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -9-
                                  Figure 10. A gated D Latch.
Example 4.
Solution.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -10-
Implementation of gated D latch.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -11-
  Figure 13. Edge-triggered FF logic symbols (top: positive edge-triggered; bottom:
                             negative edge-triggered).
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -12-
The operation and truth table for a negative edge-triggered D flip-flop are the same as
those for a positive edge-triggered device except that the falling edge of the clock
pulse is the triggering edge and the change happened at the falling edge of the clock..
Example 4.
Determine the Q and Q output waveforms of the flip-flop in figure 15 for the D and
CLK inputs in figure 16-a. Assume that the positive-edge-triggered FF is initially
RESET.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -13-
  1.3.2. J-K Flip-Flop.
The JK flip flop is basically a gated SR flip-flop with the addition of a clock input
circuitry that prevents the illegal or invalid output condition that can occur when both
inputs S and R are equal to logic level “1”.
The inputs are labeled J and K in honor of the inventor of the device, Jack Kilby.
Referring to figure 17, the J and K inputs of the J-K flip-flop are synchronous inputs
because data on these inputs are transferred to the flip-flop’s output only on the
triggering edge of the clock pulse. When J is HIGH and K is LOW, the Q output goes
HIGH on the triggering edge of the clock pulse, and the flip-flop is SET. When J is
LOW and K is HIGH, the Q output goes LOW on the triggering edge of the clock
pulse, and the flip-flop is RESET. When both J and K are LOW, the output does not
change from its prior state. When J and K are both HIGH, the flip-flop changes state.
This called the toggle mode. Toggle means that the Q output will change states on
each active clock edge (if Q was 1 becomes 0 and if Q was 0 becomes 1).
This basic operation of a positive edge-triggered flip-flop is illustrated in Figure 17,
and Table 4 is the truth table for this type of flip-flop. Remember, the flip-flop cannot
change state except on the triggering edge of a clock pulse. The J and K inputs can be
changed at any time when the clock input is LOW or HIGH without affecting the
output.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -14-
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -15-
Example 5.
Solution.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -16-
Note:
In "JK Flip Flop", when both the inputs and CLK set to 1 for a long time, then Q
output toggle until the CLK is 1. Thus, the uncertain or unreliable output produces.
This problem is referred to as a race-round condition in JK flip-flop and avoided by
ensuring that the CLK set to 1 only for a very short time.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -17-
      The output 𝑄 =1 of the master flip flop is passed to the slave flip flop as an
       input K when the input J set to 0 and K set to 1. The clock forces the slave flip
       flop to work as reset, and then the slave copies the master flip flop.
      When J=1, and K=0, the output Q=1 is passed to the J input of the slave. The
       clock's negative transition sets the slave and copies the master.
      The master flip flop toggles on the clock's positive transition when the inputs J
       and K set to 1. At that time, the slave flip flop toggles on the clock's negative
       transition.
      The flip flop will be disabled, and Q remains unchanged when both the inputs
       of the JK flip flop set to 0.
      When the clock pulse set to 1, the output of the master flip flop will be one
       until the clock input remains 0.
      When the clock pulse becomes high again, then the master's output is 0, which
       will be set to 1 when the clock becomes one again.
      The master flip flop is operational when the clock pulse is 1. The slave's output
       remains 0 until the clock is not set to 0 because the slave flip flop is not
       operational.
      The slave flip flop is operational when the clock pulse is 0. The output of the
       master remains one until the clock is not set to 0 again.
      Toggling occurs during the entire process because the output changes once in
       the cycle.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -18-
As shown in figure 21, the TTL 74LS73 is a Dual JK flip-flop IC, which contains two
individual JK type bistable’s within a single chip enabling single or master-slave
toggle flip-flops to be made.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -19-
1.5.   Asynchronous Preset and Clear Inputs
For the flip-flops just discussed, the D and J-K inputs are called synchronous inputs
because data on these inputs are transferred to the flip-flop’s output only on the
triggering edge of the clock pulse; that is, the data are transferred synchronously with
the clock.
Most integrated circuit flip-flops also have asynchronous inputs. These are inputs
that affect the state of the flip-flop independent of the clock. They are normally
labeled preset (PRE) and clear (CLR), or direct set (SD) and direct reset (RD) by
some manufacturers. An active level on the preset input will set the flip-flop, and an
active level on the clear input will reset it; they can set or reset the flip-flop regardless
of the status of the clock signal. A logic symbol for a D flip-flop with preset and clear
inputs is shown in Figure 22. These inputs are active-LOW, as indicated by the
bubbles. These preset and clear inputs must both be kept HIGH for synchronous
operation. In normal operation, preset and clear would not be LOW at the same time.
Figure 23 shows the logic diagram for an edge-triggered D flip-flop with active-LOW
preset (PRE) and clear (CLR) inputs. This figure illustrates basically how these inputs
work. As you can see, they are connected so that they override the effect of the
synchronous input, D and the clock.
Example 7.
For the positive edge-triggered D flip-flop with preset and clear inputs in Figure 24,
determine the Q output for the inputs shown in the timing diagram in part (a) if Q is
initially LOW.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -20-
Solution.
Implementation: D Flip-Flop
Fixed-Function Device The 74HC74 dual D flip-flop contains two identical D flip-
flops that are independent of each other except for sharing VCC and ground. The flip-
flops are positive edge-triggered and have active-LOW asynchronous preset and clear
inputs. The logic symbols for the individual flip-flops within the package are shown
in Figure 25(a), and an ANSI/IEEE standard single block symbol that represents the
entire device is shown in part (b). The pin numbers are shown in parentheses.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -21-
Implementation: J-K Flip-Flop
Fixed-Function Device The 74HC112 dual J-K flip-flop has two identical flip-flops
that are negative edge-triggered and have active-LOW asynchronous preset and clear
inputs. The logic symbols are shown in Figure 26.
EXAMPLE 8
The 1J, 1K, 1CLK, 1PRE, and 1CLR waveforms in Figure 27(a) are applied to one of
the negative edge-triggered flip-flops in a 74HC112 package. Determine the 1Q
output waveform.
Solution.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -22-
1.6. T Flip-flop
While the Data (D) flip-flop is a variation of a clocked SR flip-flop constructed using
either NAND or NOR gates, the Toggle (T) flip-flop is a variation of the clocked JK
flip-flop. The toggle or T-type flip-flop gets its name from the fact that its two
outputs Q and 𝑄 invert from their previous state as it toggles back and forth every
time it is triggered (T = 1). Figure 28 shows the symbol of T flip-flop.
That is, the Q and 𝑄 outputs change to a “1” if it was “0”, and “0” if it was previously
a “1” but only when the “T” input changes HIGH, otherwise they do not change, and
its asynchronous toggling action is explained here.
The JK is renamed T for T-type or Toggle flip-flop and is generally represented by
the logic or graphical symbol shown. The Toggle schematic symbol has two inputs
available, one represents the “toggle” (T) input and the other the “clock” (CLK)
input.
Also, just like the 74LS73 JK flip-flop, the T-type can also be configured to have an
enable input called EN or CE (clock enable) allowing it to hold the last data state
stored on its outputs indefinitely. Thus with the clock enable input set, the application
of any new clock pulses prevents toggling of the outputs. But this “enable” feature, if
required, must be implemented using additional logic gates.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -23-
The triangle of chevron on the input of either type of T-type flip-flop indicates that it
is an edge-triggered device. If there is a small bubble or circle at the input, then it
indicates that the flip-flop toggles on the negative falling edge (HIGH-to-LOW) of
each pulse, otherwise, it changes state on the positive or rising transistional edge
(LOW-to-HIGH) of each input pulse.
Then we can create the logic circuit of a single bit toggle flip-flop using the basic JK
flip-flop by connecting the J and K data inputs together where the common point at
the connection of the two inputs is designated T, as shown in figure 29..
Figure 29. The formulation of T- FF from J-K FF and its timing diagram.
Suppose that initially CLK and input T are both LOW (CLK = T = 0), and that
output Q is HIGH (Q = 1). At the rising edge or falling edge of a CLK pulse, the
logic “0” condition present at T prevents the output at Q from changing state. Thus
the output remains unchanged when T = 0.
Now let’s suppose that input T is HIGH (T = 1) and CLK is LOW (CLK = 0). At the
rising edge (assuming positive transition) of a CLK pulse at time t1, the output
at Q changes state and becomes LOW, making Q HIGH. The negative transition of
the clock pulse from HIGH to LOW at time t2 has no effect on the output at Q as the
flip-flop is reset into one stable state.
At the next rising edge of the clock signal at time t3, the logic “1” at T passes to Q,
changing its state making output Q HIGH again. The negative transition of the CLK
pulse at time t4 from HIGH to LOW once again has no effect on the output. Thus
the Q output of the flip-flop “toggles” at each positive going edge (for this example)
of the CLK pulse.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -24-
Note: T-FF’s are not available commercially as a dedicated TTL or CMOS logic
chip, and as we mentioned, they can be easily constructed by connecting together
the J and K inputs of a basic JK flip-flop.
Further division of a clock frequency can be achieved by using the output of one
flipflop as the clock input to a second flip-flop, as shown in Figure 7–31. The
frequency of the QA output is divided by 2 by flip-flop B. The QB output is,
therefore, one-fourth the frequency of the original clock input. Propagation delay
times are not shown on the timing diagrams.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -25-
FIGURE 31 Example of two D flip-flops used to divide the clock frequency by 4. QA
            is one-half and QB is one-fourth the frequency of CLK.
     1.7.2. Counting
Another important application of flip-flops is in digital counters, the concept is
illustrated in Figure 32. Negative edge-triggered J-K flip-flops are used for
illustration. Both flip-flops are initially RESET. Flip-flop A toggles on the negative-
going transition of each clock pulse. The Q output of flip-flop A clocks flip-flop B, so
each time QA makes a HIGH-to-LOW transition, flip-flop B toggles. The resulting
QA and QB waveforms are shown in the figure.
Observe the sequence of QA and QB in Figure 32. Prior to clock pulse 1, QA = 0 and
QB = 0; after clock pulse 1, QA = 1 and QB = 0; after clock pulse 2, QA = 0 and QB =
1; and after clock pulse 3, QA = 1 and QB = 1. If we take QA as the least significant
bit, a 2-bit sequence is produced as the flip-flops are clocked. This binary sequence
repeats every four clock pulses, as shown in the timing diagram of Figure 7–40. Thus,
the flip-flops are counting in sequence from 0 to 3 (00, 01, 10, 11) and then recycling
back to 0 to begin the sequence again.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -26-
FIGURE 32 J-K flip-flops used to generate a binary count sequence (00, 01, 10, 11).
                           Two repetitions are shown.
Example 9.
Determine the output waveforms in relation to the clock for QA, QB, and QC in the
circuit of Figure 33 and show the binary sequence represented by these waveforms.
                                             Figure 33
Solution
The output timing diagram is shown in Figure 34. Notice that the outputs change on
the negative-going edge of the clock pulses. The outputs go through the binary
sequence 000, 001, 010, 011, 100, 101, 110, and 111 as indicated.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -27-
                                                     Figure 34.
The 555 timer is a versatile and widely used IC device because it can be configured in two
different modes as either a monostable multivibrator (one-shot) or as an astable multivibrator
(pulse oscillator).
An astable multivibrator is a device that has no stable states; it changes back and
forth (oscillates) between two unstable states without any external triggering. The
resulting output is typically a square wave that is used as a clock signal in many types
of sequential logic circuits. Astable multivibrators are also known as pulse oscillators
and are normally used as a clock pulse generator.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -28-
        Figure 34 Internal functional diagram of a 555 timer (pin numbers are in
                                      parentheses).
       tw = 1.1R1C1
The control voltage input is not used and is connected to a decoupling capacitor C2 to
prevent noise from affecting the trigger and threshold levels.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -29-
                     Figure 35 The 555 timer connected as a one-shot.
Example 10.
What is the output pulse width for a 555 monostable circuit with R1 = 2.2 kΩ and
C1 = 0.01 mF?
Solution
From Equation that applied for one shot connection , the pulse width is
       tW = 1.1R1C1 = 1.1(2.2 kΩ)(0.01 mF) = 24.2 ms
Astable Multivibrator
An astable multivibrator is a device that has no stable states; it changes back and
forth (oscillates) between two unstable states without any external triggering. The
resulting output is typically a square wave that is used as a clock signal in many types
of sequential logic circuits. Astable multivibrators are also known as pulse oscillators
and are normally used as a clock pulse generator.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -30-
Initially, when the power is turned on, the capacitor (C1) is uncharged and thus the
trigger voltage (pin 2) is at 0 V. This causes the output of comparator B to be HIGH
and the output of comparator A to be LOW, forcing the output of the latch, and thus
the base of Q1, LOW and keeping the transistor off. Now, C1 begins charging
through R1 and R2, as indicated in Figure 37. When the capacitor voltage reaches 1/3
VCC, comparator B switches to its LOW output state; and when the capacitor voltage
reaches 2/3 VCC, comparator A switches to its HIGH output state. This resets the
latch, causing the base of Q1 to go HIGH and turning on the transistor. This sequence
creates a discharge path for the capacitor through R2 and the transistor, as indicated.
The capacitor now begins to discharge, causing comparator A to go LOW. At the
point where the capacitor discharges down to 1/3 VCC, comparator B switches
HIGH; this sets the latch, making the base of Q1 LOW and turning off the transistor.
Another charging cycle begins, and the entire process repeats. The result is a
rectangular wave output whose duty cycle depends on the values of R1 and R2.
The frequency of oscillation is given by the following formula.
To achieve duty cycles of less than 50 percent, the circuit in Figure 36 can be
modified so that C1 charges through only R1 and discharges through R2. This is
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -31-
achieved with a diode, D1, placed as shown in Figure 39. The duty cycle can be made
less than 50 percent by making R1 less than R2. Under this condition, the expression
for the duty cycle is,
Example 11.
EXAMPLE 7–14
A 555 timer configured to run in the astable mode (pulse oscillator) is shown in
Figure 38. Determine the frequency of the output and the duty cycle.
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -32-
Solution.
Using the appropriate equations to calculate the value of frequency and duty cycle of
the circuit output as follows, (it is obvious that the circuit is for duty cycle )
Biomedical Engineering - Digital Electronics II - Fourth year – Prof. Dr. Mahmoud Alshemmary -33-