LC02

advertisement
2. The Algebra of Logic. Logic Functions
2. THE ALGEBRA OF LOGIC. LOGIC FUNCTIONS
When information is processed, both mathematical operations and operations of logic are
performed. The operations of logic are based on the algebra of logic.
An English mathematician, George Boole, in 1854 published a book entitled An
Investigation of the Laws of Thought. Boole introduced the idea of examining the truth or
falsehood of complicated statements via algebra of logic. Variables in Boole's algebra X, Y, Z,
... were only allowed to take on two values: false, assigned the value 0, and true, assigned the
value 1. Logic variables are linked by logic functions F = F(X, Y, Z, ...). Logic functions, like
logic variables, were allowed to take on two values – 0 or 1.
Every branch of mathematics is based on evident principles' – axioms. In 1904 E.V.
Huntington published Sets of Independent Postulates for the Algebra of Logic, where he
defined the binary operators of AND, OR, and Complement (NOT).
In 1938 Claude Shannon published the abstract of his Master Thesis in Massachusetts
Institute of Technology A Symbolic Analysis of Relay and Switching Circuits, providing the
first application of principles of Boolean algebra to the design of electrical switching circuits.
2.1. The Main Logic Functions
Logic function AND – operation AND, logical multiplication or con+ E junction. This function is performed by the circuit with switches conX
nected in series (Fig. 2.1). The switches are controlled by logic variables.
Y
The switch is pushed when X  1. Logic function in the output of
the element AND F(X,Y) = 1, if the level of output voltage is high:
Uout = +E = U1 = UH (high).
R
Uout
F(X,Y) = 0, if Uout = 0 = U0 = UL (low).
Logic function AND is marked with various symbols: F= X . Y,
Fig. 2.1
F = XY, F = XY, F = XY, F = XY.
Logic functions can be represented by truth tables.
X
Y
F = X Y
The truth table is a tabular form that contains all combi0
0
0
nations of n independent variables X, Y, Z, ... . For n
0
1
0
variables there are 2n possible combinations – the rows of
1
0
0
the table. The truth table of logic function 2AND (the
number 2 before AND marks two independent logic
1
1
1
variables X and Y, two inputs of logic operator AND) is
Fig.2.2
12
2. The Algebra of Logic. Logic Functions
shown in Fig. 2.2. The values of the function in the table are written with respect to the circuit
in Fig. 2.1.
The rows of the truth table are filled up in the sequence of binary code. The row is called
as a binary digit filled up in the row: row 0, row 1, row 2, and row 3.
F = X Y
X

