Upload
ravighael
View
208
Download
3
Embed Size (px)
DESCRIPTION
Number system, 1's & 2's Complement, Boolean Algebra
Citation preview
Digital Electronics
Number System
By, Ravi Ghael
Common Number Systems
Conversion Among Bases
•The possibilities:
Decimal
Hexadecimal
2510 = 110012 = 318 = 1916
Decimal to Decimal
Hexadecimal
Decimal Octal
Binary
N=.. ++ ++ ……+
r=10 (decimal)
12510 => 5 x 100 = 52 x 101 = 201 x 102 = 100
125
Base
Weight
Binary to Decimal
Hexadecimal
Decimal Octal
Binary
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
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”
Decimal to Binary
Hexadecimal
Decimal Octal
Binary
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.
Example12510 = ?2
2 125 62 12 31 02 15 12 7 12 3 12 1 1
12510 = 11111012
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
Binary Arithmetic:
Binary Addition:
• Two 1-bit values
A B A + B
0 0 00 1 11 0 11 1 10
“two”
Binary Addition
• Two n-bit values• Add individual bits• Propagate carries• E.g.,
10101 21+ 11001 + 25 101110 46
11
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
18
Complements of Binary Numbers
• 1’s complements• 2’s complements
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.
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
Ex 1: Obtain the two’s complement of the binary number 1011010.110
Second solution
First solution
Ex 2: Calculate the following binary Subtraction: 1101.101 – 11011.11 ,
then verify the result in decimal System.Solution
Basic Logic Gates
NOT Gate -- Inverter
X Y
01
10
X Y
Y
NOTX Y
Y = ~X
NOT
NOT
X ~X ~~X = X
X ~X ~~X0 1 01 0 1
AND GateAND
X
Y
Z
Z = X & Y
X Y Z0 0 00 1 01 0 01 1 1
OR Gate
OR
X
YZ
Z = X | Y
X Y Z0 0 00 1 11 0 11 1 1
NAND GateNAND
X
Y
Z
X Y Z0 0 10 1 11 0 11 1 0
Z = ~(X & Y)nand(Z,X,Y)
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
NOR Gate
NOR
X
YZ
X Y Z0 0 10 1 01 0 01 1 0
Z = ~(X | Y)nor(Z,X,Y)
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
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
De Morgan’s Theorem-1
~(X & Y) = ~X | ~Y
• NOT all variables• Change & to | and | to &• NOT the result
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
De Morgan’s Theorem-2
~(X | Y) = ~X & ~Y
• NOT all variables• Change & to | and | to &• NOT the result
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
Exclusive-OR Gate
X Y ZXOR
X
YZ 0 0 0
0 1 11 0 11 1 0
Z = X ^ Yxor(Z,X,Y)
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)
Boolean Algebra
• Boolean Algebra is a set of rules and theorems by which logical operations can be expressed mathematically.
Boolean Logic Operations
• AND function Y=A.B
• OR function Y=A+B
• NOT function Y=Ᾱ
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
|
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