Você está na página 1de 71

Chapter 3

Boolean Algebra and Logic Gate


Objectives
• A brief review of Boolean Algebra – a
mathematical foundation of digital logic
• Introduce concept of a gate
• Describe combinational and sequential circuits
which are constructed from gates
Overview
• Operation of most computers is based on
binary systems
• Binary number 1 and 0  called propositional
logic  TRUE or FALSE
• Stated as functions of other propositions
which are connected by the three basic logical
connectives: AND, OR and NOT
An example

• I will take an umbrella with me IF AND ONLY IF it is


raining OR the weather forecast is bad

Rain
OR Take Umbrella
Bad
Weather
\Forecast Output proposition
Input propositions OR connective

• The output is TRUE if either one of the input propositions is TRUE


• Otherwise it is FALSE
An Example (cont.)

• Based on the example, there are only two


possible values for any proposition
• The truth value for the output for all possible
input  produces the Truth Table

Raining Bad Forecast Umbrella


FALSE FALSE FALSE

FALSE TRUE TRUE

TRUE FALSE TRUE

TRUE TRUE TRUE


Basic Operations of Boolean Algebra
• Boolean algebra – used in electronic digital
circuit design
• Introduced by George Boole in 1854
• Algebra : uses variables (statements) and
operations (relations)
• Boolean algebra : logic variable (TRUE (1) or
FALSE (0)) and logical operations
• Three basic logical operations:
AND . dot
OR + plus sign
NOT ¯
over-bar

Example:
A AND B = A.B
A OR B = A + B
NOT A = Ā
• These operations are used to combine
operands to form logical expressions
X or NOT (X)
X.Y + Z or NOT (X AND Y) OR Z
(X.Y) + (Y.Z)or (X AND NOT(Y)) OR (Y AND Z)

Try: A + (B.C)

• Other logical operations : NAND, NOR and XOR are widely


used in building logical circuits
NAND is a combination of AND followed by NOT
NOR is a combination of OR followed by NOT
• AND yields true (binary value 1) if and only if both of its
operands are true
• OR yields true if either or both of its operands are true
• NOT inverts the value of its operand, true to false
• NAND gives the true result if one or both of the operands are
false
• NOR only gives the true value if and only if both operands are
false
• XOR gives the true value if and only if only one operand is
true
P Q NOT P P AND Q P OR Q P XOR Q P NAND Q P NOR Q

0 0 1 0 0 0 1 1
0 1 1 0 1 1 1 0
1 0 0 0 1 1 1 0
1 1 0 1 1 0 0 0
Match the items on the right with the items on the left.

AND a) Gives a 0 when both Input


A and Input B are a 1.

X-OR
b) Gives a 1 if either Input A
or Input B is a 1, but not both.
OR

NAND c) Gives a 1 if both Input A


and Input B are 1

d) Gives a 1 if either Input


A or Input B is a 1
Relationship Between Basic Operation of
Boolean and Basic Logic Gate
• The basic construction of a logical circuit is gates
• Gate is an electronic circuit that emits an output
signal as a result of a simple Boolean operation on its
inputs
• Logical function is presented through the
combination of gates
• The basic gates used in digital logic is the same as the
basic Boolean algebra operations (e.g., AND, OR,
NOT,…)
• The package Truth Tables and Boolean Algebra set out the
basic principles of logic.
• Any Boolean algebra operation can be associated with an
electronic circuit in which the inputs and outputs represent
the statements of Boolean algebra.
• Although these circuits may be complex, they may all be
constructed from three basic devices. These are the AND
gate, the OR gate and the NOT gate.
• the symbols, algebra signs and the truth table for
the gates
Name Graphic Symbol Boolean Algebra Truth Table
F =A. B A B F
A 0 0 0
AND B F Or
0 1 0
F = AB 1 0 0
1 1 1
A B F
A F 0 0 0
OR B
F=A+B 0 1 1
1 0 1
1 1 1

B F
NOT A F F=A 0 1
1 0
  ____ A B F
A F=A.B 0 0 0
NAND B F
Or 0 1 1
1 0 1
F = AB 1 1 1
A B F
A
_____ 0 0 0
NOR B F F=A+B 0 1 0
1 0 0
1 1 1
Basic Theorems of Boolean Algebra
Identity Elements : 1 . A = A
0+A=A
Boundess Laws : A . 0 = 0
A+ 1 = 1
Basic Theorems of Boolean Algebra
1. Identity Elements 2. Inverse Elements

