• No results found

CS1010 Introduction to Computing Lecture 11 (Boolean Algebra and Logic Circuits)

N/A
N/A
Protected

Academic year: 2020

Share "CS1010 Introduction to Computing Lecture 11 (Boolean Algebra and Logic Circuits)"

Copied!
91
0
0

Loading.... (view fulltext now)

Full text

(1)

1

CS1010 Introduction to Computing

Lecture 11

(2)

LEARNING GOALS FOR TODAY

• To become familiar with boolean algebra used by the microprocessors.

• To understand the NOT, AND, OR and XOR

(3)

WHY BINARY?

• Because this number system is natural to

microprocessor.

• In microprocessor the simplest element is switch, the switch has only two states i.e. ON or OFF.

• Binary number has only two numbers 1 & 0, so there is analogy between the operations of switches and the

binary number system.

(4)

INTRODUCTION

• Boolean algebra is useful in designing logic circuits, which are used by the processors.

• Boolean algebra deals with binary number system.

• Logic gates, are used to build up circuits of different types, for performing the necessary arithmetic

operations.

(5)

BOOLEAN ALGEBRA

• In mid-1800’s, George Boole, English mathematician, developed an algebra, which simplified manipulation of propositional logic.

• In the year 1938, Claude E. Shannon proposed the use of Boolean algebra in the design of relay switching

circuits.

(6)

Fundamentals Concepts in Boolean

Algebra

• Binary variables take on one of two values.

• Logical operators operate on binary values and binary variables.

Basic logical operators are the logic functions AND, OR

and NOT.

• Logic gates implement logic functions.

(7)

BINARY VARIABLES

• Recall that the two binary values have different names:

– True/False – On/Off

– Yes/No

– 1/0

• We use 1 and 0 to denote the two values.

• Variable identifier examples:

(8)

LOGICAL OPERATIONS

• The three basic logical operations are:

– AND – OR

– NOT

• AND is denoted by a dot (·)

• OR is denoted by a plus (+)

• NOT is denoted by an overbar ( ¯ ), a single

(9)

BOOLEAN OPERATOR PRECEDENCE

The order of evaluation is:

1

.

Parenthese

s

2

.

NO

T

3

.

AND

4

.

OR

Consequence: Parentheses appear

around OR expressions

(10)

NOTATION EXAMPLES

• Examples:

– is read “Y is equal to A AND B”

– is read “z is equal to x OR y”

– is read “X is equal to NOT A”

• Note: The statement:

1 + 1 = 2 (read “one plus one equals two”)

is not the same as

1 + 1 = 1 (read “1 or 1 equals 1”).

= A B

Y

y x

z = +

(11)

TRUTH TABLE

• It’s a table in which, we write all possible inputs and for all possible inputs, what are the

outputs.

• The rows in a truth table depends upon, the

variables, we have in a Boolean expression:

– 1 variable, 2¹ = 2 rows

– 2 variables, 2² = 4 rows

(12)

EXAMPLES

• Simplify these Boolean expressions by using

truth table:

a) z = (x + y) ׳ b) z = y . (x + y)

c) z = (y . x) + w

(13)

SOLUTION

z = (x + y) ׳

x y x + y (x + y) ׳

1 1 1 0

1 0 1 0

0 1 1 0

(14)

SOLUTION

z = y . (x + y)

x y x + y y . (x + y)

1 1 1 1

1 0 1 0

0 1 1 1

(15)

SOLUTION

z = (y . x) + w

x y w y . x (y . x) + w

1 1 1 1 1

1 1 0 1 1

1 0 1 0 1

1 0 0 0 0

0 1 1 0 1

0 1 0 0 0

0 0 1 0 1

(16)

SOLUTION

• F(X, Y, Z) = X Y + Y Z

X Y Z X Y Y Y Z F = X Y + Y Z

1 1 1 1 0 0 1

1 1 0 1 0 0 1

1 0 1 0 1 1 1

1 0 0 0 1 0 0

0 1 1 0 0 0 0

0 1 0 0 0 0 0

0 0 1 0 1 1 1

(17)

De-Morgan’s Law

• The complement of a sum of variables is equal to the product of the complements of the variables.

o X + Y = X · Y

• The complement of a product of variables is equal to the sum of the complements of the variables.

o X . Y = X + Y

• Proves this theorem by using truth table.

