Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

Logic: Language and Information 1

§3-3 Truth Tables, Logic Formulas and Logic Circuits

Jen Davoren
Jobs done by combinational systems
▶ Encoding and Decoding of digital signals. Tech term:
codec = encoding-decoding. E.g. of encoding: buttons
on mobile phone: press button “7”on keypad, and 4-bit
encoder produces 0111 as output.
▶ Selecting and Distributing digital signals. Tech term: a
multiplexer (MUX) is a data selecter, and a demultiplexer
(DEMUX) is a data distributer.
▶ Binary arithmetic: operations of addition, subtraction,
multiplication, and more, with binary coding of negative
numbers and finite-precision real numbers.
▶ Comparison and classification: E.g. input two 4-bit
binary numbers a = a3 a2 a1 a0 and b = b3 b2 b1 b0, and
output 0 or 1 to questions “a > b?”, “a = b?” or “a < b?”.
Binary Coded Decimal (BCD) Encoder
Functional description: the system has 10 inputs for decimal digits, p0,
p1,p2, p3, p4, p5, p6, p7, p8, p9, and outputs 4-bit m = m3 m2 m1 m0 and
a 1-bit error signal r such that: if exactly one on the inputs pi is active (value
1) then r is 0 and q is the 4-bit binary value of the decimal i, while if either
zero or two or more of the inputs are active, then r is 1 and m = 0000.
BCD Encoder
p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 r m3 m2 m1 m0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 1 0 0 0 0 0 0 0 0 0 1 1
0 0 0 0 1 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 1 0 0 0 0 0 0 1 0 1
0 0 0 0 0 0 1 0 0 0 0 0 1 1 0
0 0 0 0 0 0 0 1 0 0 0 0 1 1 1
0 0 0 0 0 0 0 0 1 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 1
1 1 × × × × × × × × 1 0 0 0 0
1 × 1 × × × × × × × 1 0 0 0 0

× means “don’t care” (210 = 1024 rows in full truth table)


BCD Encoder

Introduce intermediate signals for 10-input AND gates:


s0 ≡ (p0 & ∼p1 & ∼p2 & ∼p3 & ∼p4 & ∼p5 & ∼p6 & ∼p7 & ∼p8 & ∼p9)
s1 ≡ (∼p0 & p1 & ∼p2 & ∼p3 & ∼p4 & ∼p5 & ∼p6 & ∼p7 & ∼p8 & ∼p9)
s2 ≡ (∼p0 & ∼p1 & p2 & ∼p3 & ∼p4 & ∼p5 & ∼p6 & ∼p7 & ∼p8 & ∼p9)
s3 ≡ (∼p0 & ∼p1 & ∼p2 & p3 & ∼p4 & ∼p5 & ∼p6 & ∼p7 & ∼p8 & ∼p9)
s4 ≡ (∼p0 & ∼p1 & ∼p2 & ∼p3 & p4 & ∼p5 & ∼p6 & ∼p7 & ∼p8 & ∼p9)
s5 ≡ (∼p0 & ∼p1 & ∼p2 & ∼p3 & ∼p4 & p5 & ∼p6 & ∼p7 & ∼p8 & ∼p9)
s6 ≡ (∼p0 & ∼p1 & ∼p2 & ∼p3 & ∼p4 & ∼p5 & p6 & ∼p7 & ∼p8 & ∼p9)
s7 ≡ (∼p0 & ∼p1 & ∼p2 & ∼p3 & ∼p4 & ∼p5 & ∼p6 & p7 & ∼p8 & ∼p9)
s8 ≡ (∼p0 & ∼p1 & ∼p2 & ∼p3 & ∼p4 & ∼p5 & ∼p6 & ∼p7 & p8 & ∼p9)
s9 ≡ (∼p0 & ∼p1 & ∼p2 & ∼p3 & ∼p4 & ∼p5 & ∼p6 & ∼p7 & ∼p8 & p9)
BCD Encoder

p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 r m3 m2 m1 m0
s0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
s1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1
s2 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0
s3 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1
s4 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0
s5 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1
s6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× × × 1 0 0 0 0

r ≡ ∼(s0 ∨ s1 ∨ s2 ∨ s3 ∨ s4 ∨ s5 ∨ s6 ∨ s7 ∨ s8 ∨ s9)
Method: from truth table to logic formula
Method: from truth table to logic formula

From a truth table column for output z depending on inputs


p1 , p2 , up to pn (in a truth table with 2n -many rows):
Method: from truth table to logic formula

From a truth table column for output z depending on inputs


p1 , p2 , up to pn (in a truth table with 2n -many rows):
1. Look down column for output z and identify each of the
rows in which output is 1.
Method: from truth table to logic formula

From a truth table column for output z depending on inputs


p1 , p2 , up to pn (in a truth table with 2n -many rows):
1. Look down column for output z and identify each of the
rows in which output is 1.
2. For each such row, write down the size-n conjunction of
inputs or negated inputs which uniquely describes that
row: if input pi is 0 on that row, include ∼pi in
conjunction; if input pi is 1 on that row, include pi in
conjunction.
Method: from truth table to logic formula

