42
Digital Electronics Number System By, Ravi Ghael

Digital electronics

Embed Size (px)

DESCRIPTION

Number system, 1's & 2's Complement, Boolean Algebra

Citation preview

Page 1: Digital electronics

Digital Electronics

Number System

By, Ravi Ghael

Page 2: Digital electronics

Common Number Systems

Page 3: Digital electronics

Conversion Among Bases

•The possibilities:

Decimal

Hexadecimal

Page 4: Digital electronics

2510 = 110012 = 318 = 1916

Page 5: Digital electronics

Decimal to Decimal

Hexadecimal

Decimal Octal

Binary

Page 6: Digital electronics

N=.. ++ ++ ……+

r=10 (decimal)

Page 7: Digital electronics

12510 => 5 x 100 = 52 x 101 = 201 x 102 = 100

125

Base

Weight

Page 8: Digital electronics

Binary to Decimal

Hexadecimal

Decimal Octal

Binary

Page 9: Digital electronics

Binary to Decimal

• Technique• Multiply each bit by 2n, where n is the “weight” of the bit• The weight is the position of the bit, starting from 0 on the

right• Add the results

Page 10: Digital electronics

Example

1010112 => (1 x 20)+(1 x 21)+(0 x 22)+(1 x 23)+(0 x 24)

+(1 x 25)

= 1+2+0+8+0+32

=

Bit “0”

Page 11: Digital electronics

Decimal to Binary

Hexadecimal

Decimal Octal

Binary

Page 12: Digital electronics

Decimal to Binary

• Technique• Divide by two, keep track of the remainder• First remainder is bit 0 (LSB, least-significant bit)• Second remainder is bit 1• Etc.

Page 13: Digital electronics

Example12510 = ?2

2 125 62 12 31 02 15 12 7 12 3 12 1 1

12510 = 11111012

Page 14: Digital electronics