X Y X·Y X+Y X Y X+Y X · Y X·Y X+Y

1 1 1 1 0 0 0 0 0 0

1 0 0 1 0 1 0 0 1 1

0 1 0 1 1 0 0 0 1 1

(18)

Double Complement Law

X = X

• Proof this theorem by using truth table.

X X X

1 0 1

(19)

THEOREM

X . (X + Y) = X · Y

X Y X X+Y X · (X+Y) X·Y

1 1 0 1 1 1

1 0 0 0 0 0

0 1 1 1 0 0

0 0 1 1 0 0

(20)

EXAMPLE

X + X . Y = X + Y

X Y X X.Y X + (X.Y) X+Y

1 1 0 0 1 1

1 0 0 0 1 1

0 1 1 1 1 1

0 0 1 0 0 0

(21)

NOT OPERATOR

• The truth table for NOT operation.

• If input is true, the output is false and vice versa.

x x ׳

1 0

(22)

AND OPERATOR

• The truth table for AND operation.

• The output is true, if and only if both inputs are

true.

x y x . y

1 1 1

1 0 0

0 1 0

(23)

OR OPERATOR

• The truth table for OR operation.

• The output is true, if either of two inputs is true.

x y z = x + y

1 1 1

1 0 1

0 1 1

(24)

24

LAWS OF BOOLEAN ALGEBRA

Commutative Law

for addition and multiplication

Associative Law

for addition and multiplication

Distributive Law

(25)

Commutative Law

Commutative Law for Addition

A + B = B + A

Commutative Law for Multiplication

(26)

Associative Law(1)

Associative Law for Addition

(27)

Associative Law(2)

Associative Law for Multiplication

(28)

Distributive Law

Distributive Law

(29)

De-morgan’s Theorems

First Theorem

(30)
(31)

Minimization of Boolean Function

Boolean Algebra and Logic Gates 31

• A given Boolean function, the minimization of the number of literals, and the number of terms, will result in a circuit

with less components.

For Example: Equal Boolean Functions, F1 is more economical.

• F1 = x.y.z + x.y.z + x.y • F1 = x.y + x.z

(32)

EXAMPLE

• Simplify the following Boolean function to a minimum number of literals.

A + AB = A

L.H.S

= A + AB Given Statement

= A(1 + B) Factoring

= A . 1 Rule: 1 + B = 1

= A Rule: A . 1 = A

(33)

EXAMPLE

• Simplify the following Boolean function to a minimum number of literals.

x . ( x + y )

= x . ( x + y ) Given statement

= x . x + x . y Distributive Law

= 0 + x . y Complement Law

= x . y + 0 Commutative Law

(34)

EXAMPLE

• (A + B)(A + C) = A + BC

L.H.S

This rule can be proved as follows:

= (A + B)(A + C) = AA + AC + AB + BC Distributive law

= A + AC + AB + BC Rule: AA = A

= A( 1 + C) + AB + BC Rule: 1 + C = 1

= A. 1 + AB + BC

= A(1 + B) + BC Rule: 1 + B = 1

= A. 1 + BC Rule: A . 1 = A

= A + BC

(35)

Simplification using Boolean Algebra

• AB + A(B+C) + B(B+C)

= AB + AB + AC + BB +BC = AB + AC + B + BC

= AB + B + AC + BC = B(A + 1) + AC + BC = B(1) + AC + BC

(36)

Simplify: C+ BC

• C + BC Given

= C + ( B + C ) De-morgan’s Law

= (C + C )+ B Associative Law

= 1+B Apply A + A = 1

(37)

Simplify: AB( A+B)(B + B)

• AB( A+B)(B + B) Given

= AB( A+B) Apply A + A = 1

= (A +B)( A+B) De-morgan’s law

= A A+AB+B A+BB

= A+AB+B A Apply A.A = A & A.A = 0

= A+A(B+B ) Apply A + A = 1

= A +A Apply A + A = A

(38)
(39)

Simplify: A( A+B)+(B + AA)(A + B )

• A( A+B)+(B + AA)(A + B)

= AA + AB +(B + A) (A+B)

= AB + BA + BB + AA + AB

= AB + BA+ A+AB

= B(A + A) +A(1 + B)

(40)

EXAMPLE

• Apply DeMorgan's theorems to the expressions:

• XYZ

• X + Y + z

Solution:

