Boolean Algebra and Logic Gates CSE-1108 Ahsanullah University of Science and Technology (AUST)

Preview:

Citation preview

Boolean Algebra and Logic Gates

CSE-1108

Ahsanullah University of Science and Technology (AUST)

2

Have you ever asked yourself?

1. How does a computer adds/ subtract/ multiply/ divide two (or more) numbers? Does it have a brain like human?

2. How does computer stores something? (Documents, songs, movies etc.) Does it have a memory like human?

Answer 01: Logic gates and circuits.

Answer 02: Logic gates and circuits.

3

What is Logic Gate?

Logic gates are electronic circuits that operates on one or more input signals to produce standard output signals.

Are the building blocks of all the circuits in a computer.

Some of the most useful and basic logic gates are AND, OR, NOT, NAND and NOR gates.

Logic Gate Implementation

Using Switches Inputs:

logic 1 is switch closed

logic 0 is switch open Outputs:

logic 1 is light on

logic 0 is light off. NOT input:

logic 1 is switch open

logic 0 is switch closed

Switches in series => AND

Switches in parallel => OR

CNormally-closed switch => NOT

Logic Gate ImplementationIn the earliest computers, switches were

opened and closed by magnetic fields

produced by energizing coils in relays. The

switches in turn opened and closed the current

paths.

Later, vacuum tubes that open and close

current paths electronically replaced relays.

Today, transistors are used as electronic

switches that open and close current paths.

What is Boolean Algebra?

We need operator and operands in an Algebra.

In Boolean algebra, operands are called binary variables.

Operators are called Logical Operators.

Basic logical operators are the logic functions AND, OR and NOT.

Logic gates implement logic functions.

Boolean Algebra is a useful mathematical system for specifying and transforming logic functions.

We study Boolean algebra as a foundation for designing and analyzing digital systems!

7

Basic logic gates

Not

And

Or

Nand

Nor

Xor

xx

xy

xy xy

xyz

zx+yx

yxy

x+y+z

z

xy

xy

x+yxy

xÅyxy

Truth TablesTabular listing of the values of a function for all possible combinations of values on its argumentsExample: Truth tables for the basic logic operations:

01

10

X

NOT

XZ=

111

001

010

000

Z = X·YYX

AND OR

X Y Z = X+Y

0 0 0

0 1 1

1 0 1

1 1 1

Truth Tables – Cont’d

Used to evaluate any logic function

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

X Y Z X Y Y Y Z F = X Y + Y Z0 0 0 0 1 0 00 0 1 0 1 1 10 1 0 0 0 0 00 1 1 0 0 0 01 0 0 0 1 0 01 0 1 0 1 1 11 1 0 1 0 0 11 1 1 1 0 0 1

Logic Diagrams and Expressions

Boolean equations, truth tables and logic diagrams describe the same function!Truth tables are unique, but expressions and logic diagrams are not. This gives flexibility in implementing functions.

X

Y F

Z

Logic Diagram

Logic Equation

ZY X F +=

Truth Table

11 1 1

11 1 0

11 0 1

11 0 0

00 1 1

00 1 0

10 0 1

00 0 0

X Y Z Z Y X F ×+=

Boolean Algebra

1.

3.

5.

7.

9.

11.

13.

15.

17.

Commutative

Associative

Distributive

DeMorgan’s

2.

4.

6.

8.

X . 1 X=

X . 0 0=

X . X X=

0=X . X

10.

12.

14.

16.

X + Y Y + X=

(X + Y) Z+ X + (Y Z)+=

X(Y + Z) XY XZ+=

X + Y X . Y=

XY YX=

(XY) Z X(Y Z)=

X + YZ (X + Y) (X + Z)=

X . Y X + Y=

X + 0 X=

+X 1 1=

X + X X=

1=X + X

X = X

Invented by George Boole in 1854 An algebraic structure defined by a set B = {0, 1}, together with two

binary operators (+ and ·) and a unary operator ( )

Idempotence

Complement

Involution

Identity element

Boolean Operator Precedence

The order of evaluation is:

1. Parentheses2. NOT3. AND4. OR

Consequence: Parentheses appear around OR expressions

Example: F = A(B + C)(C + D)

13

Logic Circuit to Boolean expression

Find the output of the following circuit

Answer: (x+y)y Or (xy)y

xy

x+y

y

(x+y)y

__

xy

y

14

x

y

Logic Circuit to Boolean expression

Find the output of the following circuit

Answer: xy Or (xy) ≡ xy

x

y

x y x y

_ _ ___

15

Boolean expression to Logic Circuit

Write the circuits for the following Boolean algebraic expressions

a) x+y

xyxyxy

__

x x+y

16

xyxyxy

Boolean expression to Logic Circuit

Write the circuits for the following Boolean algebraic expressions

b) (x+y)x_______

xy

x+yx+y (x+y)x

17

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 Sum0 0 0 00 1 0 11 0 0 11 1 1 0

18

The half-adder

Sum = x XOR y

Carry = x AND y

xy Sum

Carry

19

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 0010?

001

20

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 Will add x and y with a half-adder Will add the sum of that to the

carry in

What about the carry out? It’s 1 if either (or both): x+y = 10 x+y = 01 and carry in = 1

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

0 0 0 0 0

21

The full adder

The “HA” boxes are half-adders

HAX

Y

S

C

HAX

Y

S

C

xy

c

c

s

HAX

Y

S

C

HAX

Y

S

C

xy

c

22

The full adder

The full circuitry of the full adder

xy

s

c

c

Recommended