Example:(0.31250.3125 x 2=0.625 0 MSB0.625 x 2=1.25 10.25 x 2=0.50 00.50 x 2=1.00 1 LSB

Ans.:- (0101

Page 15: Digital electronics

Binary Arithmetic:

Binary Addition:

• Two 1-bit values

A B A + B

0 0 00 1 11 0 11 1 10

“two”

Page 16: Digital electronics

Binary Addition

• Two n-bit values• Add individual bits• Propagate carries• E.g.,

10101 21+ 11001 + 25 101110 46

11

Page 17: Digital electronics

Binary Subtraction

Rules for binary subtraction are:0 – 0 = 01 – 0 = 11 – 1 = 00 – 1 = 1 , with 1 borrowed from the next columnEx 1: 1100101 – 100111

Verify the result in decimal system.

Solution:

(10011)2 = 1*24 + 1*21 + 1*20 = (19)10

Page 18: Digital electronics

18

Complements of Binary Numbers

• 1’s complements• 2’s complements

Page 19: Digital electronics

1’s and 2’s Complement:

The 1’s complement of a binary number is simply obtained by

replacing every 1 by 0 , and every 0 by 1.

The 2’s complement of a binary number can be obtained in

two ways:

By adding 1 to the 1’s complement.

Start the binary number from right. Leave the binary digits

unchanged until the first 1 appear, then replace every 1 by

0 , and every 0 by 1.

Page 20: Digital electronics

Complements of Binary Numbers

• 1’s complement• Change all 1s to 0s and all 0s to 1s

1 0 1 0 1 0 1 0

0 1 0 1 0 1 0 1

Page 21: Digital electronics

Ex 1: Obtain the two’s complement of the binary number 1011010.110

Second solution

First solution

Page 22: Digital electronics

Ex 2: Calculate the following binary Subtraction: 1101.101 – 11011.11 ,

then verify the result in decimal System.Solution

Page 23: Digital electronics

Basic Logic Gates

Page 24: Digital electronics

NOT Gate -- Inverter

X Y

01

10

X Y

Y

NOTX Y

Y = ~X

NOT

Page 25: Digital electronics

NOT

X ~X ~~X = X

X ~X ~~X0 1 01 0 1

Page 26: Digital electronics

AND GateAND

X

Y

Z

Z = X & Y

X Y Z0 0 00 1 01 0 01 1 1

Page 27: Digital electronics

OR Gate

OR

X

YZ

Z = X | Y

X Y Z0 0 00 1 11 0 11 1 1

Page 28: Digital electronics

NAND GateNAND

X

Y

Z

X Y Z0 0 10 1 11 0 11 1 0

Z = ~(X & Y)nand(Z,X,Y)

Page 29: Digital electronics

NAND Gate

NOT-AND

X

Y

Z

W = X & Y

Z = ~W = ~(X & Y)

X Y W Z0 0 0 10 1 0 11 0 0 11 1 1 0

W

Page 30: Digital electronics

NOR Gate

NOR

X

YZ

X Y Z0 0 10 1 01 0 01 1 0

Z = ~(X | Y)nor(Z,X,Y)

Page 31: Digital electronics

NOR Gate

NOT-OR

X

Y

W = X | Y

Z = ~W = ~(X | Y)

X Y W Z0 0 0 10 1 1 01 0 1 01 1 1 0

ZW

Page 32: Digital electronics

NAND Gate

X

Y

X

Y

Z Z

Z = ~(X & Y) Z = ~X | ~Y

=

X Y W Z0 0 0 10 1 0 11 0 0 11 1 1 0

X Y ~X ~Y Z0 0 1 1 10 1 1 0 11 0 0 1 11 1 0 0 0

Page 33: Digital electronics

De Morgan’s Theorem-1

~(X & Y) = ~X | ~Y

• NOT all variables• Change & to | and | to &• NOT the result

Page 34: Digital electronics

NOR Gate

X

YZ

Z = ~(X | Y)

X Y Z0 0 10 1 01 0 01 1 0

X

YZ

Z = ~X & ~Y

X Y ~X ~Y Z0 0 1 1 10 1 1 0 01 0 0 1 01 1 0 0 0

Page 35: Digital electronics

De Morgan’s Theorem-2

~(X | Y) = ~X & ~Y

• NOT all variables• Change & to | and | to &• NOT the result

Page 36: Digital electronics

De Morgan’s Theorem• NOT all variables• Change & to | and | to &• NOT the result• --------------------------------------------• ~X | ~Y = ~(~~X & ~~Y) = ~(X & Y)• ~(X & Y) = ~~(~X | ~Y) = ~X | ~Y• ~X & !Y = ~(~~X | ~~Y) = ~(X | Y)• ~(X | Y) = ~~(~X & ~Y) = ~X & ~Y

Page 37: Digital electronics

Exclusive-OR Gate

X Y ZXOR

X

YZ 0 0 0

0 1 11 0 11 1 0

Z = X ^ Yxor(Z,X,Y)

Page 38: Digital electronics

Exclusive-NOR Gate

X Y ZXNOR

X

YZ 0 0 1

0 1 01 0 01 1 1

Z = ~(X ^ Y)

Z = X ~^ Yxnor(Z,X,Y)

Page 39: Digital electronics

Boolean Algebra

• Boolean Algebra is a set of rules and theorems by which logical operations can be expressed mathematically.

Page 40: Digital electronics

Boolean Logic Operations

• AND function Y=A.B

• OR function Y=A+B

• NOT function Y=Ᾱ

Page 41: Digital electronics

Arithmetic of Boolean Algebra

• Boolean Addition | Boolean Multiplication 0+0=0 | 0.0=0 0+1=1 | 0.1=0 1+0=1 | 1.0=0 1+1=1 | 1.1=1

|

Page 42: Digital electronics

Basic Laws1. Commutative Property

A+B=B+A / A.B=B.A2. Associative Property

(A+B)+C=A+(B+C) / (A.B).C=A.(B.C) 3. Distributive Property

A+BC=(A+B)(A+C) / A.(B+C)=A.B+A.C4. Absorption Property

A+AB=A / A.(A+B)=A