From a truth table column for output z depending on inputs


p1 , p2 , up to pn (in a truth table with 2n -many rows):
1. Look down column for output z and identify each of the
rows in which output is 1.
2. For each such row, write down the size-n conjunction of
inputs or negated inputs which uniquely describes that
row: if input pi is 0 on that row, include ∼pi in
conjunction; if input pi is 1 on that row, include pi in
conjunction.
3. Output z is equivalent to the disjunction of all these
row-conjunctions; if there are m-many rows in which
output z is 1, then it will be a size-m disjunction.
Exercise: from truth table to logic formula
row p q r z
0 0 0 0 0
1 0 0 1 1
2 0 1 0 1
3 0 1 1 1
4 1 0 0 0
5 1 0 1 0
6 1 1 0 0
7 1 1 1 0
Which of these formulas correctly describe output z as a function of inputs
p, q and r:
(a) z ≡ ((∼p & ∼q & ∼r) ∨ (∼p & q & ∼r) ∨ (∼p & q & r))
(b) z ≡ ((∼p & ∼q & r) ∨ (∼p & q & ∼r) ∨ (p & q & r))
(c) z ≡ ((∼p & ∼q & ∼r) ∨ (∼p & q & ∼r) ∨ (p & q & r))
(d) z ≡ ((∼p & ∼q & r) ∨ (∼p & q & ∼r) ∨ (∼p & q & r))
Exercise Solution: from truth table to logic formula

row p q r z
0 0 0 0 0
1 0 0 1 1 (∼p & ∼q & r)
2 0 1 0 1 (∼p & q & ∼r)
3 0 1 1 1 (∼p & q & r)
4 1 0 0 0
5 1 0 1 0
6 1 1 0 0
7 1 1 1 0

The formula which correctly describes output z as a function


of inputs p, q and r:

(d) z ≡ ((∼p & ∼q & r) ∨ (∼p & q & ∼r) ∨ (∼p & q & r))
Disjunctive Normal Form
Disjunctive Normal Form

A logic formula A is in disjunctive normal form


(DNF) iff A is a disjunction of conjunctions of lit-
erals, where a literal is either an atomic proposition
or the negation of an atomic proposition.
Disjunctive Normal Form

A logic formula A is in disjunctive normal form


(DNF) iff A is a disjunction of conjunctions of lit-
erals, where a literal is either an atomic proposition
or the negation of an atomic proposition.

Called sum-of-products (SOP) form in digital systems and


Boolean algebra literature.
Disjunctive Normal Form (DNF)

Fact: For every propositional logic formula A, there exists at


least one (but usually many) formulas B such that A ≡ B is a
tautology, and B is in DNF.
Disjunctive Normal Form (DNF)

Fact: For every propositional logic formula A, there exists at


least one (but usually many) formulas B such that A ≡ B is a
tautology, and B is in DNF.

Method for going from an input-output truth table to a logic


formula by taking the disjunction of the row-conjunctions in
which the output is true: the result is the canonical DNF for
each output.
DNF formulas and and DNF logic circuits
When z ≡ A(p, q, r), where A(p, q, r) is in DNF and circuit
implements formula A(p, q, r), then circuit diagram has
standard two-level structure:
DNF circuits implemented using only NAND gates
A circuit in DNF (SOP) form can be easily transformed into a
NAND-only circuit by simply replacing all the gates with
NAND gates:
Exercise: from truth table to logic formula

row p q r z
0 0 0 0 0
1 0 0 1 1 (∼p & ∼q & r)
2 0 1 0 1 (∼p & q & ∼r)
3 0 1 1 1 (∼p & q & r)
4 1 0 0 0
5 1 0 1 0
6 1 1 0 0
7 1 1 1 0

z ≡ ((∼p & ∼q & r) ∨ (∼p & q & ∼r) ∨ (∼p & q & r))
Exercise: from truth table to logic formula

row p q r z
0 0 0 0 0
1 0 0 1 1 (∼p & ∼q & r)
2 0 1 0 1 (∼p & q & ∼r)
3 0 1 1 1 (∼p & q & r)
4 1 0 0 0
5 1 0 1 0
6 1 1 0 0
7 1 1 1 0

z ≡ ((∼p & ∼q & r) ∨ (∼p & q & ∼r) ∨ (∼p & q & r))
This can in fact be simplified to a smaller DNF:

z ≡ ((∼p & q) ∨ (∼p & r))


Minimal DNFs

A logic formula A is a minimal DNF if and only if A


is in DNF and there does not exist a logic formula
B such that B is in DNF, B ≡ A is a tautology, and
either B has fewer disjuncts than A, or B has a dis-
junct that is smaller than (contains fewer conjuncts
than) all of A’s disjuncts.
Minimal DNFs

A logic formula A is a minimal DNF if and only if A


is in DNF and there does not exist a logic formula
B such that B is in DNF, B ≡ A is a tautology, and
either B has fewer disjuncts than A, or B has a dis-
junct that is smaller than (contains fewer conjuncts
than) all of A’s disjuncts.

In general, minimal DNFs are not unique: there can be several


different DNF’s that are equally as “small”.
Minimal DNF circuit

