03a Boolean Algebra

You might also like

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

MTK 313

03a-Boolean Algebra
Irmawan
Semester-IV 2008 - 2009

The materials on these slides are adopted from those in


CS231s Lecture Notes at UIUC, which is derived from
Howard Huangs work and developed by Jeff Carlyle.

Road Map
3
Boolean Algebra

Finite-State
Machines

Logic Gates & 3


Flip-flops

2
Binary Systems
& Data Represent.

8
Generalized FSM

Logic Design
Techniques

Combinatorial 5
Components

6
Sequential Design
Techniques

Storage
Components

8
Register-Transfer
Design

Processor
Components

9
2

Boolean values

Earlier, we used electrical voltages to represent


two discrete values 1 and 0, from which binary numbers
can be formed.
Its also possible to think of voltages as representing
two logical values, true and false.
For simplicity, we often still write digits instead:
1 (high) is true
0 (low) is false
We will use these values 1 and 0 as the elements of our Boolean System.

Basic boolean operations

There are two basic operations for logical values.


Operation:

AND (product)
of two inputs

Expression:

xy, or xy

Truth table:

OR (sum) of
two inputs
x+y

xy

x+y

Axiomatic definition of Boolean Algebra

A Boolean algebra requires


A set of elements B, consisting of two elements (0 and 1)
Two binary operations OR and AND
The axioms below must always be true
1.
2.
3.
4.
5.
6.

x+yB
x+0=x
x+y=y+x
x(y + z) = xy + xz
x + x = 1
At least 2 elements: x,y B

xyB
x1=x
xy=yx
x + yz = (x + y)(x + z)
x x = 0
such that x y

Closure
Identity
Commutativity
Distributivity
Complement
Cardinality

Based on axiom #5, we can develop a unary (one-argument)


operation NOT
x

Basic theorems of Boolean Algebra

In addition to the axioms, additional laws can be derived; they are


called theorems of Boolean Algebra
These theorems are useful in performing algebraic manipulations of
Boolean expressions
1.
2.
3.
4.
5.
6.

x+x=x
x+1=1
yx + x = x
(x) = x
x + (y + z) = (x + y) + z
(x + y) = xy

xx=x
x0=0
(y + x) x = x
x(yz) = (xy)z
(xy) = x + y

Idempotency
Absorption
Involution
Associative
DeMorgans

Proofing the theorems using axioms

Idempotency: x + x = x
Proof:
x + x = (x + x) 1
= (x + x) (x + x)
= x + x x
=x+0
=x

by identity
by complement
by distributivity
by complement
by identity

Idempotency: x x = x
Proof:
x x = (x x) + 0
= (x x) + (x x)
= x (x + x)
=x1
=x

by identity
by complement
by distributivity
by complement
by identity

Duality principle

The left and right columns of axioms are duals


exchange all ANDs with ORs, and 0s with 1s
1.
2.
3.
4.
5.
6.

x+yB
x+0=x
x+y=y+x
x(y + z) = xy + xz
x + x = 1
At least 2 elements: x,y B

xyB
x1=x
xy = yx
x + yz = (x + y)(x + z)
x x = 0
such that x y

Closure
Identity
Commutativity
Distributivity
Complement
Cardinality

So are the theorems:


1.
2.
3.
4.
5.
6.

x+x=x
x+1=1
yx + x = x
(x) = x
x + (y + z) = (x + y) + z
(x + y) = xy

xx=x
x0=0
(y + x) x = x
x(yz) = (xy)z
(xy) = x + y

Idempotency
Absorption
Involution
Associative
DeMorgans

Boolean Functions

Computers take inputs and produce outputs, just like functions in math!
Mathematical functions can be expressed in two ways:
An expression is
finite but not unique
f(x,y) = 2x + y
=x+x+y
= 2(x + y/2)
= ...

A function table is
unique but infinite
x

f(x,y)

23

41

87

We can represent logical functions in two analogous ways too:


A finite, but non-unique Boolean expression.
A truth table, which will turn out to be unique and finite.
9

Boolean expressions

We can use these basic operations to form more complex expressions:


f(x,y,z) = (x + y)z + x

Some terminology and notation:


f is the name of the function.
(x,y,z) are the input variables, each representing 1 or 0. Listing the
inputs is optional, but sometimes helpful.
A literal is any occurrence of an input variable or its complement.
The function above has four literals: x, y, z, and x.
Precedence is important, but not too difficult.
NOT has the highest precedence, followed by AND, and then OR.
Fully parenthesized, the function above would be kind of messy:
f(x,y,z) = (((x +(y))z) + x)