1.A=A A.A=0

0+A=A A+A=1
 
3. Idempotent Laws 4. Boundess Laws
A+A=A A + 1 = 1 
A.A=A A.0=0
 
5. Distributive Laws 6. Order Exchange Laws
A . (B + C) = A.B + A.C A . B = B . A 
A + (B . C) = (A+B) . (A+C) A+B=B+A
 
7. Absorption Laws 8. Associative Laws
A + (A . B) = A A + (B + C) = (A + B) + C
A . (A + B) = A A . (B . C) = (A . B) . C
 
9. Elimination Laws 10. De Morgan Theorem
   
A + (A . B) = A + B (A + B) = A . B
   
Exercise 1
• Apply De Morgan theorem to the following
equations:
F=V+A+L
F=A+B+C+D
• Verify the following expressions:
S.T + V.W + R.S.T = S.T + V.W
A.B + A.C + B.A = A.B + A.C
Relationship Between Boolean
Function and Logic Circuit

Boolean function  Q = AB + B
= (NOT A AND B) OR B
Logic circuit
A
A AB
B B Q
= AB + B
Relationship Between Boolean Function and Logic
Circuit

• Boolean function  e.g.


F=A.B+C+D
 ((A AND B) OR (C NOR D))
or
 ((A AND B) OR NOT (C OR D))
• Any Boolean function can be implemented in electronic form as a
network of gates called logic circuit

A A.B = AB
B
F = AB + C + D
C
D C+D
G = A . (B + C + D)

A G = A . (B + C + D)

B B+C+D

C C+D
D
Try to work out the output of the combination.

C = A.B

A = 0, B = 0, C = ?, Q = ? C = 1, Q = 0
A = 1, B = 0, C = ?, Q = ? C = 1, Q = 0
A = 0, B = 1, C = ?, Q = ? C = 1, Q = 0

A = 1, B = 1, C = ?, Q = ? C = 0, Q = 1
Truth Table
The Exclusive OR gate (XOR)
                                    
A
B Output

XOR  1 when A or B are 1 but not both


For the XOR gate the truth table looks like this:

A B OUTPUT

0 0 0
1 0 1
0 1 1
1 1 0
The NAND gate

A
Output
B

For the NAND gate the truth table looks like this:

A B OUTPUT
0 0 1
1 0 1
0 1 1
1 1 0
The NOR gate

A
Output
B

For the NOR gate the truth table looks like this:

A B OUTPUT
0 0 1
1 0 0
0 1 0
1 1 0
Truth Table
A = 0, B = 0, C = 1, Q = 0
A B C Q
A = 1, B = 0, C = 1, Q = 0
0 0 1 0
A = 0, B = 1, C = 1, Q = 0 1 0 1 0
A = 1, B = 1, C = 0, Q = 1 0 1 1 0
1 1 0 1
Truth Table A B Q
0 0 0
1 0 1
0 1 0
1 1 0
A
A AB
B B Q
= AB + B

Produce a truth table from the logic circuit


A B A AB Q
0 0 1 0 0
0 1 1 1 1
1 0 0 0 0
1 1 0 0 1
p q r p.q q q+r

0 0 0  0    
0 0 1      
0 1 0      
0 1 1      
1 0 0      
1 0 1      
1 1 0      
1 1 1      
p q r p.q q q+r

0 0 0  0 1   1
0 0 1  0 1  1
0 1 0  0 0  0 
0 1 1  0 0   1
1 0 0  0  1  1
1 0 1 0   1 1 
1 1 0  1 0   0
1 1 1 1  0   1
Elimination Laws:A.(A + B) = A.B

Proof using truth table.

A B A A+ B A.B A.(A + B)
0 0 1 1 0 0
0 1 1 1 0 0
1 0 0 0 0 0
1 1 0 1 1 1

Proof the Absorption Laws: A . (A + B) = A using


truth table.
p q p+q p.(p+q) p.q p.p (p.p)+(p.q)
0 0 0 0 0 0 0

0 1 1 0 0 0 0

