Вы находитесь на странице: 1из 40

Boolean Variables and Expressions

Definition (Boolean Variable)


A variable x is called a Boolean (binary) variable when it can only hold 0
or 1, x {0, 1}.

Definition (Boolean Expression)


Using the operations of Boolean Algebra on Boolean variables yields
Boolean expressions. Brackets are used to clarify which operation is
applied first.
Examples:
(x x ) y
x (x y )

Tilman Schieber (TU Berlin)

Computer Engineering

2016

14

Boolean Functions

Definition (Boolean Function)


A Boolean Function is a function f (b1 , b2 , . . . bn ) with bi being Boolean
variables and with f only taking the values 0 and 1.
Depending on the number n, we call it a n-ary function.
Such a function can be represented with a Boolean expression.

Examples:
g(x ) = 0 is a unary Boolean function.
f (x , y ) = x y
is a binary B. function.
the operators and and or are binary B. functions.

Tilman Schieber (TU Berlin)

Computer Engineering

2016

15

Boolean Identities

A Boolean expression may not be in its simplest form.


If so, it is possible to reduce it using the axioms and identities of

Boolean algebra.
analogous to reduction in regular algebra (e.g. 2x + x + x 4x )

Example 1
(x y ) x

Tilman Schieber (TU Berlin)

Computer Engineering

2016

16

Boolean Identities

A Boolean expression may not be in its simplest form.


If so, it is possible to reduce it using the axioms and identities of

Boolean algebra.
analogous to reduction in regular algebra (e.g. 2x + x + x 4x )

Example 1
(x y ) x
(x y ) x

Tilman Schieber (TU Berlin)

De Morgans law (9)

Computer Engineering

2016

16

Boolean Identities

A Boolean expression may not be in its simplest form.


If so, it is possible to reduce it using the axioms and identities of

Boolean algebra.
analogous to reduction in regular algebra (e.g. 2x + x + x 4x )

Example 1
(x y ) x
(x y ) x
(x y ) x

Tilman Schieber (TU Berlin)

De Morgans law (9)


Double Complement (10)

Computer Engineering

2016

16

Boolean Identities

A Boolean expression may not be in its simplest form.


If so, it is possible to reduce it using the axioms and identities of

Boolean algebra.
analogous to reduction in regular algebra (e.g. 2x + x + x 4x )

Example 1
(x y ) x
(x y ) x
(x y ) x
x

Tilman Schieber (TU Berlin)

De Morgans law (9)


Double Complement (10)
Absorption (8)

Computer Engineering

2016

16

Boolean Identities: Example

Boolean identitities can be applied to any Boolean expressions, not just to


variables. Consider this example:

Example 2
(x y z) (x y z)

Tilman Schieber (TU Berlin)

Computer Engineering

2016

17

Boolean Identities: Example

Boolean identitities can be applied to any Boolean expressions, not just to


variables. Consider this example:

Example 2
(x y z) (x y z)
(x y ) (z z)

Tilman Schieber (TU Berlin)

Distributive law (3)

Computer Engineering

2016

17

Boolean Identities: Example

Boolean identitities can be applied to any Boolean expressions, not just to


variables. Consider this example:

Example 2
(x y z) (x y z)
(x y ) (z z)
(x y ) 1

Tilman Schieber (TU Berlin)

Distributive law (3)


Complement law (5)

Computer Engineering

2016

17

Boolean Identities: Example

Boolean identitities can be applied to any Boolean expressions, not just to


variables. Consider this example:

Example 2
(x y z) (x y z)
(x y ) (z z)
(x y ) 1
x y

Tilman Schieber (TU Berlin)

Distributive law (3)


Complement law (5)
Identity law (4)

Computer Engineering

2016

17

Boolean Identities: Example

Boolean identitities can be applied to any Boolean expressions, not just to


variables. Consider this example:

Example 2
(x y z) (x y z)
(x y ) (z z)
(x y ) 1
x y

Distributive law (3)


Complement law (5)
Identity law (4)

Remark: here, a Boolean expression (x y ) was treated like a variable to


apply the Distributive law.

Tilman Schieber (TU Berlin)

Computer Engineering

2016

17

Representing Boolean Functions


How can we represent a Boolean Function f ?
We already know two ways:
1

Boolean expression:
f (x , y ) = (x y ) x
f (x , y ) = x y
f (x , y ) = (x y )

Truth table:
x
0
0
1
1

Tilman Schieber (TU Berlin)

y
0
1
0
1

f (x , y )
0
1
0
0

Computer Engineering

2016

18

Representing Boolean Functions 2


3

