Professional Documents
Culture Documents
MOHAMMED KAMIL
Tikrit University
College Of Engineering
Logic circuits
ادلوائر املنطقية
Done by:
List of Contents:
Lecture 1 .... Combinational Logic Analysis............................................................................................................
5–2 Implementing Combinational Logic
5–4 Combinational Logic Using NAND and NOR Gates
5–5 Pulse Waveform Operation
Lecture 2 .. Functions of Combinational Logic (Half and Full Adders, Comparators) ...................
6–1 Half and Full Adders
6–2 Parallel Binary Adders
6–4 Comparators
Lecture 3 .... Decoders, Encoders, and Multiplexers..............................
5 Decoders
The BCD-to-Decimal Decoder
The BCD-to-7-Segment Decoder
6–6 Encoders
6–7 Code Converters
6–8 Multiplexers (Data Selectors)
6–9 Demultiplexers
Lecture 4 .. Latches, D- Flip-Flops................................................
7–1 Latches
7–2 Flip-Flops
The D Flip-Flop
Lecture The J-K Flip-Flop ................................................................................................................................
The J-K Flip-Flop
Asynchronous Preset and Clear Inputs
7–4 Flip-Flop Applications
Lecture 6 . Counters...................................................................................................................................
Asynchronous Counters
A 2-Bit Asynchronous Binary Counter
A 3-Bit Asynchronous Binary Counter
Asynchronous Decade Counters
Partial Decoding
9–3 Synchronous Counters
9–5 Design of Synchronous Counters
Up/Down counter
1
Digital Techniques Dr. MOHAMMED KAMIL
Lecture 1
Combinational Logic Analysis
The first term is formed by ANDing A with B, and the second term is formed by ANDing C,
D, and E. The two terms are then ORed to form the output X. These operations are indicated
in the structure of the expression as follows:
Example 2:
2
Digital Techniques Dr. MOHAMMED KAMIL
Solution:
3
Digital Techniques Dr. MOHAMMED KAMIL
4
Digital Techniques Dr. MOHAMMED KAMIL
• NAND Logic
As you have learned, a NAND gate can function as either a NAND or a negative-OR because,
by DeMorgan’s theorem,
Solution:
5
Digital Techniques Dr. MOHAMMED KAMIL
Example: Rewrite the following expression using only NAND gate 𝑋 = (𝐴𝐵 + 𝐶̅ )𝐷 + 𝐸𝐹
Solution:
• NOR Logic
A NOR gate can function as either a NOR or a negative-AND, as shown by DeMorgan’s
theorem.
6
Digital Techniques Dr. MOHAMMED KAMIL
Example: Rewrite the following expression using only NOR gate 𝑋 = (𝐴 + 𝐵 )(𝐶 + 𝐷)
Solution:
1. The output of an AND gate is HIGH only when all inputs are HIGH at the same time.
2. The output of an OR gate is HIGH only when at least one of its inputs is HIGH.
3. The output of a NAND gate is LOW only when all inputs are HIGH at the same time.
4. The output of a NOR gate is LOW only when at least one of its inputs is HIGH.
7
Digital Techniques Dr. MOHAMMED KAMIL
8
Digital Techniques Dr. MOHAMMED KAMIL
9
Digital Techniques Dr. MOHAMMED KAMIL
HOMEWORKS -1-
10
Digital Techniques Dr. MOHAMMED KAMIL
Lecture 2
Functions of Combinational Logic
6–1 Half and Full Adders
Half-Adder
Recall the basic rules for binary addition as stated in Chapter 2.
The half-adder accepts two binary digits on its inputs and produces two
binary digits on its outputs—a sum bit and a carry bit.
Half-Adder Logic
11
Digital Techniques Dr. MOHAMMED KAMIL
The Full-Adder
The full-adder accepts two input bits and an
input carry and generates a sum output and an
output carry.
12
Digital Techniques Dr. MOHAMMED KAMIL
Notice in Figure 6–4(b) there are two half-adders, connected as shown in the block diagram of
Figure 6–5(a), with their output carries ORed. The logic symbol shown in Figure 6–5(b) will
normally be used to represent the full-adder.
13
Digital Techniques Dr. MOHAMMED KAMIL
To add two binary numbers, a full-adder (FA) is required for each bit in the numbers. So, for
2-bit numbers, two adders are needed; for 4-bit numbers, four adders are used; and so on. The
carry output of each adder is connected to the carry input of the next higher-order adder, as
shown in Figure 6–7 for a 2-bit adder.
14
Digital Techniques Dr. MOHAMMED KAMIL
A group of four bits is called a nibble. A basic 4-bit parallel adder is implemented with four
full-adder stages as shown in Figure 6–9. Again, the LSBs (A1 and B1) in each number being
added go into the right-most full-adder; the higher-order bits are applied as shown to the
successively higher-order adders, with the MSBs (A4 and B4) in each number being applied to
the left-most full-adder. The carry output of each adder is connected to the carry input of the
next higher-order adder as indicated. These are called internal carries.
15
Digital Techniques Dr. MOHAMMED KAMIL
Adder Expansion
The 4-bit parallel adder can be expanded to handle the addition of two 8-bit numbers by using
two 4-bit adders. The carry input of the low-order adder (C0) is connected to ground because
there is no carry into the least significant bit position, and the carry output of the low-order
adder is connected to the carry input of the high-order adder, as shown in Figure 6–11.
16
Digital Techniques Dr. MOHAMMED KAMIL
An application
An example of full-adder and parallel adder application is a simple voting system that can be
used to simultaneously provide the number of “yes” votes and the number of “no” votes.
17
Digital Techniques Dr. MOHAMMED KAMIL
6–4 Comparators
The basic function of a comparator is to compare the magnitudes of two binary quantities to
determine the relationship of those quantities.
Equality
In order to compare binary numbers containing two bits each, an additional exclusive- NOR
gate is necessary. The two least significant bits (LSBs) of the two numbers are compared by
gate G1, and the two most significant bits (MSBs) are compared by gate G2, as shown in Figure
6–19.
18
Digital Techniques Dr. MOHAMMED KAMIL
Inequality
3. If A3 = B3, then you must examine the next lower bit position for an inequality.
19
Digital Techniques Dr. MOHAMMED KAMIL
Lecture 3
Functions of Combinational Logic
(Decoders, Encoders, and Multiplexers)
5 Decoders
A decoder is a digital circuit that detects the presence of a specified combination of bits (code)
on its inputs and indicates the presence of that code by a specified output level. In its general
form, a decoder has n input lines to handle n bits and from one to 2n output lines to indicate the
presence of one or more n-bit combinations.
20
Digital Techniques Dr. MOHAMMED KAMIL
EXAMPLE 6–10
If the input waveforms in Figure 6–32(a) are applied to the inputs of the BCD-to-decimal
decoder, show the output waveforms.
21
Digital Techniques Dr. MOHAMMED KAMIL
EXAMPLE
A 7-segment decoder/driver drives the display in Figure below. If the waveforms are applied
as indicated, determine the sequence of digits that appears on the display.
6–6 Encoders
22
Digital Techniques Dr. MOHAMMED KAMIL
The basic process for Gray-binary conversions was covered in Chapter 2. Exclusive-OR gates
can be used for these conversions. Figure 6–40 shows a 4-bit binary-to-Gray code converter,
and Figure 6–41 illustrates a 4-bit Gray-to-binary converter.
23
Digital Techniques Dr. MOHAMMED KAMIL
24
Digital Techniques Dr. MOHAMMED KAMIL
25
Digital Techniques Dr. MOHAMMED KAMIL
EXAMPLE 6–15
Use an eight-Input Data Multiplexer and any other logic necessary to multiplex 16 data lines
onto a single data-output line.
Solution
26
Digital Techniques Dr. MOHAMMED KAMIL
Multiplexer Applications
27
Digital Techniques Dr. MOHAMMED KAMIL
28
Digital Techniques Dr. MOHAMMED KAMIL
6–9 Demultiplexers
A demultiplexer (DEMUX) basically reverses the multiplexing function. It takes digital
information from one line and distributes it to a given number of output lines. For this reason,
the demultiplexer is also known as a data distributor.
Figure 6–52 shows a 1-line-to-4-line demultiplexer (DEMUX) circuit. The data-input line goes
to all of the AND gates. The two data-select lines enable only one gate at a time, and the data
appearing on the data-input line will pass through the selected gate to the associated data-output
line.
29
Digital Techniques Dr. MOHAMMED KAMIL
30
Digital Techniques Dr. MOHAMMED KAMIL
Homework
31
Digital Techniques Dr. MOHAMMED KAMIL
32
Digital Techniques Dr. MOHAMMED KAMIL
Lecture 4
Latches, D- Flip-Flops
7–1 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.
A latch is a type of bistable logic device or multivibrator. An active-HIGH input S-R (SET-
RESET) latch is formed with two cross-coupled NOR gates, as shown in Figure 7–1(a); an
active-LOW input 𝑆̅-𝑅̅ latch is formed with two cross-coupled NAND gates, as shown in Figure
7–1(b). Notice that the output of each gate is connected to an input of the opposite gate. This
produces the regenerative feedback that is characteristic of all latches and flip-flops.
33
Digital Techniques Dr. MOHAMMED KAMIL
34
Digital Techniques Dr. MOHAMMED KAMIL
35
Digital Techniques Dr. MOHAMMED KAMIL
36
Digital Techniques Dr. MOHAMMED KAMIL
7–2 Flip-Flops
Flip-flops are synchronous bistable devices, also known as bistable multivibrators. In this case,
the term synchronous means that the output changes state only at a specified point (leading or
trailing edge) on the triggering input called the clock (CLK), which is designated as a control
input, C; that is, changes in the output occur in synchronization with the clock. Flip-flops are
edge-triggered or edge-sensitive whereas gated latches are level-sensitive.
An edge-triggered flip-flop changes state either at the positive edge (rising edge) or at the
negative edge (falling edge) of the clock pulse and is sensitive to its inputs only at this transition
of the clock. Two types of edge-triggered flip-flops are covered in this section: D and J-K. The
logic symbols for these flip-flops are shown in Figure 7–13.
The D Flip-Flop
The D input of the D flip-flop is a synchronous input because data on the input are transferred
to the flip-flop’s output only on the triggering edge of the clock pulse. When D is HIGH, the Q
output goes HIGH on the triggering edge of the clock pulse, and the flip-flop is SET. When D
is LOW, the Q output goes LOW on the triggering edge of the clock pulse, and the flip-flop is
RESET.
37
Digital Techniques Dr. MOHAMMED KAMIL
38
Digital Techniques Dr. MOHAMMED KAMIL
39
Digital Techniques Dr. MOHAMMED KAMIL
Lecture 5
The J-K Flip-Flop
The J-K Flip-Flop
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.
40
Digital Techniques Dr. MOHAMMED KAMIL
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. A
logic symbol for a D flip-flop with preset and clear inputs is shown in Figure 7–25. 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 7–26 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.
41
Digital Techniques Dr. MOHAMMED KAMIL
EXAMPLE 7–7
For the positive edge-triggered D flip-flop with preset
and clear inputs in Figure 7–27, determine the Q output
for the inputs shown in the timing diagram in part (a) if
Q is initially LOW.
42
Digital Techniques Dr. MOHAMMED KAMIL
43
Digital Techniques Dr. MOHAMMED KAMIL
Frequency Division
Another application of a flip-flop is dividing (reducing) the frequency of a periodic waveform.
When a pulse waveform is applied to the clock input of a D or J-K flip-flop that is connected
to toggle (D = 𝑄̅ or J = K = 1), the Q output is a square wave with one-half the frequency of the
clock input. Thus, a single flip-flop can be applied as a divide-by-2 device, as is illustrated in
Figure 7–36 for both a D and a J-K 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–37. 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.
44
Digital Techniques Dr. MOHAMMED KAMIL
Homework
45
Digital Techniques Dr. MOHAMMED KAMIL
46
Digital Techniques Dr. MOHAMMED KAMIL
Lecture 6
Counters
Asynchronous Counters
The term asynchronous refers to events that do not have a fixed time relationship with each
other and, generally, do not occur at the same time. An asynchronous counter is one in which
the flip-flops (FF) within the counter do not change states at exactly the same time because
they do not have a common clock pulse.
Figure 9–4 shows a 2-bit counter connected for asynchronous operation. Notice that the clock
(CLK) is applied to the clock input (C) of only the first flip-flop, FF0, which is always the least
significant bit (LSB). The second flip-flop, FF1, is triggered by the 𝑄̅0 output of FF0. FF0
changes state at the positive-going edge of each clock pulse, but FF1 changes only when
triggered by a positive-going transition of the 𝑄̅0 output of FF0. Because of the inherent
propagation delay time through a flip-flop, a transition of the input clock pulse (CLK) and a
transition of the 𝑄̅0 output of FF0 can never occur at exactly the same time. Therefore, the two
flip-flops are never simultaneously triggered, so the counter operation is asynchronous.
47
Digital Techniques Dr. MOHAMMED KAMIL
The state sequence for a 3-bit binary counter is listed in Table 9–2, and a 3-bit asynchronous
binary counter is shown in Figure 9–6(a).
48
Digital Techniques Dr. MOHAMMED KAMIL
The modulus of a counter is the number of unique states through which the counter will
sequence.
One common modulus for counters with truncated sequences is ten (called MOD10). Counters
with ten states in their sequence are called decade counters. A decade counter with a count
sequence of zero (0000) through nine (1001) is a BCD decade counter because its ten-state
sequence produces the BCD code.
To obtain a truncated sequence, it is necessary to force the counter to recycle before going
through all of its possible states. For example, the BCD decade counter must recycle back to
the 0000 state after the 1001 state. A decade counter requires four flip-flops (three flip-flops
are insufficient because 23 = 8).
Let’s use a 4-bit asynchronous counter such as the one in Example 9–1 and modify its sequence
to illustrate the principle of truncated counters. One way to make the counter recycle after the
count of nine (1001) is to decode count ten (1010) with a NAND gate and connect the output
of the NAND gate to the clear (CLR) inputs of the flip-flops, as shown in Figure 9–9(a).
Partial Decoding
Notice in Figure 9–9(a) that only Q1 and Q3 are connected to the NAND gate inputs. This
arrangement is an example of partial decoding, in which the two unique states (Q1 = 1 and Q3
= 1) are sufficient to decode the count of ten because none of the other states (zero through
49
Digital Techniques Dr. MOHAMMED KAMIL
nine) have both Q1 and Q3 HIGH at the same time. When the counter goes into count ten (1010),
the decoding gate output goes LOW and asynchronously resets all the flip-flops.
Q3 Q2 Q1 Q0
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
The term synchronous refers to events that have a fixed time relationship with each other. A
synchronous counter is one in which all the flip-flops in the counter are clocked at the same
time by a common clock pulse. J-K flip-flops are used to illustrate most synchronous counters
Figure 9–12 shows a 2-bit synchronous binary counter. Notice that an arrangement different
from that for the asynchronous counter must be used for the J1 and K1 inputs of FF1 in order to
achieve a binary sequence. A D flip-flop implementation is shown in part (b).
50
Digital Techniques Dr. MOHAMMED KAMIL
A 3-bit synchronous binary counter is shown in Figure 9–15, and its timing diagram is shown
in Figure 9–16. You can understand this counter operation by examining its sequence of states
as shown in Table 9–3.
51
Digital Techniques Dr. MOHAMMED KAMIL
52
Digital Techniques Dr. MOHAMMED KAMIL
53
Digital Techniques Dr. MOHAMMED KAMIL
54
Digital Techniques Dr. MOHAMMED KAMIL
D-Flip-Flop
Solution
The D inputs are plotted on the present-state Karnaugh maps in Figure 9–31. Also “don’t cares”
can be placed in the cells corresponding to the invalid states of 000, 011, 100, and 110
(0, 3, 4, 6), as indicated by the red Xs.
55
Digital Techniques Dr. MOHAMMED KAMIL
T-Flip-Flop
Construct a synchronous 3-bit Up/Down counter by using T flip-flops
56
Digital Techniques Dr. MOHAMMED KAMIL
0 0 1 1 1 0 0 1 1 1
0 1 0 0 1 0 1 0 0 1
0 1 0 1 1 1 0 0 1 1
0 1 1 0 1 1 1 0 0 1
0 1 1 1 0 0 0 1 1 1
1 0 0 0 1 1 1 1 1 1
1 0 0 1 0 0 0 0 0 1
1 0 1 0 0 0 1 0 1 1
Down -Counter
1 0 1 1 0 1 0 0 0 1
1 1 0 0 0 1 1 1 1 1
1 1 0 1 1 0 0 0 0 1
1 1 1 0 1 0 1 0 1 1
1 1 1 1 1 1 0 0 0 1
00 01 11 10 00 01 11 10 00 01 11 10
00 1 00 1 1 00 1 1 1 1
01 1 01 1 1 01 1 1 1 1
11 1 11 1 1 11 1 1 1 1
10 1 10 1 1 10 1 1 1 1
𝑇1 = 𝑀 ̅̅̅ ̅ 𝑄0
𝑄0 + 𝑀 𝑇0 = 1
̅̅̅1 𝑄
𝑇2 = 𝑀𝑄 ̅̅̅0 + 𝑀
̅ 𝑄1 𝑄0
57
Digital Techniques Dr. MOHAMMED KAMIL
Homework
Fig. 9-75
58