1 0 1 1 0 1 1

1 1 1 1 1 1 1

Logically equivalent
p.(p+q) = (p.p)+(p.q)
Elimination Laws:A.(A + B) = A.B

Proof using truth table.

A B A A+ B A.B A.(A + B)
0 0 1 1 0 0
0 1 1 1 0 0
1 0 0 0 0 0
1 1 0 1 1 1

Draw the logic circuit for output = A.(A + B)


Draw the logic circuit for output = A.(A + B)

A A A+ B
B

A.(A+B)
A
De Morgan Theorem : (A + B) = A . B

Proof using truth table.

A B A+B A B A.B (A + B)
0 0 0 1 1 1 1
0 1 1 1 0 0 0
1 0 1 0 1 0 0
1 1 1 0 0 0 0

Draw the logic circuit for output = (A + B)


Exercise 2

• Build a truth table for the following


Boolean function

G = A . (B + C + D)
Karnaugh Map
• A graphical way of depicting the content of a truth table
where the adjacent expressions differ by only one variable
• For the purposes simplification, the Karnaugh map is a
convenient way of representing a Boolean function of a
small number (up to four) of variables
• The map is an array of 2n squares, representing all possible
combination of values of n binary variables
• Example: 2 variables, A and B
B B
A B B 1 0
A
A AB AB 00 01
0
A AB AB 1 10 11
• The number of squares in Karnaugh map depends
on the number of variables
• e.g., if 2 variables, A, and B, there are 22 = 4
squares in the Karnaugh map
• e.g., if 3 variables, A, B, and C, there are 23=8
squares
C AB
AB C C AB AB AB AB
C
AB 000 001 000
C
AB 010 011
C 001
or
110 111
AB

AB 100 101
4 variables, A, B, C, D  24 = 16 squares

CD
AB CD CD CD CD

AB 0000 0001

AB 0100

AB 1100

AB 1000
00 01 11 10
AB
• The adjacent differ by AB AB AB AB
C
only one variable 000 010 110 100
• List combinations in 0 C

the order 00, 01, 11, 10 1 C 001 011 111 101

C 0 1
AB C C

00 AB 000 001

01 AB 010 011

AB 110 111
11
10 AB 100 101
Karnaugh Maps to Represent Boolean Functions

AB 00 01 11 10
AB AB AB AB
1 1

F = AB + AB
BC 00 01 11 10
A BC BC BC BC

A 1 1 ABC

A 1 ABC

ABC

F=ABC + ABC + ABC


CD 00 01 11 10
AB CD CD CD CD
1
00 AB ABCD
01 AB

11 AB 1
10 AB 1

ABCD
ABCD

F = ABCD + ABCD + ABCD


Create Karnaugh Map
Truth Table
A B C F
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1 1. Place 1 in the corresponding
1 0 1 1 square
1 1 0 0
1 1 1 0
Karnaugh Map
BC BC BC BC BC
A 00 01 11 10

A 0
1 1
1 1
A 1
Represent Boolean Functions
2. Group the adjacent squares:
Begin grouping square with 2n-1 for n variables
• e.g. 3 variables, A, B, and C
23-1 = 22 = 4
= 21 = 2
= 20 = 1

BC BC BC BC BC
A 00 01 11 10

A 0
1 1
1 1
A 1

BC AB ABC F = BC + AB + ABC
3 variables:
BC BC BC BC BC 23-1 = 22 = 4
A 00 01 11 10
22-1 = 21 = 2
A 0
1 1 21-1 = 20 = 1

1 1 1
A 1

AB
C
F = C + AB
3 variables:
BC BC BC BC BC 23-1 = 22 = 4
A 00 01 11 10
22-1 = 21 = 2
A 0
1 21-1 = 20 = 1
BC
1 1 1 1
A 1

F = A + BC
4 variables, A, B, C, D  24-1 = 23 = 8 (maximum); 22 = 4;
21 = 2; 20 = 1 (minimum);

CD
AB 00 01 11 10

00 1 1

01 1

11 1

10 1 1 1

F= CD + BD + ABC
CD
AB 00 01 11 10

00

01 1 1
F = ABD
11

10

CD
AB 00 01 11 10

00 1

01 F = BCD
11

10 1
CD
AB 00 01 11 10

00