XYZ = X + Y + Z

(41)

COMPLEMENT OF A FUNCTIONS

Use De-Morgan's Theorem:

1. Interchange AND and OR operators

2. Complement each constant and literal

Example:

Complement

F = x.y.z + x.y.z

(42)

EXAMPLE

F = x.y.z + x.y.z

• Apply De-Morgan’s theorem as many times as necessary, the complements are obtained as follows:

F = x.y.z + x.y.z = (x.y.z).(x.y.z)

(43)

EXAMPLE

F = x.(y.z + y.z)

• Apply De-Morgan’s theorem as many times as necessary, the complements are obtained as follows:

(44)

LOGIC GATES

• All operations within a computer are carried out by means of combinations of signals passing through standard blocks of built-in circuits. Which are known as gates.

• A logic gate is an electronic circuit, which operates on one or more inputs signals, to produce standard

output signals.

• Computer circuits are built up using combinations of different types of logic gates to perform necessary

(45)

AND Gate

• It is an electronic circuit, which generates an output signal 1, only if all inputs are also 1.

• Here two switches A and B are connected in series. It is obvious that the input current will reach the output point, only when both the switches are in ON(1) state.

• Two or more switches connected in series behave as an

AND gate.

(46)

AND GATE SYMBOL & BEHAVIOR

x y z = x . y

1 1 1

1 0 0

0 1 0

0 0 0

(47)

OR Gate

• It is an electronic circuit, which generates an output signal 1, if any of the input signals is also 1.

• The input current will reach the output, when any one of the two switches are in the ON(1) state. There will be no output when both the switches are in OFF(0) state.

• Two switches A and B are connected in parallel behave as an OR gate.

(48)

OR GATE SYMBOL & BEHAVIOR

x y z = x + y

1 1 1

1 0 1

0 1 1

0 0 0

(49)

NOT Gate

• It is physical realization of the complementation operation.

• It is an electronic circuit, which generates an output signal, which is reverse of the input signal.

(50)

NOT GATE SYMBOL & BEHAVIOR

NOT

x z = x

0 1

(51)

SWITCHING CIRCUITS

(52)

LOGIC CIRCUITS

• The logic gates are seldom used alone, but are used in combinations. They are interconnected to form combinational logic circuits.

• For these logic circuits, the Boolean algebra expression can be derived.

(53)

EXAMPLE

• Find the Boolean Expression of the logic circuit

given below:

D = A . (B + C) is the required Boolean expression for the output of given logic circuit.

A

B C

D

A

B + C

(54)

EXAMPLE

• Find the logic expression for the output produced by the logic circuit given below:

= (x + y)(x .y) is the required Boolean expression for the output of given logic circuit.

x + y

x. y

x.

y (x +

(55)

EXAMPLE

• Find the Boolean expression for the output of the logic circuit given below:

• Hence, (A + B) . C . D + (A + B) . C . D is the

required Boolean expression.

B A

C

D

A + B

C

D

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

(56)

Rules to form a COMBINATIONAL

CIRCUIT

1) To combine two inputs we will MUST use any

gate.

2) We can split input and use it for different gates. 3) The output of one gate can be use for input for

other gates.

4) The output of one gate CANNOT be used for

(57)

CONVERTING EXPRESSIONS TO LOGIC

CIRCUITS

• The reverse problem of constructing a logic circuit for a Boolean expression is also not difficult.

Example: Construct a logic circuit for the Boolean expression A . B + C

• The desired logic circuit.

A B C

A . B

(58)

EXAMPLE

• Construct a logic circuit for the Boolean expression: (A.B) + (C.D) + (E.F)

• The desired logic circuit is shown above.

A

B A.B A.B C

D E F

C.D

E.F

E.F

(59)

EXAMPLE

• Construct a logic circuit for the Boolean expression: (x + y) . (x + z) . (y + z)

• The desired logic circuit is show above.

y

z

x

x + y

x + z

y + z

(60)

EXAMPLE

• Construct a logic circuit for the Boolean expression: (x + y + z) . (x + y) . (x + y)

• The desired logic circuit shown above.

y

z

x

v

( x + y + z)

( x + y)

v

( x + y)

(61)

SUM OF PRODUCT(SOP)

• The following steps are followed to express a Boolean function in its sum-of-products form:

❖ From the given table, form a term for each