z ≡ ((∼p & q) ∨ (∼p & r))


Smaller non-DNF circuit

z ≡ (∼p & (q ∨ r))


2-in multiplexer (MUX)

Functional description: take as input two data input signals x


and y, together with a select input signal s, and produce as
output data signal z such that z ≡ x if s is 0 and z ≡ y if s is 1.

Block:
2-in MUX: truth table

row x y s z
0 0 0 0 0
1 0 0 1 0
2 0 1 0 0
3 0 1 1 1
4 1 0 0 1
5 1 0 1 0
6 1 1 0 1
7 1 1 1 1
2-in MUX: truth table

row x y s z
0 0 0 0 0 z≡x
1 0 0 1 0
2 0 1 0 0 z≡x
3 0 1 1 1
4 1 0 0 1 z≡x
5 1 0 1 0
6 1 1 0 1 z≡x
7 1 1 1 1
2-in MUX: truth table

row x y s z
0 0 0 0 0
1 0 0 1 0 z≡y
2 0 1 0 0
3 0 1 1 1 z≡y
4 1 0 0 1
5 1 0 1 0 z≡y
6 1 1 0 1
7 1 1 1 1 z≡y
2-in MUX: canonical DNF logic formula

row x y s z
0 0 0 0 0
1 0 0 1 0
2 0 1 0 0
3 0 1 1 1 (∼x & y & s)
4 1 0 0 1 (x & ∼y & ∼s)
5 1 0 1 0
6 1 1 0 1 (x & y & ∼s)
7 1 1 1 1 (x & y & s)

z ≡ ((∼x & y & s) ∨ (x & ∼y & ∼s) ∨ (x & y & ∼s) ∨ (x & y & s))
2-in MUX: DNF circuit

z ≡ ((∼x & y & s) ∨ (x & ∼y & ∼s) ∨ (x & y & ∼s) ∨ (x & y & s))
2-in MUX: DNF circuit

z ≡ ((∼x & y & s) ∨ (x & ∼y & ∼s) ∨ (x & y & ∼s) ∨ (x & y & s))
2-in MUX: DNF circuit

z ≡ ((∼x & y & s) ∨ (x & ∼y & ∼s) ∨ (x & y & ∼s) ∨ (x & y & s))
2-in MUX

Consider the following sequence of logical equivalences:

z ≡ (∼x & y & s) ∨ (x & ∼y & ∼s) ∨ (x & y & ∼s) ∨ (x & y & s)
2-in MUX

Consider the following sequence of logical equivalences:

z ≡ (∼x & y & s) ∨ (x & ∼y & ∼s) ∨ (x & y & ∼s) ∨ (x & y & s)
z ≡ (x & y & ∼s) ∨ (x & ∼y & ∼s) ∨ (x & y & s) ∨ (∼x & y & s)
2-in MUX

Consider the following sequence of logical equivalences:

z ≡ (∼x & y & s) ∨ (x & ∼y & ∼s) ∨ (x & y & ∼s) ∨ (x & y & s)
z ≡ (x & y & ∼s) ∨ (x & ∼y & ∼s) ∨ (x & y & s) ∨ (∼x & y & s)
z ≡ (x & ∼s & y) ∨ (x & ∼s & ∼y) ∨ (y & s & x) ∨ (y & s & ∼x)
2-in MUX

Consider the following sequence of logical equivalences:

z ≡ (∼x & y & s) ∨ (x & ∼y & ∼s) ∨ (x & y & ∼s) ∨ (x & y & s)
z ≡ (x & y & ∼s) ∨ (x & ∼y & ∼s) ∨ (x & y & s) ∨ (∼x & y & s)
z ≡ (x & ∼s & y) ∨ (x & ∼s & ∼y) ∨ (y & s & x) ∨ (y & s & ∼x)
z ≡ (x & ∼s & (y ∨ ∼y)) ∨ (y & s & (x ∨ ∼x))
2-in MUX

Consider the following sequence of logical equivalences:

z ≡ (∼x & y & s) ∨ (x & ∼y & ∼s) ∨ (x & y & ∼s) ∨ (x & y & s)
z ≡ (x & y & ∼s) ∨ (x & ∼y & ∼s) ∨ (x & y & s) ∨ (∼x & y & s)
z ≡ (x & ∼s & y) ∨ (x & ∼s & ∼y) ∨ (y & s & x) ∨ (y & s & ∼x)
z ≡ (x & ∼s & (y ∨ ∼y)) ∨ (y & s & (x ∨ ∼x))
z ≡ (x & ∼s) ∨ (y & s)

The last equivalence is because A ≡ (A & (B ∨ ∼B)) is a


tautology, for any formulas A, B.
2-in MUX
Go back to: Functional description: output data signal z
such that z ≡ x when ∼s is 1, while z ≡ y when s is 1.

z ≡ ((x & ∼s) ∨ (y & s))


Next Up: Minimizing DNF Circuits using K-Maps

We want a general and mechanical method for finding a


minimal DNF circuit for a combinational system:
▶ minimal number of inputs to OR gate at outer level

▶ minimal-sized AND gates at inner level

You might also like