Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
INFORMATION SCIENCE
AND ENGINEERING AND
ABHILASH
Pavitra Bai C
SN
SJB
SSJJBB
I NS T I T U T E O F T EC H O LO G Y
IIININS
NNS
SSTTITTIITU
TUU
TTETEEOOF FT ETC
EC
ECHH
N O LO
LOGGYY
CHAPTER 2
Basic Gates
This module gives a quick review of Basic Logic Gates, Integrated Circuits along with its working and
truth table. Introduction to combinational circuits will be given and circuits will be designed.
Simplification methods such as k-map and Quine-mcClusky method is all discussed in detail. This
module will also introduce to Hardware Description Language(HDL)
1
SECTION 1
Above figure shows symbolic representation of logic gates used in circuit design. Further details about each gate is discussed in further section
✴ A logic gate is a digital circuit with 1 or more input voltages but only 1 ✴ Because the circuits simulate mental processes, gates are often called
output voltage. logic circuits. NOT, OR & AND gates are the basic types of gates.
✴ Logic gates are the fundamental building blocks of digital systems. ✴ The inter-connection of gates to perform a variety of logical operations is
called logic design.
✴ By connecting the different gates in different ways, we can build circuits
that perform arithmetic and other functions associated with the human ✴ The operation of a logic gate can be easily understood with the help of
brain. " t r u t h t a b l e " .
2
THE BASIC GATES - NOT, OR, AND EXAMPLE 2.1
N O T G A T E ( I N V E R T E R )
A 1-kHz square wave drives pin 1 of a 7404 (see Fig. 2.3). What does the
• It is a gate with only 1 input and a complemented output (Figure 2.2).
voltage waveform at pin 2 look like?
• 7 4 0 4 I C i s c a l l e d a h e x i n v e r t e r ( F i g u r e 2 . 3 ) .
• 7 4 0 4 I C c o n t a i n s s i x i n v e r t e r s .
• After applying +5 V dc (the supply voltage for all TTL devices) to pin
14 and grounding pin 7, you can connect any inverters to other TTL
d e v i c e s .
• For example, if you only need one inverter, you can connect an input EXAMPLE 2.2
signal to pin 1 and take the output signal from pin 2.
If a 500-Hz square wave drives pin 3 of a 7404(see Fig. 2.2), what is the
waveform on pin 4?
Figure 2.3 Timing Diagram of (a) example 2.1 (b) example 2.2
3
OR GATE EXAMPLE 2.3
• It is a gate with 2 or more inputs. Work out the truth table for below figure
b) Truth Table
AND GATE
7 4 0 8
• 7408 IC is a TTL quad 2-input AND gate (Figure 2.8).
• 7408 contains four 2-input AND gates inside a 14-pin DIP.
Figure 2.5 Pinout diagram of Figure 2.6 Timing Diagram of
7432 2-input OR gate
4
• After connecting a supply voltage of +5 V to pin 14 and a ground to pin EXAMPLE 2.4
7, you can connect one or more of the AND gates to other TTL devices.
Work out the truth table for below figure
Figure 2.9 a)
2-Input AND
Gate Symbol b)
Truth Table
EXAMPLE 2.5
What is the Boolean equation for the logic circuit given below
5
UNIVERSAL LOGIC GATES - NOR, NAND
• Any logic function can be realized using only NAND gates or only
NOR gates. For this reason, AND & NOR gates are called universal
g a t e s .
N O R G A T E
• This represents an OR gate followed by an inverter (fig 2.10a)
EXAMPLE 2.6
• 7402 IC is a quad 2-input NOR gate in a 14-pin DIP (fig 2.10 d)
Write the Boolean equation for below figure
• Bubbles on the inputs are a reminder of inversion that takes place
before AND operation
EXAMPLE 2.7
EXAMPLE 2.7
6
Note: NOR gate is equivalent to Bubbled OR gate. Click below image
for further information.
• It says the complement of a sum equals the product of the complements. Video Tutorial
7
EXAMPLE 2.10
What is the truth table for the NOR-NOR circuit of above figure?
EXAMPLE 2.9
EXAMPLE 2.11
8
NAND GATE
• This represents an AND gate followed by an inverter (fig 2.13a) De Morgan's Second Theorem
• 7400 is a quad 2-input NAND gate in a 14-pin DIP(fig 2.13d) • It says the complement of a product equals the sum of the complements.
• Bubbles on the inputs are a reminder of inversion that takes place Universality of NAND Gate
before OR operation
Interactive 2.1 Image showing equivalence between NAND and
• fig 2.13c represents the IEEE symbol of NAND gate
Bubbled OR gate
Bubble OR gate
NAND GATE
A & B input are passed to
NAND gate which
produces (AB)`
9
Review 2.1 Review questions on Logic Gates
Movie 2.2 Video Lecture on universality of NAND gate
Question 1 of 3
The output will be a LOW for any case when one or more
inputs are zero in a(n)
A. OR gate
B. NOT gate
C. AND gate
D. NAND gate
Click above video for more explanation on NAND gate Check Answer
10
SECTION 2
11
• In negative logic, the lower voltage level is assigned binary 1 & higher
voltage level is assigned binary 0. So, we can convert table 2.3 to table
2.4. HIGH=0 and LOW=1
We know that, in binary logic, two voltage levels represent the two binary
digits, 1 and 0.
Table 2.4 Negative Logic Truth Table
In positive logic, the lower voltage level is assigned binary 0 & higher
voltage level is assigned binary 1. So, we can convert table 2.3 to table
2.2.
12
ASSERTION LEVEL
• To activate, if an input line has a bubble on it, you assert the input by
making it low. If there is no bubble, you assert the input by making it
high. This is called as Assertion level.
• It means that you draw chips with the kind of input that causes
something to happen, or with the kind of output that indicates
something has happened.
• If a low input signal turns on a chip, you show a bubble on that input
• A n i n p u t i s a s s e r t e d w h e n i t i s a c t i v e .
• This means it may be low or high, depending on whether it is an
a c t i v e - l o w o r a c t i v e - h i g h i n p u t .
• For instance, given a positive AND gate, all inputs must be asserted
( h i g h ) t o g e t a h i g h o u t p u t .
• As another example, the STROBE input of a TTL multiplexer must be
a s s e r t e d ( l o w ) t o t u r n o n t h e m u l t i p l e x e r .
• In short, you can equate the word assert with activate.
• You assert, or activate, the inputs of a gate or device to get something
to happen.
13
SECTION 3
Combinational circuit is a circuit in which we combine the different The combinational circuit do not use any memory. The previous state
gates in the circuit, for example encoder, decoder, multiplexer and of input does not have any effect on the present state of the circuit.
demultiplexer.
A combinational circuit can have an n number of inputs and m number
Some of the characteristics of combinational circuits are following of outputs.
14
Types of Combinational Circuits
The fundamental products are also called minterms (Figure: 2.17 &
2.18).
Figure 2.18 Fundamental Products for three inputs
Product-terms are represented as follows (Table: 2.6):
➡ AB' → m2
➡ AB → m3
15
S U M O F P R O D U C T S E Q U A T I O N
• Y=F(A,B,C) means Y is a function of 3 boolean variables A,B and C.
• Sum-of-products equation means the logical sum of fundamental
p r o d u c t s t h a t p r o d u c e o u t p u t 1 s i n t h e t r u t h t a b l e .
• To get the sum of products equation, we have to OR the minterms.
• Each product-term is called minterm. Y = F ( A , B , C ) = A ' B C + A B ' C + A B C ' + A B C
For example, A.B, A.B.C, A.B.C.D etc Y=F(A,B,C)=m3+m5+m6+m7 where minterm is denoted by mi
Y=F(A,B,C)=Σm(3,5,6,7) where ∑ denotes summation i.e. OR
• Here, we have to locate output 1 in the truth table and write down the operation
minterm.
• This kind of representation of a truth table is also known as canonical
sum form.
→ NAND-NAND circuit.
Figure 2.19
Table 2.7 Fundamental Products AND-OR
solution
✤First output 1 appears for an input A=0, B=1 and C=1. The
corresponding minterm is A'BC.
✤Second output 1 appears for A=1, B=0 and C=1. The corresponding
minterm is AB'C.
✤Third output 1 appears for A=1, B=1 and C=0. The corresponding
minterm is ABC’.
✤Fourth output 1 appears for A=1, B=1 and C=1. The corresponding
minterm is ABC.
16
Figure 2.20 EXAMPLE 2.13
NAND-NAND
solution for the Simplify the following Boolean equation and describe the logic circuit.
above Sum of Y=A’B’C’ +A’BC’ +AB’C’ +ABC’
products
expression
EXAMPLE 2.12
Suppose a three-valuable truth table has a high output for these input
conditions: 000, 010, 100, and 110. What is the sum-of-products circuit? TRUTH TABLE TO Karnaugh Map (KMAP)
In Table 2.8
i) The first output 1 appears for A=1 and B=0. The minterm for this input
condition is AB'.
ii) Similarly, enter 1 into cell identified by row A and column B.
iii) Finally, enter 0s in the remaining cells.
17
Table 2.8 Figure 2.22 K-Map for the above logic equation
Sample Truth
Table
18
Table 2.10 Truth Table for the 4 variable
expression given above • Entered variable map for Table: 2.11 is constructed as follows.
19
PAIRS, QUADS AND OCTETS
• Pair means two horizontally or vertically adjacent 1s on a Kmap. It
eliminages 1 variable and its complement
KARNAUGH SIMPLIFICATIONS
20
Overlapping Groups Rolling the Map
• Overlapping groups means using the same 1(minterm) more than once
when grouping the 1s of a Kmap.
• In Figure 2.26 (a) ,you can find an octet and a pair grouping. The • In figure 2.27(a) two pairs are being identified which would be wrong.
Instead, we choose figure 2.27(b) where the quad has the equation
simplified equation for the overlapping groups is Y=A+BC’D
Y=BD’.
• In Figure 2.26(b) you can find an octet and a single 1(minterm).The • Thus, 1s on the edges of a Kmap can be grouped with ls on opposite
simplified equation for the groups is Y=A+A`BC’D which requires edges.
more no. of gates compared to the above expression. Therefore , it is
suggested to opt for the bigger grouping. i.e., grouping done as in fig Rolling and Overlapping
2.26(b) is not recommended
• In Figure. 2.29(b), rolling as well as overlapping is being applied; thus
• So, always overlap groups if possible. That is, use the 1s more than the Boolean equation is Y= C’+BD’
once to get the largest groups you can.
21
KMAP METHOD FOR SIMPLIFYING BOOLEAN EQUATIONS
iii) 1=C+C'
22
Case (ii): Example for using 1=1+C DON’T CARE CONDITION (X)
• As shown in Figure. 2.30(B), A is grouped with 1 to get a larger group • This is an input-output condition that never occurs during normal
as 1 can be written as 1=1+A. • Here, operation.
Group-1 gives B.(A)=AB and Group-2 gives BC'.(1)=BC' Thus, Y=BC'+ • Since the condition never occurs, you can use an ‘X’ on the Kmap
AB. (Table: 3.8).
Case (iii): Example for using 1=C+C' • This X can be a 0 or a 1, whichever you prefer (Table 2.12)
• As shown in Figure. 2.30(c) EVM
→ has only two product-terms and
→ doesn't need a separate coverage of 1.
• This is because one can write 1=C+C' and C is included in one group
while C' in other. • Here,
Example 2.14
What is the simplified Boolean equation for the following logic equation
expressed by minterms? Y=F(A,B,C,D)=Σm(7,9, 10, 11, 12, 13, 14, 15)
23
How to use Don’t Care conditions(X) in KMAP Click on below image gallery for some of wrong grouping examples in K MAP
simplification
1)Given the truth table, draw a kmap with 0s, 1s and don't cares.
2) Encircle the actual 1s on the kmap in the largest groups you can find by
t r e a t i n g t h e d o n ' t c a r e s a s 1 s .
3) After the actual 1s have been included in groups, discard the remaining
don't cares by visualizing them as 0s.
Other Study Material
EXAMPLE 2.15 Web Link for online k-map calculator
Give the simplest logic circuit for following logic equation where d
represents don't-care condition for following locations.
F(A,B,C,D)=Σm(7)+d(10,11,12,13,14,15)
24
SECTION 4
HDL (HARDWARE DESCRIPTION LANGUAGE) is a specialized ✴ To describe large complex design requiring hundreds of logic gates in
computer language used to describe the structure and behavior of a convenient manner.
electronic circuits, and most commonly, digital logic circuits.
✴ To use software test-bench to detect functional error and correct it
✴A hardware description language enables a precise, formal description (called simulation)
of an electronic circuit that allows for the automated analysis and
simulation of an electronic circuit. ✴ To get hardware implementation details (called synthesis).
25
Currently, there are 2 widely used HDLs:
• The symbol '//' is used
- Verilog
→ to put comments &
- VHDL (Very high speed integrated circuit Hardware Description
→ to improve readability for a human.
Language).
In this section ,we will be discussing on Verilog Code • The module-body describes the logic within the black box which
→ acts on the inputs a, b, c and
VERILOG HDL
→ generates output x, y.
• This describes a digital system as a set of modules.
• In a digital circuit, there are a set of inputs and a set of outputs which • Semicolon ';' is used to indicate end the statement.
are called as ports. Writing module body
1) Structural model
3) Behavioral modeling.
Each model has its own advantage and suited for certain kind of design.
Figure 2.32 Verilog code for a sample circuit Sample Verilog Code
Figure 2.32 shows Input/output definition in Verilog HDL for logic
1. Write a verilog for following gate using Structural Model
circuit described within black-box testckt
Describing input/output
• module and endmodule are the keywords.
• Module describes a design-entity with a name or identifier selected by
user (here, testckt) followed by input-output port-list.
26
module or_gate(A,B,Y); PREPARATION OF TEST BENCH
input A,B; output Y; • Here, we write a verilog code for simulating a OR gate
and g1(Y,A,B);
• .The test bench creates an input in the form of a timing waveform and
endmodule passes this to OR gate module through a function or procedural call
2. Write a verilog for following circuit using Structural Model
• .To generate timing waveform, we use time delay available in the
//defines two input port //define one output port //represents OR gate form of #n where n=number in decimal that gives delay in
nanoseconds.
module fig2_24(A,B,C,D,Y) • The keyword 'initial' ensures sequential execution of codes following
it, but once.
input A,B,C,D;
output Y;
• The keyword 'always' is used for sequential execution but for infinite
wire op1,op2;
time.
and g1(op1,A,B); and g2(op2,C,D); or g3(Y,op1,op2);
Below figure shows simulation of 2 input OR gate with 20ns gate
endmodule delay
//g1 represents upper AND gate //g2 represents lower AND gate
//internal connections
27
28
SECTION 5
Canonical Expression
A boolean expression consisting entirely either of minterm or maxterm is Following is a canonical expression consisting of minterms
called canonical expression. Different Forms of Canonical Expression
XY + X’Y’ and
Sum of Products (SOP)
Following is a canonical expression consisting of maxterm
Product of Sums (POS)
(X+Y) . (X’ + Y’)
If we have two variables X and Y then,
29
Product-of-sums equation means the logical product of those fundamental
s u m s t h a t p r o d u c e o u t p u t 0 s i n t h e t r u t h t a b l e .
• Each sum-term is called maxterm.
For example,
• Here, we have to locate output 0 in the truth table and write down the Table 2.13 Fundamental sums for three inputs
maxterm
1.First output 0 appears for an input A=0, B=0 and C=0. The
corresponding maxterm is A+B+C.
3.Third output 0 appears for A=1, B=1 and C=0. The corresponding
maxterm is A’+B’+C.
Y=F(A,B,C)=∏M(0,3,6) where ∏ denotes product, i.e. AND → OR-AND circuit (FIGURE 2.35)or
operation → NOR-NOR circuit (Figure 2.34).
30
STEPS TO CONVERT BETWEEN STANDARD SOP & POS LIMITATIONS (OR DRAWBACKS) OF KMAP
FORM
1) The map method depends on the user's ability to identify patterns that
1) Identify complementary locations. gives largest size.
2) Changing minterm to maxterm or reverse. 2) The map method becomes difficult to adapt for simplification of 5 or
more variables.
3) Changing summation by product or reverse.
PRODUCT-Of-SUMS SIMPLIFICATION
• This is known as conversion between canonical forms. For example,
• Procedure to simplify boolean equation in product-of-sums form:
If Y=F(A,B,C)=A'BC'+AB'C+A'B'C' then Y'=F’(A,B,C)=(A+B'+C).
(A'+B+C').(A+B+C) 1) Convert the truth table into a Kmap.
2) Complement the Kmap i.e. interchange 0 and 1.
If Y=F(A,B,C)=∏M(0,3,6) then Y’=F’(A,B,C)=Σm(1,2,4,5,7) 3) Group the 1s, write the sum-of-products equation for Y’.
4) Using duality theorem, convert the sum-of-products equation to
EXAMPLE 2.14
equivalent product-of-sums equation.
Suppose a truth table has a low output for the first three input conditions:
000, 001, and 010. If all other outputs are high, what is the EXAMPLE 2.15
product-of-sums circuit? • Consider truth table: Table 2.14
Figure 2.36
using only NOR
gate
Y’=A’B+AB’C’
Y=(A+B’).(A’+B+C)
Figure 2.38 Logic circuit for Y Give simplest POS form of Kmap shown in below figure by grouping
zeros.
32
Review 2.2 Logic Gates
Question 1 of 6
The output of an AND gate with
three inputs, A, B, and C, is HIGH
when ________.
A. A = 1, B = 1, C = 0
B. A = 0, B = 0, C = 0
C. A = 1, B = 1, C = 1
D. A = 1, B = 0, C = 1
Check Answer
33
SECTION 6
A static hazard is the situation where, when one input variable changes, Static Hazards
the output changes momentarily before stabilising to the correct value.
• Static-1 Hazard: the output is currently 1 and after the inputs change,
There are 2 types of Hazards, namely
the output momentarily changes to 0,1 before settling on 1.
- Static Hazards • Static-0 Hazard: the output is currently 0 and after the inputs changes,
- Dynamic Hazards the output momentarily changes to 1,0 before settling on to 0
34
In properly formed two-level AND-OR logic based on a Sum Of Products
expression, there will be no static-0 hazards. Conversely, there will be no
static-1 hazards in an OR-AND implementation of a Product Of Sums
expression.
Static-0 hazard
Figure 2.40 Static-0 hazard Figure 2.41 Hazard free circuit
In a combinational circuit, if output goes momentarily 1 when it should
r e m a i n a 0 , t h e h a z a r d i s k n o w n a s s t a t i c - 0 h a z a r d
• Static-0 hazard occurs when C o n s i d e r K m a p s h o w n i n F i g . 2 . 4 0
→ Y=AA' type of situation appears in a logic circuit. • Minimally, the Kmap is represented by output Y=(B+C)(A+C')
• T h e c o r r e s p o n d i n g c i r c u i t i s s h o w n i n F i g . 2 . 4 0 ( b )
→ ‘A‘ makes a transition 0 1.
• A s s u m e , i n p u t A = 0 , B = 0 .
• Here is how static-0 hazard occurs:
• When C makes a transition 0-->1, there will be static-0 hazard occurring
An AA' condition should always generate 0 at the output, i.e. static-0. at output.
But the NOT gate output takes finite time to become 0 following 0 1
Example for circuit with hazard cover
transition of A.
Thus for AND gate, there are 2 ones appearing at its input for the • Consider another grouping for the Kmap in Fig.2.41.
small duration, resulting a 1 at its output. • This includes one additional term (A+ B) and now output
The width of this zero is in nanosecond order and is called a glitch. Y=(B+C)(A+C')(A+B)
• T h e c o r r e s p o n d i n g c i r c u i t i s s h o w n i n F i g . 2 . 4 1
Example for circuit with static-0 hazard
• T h i s c i r c u i t i s h a z a r d f r e e .
• • This circuit requires more hardware than minimal representation.
• The additional term (A + B) ensures Y=0 for A=0, B=0.
• A 0--> 1 transition at C does not affect output.
35
STATIC -1 HAZARD DYNAMIC H A Z A R D
• Dynamic hazard occurs when circuit output makes multiple transitions
A static 1 hazard may occur in a two level sum of products (SOP)
before it settles to a final value while the logic equation asks for only one
implementation. Consider an AND-OR SOP implementation with the
following characteristics: t r a n s i t i o n .
• When this hazard occurs, an output transition designed as
1 For the current input conditions only one AND gate has a 1--> 0 may give 1-->-->1-->0
logic '1' output. This causes the output of the OR to be '1'.
0-->1 may give 0-->1-->0-->1
2 A single input variable changes which "simultaneously"
causes the first AND gate output to a logic '0' and causes another AND • The output of logic equation in dynamic hazard degenerates into
gate output to go to a logic '1'.
Y = A + A ' . A o r Y = ( A + A ' ) .
If the first AND gate changes before the second, the OR will have two '0' • A kind of relations for certain combinations of the other input variables.
inputs for a short time and an output glitch will occur. • Dynamic hazard occur in multilevel circuits having implicit static-1
and/or static-0 hazards.
For example, consider the function f(A,B,C) = A'B+AC implemented in
this minimized SOP form. • By providing covers to each one of them, dynamic hazard can be
prevented.
In this case R=A'B and S=AC so f(A,B,C)=R+S.
36
SECTION 7
The Quine–McCluskey algorithm (or the method of prime implicants) It is functionally identical to Karnaugh mapping, but the tabular form
is a method used for minimization of Boolean functions. makes it more efficient for use in computer algorithms, and it also gives
a deterministic way to check that the minimal form of a Boolean function
It is sometimes referred to as the tabulation method. has been reached.
37
The method involves two steps: iii) This means corresponding variable is not required to represent those
members.
1 Finding all prime implicants of the function.
Stage 3
2 Use those prime implicants in a prime implicant chart to find
the essential prime implicants of the function, as well as other prime i) We combine members of different groups of stage 2 in a similar way.
implicants that are necessary to cover the function. ii) Now it will have two '-' elements in each combination.
iii) This means each combination requires 2 literals to represent it.
PROCEDURE USED FOR DETERMINING ESSENTIAL PRIME
iv) There is no stage 4 for this problem. This completes process of
IMPLICANTS determination of prime implicants.
Consider a 4-variable simplification problem for Table 2.15 Figure 2.43
shows prime implicant determination table for the problem.
Stage 1
Table 2.15 Truth table
i) We find out all the terms that gives output 1 from truth table (Table
2 . 1 5 ) .
ii) We put them in different groups depending on how many 1 i/p variable
combinations have.
For example,
- First group has no 1 in input combination.
- Second group has only one 1.
- Third group has two 1s.
- Fourth group has three 1s.
- Fifth group has four 1s.
iii) We also write decimal equivalent of each combination to their right
for convenience.
Stage 2
38
Figure 2.43 Quine McClusky method of simplification
Te r m s 0 a n d 1 a r e c o v e r e d b y A ' B '
Terms 2 and 3 are covered by both A'B and B'C'. Thus, the
c o r r e s p o n d i n g c r o s s - p o i n t s a r e t i c k e d .
This way we complete the table for rest of the terms.
39
To know more simplification examples using Quine Mcclusky method ,
click below weblink
40
Canonical
A hazard is an agent which has the potential to cause harm to a vulnerable target. The terms
"hazard" and "risk" are often used interchangeably. However, in terms of risk assessment,
they are two very distinct terms.
A power inverter, or inverter, is an electronic device or circuitry that changes direct current
(DC) to alternating current (AC).
The Karnaugh map (KM or K-map) is a method of simplifying Boolean algebra expressions.
Maurice Karnaugh introduced it in 1953 as a refinement of Edward Veitch's 1952 Veitch
chart,which actually was a rediscovery of Allan Marquand's 1881 logical diagram aka
Marquand diagram but with a focus now set on its utility for switching circuits.
In electronics, a multiplexer (or mux) is a device that selects one of several analog or digital
input signals and forwards the selected input into a single line.
The Quine–McCluskey algorithm (or the method of prime implicants) is a method used for
minimization of Boolean functions that was developed by Willard V. Quine and extended by
Edward J. McCluskey.
Simulation is the imitation of the operation of a real-world process or system. The act of
simulating something first requires that a model be developed; this model represents the
key characteristics, behaviours and functions of the selected physical or abstract system or
process.