10

Truth tables

A truth table shows all possible inputs and outputs of a function.


Remember that each input variable represents either 1 or 0.
Because there are only a finite number of values (1 and 0), truth
tables themselves are finite.
A function with n variables has 2n possible combinations of inputs.
Inputs are listed in binary orderin this example, from 000 to 111.
f(x,y,z) = (x + y)z + x

f(0,0,0)
f(0,0,1)
f(0,1,0)
f(0,1,1)
f(1,0,0)
f(1,0,1)
f(1,1,0)
f(1,1,1)

= (0 + 1)0 + 1
= (0 + 1)1 + 1
= (0 + 0)0 + 1
= (0 + 0)1 + 1
= (1 + 1)0 + 0
= (1 + 1)1 + 0
= (1 + 0)0 + 0
= (1 + 0)1 + 0

=1
=1
=1
=1
=0
=1
=0
=1

f(x,y,z)

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

1
1
1
1
0
1
0
1

11

Complement of a function

The complement of a function always outputs 0 where the original


function outputted 1, and 1 where the original produced 0.
In a truth table, we can just exchange 0s and 1s in the output column(s)
f(x,y,z) = x(yz + yz)
x

f(x,y,z)

f(x,y,z)

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

0
0
0
0
1
0
0
1

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

1
1
1
1
0
1
1
0

12

Complementing a function algebraically

You can use DeMorgans law to keep pushing the complements inwards
f(x,y,z) = x(yz + yz)
f(x,y,z) = ( x(yz + yz) )
= x + (yz + yz)
= x + (yz) (yz)
= x + (y + z)(y + z)

[ complement both sides ]


[ because (xy) = x + y ]
[ because (x + y) = x y ]
[ because (xy) = x + y, twice]

You can also take the dual of the function, and then complement each
literal
If f(x,y,z) = x(yz + yz)
the dual of f is x + (y + z)(y + z)
then complementing each literal gives x + (y + z)(y + z)
so f(x,y,z) = x + (y + z)(y + z)

13

Algebraic manipulation

We can now start doing some simplifications


xy + xyz + xy
= x(y + y) + xyz
= x1 + xyz
= x + xyz
= (x + x)(x + yz)
= 1 (x + yz)
= x + yz

[ Distributive; xy + xy = x(y + y) ]
[ Axiom 5; y + y = 1 ]
[ Axiom 2; x1 = x ]
[ Distributive ]
[ Axiom 5; x + x = 1 ]
[ Axiom 2 ; x1 = x]

14

Canonical Forms

Any boolean function that is expressed as a sum of minterms or as a


product of maxterms is said to be in its canonical form.

15

Minterms

A minterm is a special product of literals, in which each input variable


appears exactly once.
A function with n variables has 2n minterms (since each variable can
appear complemented or not)
A three-variable function, such as f(x,y,z), has 23 = 8 minterms:
xyz
xyz

xyz
xyz

xyz
xyz

xyz
xyz

Each minterm is true for exactly one combination of inputs:


Minterm
xyz
xyz
xyz
xyz
xyz
xyz
xyz
xyz

Is true when
x=0, y=0, z=0
x=0, y=0, z=1
x=0, y=1, z=0
x=0, y=1, z=1
x=1, y=0, z=0
x=1, y=0, z=1
x=1, y=1, z=0
x=1, y=1, z=1

Shorthand
m0
m1
m2
m3
m4
m5
m6
m7
16

Sum of minterms form

Every function can be written as a sum of minterms, which is a special


kind of sum of products form
The sum of minterms form for any function is unique
If you have a truth table for a function, you can write a sum of
minterms expression just by picking out the rows of the table where
the function output is 1 (1-minterm).
x

f(x,y,z)

f(x,y,z)

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

1
1
1
1
0
0
1
0

0
0
0
0
1
1
0
1

f = xyz + xyz + xyz + xyz + xyz


= m0 + m1 + m2 + m3 + m6
= (0,1,2,3,6)
f = xyz + xyz + xyz
= m4 + m5 + m7
= (4,5,7)
f contains all the minterms not in f

17

Sum of minterms: practise

F = x + yz, how to express this in the sum of minterms?


= x(y + y)(z + z) + (x + x)yz
= xyz + xyz + xyz + xyz + xyz + xyz
= xyz + xyz + xyz + xyz + xyz
= (3,4,5,6,7)
or, convert the expression into truth-table and then read the minterms
from the table