Binary decision diagram (BDD):


x

0
4

Circuit diagrams:

Tilman Schieber (TU Berlin)

Computer Engineering

2016

19

Canonical Representations

There are infinitely many boolean expressions that represent one B.

function.
the same is true for circuits and binary decision diagrams.

Tilman Schieber (TU Berlin)

Computer Engineering

2016

20

Canonical Representations

There are infinitely many boolean expressions that represent one B.

function.
the same is true for circuits and binary decision diagrams.
But: each function has only one truth table.
A truth table is a canonical representation of a B. function.

Tilman Schieber (TU Berlin)

Computer Engineering

2016

20

Canonical Representations

There are infinitely many boolean expressions that represent one B.

function.
the same is true for circuits and binary decision diagrams.
But: each function has only one truth table.
A truth table is a canonical representation of a B. function.
Question: Can we find canonical representation for expressions,

circuits and BDDs?

Tilman Schieber (TU Berlin)

Computer Engineering

2016

20

Minterms
Definition (Minterm)
A minterm of n variables is a conjunction (product) in which each variable
appears exactly once in true or complemented form
n
^

()xi

i=1

a minterm is true for exactly one combination of values.


for a function f (x , y , z) an example minterm is x y z.
it is true for x = 1, y = 1, z = 0
The expression x y x is not a minterm.

Tilman Schieber (TU Berlin)

Computer Engineering

2016

21

Disjunctive Normal Form

Definition (DNF)
A formula is in disjunctive normal form (DNF) when it is a disjunction ()
of conjunctions().
If the conjunctions are minterms, it is canonical.
Example: (x y z) (x y z)
Remark: Another name for DNF is Sum of Product-Form (SoP)

Tilman Schieber (TU Berlin)

Computer Engineering

2016

22

Maxterms
Definition (Maxterm)
A maxterm of n variables is a disjunction (sum) in which each variable
appears exactly once in true or complemented form
n
_

()xi

i=1

a maxterm is false for exactly one combination of values.


for a function f (x , y , z) an example maxterm is x y z.
it is false only for x = 0, y = 0, z = 1

Tilman Schieber (TU Berlin)

Computer Engineering

2016

23

Conjunctive Normal Form

Definition (CNF)
A formula is in conjunctive normal form (CNF) when it is a conjunction()
of disjunctions ().
If the disjunctions are maxterms, it is canonical.
Example: (x y z) (x y z)
Remark: Another name for CNF is Product of Sums-Form (PoS)

Tilman Schieber (TU Berlin)

Computer Engineering

2016

24

Canonical Normal Forms

canonical normal forms are also called full or perfect DNF or

CNF.
important for many fields:
3SAT (a NP-complete problem from computational theory)
Quine-McClusky algorithm (minimizing Boolean functions)
automated proving (mathematics)

all Boolean expressions can be converted to canonical DNF and CNF

by using Boolean Identities. (can be difficult, worst-case: exponential


blow-up)
most easily we can obtain normal forms from truth tables.

Tilman Schieber (TU Berlin)

Computer Engineering

2016

25

Truth Table to DNF


x1 x2 x3 f (x1 , x2 , x3 )
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
1
0
0
1
0
0
1

Step 1: mark all rows with function value 1

Tilman Schieber (TU Berlin)

Computer Engineering

2016

26

Truth Table to DNF


x1 x2 x3 f (x1 , x2 , x3 )
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
1
0
0
1
0
0
1

x1 x2 x3

x1 x2 x3

x1 x2 x3

Step 2: note the corresponding minterms

Tilman Schieber (TU Berlin)

Computer Engineering

2016

26

Truth Table to DNF


x1 x2 x3 f (x1 , x2 , x3 )
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
1
0
0
1
0
0
1

x1 x2 x3

x1 x2 x3

x1 x2 x3

(x1 x2 x3 ) (x1 x2 x3 ) (x1 x2 x3 )


Step 3: write down the disjunction of minterms
Tilman Schieber (TU Berlin)

Computer Engineering

2016

26

Truth Table to CNF


x1 x2 x3 f (x1 , x2 , x3 )
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
1
0
0
1
0
0
1

Step 1: mark all rows with function value 0

Tilman Schieber (TU Berlin)

Computer Engineering

2016

27

Truth Table to CNF


x1 x2 x3 f (x1 , x2 , x3 )
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
1
0
0
1
0
0
1

x1 x2 x3
x1 x2 x3
x1 x2 x3
x1 x2 x3
x1 x2 x3

Step 2: note the corresponding maxterms

Tilman Schieber (TU Berlin)