01 1 1

1 1 F = BC
11

10

CD
AB 00 01 11 10

00 1 1 1 1

01 1 1 1 1
F= A
11

10
CD
AB 00 01 11 10

00 1 1

01 1 1
F= D
1 1
11

10 1 1
The following diagram illustrates some of the possible pairs of
values for which simplification is possible:
Karnaugh Map

Boolean Function

Logic Circuit
Exercise 3
Transform the following truth table to Karnaugh Map and
find the Boolean function
Example of Digital Problem
ð To build a logic circuit of an Alarm System at the office (with one
door and one window) that will ring if the door or window is/are
opened after working hours.
 ð Followings are the steps that are to be taken to build a logical circuit.
1. Problem Determination
-- Determine the problem that has to be solved
-- A logical circuit that will trigger the emergency bell if door or
window is/are opened outside office hours has to be built
 2. Conceptualization
- Obtain the relevant logical variable and make a logical table and
also a truth table. Obtain the logical expression from the truth table
• The related variables are :
Time T = 0 (work time) T = 1 (not work time)
Doors D = 0 (closed) D = 1 (opened)
Windows W = 0 (closed) W = 1 (opened)

• Whether Bell B will ring (1) or will not ring (0) depends
on all three logical variables (depending on the
condition or problem given)
Logic Table
INPUT VARIABLES OUTPUT
Time Door Window Bell

Work closed closed Doesn’t ring


Work closed opened Doesn’t ring
Work opened closed Doesn’t ring
Work opened opened Doesn’t ring
Not Work closed closed Doesn’t ring
Not Work closed opened Will Ring
Not Work opened closed Will Ring
Not Work opened opened Will Ring
Truth Table (based on logical variable and
function above)
INPUTS OUTPUT
T D W B
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
• B is the output or the function that we have to find. The B
function or expression can be obtained through many was
based on the truth table above. One of the methods is by
using a Karnaugh map. Below is the Karnaugh Map for the
Truth Table above
WD
00 01 11 10
T
  From the Karnaugh Map
above,
0 B = TW + TD

1 1 1 1

TD TW
• The expression B above can be further summarized using
theorem or the laws in Boolean algebra
B = TW + TD = T(W + D) (from the Law of Distribution)
• From the expression obtained, the logical circuit
for B= T(W + D) is as follow :
T
T(W + D)

W (W + D)
D
Building logical circuits using only NAND
or only NOR gates
• Most components in computers are built using only
either the NAND or the NOR. This can further
simplify the construction of such circuits (i.e. do
not need to use various gates in a logic circuit)
• To build a circuit that only uses NAND or NOR
gates, firstly the expression for the circuit has to be
changed into an expression that only has either the
NAND or NOR operations. To change it, the De
Morgan and Involution Theorems are used.
The Involution Theorem is as follow:
 
A=A

Example:
Take the B expression B = T(W + D) as an example.

1. Using only the NAND gate


• To get an expression that only uses the NAND gate,
eliminate the OR operation in the expression by using the
Involution Theorem and De Morgan theorem.
Example :
B = T.(W + D)

= T.(W + D) Involution Theorem

= T. (W . D) De Morgan theorem

= T. (W . D) Involution Theorem

• Hence, the logic circuit for B that only uses the NAND gate
can be drawn as follow:
T

D
 
2. Using only the NOR gate
• To get an expression that only uses the NOR gate, eliminate the AND
operation in the expression by using the Involution Theorem and the
De Morgan Theorem.
 
Example:
B = T.(W + D)

= T . (W + D) Involution Theorem

= T + (W + D) De Morgan theorem
• It is found that the expression produced no longer
has the AND operation and all the OR operation
has the complement sign or NOT symbol (or the
NOR operation). Hence, the logic circuit for L that
only uses the NOR gate can be drawn as follow:

W
D
Circuits from NAND and NOR gates

• Buying separate AND, OR gates etc. is wasteful


• These gates can be made of NAND or NOR
gates
• NAND gates are particularly cheap
• Sometimes there can be redundancy, so
circuits can be simplified
Summary
• A brief review of Boolean Algebra – a
mathematical foundation of digital logic
• Introduce concept of a gate
• Describe combinational and sequential circuits
which are constructed from gates

Você também pode gostar