m1 Intro Logic Circuits
m1 Intro Logic Circuits
Mazen A. R. Saghir
011101
x1 001001
100110 y1
x2 Logic Operations 110010
101001 y2
x3
Because logic circuits process binary digits they are also called
binary circuits. In this course we will use these two terms
interchangeably.
x = 0 x = 1
x = 0 x = 1
(a) Two states of a switch
A switch can be represented by a box S controlled by the binary
(a) Two states of a switch
variable x:
S
S
x
S x L( x )
0 0
Battery x Light
1 1
L(x) = x
(b) Using a ground connection as the return path
When the switches are connected in series, the light will only turn on
if both switches are closed. In other words, L = 1 only if x1 = 1 and
x2 = 1; otherwise L = 0.
x1 x2 L ( x1 , x2 )
S S 0 0 0
Power x1 x2 Light 0 1 0
supply
1 0 0
1 1 1
(a) The logical AND function (series connection)
We can express the two-variable binary function x1 L(x
x2 1 ,Lx(2x)1 ,as
x2 )a logic
expression using a logical
S AND operator (“·”):0 0 0
x1 0 1 1
L(x1 , x2 ) = x1 · x2 1 0 1
Power
supply S Light 1 1 1
M. Saghir (EECE 320 – Summer 2023) Introduction to Logic Circuits 6 / 86
Two-variable binary functions (2)
S S x1 x2 L ( x1 , x2 )
Power 0 0 0
x1 x2 Light
When the switches are connected in parallel, the light will 0turn on if
supply 0 1
either one of the switches is closed. In other 1words, 0 L = 10if x1 = 1,
x2 = 1, or x1 = x2 = 1; L = 0 only if x1 = 0 and x12 = 0. 1
(a) The logical AND function (series connection) 1
S x1 x2 L ( x1 , x2 )
x1 0 0 0
0 1 1
Power
supply S Light 1 0 1
1 1 1
x2
We (b)canTheexpress
logical OR function
the (parallel connection)
two-variable x1 x2 L(x
binary function , x2a, xlogic
x3 1 , xL2()x1as 3)
expression OR operator (“+”): 0 0 0 0
Figure using
2.3. Two a logical
basic functions.
0 0 1 0
L(x1 , x2 ) = x1 +0 x2 1 0 0
0 1 1 1
1 0 0 0
M. Saghir (EECE 320 – Summer 2023) Introduction to Logic Circuits 1 0 1 1 7 / 86
1 0 0
1 1 1
Multi-variable binary functions
x1 x2 L ( x1 , x2 )
0 0 0
The AND and OR operators are fundamental logic
0 1
functions
1
that can
be combined to generate complex logical expressions
1 0 involving
1
multiple binary variables. 1 1 1
x1 x2 x3 L ( x1 , x2 , x3 )
0 0 0 0
S 0 0 1 0
X1 0 1 0 0
S
0 1 1 1
Power
X3 Light 1 0 0 0
supply S
1 0 1 1
X2 1 1 0 0
1 1 1 1
Power x L( x )
supply x S Light 0 1
1 0
x L( x )
In the above circuit, L = 1 when x = 0, and L0 = 0 0when x = 1. The
Figure 2.5.LAn
binary function can be expressed
inverting circuit. 1 expression:
as the logic 1
L(x) = x = x 0
The bar over the variable x, or the apostrophe next to it, denotes the
inverse (also called the complement, or logical NOT) operator.
M. Saghir (EECE 320 – Summer 2023) Introduction to Logic Circuits 9 / 86
Inversion (2)
f(x1 , x2 ) = x1 + x2
f(x1 , x2 ) = x1 + x2
For example, the following truth table shows the outcomes of the
two-variable logical AND and OR functions.
x1 x2 x1 · x2 x1 + x2
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 1
AND OR
Logic gates have one or more binary logic inputs, but only one binary
logic output. The output value corresponds to the gate’s logic function.
x1
x2 Logic
f (x1, x2 ,…, xn )
…
Gate
xn
The circuit uses a two-input OR gate and a two-input AND gate. More
complex circuits will need more logic gates.
Figure 2.9. The function from Figure 2.4.
The larger the number of logic gates used in a circuit, the more costly
the circuit will be. While this seems obvious, we will later learn that it
is possible for different logic circuits to implement the same binary
logic function. It is therefore important that we design logic circuits
using the smallest number of logic gates.
Example:x1 0 0 1 1 1 1 0 0
A
1 1 0 1 f
x1 0 0 1 1 1 1 0 0
0 0 0 1 AB 1 1 0 1
0 1 0 1 f
x2
0 0 01 B
0 1 0 1
x2
(a) Network that implementsf = x1 + x1 x2
(a) Network that implementsf = x1 + x1 x2
x x f (x , x ) A B
1 x 2x f (1x , x2 )
1 2 1 2 A B
0 0 0 11 1 0
0 1 0
0 01 1 11 11 0 0
1 10 0 00 0 0 0 0
1 11 1 11 0 0 1 1
(b) Truth table
M. Saghir (EECE 320 – Summer 2023) (b) Truth table
Introduction to Logic Circuits 16 / 86
1
1 1 0 1 f
Analyzing logic0 circuits
1 0 1
(2) 0 0 01 B
x2
x 1
2 0
1
A
0
1
B
0
1
f
0 Time
(c) Timing diagram
001 1 1100
M. Saghir (EECE 320 – xSummer 2023) Introduction to Logic Circuits 17 / 86
1 0
0 0 1 x1 x2 x1 · x2 x1 + x2
0 1 1 1 0
Functionally equivalent logic circuits 1 0 0 0 00 0 0 0
1 1 1 0 01 1 0 1
1 0 0 1
The following logic circuits1implement
(b) Truth table
1 1 two1 different
binary functions,
1
f xand
1 0 g. Yet both functions have the same truth table, which indicates
AND OR
the
x 1two circuits are functionally equivalent.
2 0
1
A
0 x1 x2 x3 x1 · x2 · x3 x1 + x2 + x3
0 0 1 1 1 1 0 0
x 1
B1 0 0 A0 0 0
0 1 0 1 f 1 f(x , x ) = x + (x
0
0 0 1 1
· x2 )
1 1 2 1 1
f 0 0 0 0 1 1 B0 0 1
0 0 1 0 1 Time
x2 0 1 1 0 1
(c) Timing diagram
1 0 0 0 1
(a) Network that implementsf = x1 + x1 x2
001 1 11 1 0 00 1 0 1
x x x f (x , x )
1 1 2 11 2 1 A0 B 0 1
1 1 0 1 g(x1 , x2 ) = x1 + x2
010 1 0 0 11 1 11 0 1 g1
x
2 0 1 1 1 0
1 0 0 0 0
(d) 1Network
1 that
1 g
implements = x +x
1 1 2
x1 x2 x1 x1 · x2
0
f = x 1 + ( x1 · x2 ) g = x 1 + x2
0 Truth
Figure (b)
2.10. 0 table
An 1
example of0logic networks. 1 1
x 1 0 1 1 0 1 1
1 0
1 0 0 0 0 0
x 1 1 1 0 1 1 1
2 0
1
M. SaghirA (EECE 320 – Summer 2023) Introduction to Logic Circuits 18 / 86
Functionally equivalent logic circuits (2)
In general, we would like to find the least expensive logic circuit that
implements an arbitrary binary logic function. We must therefore
learn techniques for minimizing the complexity of binary logic
expressions, and using the rules of Boolean algebra to manipulate
binary logic expressions.
A1 x = 0 if x 6= 1
A1’ x = 1 if x 6= 0
A2 If x = 0, then x = 1
A2’ If x = 1, then x = 0
A3 0·0 = 0
A3’ 1+1 = 1
A4 1·1 = 1
A4’ 0+0 = 0
A5 0·1 = 1·0 = 0
A5’ 1+0 = 0+1 = 1
(x1 + x3 ) · (x1 + x3 ) = x1 · x3 + x1 · x3
x1 · x3 + x2 · x3 + x1 · x3 + x2 · x3 = x1 · x2 + x1 · x2 + x1 · x2
LHS = x1 · x3 + x1 · x3 + x2 · x3 + x2 · x3 using T6
= x1 · (x3 + x3 ) + x2 · (x3 + x3 ) using T8
= x1 · 1 + x2 · 1 using T5
= x1 + x2 using T1’
The AND, OR, and NOT operators form the basis of all logic
expressions. However, operations must be evaluated in the following
order: NOT, AND, and then OR.
Example: Design a logic circuit with two binary inputs x1 and x2 such
that the circuit produces a logic 0 when x1 = 1 and x2 = 0, and a
logic 1 otherwise.
1. The following truth table captures the functionality of the circuit:
x1 x2 f ( x1 , x2 )
0 0 1
0 1 1
1 0 0
1 1 1
f(x1 , x2 ) = x1 x2 + x1 x2 + x1 x2
x1
f
x2
Each product term will include a combination of all the function’s input
variables. If a variable xi = 1 in a given row, then xi is used in the
product term. Alternatively, if xi = 0 in the row, xi is used. For
example, if a three-variable function is 1 when x1 = 1, x2 = 0, and
x3 = 1, the corresponding product term will be x1 x2 x3 . The function is
then expressed as the logical sum of the product terms.
Each row of the function’s truth table will have an associated minterm
that includes xi if xi = 1, and xi if xi = 0.
f(x1 , x2 , x3 ) = m 0 + m 2 + m 3 + m7
f(x1 , x2 , x3 ) = m 0 + m 2 + m 3 + m7
= m 0 · m2 · m 3 · m 7
Row
number x1 x2 x3 f ( x1 , x2 , x3 )
0 0 0 0 0
1 0 0 1 1
2 0 1 0 0
3 0 1 1 0
4 1 0 0 1
5 1 0 1 1
6 1 1 0 1
7 1 1 1 0
= m0 · m2 · m3 · m7 = M0 · M2 · M3 · M7
f(x1 , x2 , x3 )
= Π(M0 , M2 , M3 , M7 ) = ΠM(0, 2, 3, 7)
= (x1 + x2 + x3 ) · (x1 + x2 + x3 ) · (x1 + x2 + x3 ) · (x1 + x2 + x3 )
Keep in mind that neither canonical form will be optimal, and that it is
often possible to use Boolean algebraic transformations and
manipulations to simplify canonical SOP and POS expressions.
X1
n−
V(B) = bi × 2i
i=0
For example, the 4-bit binary number 1011 has a value of:
1 × 23 + 0 × 22 + 1 × 21 + 1 × 20 = 8 + 0 + 2 + 1 = 11
We also say that (1011)2 = (11)10 , where 2 and 10 are the number’s
base, or radix. Binary numbers are radix-2 numbers, while decimal
numbers are radix-10 numbers.
f = x1 x2 x3 + x1 x2 x3 + x1 x2 x3 + x1 x2 x3 + x1 x2 x3 canonical SOP
= x1 x2 (x3 + x3 ) + x1 x2 x3 + x1 x2 (x3 + x3 ) T8
= x1 x2 + x1 x2 x3 + x1 x2 T5 and T1’
= x2 (x1 + x1 ) + x1 x2 x3 T8
= x2 + x1 x2 x3 T5 and T1’
= x2 + x1 x2 x3 + x1 x3 T11
= x2 + x1 x3 (x2 + 1) T8
= x2 + x1 x3 T2 and T1’
We have seen that AND, OR, and NOT gates can be used to
implement virtually any logic circuit. But there are two other logic
gates that are also useful for implementing logic circuits: NAND
and NOR gates.
xn
n
x
NOR gate = NOT(OR) gate = OR gate with a complemented output.
The NOR gate symbol is the(a)same as the OR symbol, but includes a
NAND gates
bubble at the output of the gate to represent inversion (NOT).
x1
x2
x1
x1 + x2 x 1 + x 2 + + x n
x2
xn
NAND and NOR gates use fewer transistors than AND and OR gates,
and therefore costFigure
less. 2.20.
It follows that and
NAND a circuit
NOR implemented
gates. using
NAND and NOR gates will cost less than a functionally-equivalent
circuit implemented using AND and OR gates.
We have seen that any logic circuit can be expressed in SOP or POS
forms using AND-OR or OR-AND structures, respectively. How can
we transform such circuits to only use NAND or NOR gates?
x1 x2 = x1 + x2
x1
x1 x1
x2 x2
x2
x1 + x2 = x1 x2
x1 x1
x2 x2
x3 x3
x4 x4
x5 x5
x1
x2
x3
x4
x5
x1 x1
x2 x2
x3 x3
x4 x4
x5 x5
x1
x2
x3
x4
x5
x1
x2 f
x3
POS implementation
x1
M. Saghir (EECE 320 – Summer 2023) Introduction to Logic Circuits 53 / 86
Example 5 (continued)
x 3
POS implementation
The OR-AND circuit can be easily transformed to a NOR-NOR circuit.
x1
x2 f
x3
NOR implementation
Notice
Figurehow
2.24theNOR-gate
NOT gate realization
used to invert x3 in
of the the POS
function in circuit
Example was2.4.
also
converted to a NOR gate: x3 = (x3 + x3 ) (T3).
More generally, NOR and NAND gates whose inputs are tied together
(to a single signal) become inverters: xi + xi + · · · + xi =
xi xi . . . xi = xi due to idempotency (T3 and T3’).
x3
x2
f
x1
x3
x2
An AND-OR circuit can be easily transformed to a NAND-NAND
f
x 1 we handle x2 , which is connected to the OR gate
circuit. But, how do
directly?
x3
We simply invert it twice: x2 = x2 (T4). We use a NAND gate to invert
x2 once, and we use the bubble needed to invert x2 a second time, at
(a) SOP implementation
the input of the OR gate, to transform the OR gate to a NAND gate.
x2
f
x1
x3
NAND-gate
Figure 2.25Introduction
M. Saghir (EECE 320 – Summer 2023)
realization of the function in Example 2.3.56 / 86
to Logic Circuits
Multilevel logic circuits
x 45 f
x6
x5
x7
x6
(a) Circuit with
x AND and OR gates
7
x 12
x3
x2
x 34 f
x 45 f
x6
x5
x7
x6
(b) Inversions xneeded to convert to NANDs
M. Saghir (EECE 320 – Summer 2023) Introduction7 to Logic Circuits 58 / 86
x4 f
Multilevel logic circuits (3)
x5
x6
x7
x1
x2
x3
x4 f
x5
x6
x7
If we are converting
vra_29532_ch04
to a NOR circuit we add
Sheet number 36 Page number 202
a bubble to the output of
black
each OR gate, or we add bubbles to the inputs of each AND gate. If
these conversions result in a bubble at one end of a wire, another
bubble must also be added to the other end. We can now replace all
gates with NOR
•
gates, which can also be used to invert input or
CHAPTER 4 Optimized Implementation of Logic Functions
output signals as needed.
x1
x2
x3
x4 f
x5
x6
x7
x1
x2
x3
x4
x5
x6
x7
x1 0x2 0 f = x1 ⊕0x2
0 00 1 0 1 x1
0 11 0 1 1 f = x ⊕ x2
x2 1
1 10 1 1 0
1 1 0
(a) Truth table (b) Graphical symbol
We can use the truth table to derive the canonical SOP representation
of the 2-input
x
XOR logic function: f(x1 , x2 ) = x1 x2 + x1 x2 .
1
x
2
f = x
1 ⊕ x2
M. Saghir (EECE 320 – Summer 2023) Introduction to Logic Circuits 62 / 86
008 11:37 vra_29532_ch04 Sheet number 32 Page number 198 black
XOR gate (2)
The 2-input XOR function can be implemented using standard logic
198 •
gatesC HorA PNAND
TER 4
gates only: Implementation of Logic Functions
Optimized
x1
x1 ⊕ x2
x2
N ⊕ N
x1 ⊕ x2
b
N
x2
M. Saghir (EECE 320 – Summer 2023) Introduction to Logic Circuits 63 / 86
XOR gate (3)
a = x1 · x 2 b = x2 · x 1
= x 1 + x2 = x 2 + x1 T13 (DeMorgan’s Theorem)
= x 1 + x2 · 1 = x 2 + x1 · 1 T1’ (Identities)
= x 1 + x2 · ( x1 + 1) = x 2 + x1 · ( x2 + 1) T2 (Null elements)
= x 1 + x1 x2 + x2 = x 2 + x1 x2 + x1 T8 (Distributivity)
= x 1 + x1 x2 = x 2 + x1 x2 T11 (Consensus Theorem)
= x1 · ( x1 · x2 ) = x2 · ( x1 · x2 ) T13 (DeMorgan’s Theorem)
g = x1 · x2
a = x1 · g b = x2 · g
N
a
g N ⊕ N
N
b
0 0 1
0 1 0
1 0 0
1 1 1
f(x1 , x2 ) = x1 x2 = x1 x2 + x1 x2
1 of 1 7/9/17, 12:35 AM
Like the XOR function, the XNOR funtion can be implemented using
standard gates or NAND gates. It also can be implemented using
NOR gates (starting from a POS expression), and it can be optimized
to use only four NOR gates:
2000px-XNOR_using_NOR.svg.png (PNG Image, 2000 × 594 pixels) - ... https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/XNOR_us...
n Module 4.2
ction, you should be able to:
a Select and Multiplexer
0 0 1 0
We can now apply Boolean agebraic transformations
0 1 0 1 to simplify the
expression: 0 1 1 1
f(s, x1 , x2 ) = sx1 x2 + sx1 x2 + sx1 x1 20 +0 sx1 x2 0 canonical SOP
= sx1 (x2 + x2 ) + sx2 (x11 0+1 x1 ) 1 T8
= sx1 + sx2 T5 and T1’
1 1 0 0
1 1 1 1
Finally we can implement the corresponding logic circuit using basic
logic gates: (a) Truth table
x1 s
f x1 0
f
s x2 1
x2
A 4-to-1s multiplexer
f (s, x1, x2) has four datas0inputs, one output, and log2 (4) = 2
selector0 inputs.
x1 An 8-to-1 multiplexer has eight data
w0 inputs, one
s1
output,1and xlog 2 2 (8) = 3 selector inputs. And so on...
w1
(d) More compact truth-table representation
gure
M. 2.28. Implementation
Saghir (EECE 320 – Summer 2023)of a multiplexer.
Introduction to Logic Circuits 71 / 86
Computer-aided design (CAD) tools and systems
Design Entry. The first step is to specify (or describe) a design for
the CAD system. Two main approaches: Schematic capture or
hardware description language (HDL).
Logic Synthesis. Once a design has been entered, the next step is
to generate (or synthesize) the logic circuits that implement the
design. Schematic diagrams or HDL code are first compiled into
a tool-specific format called a netlist that is easy to manipulate
algorithmically. The tool then applies a number of optimizations to
reduce design complexity and ensure an efficient (e.g. minimum-cost)
circuit implementation.
Design conception
DESIGN ENTRY
Synthesis
Functional simulation
No
Design correct?
Yes
Physical design
Timing simulation
No
Timing requirements met?
Yes
Chip configuration
In the code example, the module is called mux2to1 and it takes three
inputs parameters: x1, x2, and s, and one output parameter: f.
– The Verilog keywords input and output specify the direction of each
port. The keyword wire also specifies the type of each port, namely a
circuit element that caries digital signal values.
– Variables and signals of type wire can be assigned the values 0 or 1,
and can be processed as Booleans.
M. Saghir (EECE 320 – Summer 2023) Introduction to Logic Circuits 81 / 86
Verilog structural model
Identifiers
– An identifier is a name assigned to a Verilog object (e.g. module, port,
wire, etc...)
– Verilog is case sensitive; identifiers decoder1, Decoder1, and
DECODER1 refer different objects.
– Identifiers must begin with a letter, and may only consist of letters,
digits, or the underscore symbol ( ).
– Identifiers may not include any white space.
Files
– It is common to assign a Verilog file the same name as its
corresponding module and store it with a *.v suffix. For example, the
Verilog code for the multiplexer can be saved in a file called mux2to1.v.