18

Maxterms

A maxterm is a sum of literals, in which each input variable appears


exactly once.
A function with n variables has 2n maxterms
The maxterms for a three-variable function f(x,y,z):
x + y + z
x + y + z

x + y + z
x + y + z

x + y + z
x + y + z

x+ y + z
x+y+z

Each maxterm is false for exactly one combination of inputs:


Maxterm
x+y+z
x + y + z
x + y + z
x + y + z
x + y + z
x + y + z
x + y + z
x + y + z

Is false when Shorthand


x=0, y=0, z=0
M0
x=0, y=0, z=1
M1
x=0, y=1, z=0
M2
x=0, y=1, z=1
M3
x=1, y=0, z=0
M4
x=1, y=0, z=1
M5
x=1, y=1, z=0
M6
x=1, y=1, z=1
M7

19

Product of maxterms form

Every function can be written as a unique product of maxterms


If you have a truth table for a function, you can write a product of
maxterms expression by picking out the rows of the table where the
function output is 0 (0-maxterm).
x

f(x,y,z)

f(x,y,z)

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

1
1
1
1
0
0
1
0

0
0
0
0
1
1
0
1

f = (x + y + z)(x + y + z)(x + y + z)
= M4 M5 M7
= (4,5,7)
f = (x + y + z)(x + y + z)(x + y + z)
(x + y + z)(x + y + z)
= M0 M1 M2 M3 M6
= (0,1,2,3,6)
f contains all the maxterms not in f

20

Product of maxterms: practise

F = xy + xz, how to express this in the product of maxterms?


= (xy + x)(xy + z)
= (x + x)(y + x)(x + z)(y + z)
= (x + y)(x + z)(y + z)
= (x + y + zz)(x + z + yy)(xx + y + z)
= (x + y + z)(x + y + z)(x + y + z)(x + y + z)(x + y + z)(x + y + z)
= (x + y + z)(x + y + z)(x + y + z)(x + y + z)
= (2,3,4,6)
or, convert the expression into truth-table and then read the minterms
from the table

21

Minterms and maxterms are related

Any minterm mi is the complement of the corresponding maxterm Mi


Minterm
xyz
xyz
xyz
xyz
xyz
xyz
xyz
xyz

Shorthand
m0
m1
m2
m3
m4
m5
m6
m7

Maxterm
x+y+z
x + y + z
x + y + z
x + y + z
x + y + z
x + y + z
x + y + z
x + y + z

Shorthand
M0
M1
M2
M3
M4
M5
M6
M7

For example, m4 = M4 because (xyz) = x + y + z

22

Converting between canonical forms

We can convert a sum of minterms to a product of maxterms


From before
and
complementing
so

f
f

= (0,1,2,3,6)
= (4,5,7)
= m4 + m5 + m7
(f) = (m4 + m5 + m7)
f = m4 m5 m7
[ DeMorgans law ]
= M4 M5 M7
[ By the previous page ]
= (4,5,7)

In general, just replace the minterms with maxterms, using maxterm


numbers that dont appear in the sum of minterms:
f = (0,1,2,3,6)
= (4,5,7)

The same thing works for converting from a product of maxterms to a


sum of minterms

23

Standard Forms

Any boolean function that is expressed as a sum of products (SOP) or


as a product of sums (POS), where each product-term or sum-term may
require fewer than (n-1) operations, is said to be in its standard form.
Standard forms are not unique, there can be several different SOPs
and POSs for a given function.
A SOP expression contains:
Only OR (sum) operations at the outermost level
Each term (implicant) must be a product of literals
f(x,y,z) = xy + xyz + xyz

A POS expression contains:


Only AND (product) operations at the outermost level
Each term (implicate) must be a sum of literals
f(x,y,z) = (x + y)(x + y + z)(x + y + z)
24

Strategy for operator (literal) reduction

25

Other Logic Operations

Weve already seen all the basic Boolean operations and the associated
primitive logic gates.
There is a few additional gates that are often used in logic design.
They are all equivalent to some combination of primitive gates.
But they have some interesting properties in their own right.

Operation:
Expressions:
Truth table:

NAND
(NOT-AND)
(xy) = x + y

NOR
(NOT-OR)

XOR
(eXclusive OR)

(x + y) = x y

x y = xy + xy

y (xy)

(x+y)

xy

0
26

You might also like