Computer Engineering

2016

27

Truth Table to CNF


x1 x2 x3 f (x1 , x2 , x3 )
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
1
0
0
1
0
0
1

x1 x2 x3
x1 x2 x3
x1 x2 x3

x1 x2 x3
x1 x2 x3

(x1 x2 x3 ) (x1 x2 x3 ) (x1 x2 x3 )


(x1 x2 x3 ) (x1 x2 x3 )
Step 3: write down the conjunction of maxterms
Tilman Schieber (TU Berlin)

Computer Engineering

2016

27

Truth Table to DNF/CNF


to get DNF:
1 mark all rows with function value 1
2 note the corresponding minterms:
xi = 0 in truth table xi in minterm
xi = 1 in truth table xi in minterm
3

write down the disjunction of minterms

to get CNF:
1 mark all rows with function value 0
2 note the corresponding maxterms:
xi = 0 in truth table xi in maxterm
xi = 1 in truth table xi in maxterm
3

write down the conjunction of maxterms

Tilman Schieber (TU Berlin)

Computer Engineering

2016

28

Outlook: Logic Synthesis


today hardware is modeled in HDLs (hardware description languages)

like Verilog and VHDL


to realize a description in hardware it has to be synthesized.
multilevel synthesis is used to minimize:
space needed
critical path delay
power consumed
placeability
...
first technology-independent then technology-specific optimization
most modern systems use tranformation-based synthesis

Tilman Schieber (TU Berlin)

Computer Engineering

2016

29

Combinational Circuits

Combinational Circuits

Tilman Schieber (TU Berlin)

Computer Engineering

2016

30

Combinational Circuits

Logic in the Real World

What we have seen up to now is only theoretical


How can it be used in a computer?

Tilman Schieber (TU Berlin)

Computer Engineering

2016

31

Combinational Circuits

Logic in the Real World

What we have seen up to now is only theoretical


How can it be used in a computer?
with a digital circuit
we define a certain electric current to be 0 (e.g. 0V)
we define another current to be 1 (e.g. 6V)
we use transistors to perform logic operations

Tilman Schieber (TU Berlin)

Computer Engineering

2016

31

Combinational Circuits

Logic Functions with Transistors

OR-Gate
AND-Gate
a transistor is a simple electronic switch

NOT-Gate

it allows us to implement our boolean operators and therefore any

boolean function we want


concrete implementations vary with technology
Tilman Schieber (TU Berlin)

Computer Engineering

2016

32

Combinational Circuits

Outlook: Hardware Technology

our considerations do not depend on hardware technology. It can be:


pre-semiconductor technology (relais, vacuum tubes), 19th century
resistor-transistor logic
diode-transistor logic
transistor-transistor logic (invented 1961)
CMOS-logic - todays VLSI (very-large-scale integration) standard

Tilman Schieber (TU Berlin)

Computer Engineering

2016

33

Combinational Circuits

Outlook: Hardware Technology

our considerations do not depend on hardware technology. It can be:


pre-semiconductor technology (relais, vacuum tubes), 19th century
resistor-transistor logic
diode-transistor logic
transistor-transistor logic (invented 1961)
CMOS-logic - todays VLSI (very-large-scale integration) standard

. . . but we can also build computers out of:

Tilman Schieber (TU Berlin)

Computer Engineering

2016

33

Combinational Circuits

Tinker Toy Computer

Tinker toys are popular childrens toys in the US

Tilman Schieber (TU Berlin)

Computer Engineering

2016

34

Combinational Circuits

Tinker Toy Computer

built 1975 by two students


one built an OR-gate, the other a NOT-gate out of tinkertoys.
so they built a computer that can play tic-tac-toe
mechanical and hand-powered
Tilman Schieber (TU Berlin)

Computer Engineering

2016

34

Combinational Circuits

Future Computers?
Fluidics
use fluids (liquids) to implement logics
applications: nanotechnology, automobiles, military
naturally quite slow

Nano Transistors

single electron transistor (SET)


the way towards quantum computers?

Tilman Schieber (TU Berlin)

Computer Engineering

2016

35

Combinational Circuits

Basic Gate Symbols

Tilman Schieber (TU Berlin)

AND-Gate, x y

OR-Gate, x y

NOT-Gate x

Computer Engineering

2016

36

Combinational Circuits

More Gate Symbols

Tilman Schieber (TU Berlin)

NAND-Gate, (x y )

NOR-Gate, (x y )

XOR-Gate,
x y = (x y ) (x y )

3-input AND with negated


input, x y z

Computer Engineering

2016

37

Вам также может понравиться