combination of the variables, which produces a 1 in the function.

(62)

Exercise:

Draw a circuit for a following

Input/output Table

INPUTS OUTPUT

P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 0

0 1 1 1

0 1 0 0

0 0 1 0

(63)

SOLUTION

INPUTS OUTPUT

P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 0

0 1 1 1

0 1 0 0

0 0 1 0

0 0 0 0

P . Q . R

P . Q . R

Sum these two terms:

(64)

CIRCUIT DIAGRAM

• Below is the circuit diagram of the Boolean expression:

(65)

EXERCISE

• Design a circuit by using Sum OF PRODUCT rule, to take input signals P, Q and R and output is 1 if, and

only if, P and Q have the same value and Q and R have opposite values.

Solution:

Step1: Draw a table

(66)

Boolean Expression is:

INPUTS OUTPUT

P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 0

0 1 1 0

0 1 0 0

0 0 1 1

0 0 0 0

P . Q . R

P . Q . R

(67)

CIRCUIT DIAGRAM

• Below is the circuit diagram of the Boolean expression:

(P . Q . R) +(P . Q . R)

v P Q R v v S v

(P . Q . R)

(P . Q . R) Q

R

(68)

PRODUCT-OF-SUM (POS)

• Product-Of-Sum (POS) canonical form:

Product of terms of entries that evaluate to ‘0’

x y z F term

0 0 0 1

0 0 1 1

0 1 0 0 M2 = (x + y + z)

0 1 1 1

1 0 0 0 M

4 = (x + y + z)

1 0 1 1

1 1 0 0 M

6 = (x + y + z)

1 1 1 1

Focus on the ‘0’ entries

(69)

CONVERTING SUM-OF-PRODUCT FORM

• A function that is not in the Sum-of-Products form can be converted to that form by means of a truth table.

x y z F Minterm

0 0 0 1 m0 = x y z

0 0 1 1 m1 = x y z

0 1 0 1 m2 = x y z

0 1 1 0

1 0 0 1 m4 = x y z

1 0 1 1 m5 = x y z

1 1 0 0

1 1 1 0

F = ∑(0, 1, 2, 4, 5) =

m0 + m1 + m2 + m4 + m5 =

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

(70)

• A function that is not in the Product-of-Sums form can be converted to that form by means of a truth table

x y z F Minterm

0 0 0 1

0 0 1 1

0 1 0 1

0 1 1 0 M3 = (x+y+z)

1 0 0 1

1 0 1 1

1 1 0 0 M

6 = (x+y+z)

1 1 1 0 M7 = (x+y+z)

F = ∏(3, 6, 7) =

M3 · M6 · M7 =

(x+y+z) (x+y+z) (x+y+z)

(71)

STANDARD FORMS

Standard Sum-of-Products (SOP) form: equations are written as an OR of AND terms

Standard Product-of-Sums (POS) form: equations are written as an AND of OR terms

Examples:

SOP:

POS:

These “mixed” forms are neither SOP nor POS

B C B A C B

A + +

C · ) C B (A · B)

(72)

Standard Sum-of-Products (SOP)

A Simplification Example:

Writing the minterm expression:

F = A B C + A B C + A B C + ABC + ABC

Simplifying:

F = A B C + A (B C + B C + B C + B C) F = A B C + A (B (C + C) + B (C + C)) F = A B C + A (B + B)

F = A B C + A F = A(B C + 1) F = ABC

Simplified F contains 3 literals compared to 15

(73)

AND/OR Two-Level Implementation

The two implementations for F are shown below

It is quite

(74)

Exclusive-OR

• Exclusive-OR, denoted by ⊕ is binary operator, which perform the following Boolean functions:

x y ≡ (x + y)(x.y)

Symbolically,

x y x ⊕ y

1 1 0

1 0 1

0 1 1

(75)

CIRCUIT DIAGRAM

x+y

x.y x.y

(x+y)(x.y)

(76)

• The exclusive-OR have many excellent

characteristics as candidate for logic gates.

• However, they are expensive to construct with

physical components. Usually constructed

internally with other standard gates.

• The exclusive-OR is useful in arithmetic

(77)

EXAMPLE

• A two-input, exclusive-OR function.

• Implementation of Exclusive-OR operation with AND/OR/NOT gates.

A

B

C A

B

A . B

A . B

(78)

