46
Digital Logic Lecture 5 Boolean Algebra and Logic Gates Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

Embed Size (px)

Citation preview

Page 1: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

Digital Logic Lecture 5

Boolean Algebra and Logic Gates – Part I

By

Ghada Al-Mashaqbeh

The Hashemite University

Computer Engineering Department

Page 2: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 2

Outline

Introduction. Boolean variables and truth tables. Fundamental logic gates (AND, OR, and NOT

gates). Logic circuits, functions, and Boolean algebra. Universal logic gates (NAND and NOR). XOR and XNOR gates. Extension to multiple inputs.

Page 3: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 3

Introduction

Till now we have understood the concept of binary numbers. Next, we will study ways of describing how systems using binary logic levels make decisions. After that the definition of logic circuit will be complete.

Boolean algebra is an important tool in describing, analyzing, designing, and implementing digital circuits.

Logic gates are the basic hardware units used to implement logic function or circuits described by Boolean algebra.

Page 4: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 4

Boolean Constants and Variables

Boolean algebra allows only two values; 0 and 1.

Logic 0 can be: false, off, low, no, open switch.

Logic 1 can be: true, on, high, yes, closed switch.

Three basic logic operations: OR, AND, and NOT.

The operation of these logic operations is best described by truth tables.

Page 5: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 5

Truth Tables I

A truth table describes the relationship between the input and the output of a logic circuit.

The number of entries corresponds to the number of inputs. For example a 2 input table would have 22 = 4 entries. A 3 input table would have 23 = 8 entries, and so on.

Page 6: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 6

Truth Tables II

Examples of truth tables with 2, 3, and 4 inputs.

Page 7: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 7

Fundamental Logic Gates

OR : gives an output of ‘1’ when at least one of its input is ‘1’ (Disjunction or logical addition).

AND: gives an output of ‘1’ when all of its inputs are ‘1’ (Conjunction or logical multiplication).

NOT: invert its input, if the input is ‘1’ the output is ‘0’ and vice versa (Negation).

Page 8: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 8

OR Logic Gate I

The Boolean expression for the OR operation is X = A + B

This is read as “x equals A or B.” X = 1 when A = 1 or B = 1 or both equal 1.

Truth table and circuit symbol for a two input OR gate:

Page 9: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 9

OR Logic Gate II

The OR operation is similar to addition but when A = 1 and B = 1, the OR operation produces 1 + 1 = 1 (not 10 as in arithmetic addition).

In the Boolean expression x=1+1+1=1

We could say in English that x is true (1) when A is true (1) OR B is true (1) OR C is true (1).

Page 10: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 10

Timing Diagram of OR Gate

Page 11: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 11

AND Logic Gate I

The Boolean expression for the AND operation is X = A • B or X = AB

This is read as “x equals A and B.”

x = 1 when A = 1 and B = 1.

Truth table and circuit symbol for a two input AND gate are shown. Notice the difference between OR and AND gates.

Page 12: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 12

AND Logic Gate II

The AND operation is similar to multiplication.

In the Boolean expression X = A • B • C

X = 1 only when A = 1, B = 1, and C = 1.

Page 13: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 13

Timing Diagram of AND Gate

Page 14: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 14

NOT Logic Gate I

The Boolean expression for the NOT operation is

This is read as: x equals NOT A, or

x equals the inverse of A, or

x equals the complement of A

AX

Page 15: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 15

NOT Logic Gate II

Truth table, symbol, and sample waveform for the NOT circuit.

Page 16: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 16

Buffer Logic Gate

The function performed by Buffer gate is called transfer since this gate just transfer the value of its input to its output without any change (does not perform any logical operation).

Equivalent to two inverters (NOT gates) connected in cascade (the output of the first one is the input of the second one).

Needed for power amplification of the signal (or inputs).

A

0

1 1

0A x

x = A

Page 17: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 17

Describing Logic Circuits Algebraically I

The three basic Boolean operations (OR, AND, NOT) can describe any logic circuit.

Operators Precedence: If an expression contains AND, OR, and NOT gates combined with each other then follow these rules: First: implement NOT operators starting from left to right. Second: implement AND operations starting from left to

right. Third: implement OR operators starting from left to right. Remember that parenthesis force priority (you start

implementation of what inside a parenthesis). For nested parenthesis you start from the inner most one. If multiple parenthesis exist start implementation from left

to right

Page 18: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 18

Describing Logic Circuits Algebraically II

Examples of Boolean expressions for logic circuits:

Page 19: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 19

Describing Logic Circuits Algebraically III

The output of an inverter is equivalent to the input with a bar over it. Input A through an inverter equals A.

Examples using inverters.

Page 20: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 20

Examples

Page 21: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 21

Evaluating Logic Circuit Outputs

Output logic levels can be determined directly from a circuit diagram.

The output of each gate is noted until a final output is found.

Rules for evaluating a Boolean expression: Perform all inversions of single terms.

Perform all operations within parenthesis.

Perform AND operation before an OR operation unless parenthesis indicate otherwise.

If an expression has a bar over it, perform the operations inside the expression and then invert the result.

Page 22: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 22

Example

Evaluate Boolean expressions by substituting values and performing the indicated operations:

0