Notice that in the truth table of logic function AND stands out
Y
the combination when all logic variables equal to 1: then and only then
International
function equals to 1. The circuit with switches in series explains this
X
property of logic function AND.
F = X Y
Y
The symbols of AND element (AND gate) with two inputs are
USA
shown in Fig. 2.3.
Logic function OR – operation OR, logical addition or disjunction. This function is performed by the circuit with switches in
parallel (Fig. 2.4). Logic function OR is marked with various symbols:
F= X+Y, F = XY or F = XY.
The truth table of logic function OR (Fig.2.5) can be filled up
according the circuit on Fig. 2.4.
X
Y
F = X+Y
In the truth table of logic
0
0
0
function OR stands out the combi0
1
1
nation when all logic variables
1
0
1
equal to 0: then and only then
1
1
1
function equals to 0. The circuit
Fig.2.5
with switches in parallel explains
this property of logic function OR.
The symbols of OR element (OR gate) with two inputs are
shown in Fig. 2.6.
Logic function NOT – complement operation (1's complement)
or inversion. This function is performed by the inverter – the stage of
inverting amplifier (Fig. 2.7).
The inversion is signed by stroke over
X
FX
variable: F = X. Another symbol of inversion is
0
1
sign "" before variable: F = X. The truth table of
1
0
logic function NOT is very simple (Fig. 2.8).
Fig. 2.8
The symbols of inverter as a
F = X gate are shown in Fig. 2.9. Inversion
X 1 F= X X
is signed by a circle on the outline of
the symbol of the gate.
International
Fig. 2.9
Fig. 2.3
+E
Y
X
R
Uout
Fig. 2.4
X
Y
1
F = X Y
International
F = X Y
X
Y
USA
Fig. 2.6
+ EK
RK
X
F X
VT
USA
Fig. 2.7
13
2. The Algebra of Logic. Logic Functions
2.2. All Logic Functions of One and Two Logic Variables
There are 2n various combinations of logic variables – the rows of a truth table – when logic
function depends on n variables. There are two possible values – 0 and 1 – of logic function for
every combination of variables. It means that there are 2 2n different logic functions of n
variables. For n  1, 22n  4; for n  2, 22n  44  16; for n  3, 22n  64, etc. Evidently
analysis of logic functions becomes more complicated when quantity of variables' n increases.
We will fill up the truth tables of all possible logic functions when n  1, and when
n  2.
X
0
1
X
0
0
1
1
Y
0
1
0
1
F0
0
0
F1
1
0
F2
0
1
F3
1
1
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
Notice that in both tables the number of logic function coincides with the binary number
written in the column of values of logic function.
Notice that in both tables the functions in the second part of the table (F2, F3 in the first
table, and F8...F15 in the second table) are complement or inversion of the functions in the
first part of the table (F1, F0 in the first table, and F7...F0 in the second table). It means that it
is necessary to comment only one half of functions in the tables.
The functions F0, F3 in the first table like the functions F0, F15 in the second table are
the constants (all 0s' case or all 1s' case). The function F1(X)  X like the function F3(X,Y)  X
are the X inverter functions, while the function F2(X)  X like the function F12(X,Y)  X are
the X buffer functions. F5(X,Y)  Y. F1(X,Y)  X+Y is the NOR function, its complement is
function F14(X,Y) which is the OR function. F7(X,Y)  XY is the NAND function, its
complement is function F8(X,Y) which is the AND function. F6(X,Y)  XY is the Exclusive
OR (XOR) function, its complement is function F9(X,Y)  XY that is the Exclusive NOR
(XNOR) function or Equivalence function. The function F2(X,Y)  XY is "only Y but not X"
function; it is not popular logic function, F4, F10 and F13 are its variations.
The table below represents the summary of useful functions of one and two logic
variables.
14
2. The Algebra of Logic. Logic Functions
Truth Table
X Y
0 0
0 1
1 0
1 1
X Y
0 0
0 1
1 0
1 1
X
0
1
X Y
0 0
0 1
1 0
1 1
X Y
0 0
0 1
1 0
1 1
X Y
0 0
0 1
1 0
1 1
X
0
1
X Y
0 0
0 1
1 0
1 1
F
0
0
0
1
F
0
1
1
1
F
0
1
F
0
1
1
0
F
1
1
1
0
F
1
0
0
0
F
1
0
F
1
0
0
1
Boolean
Function
F  XY
or
FXY
or
FXY
Gates
Name
Graphic Gate Symbol
International
USA
X
AND
Y

F =X Y
FXY
OR
X
Y
FX
Buffer
X
1
F=X
F  X Y
Exclusive
OR
(XOR)
X
Y
1
F =XY
F  XY
or
FXY
or
F  X Y
X
NAND
FXY
NOR
FX
Inverter
F  X Y
Exclusive
NOR
(XNOR)
Y
1
F =X+Y

F =X Y
X
Y
1
F =X+Y
X
1
F=X
X
Y
1
F =XY
X
Y
F =X Y
X
Y
X
F =XY
F=X
X
Y
F = XY
X
Y
F =X Y
X
Y
F =XY
X
X
Y
F=X
F = XY
In the first four rows logic functions are written in direct form, in the other four rows
they are repeated in inversed or complemented form.
15
2. The Algebra of Logic. Logic Functions
2.3. The Full Set of Logic Functions
Every logic expression can be written by logic functions that form the full set. Every logic
expression can be written using logic functions AND, OR and NOT. It is the most popular set
of logic functions in software. This set is more than full, it is redundant. Only AND and NOT
or only OR and NOT already makes a full set of logic functions. But these sets are not so
convenient in software as the set from AND, OR and NOT. In hardware one type of logic gates
is used as a rule: only the gates NAND or only the gates NOR. Each of them makes full set of
logic functions and lets to make up a logic circuit of necessary complexity.
Example 2.1
Draw the circuits from the NAND gates only that perform the main logic functions AND, OR and NOT.
Solution
The circuits in the table can be checked-up by filling the truth tables
Logic
of the gates in the circuits.
The Circuit
Function
2AND
A
B
A
AB


A
2OR
B
A
NOT


B
A

A B
A+B

Example 2.2
Draw the same circuits from the NOR gates only.
Example 2.3
Draw the circuit for the robot that places the components on the
printed board. The robot puts component on the board (logic
function in the circuits output F  1), if it is not necessary to check
the component (it is necessary to check the component means that
logic variable in input A  1), or it is necessary to check the
component on the board (B  1), or it is checked (C  1), and it
works
(D  1), and its parameters are OK (E  1).
Solution (the circuit is shown on the figure) A
1
Example 2.4
B
Draw the robot circuit from NAND gates C
only.
D

E
2.4. Writing down of Logic Functions. Standard Forms of Logic Functions
Logic circuits are designed in such steps:
1. Operation of the circuit is formulated in verbal form.
2. The logic variables are defined.
3. The truth table of logic function performed by the circuit is filled up.
4. The logic function is written down from the truth table.
5. The written logic function is minimized.
6. The circuit that performs the minimized logic function is designed.
16
1
F
2. The Algebra of Logic. Logic Functions
Now we’ll perform first four steps for the three voters function.
1. The three voters function or majority function of three variables makes decision that
realizes the will of majority.
2. Three voters can be defined as logic variables A, B, C; decision – as logic function
F(A,B,C).
3. The truth table, in which the three voters logic function is determined by the will of
majority, is shown below.
Standard products
– minterms
m0  XYZ
m1  XYZ
m2  XYZ
m3  XYZ
m4  XYZ
m5  XYZ
m6  XYZ
m7  XYZ
X
Y
Z
F
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
f0  0
f1  0
f2  0
f3  1
f4  0
f5  1
f6  1
f7  1
4. First of all we will write the logic function from the table in the standard sum of products
(SOP) form. A standard product is the product expression that contains all the independent
input variables either in direct or complemented form. The variables in a standard product
represent a single row in the truth table such that on evaluating the expression for that row its
value is 1: an input variable is complemented when its value in this row is 0 and uncomplemented when its value in this row is 1. Standard products are called minterms and designated
by a small m. The standard product XYZ is minterm 011 in binary or minterm 3 in decimal and
is normally written m3.
It is particularly important that the binary number associated with minterm is formed in
the same order as the logic variables are listed in the truth table. Minterm 3 or 011 is the
formulation of the binary values of variables in the order X  0, Y  1, and Z  1, as they are
listed in the truth table.
fi's in the table are the values of the logic function F in selected row.
We can now write the general form for a standard sum of products for a function of three
independent variables:
F(X,Y,Z) = f0 m0 + f1 m1 + f2 m2 + ... + f6 m6 + f7 m7.
Substituting the values for the characteristic numbers assigned to the function F in the table
provides us with the traditional form of the standard SOP:
F(X,Y,Z) = 0 m0 + 0 m1 + 0 m2 +1 m3 + 0 m4 +1 m5 + 1 m6 + 1 m7 
= 0 + 0 + 0 +1 m3 + 0 + 1 m5 + 1 m6 + 1 m7  m3 + m5 + m6 + m7 .
17
2. The Algebra of Logic. Logic Functions
The function will evaluate to 1 if and only if m3 OR m5 OR m6 OR m7 evaluates to 1;
otherwise the function will evaluate to 0. Since only one standard SOP form can be written for
any particular function, the form is unique. Any other logic function that has this standard SOP
form must be the same function.
So we can formulate the general rule: any logic function can be written as a sum of
minterms corresponding the rows of the truth table with values of the function F  1.
Standard SOP form can be written in a more compact form
F(X,Y,Z) = m(3,5,6,7)
or in the following expanded form:
F = XYZ + XYZ + XYZ + XYZ .
Example 2.6
Write an exclusive OR function in a short and in an expanded standard SOP form.
Standard SOP form is one of the two standard forms of writing of logic functions.
The row of the truth table can be written in a form of a sum of variables. The variable is
written to the sum in direct form if its value in the row is 0, and in complemented form if its
value in the row is 1. Standard sums are called maxterms and designated by a capital M. The
standard sum X + Y + Z is maxterm 011 in binary or maxterm 3 in decimal and is normally
written M3. The standard sum for any row evaluates to 0.
In the same way as we did for sum of products we can show that any logic function can
be written as a product of sums – maxterms corresponding the rows of truth table with
values of function F  0.
The POS form of the majority function in the table
F(X,Y,Z) = M0  M1  M2  M4 .
Standard POS form can be written in a more compact form
F(X,Y,Z) = M(0,1,2,4)
or in the following expanded form:
F = (X + Y + Z)·(X + Y + Z)·(X + Y + Z)·(X + Y + Z).
Example 2.7
Write an exclusive OR function in a short and in an expanded standard POS form.
The same logic function we can write in the standard SOP form or in the standard POS
form. A conversion from one form to another is very simple: you must to write the numbers of
the maxterms that are lacking in the list of the minterms or on the contrary.
Example 2.8
a) Write function F(X,Y,Z) = m(2,4,6,7) in a short and in an expanded standard POS form;
b) Write function F(X,Y,Z) = M(1,2,4,5) in a short and in an expanded standard SOP form.
18
2. The Algebra of Logic. Logic Functions
CONTROL QUESTIONS AND PROBLEMS
2.0.1. Name the object of logic algebra.
2.0.2. Who is an author of logic algebra?
2.0.3. What idea belongs to Claude Shannon?
2.1. The Main Logic Functions
2.1.1. What connection of switches performs logic AND?
2.1.2. What connection of switches performs logic OR?
2.1.3. Draw the circuits with switches that perform these logic functions:
a) F(X,Y,Z) = X + X Y Z,
b) F(A,B,C) = A (A + B + C) + A.
2.1.4. Write down the logic function that performs the circuit with switches.
+E
A
B
C
B
F
D
2.1.5. Draw the graphic symbols (international and used in USA) of gates 3OR and 3AND.
2.2. All Logic Functions of One and Two Logic Variables
2.2.1. How many different logic functions can be made for n logic variables?
2.2.2. Fill in the truth tables of logic functions 3NAND and 3 NOR.
2.2.3. Which input signal – 1 or 0 – is active (that sets the output signal of the gate) for these gates:
a) nNAND;
b) nOR;
c) nAND;
d) nNOR?
2.2.4. Draw the circuit with 3AND gate that always repeats at its output the signal in its first input. Draw the
same circuit with 3OR gate.
2.2.5. Fill in the truth table of logic function XOR. Draw the graphic symbols of XOR gate.
2.2.6. Fill in the truth table of logic function XNOR. Do you know an other name of this logic function? Draw
the graphic symbols of XNOR gate.
2.3. The Full Set of Logic Functions
2.3.1. What set of logic functions is named as full?
2.3.2. Draw the circuits from 2NAND gates only that perform these logic functions:
a) 2AND;
b) 2OR;
c) NO;
d) 3NAND.
19
2. The Algebra of Logic. Logic Functions
2.3.3. Draw the circuit from 2OR gates only, that performs the logic function 6OR. Comment the fastness of
the circuit with 2OR gates connected in series and the circuit with gates connected in parallel.
2.4. Writing down of Logic Functions. Standard Forms of Logic Functions
2.4.1.
2.4.2.
2.4.3.
2.4.4.
2.4.5.
Comment the way in which the logic circuits are designed.
Write down the minterms m0, m3, m7, m12, and m14 of logic function F(A,B,C,D).
Write down the maxterms M0 , M3, M9, M11, and M15 of logic function F(W,X,Y,Z).
Fill in the truth table of logic function F(X,Y,Z) =  m(2,3,6,7) .
Write down the logic function XOR in standard form of SOP and in standard form of POS. Draw the
circuits realizing these two logic equations. Whish of them is more complicated?
2.4.6. Write down the logic function of 5 voters
a) in compact SOP form;
b) in compact POS form.
20
Download