HOW TO ADD BINARY NUMBERS

• Consider adding two 1-bit binary numbers x and

y.

– 0 + 0 = 0

– 0 + 1 = 1

– 1 + 0 = 1

– 1 + 1 = 10

Carry is x AND y

Sum is x XOR y

• The circuit to compute this is called a half-adder

x y Carry Sum

0 0 0 0

0 1 0 1

1 0 0 1

(79)

THE HALF-ADDER

Sum = x XOR y

(80)

DESIGN OF HALF-ADDER

Sum = x XOR y = (x + y)(x.y)

Carry = x AND y = x . y

x + y

x.y x.y

(x + y).(x.y)

(81)

USING HALF ADDERS

• We can then use a half-adder to compute the

sum of two Boolean numbers.

1 1 0 0 + 1 1 1 0 0 1 0 ?

(82)

HOW TO FIX THIS

• We need to create an adder that can take a carry bit as an additional input.

Inputs: x, y, carry in

Outputs: sum, carry out

• This is called a full adder

SUM: x.y.c + x.y.c + x.y.c + x.y.c = x y c

CARRY: x.y.c + x.y.c + x.y.c + x.y.c = x.y + x.c + y.c

– A full-adder can also be implemented with two half-adders and one OR gate.

x y c carry sum

1 1 1 1 1

1 1 0 1 0 1 0 1 1 0 1 0 0 0 1

0 1 1 1 0 0 1 0 0 1

0 0 1 0 1

(83)

S = xyc C = (xy).c

• Full-Adder can be Implemented by two

half-adders and one OR gate as shown:

HA

HA

C x

y

c

S = x.y + x.y = xy C = x . y

(84)
(85)

A PARALLEL BINARY ADDER

• Parallel binary adders are used to add two binary

numbers.

Example:

• If we want to add two four-bit numbers, we need to construct a parallel four-bit binary adder.

(86)

ADDING BIGGER BINARY NUMBERS

(87)

EXAMPLE

• Add two numbers say, 9 and 11.

• The Binary equivalent of decimal 9 is 1001. and that of decimal 11 is 1011.

• The final output of the system is 10100.

HA FA FA FA

1 1

1 1

0 0

0 1

0 0 1 0

1 1 0

carry carry carry

sum sum sum sum

carry

(88)

ADDING BIGGER BINARY NUMBERS

• A half adder has 4 logic gates.

• A full adder has two half adders plus a OR gate

– Total of 9 logic gates

• To add n bit binary numbers, you need 1 HA and n-1 FAs

• To add 32 bit binary numbers, you need 1 HA and 31 FAs

– Total of 4+9*31 = 283 logic gates

• To add 64 bit binary numbers, you need 1 HA and 63 FAs

(89)

MORE ABOUT LOGIC GATES

• To implement a logic gate in hardware, you use a transistor.

• Transistors are all enclosed in an “IC”, or

integrated circuit.

(90)

FLIP-FLOPS

• Consider the following circuit:

(91)

MEMORY

• A flip-flop holds a single bit of memory

– The bit “flip-flops” between the two NAND gates.

• In reality, flip-flops are a bit more complicated – Have 5 (or so) logic gates (transistors) per

flip-flop.

• Consider a 1 Gb memory chip.

– 1 Gb = 8,589,934,592 bits of memory. – That’s about 43 million transistors!

References

Related documents

I) Create a network of relevant cities, institutions and experts that actively exchange information and experience in the field of SUMP and promote SUMPs in general. II)

• Not only provide flexible fairness for VMs by balancing the tradeoff between bandwidth guarantee and proportional bandwidth share, but also maintain high network utilization

Digital electronics is classified into combinational logic and sequential logic. Combinational logic output depends on the inputs levels, whereas sequential

Other partners for this conference include the CAN-BIND research study, the Mood Disorders Associa- tion of Ontario, the Canadian Depression Research and Intervention Network

This study identified a functional binding site targeted by TROVE2, which was found significantly associated (adjusted p-value<10 -4 ) with the expression of proximal

• show understanding of Boolean algebra • show understanding of De Morgan's Laws • perform Boolean algebra using De Morgan's Laws • simplify a logic circuit/expression

Interestingly, among the 11 epitopes identified, only gp51N11 was capable of inducing CD8 + T cell-mediated cytotoxicity in all four calves, but it is not a suitable vaccine