0111

)1(111

1)(0111

1)(0110

D)(ABCAx

1D and 1,C 1,B 0,A

Page 23: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 23

Implementing Circuits From Boolean Expressions

It is important to be able to draw a logic circuit from a Boolean expression.

Follow the rules of operators precedence (used when evaluating Boolean expressions) when defining the locations of gate used in the circuit that represent the desired logic function.

Examples: Implement the following Boolean expressions: (a) y = AC+BC’+A’BC

(b) x=(A+B)(B’+C)‏

Page 24: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 24

Example 1 (a)

Page 25: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 25

Example 1 (b)

Page 26: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 26

NAND Logic Gate I

Combine basic AND, OR, and NOT operations.

The NAND gate is an inverted AND gate. An inversion “bubble” is placed at the output of the AND gate.

The Boolean expression is

NAND operator symbol is

ABx

BAx

Page 27: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 27

NAND Logic Gate II

Truth table and gate symbol (compare it with AND gate truth table):

BAx A B

0 0

1

1

0 1

1

1

0

1

0

1

A

Bx

Page 28: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 28

Timing Diagram of NAND Gate

Page 29: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 29

NOR Logic Gate I

Combine basic AND, OR, and NOT operations.

The NOR gate is an inverted OR gate. An inversion “bubble” is placed at the output of the OR gate.

The Boolean expression is

NOR operator symbol is

BAx

BAx

Page 30: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 30

NOR Logic Gate II

Truth table and gate symbol (Compare it with the OR gate truth table):

BAx A B

0 0

1

1

0 0

1

1

0

1

0

0

A

Bx

Page 31: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 31

Timing Diagram of NOR Gate

Page 32: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 32

Exclusive OR Gate I

Abbreviated as XOR gate.

It gives ‘1’ when its two inputs are of different values, otherwise it gives ‘0’ (when they are equal). So, it is also called the binary difference operator.

The Boolean expression is

XOR operator symbol is

BAx

BABAx

Page 33: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 33

Exclusive OR Gate II

Truth table and gate symbol:

BAx A B

0 0

1

1

0 1

0

1

0

1

0

1

A

Bx

Page 34: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 34

Exclusive NOR Gate I

Abbreviated as XNOR gate.

It gives ‘1’ when its two inputs are equal, otherwise it gives ‘0’ (when they are different). So, it is also called the binary equivalence operator.

It is the complement (or the inverter of XOR)

The Boolean expression is

XNOR operator symbol is

\BAx

''BAABx

Page 35: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 35

Exclusive NOR Gate II

Truth table and gate symbol:

\BAx A B

0 0

1

1

0 0

1

1

0

1

1

0

A

Bx

Page 36: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 36

Extension to Multiple Inputs I

All the logical gates that we have taken (except the unary ones) can be extended to have multiple inputs.

The only condition for that is the binary operation represented by the gate must be associative and commutative. E.g. OR and AND gates.

NAND and NOR gates are not associative. However, to make them extendable we define them as an inverted AND and as an inverted OR respectively. E.g.: three input NAND gate have the expression of (x.y.z)’

Page 37: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 37

Extension to Multiple Inputs II

XOR and XNOR are both commutative and associative can be extended to multiple inputs.

Uncommon from hardware point of view.

Multi-input XOR gate (more than 2 inputs) is called an odd-function since it produces 1 if and only if the number of 1’s (inputs that are 1) is odd. Otherwise, it will gives an output of 0.

Multi-input XNOR gate (more than 2 inputs) is called an even-function since it produces 1 if and only if the number of 1’s (inputs that are 1) is even. Otherwise, it will gives an output of 0.

Page 38: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 38

Universality of NAND and NOR Gates I

NAND or NOR gates can be used to create the three basic or fundamental logic gates (OR, AND, and INVERT).

So, any circuit can be implemented totally using NAND gates alone or NOR gates alone (inverters are always allowed).

For this they are called universal gates and they are used in Ics fabrication.

This characteristic provides flexibility and is very useful in logic circuit design.

Page 39: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 39

Implement AND, OR using NAND

Page 40: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 40

Implement AND, OR using NOR

Page 41: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 41

Boolean Function Using only NOR or only NAND

So, any boolean function can implemented totally using NAND gates or using NOR gates.

Example: On board.

Page 42: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 42

Logic Symbol Interpretation

When an input or output on a logic circuit symbol has no bubble on it, that line is said to be active-HIGH.

Otherwise the line is said to be active-LOW.

When a logic signal is in its active state, it can be said to be asserted (=activated). When a logic signal is not in its active state, it is said to be unasserted (=inactive).

Page 43: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 43

Example I

Page 44: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 44

Example 2

Page 45: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 45

Which Gate Representation to Use?

If the circuit is being used to cause some action when output goes to the 1 state, then use active-HIGH representation.

If the circuit is being used to cause some action when output goes to the 0 state, then use active-LOW representation.

Page 46: Boolean Algebra and Logic Gates Part I - JUfilesjufiles.com/wp-content/uploads/2016/12/Lecture-5-1.pdf · Boolean algebra is an important tool in describing, analyzing, designing,

The Hashemite University 46

Additional Notes

This lecture covers the following material from the textbook:

Chapter 1: Section 1.9

Chapter 2: Sections 2.7 and 2.8

Chapter 3: Section 3.6