Esc201: Introducton To Electronics: Number System and Logic Gates

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

ESc201 : Introducton to Electronics

Number System and Logic Gates

Dept. of Electrical Engineering


IIT Kanpur

1
Numbers

Every number system is associated with a base or radix

A positional notation is commonly used to express numbers

5 4 3 2 1 0
(a5 a4 a3a2 a1a0 ) r  a5 r  a4 r  a3r  a2 r  a1r  a0 r
The decimal system has a base of 10 and uses symbols
(0,1,2,3,4,5,6,7,8,9) to represent numbers

3 2 1 0
(2009)10  2 10  0 10  0 10  9 10

2 1 0 1 2
(123.24)10  110  2 10  3 10  2 10  4 10
2
Numbers

An octal number system has a base 8 and uses symbols


(0,1,2,3,4,5,6,7)

3 2 1 0
(2007)8  2 8  0 8  0 8  7 8

What decimal number does it represent?

1 0
(2007)8  2 512  0 64  0 8  7 8 1033

(2007)8   1033 10
3
Number Symbol
Numbers
0 0
1 1
A hexadecimal system has a base of 16
2 2
3 3
4 4
(2 BC 9)16  2 163  B 16 2  C 161  9 160
5 5
6 6
How do we convert it into decimal number? 7 7
1 8 8
(2 BC 9)16  2 4096  11256  12 16 9 9
 9 160 11209 10 A
11 B
12 C

(2 BC 9)16   11209  10 13
14
D
E
15 F 4
A Binary system has a base 2 and uses only two symbols 0, 1
to represent all the numbers 2 1 0

3 2 1 0 21 2
(1101) 2  12  12  0 2  12
22 4

Which decimal number does this 23 8


correspond to ? 24 16

1 0 25 32
(1101) 2  18  14  0 2  12 13 26 64
27 128
1101.1001 28 256
2-4 29 512
23
-2 2-3
2 2
2 1
2 0
2-1 2 210 1024(K)
220 1048576(M)
13. 5625
2-1 2-2 2-3 2-4 2-5 2-6

0.5 0.25 0.125 0.0625 0.03125 0.015625 5


Developing Fluency with Binary Numbers

11001 = ? 25

1100001 = ? 64+32+1=97

0.101 = ? 0.5+0.125=0.625

11.001 = ? 3+0.125=3.125
6
Converting decimal to binary number
Convert 45 to binary number

(45)10  bnbn  1.......b0


n n 1 1
45  bn 2  bn  1 2 .......  b1 2  b0
Divide both sides by 2
45 n 1 n 2 0
22.5  bn 2  bn  1 2 .......  b1 2  b0 0.5
2
n 1 n 2 0
22  0.5  bn 2  bn  1 2 .......  b1 2  b0 0.5

 b0 1 7
22  0.5  bn 2 n 1
 bn  1 2 .......  b1 2  b0 0.5  b0 1
n 2 0

n 1 n 2 1 0
22  bn 2  bn  1 2 .......  b2 2  b1 2
Divide both sides by 2

22 n 2 n 3 0
11  bn 2  bn  1 2 .......  b2 2  b1 0.5  b1 0
2
n 2 n 3 1 0
11  bn 2  bn  1 2 ......  b3 2  b2 2

5.5  bn 2n  3  bn  1 2n  4......  b3 20  0.5b2  b2 1


n 3 n 4 1 0
5  bn 2  bn  1 2 ......  b4 2  b3 2 8
n 3 n 4 1 0
5  bn 2  bn  1 2 ......  b4 2  b3 2
2.5  bn 2 n 4
 bn  1 2 ......  b4 2  0.5b3  b3 1
n 5 0

n 4 n 5 1 0
2  bn 2  bn  1 2 ......  b5 2  b4 2
n 5 n 6 0
1  bn 2  bn  1 2 ......  b5 2  0.5b4  b4 0

 b5 1

(45)10  b5b4b3b2b1b0 101101


9
Converting decimal to binary number

Method of successive division by 2

45 remainder
22 1
11 0
5 1 45 = 101101
2 1
1 0
0 1 44 = 101100
10
Converting decimal to binary number
Convert (0.35)10 to binary number

(0.35)10  0.b 1b 2b 3 .......b n


1 2 n
0.35  0  b 1 2  b 2 2  .......b n 2
How do we find the b-1 b-2 …coefficients?

Multiply both sides by 2

1  n 1
0.7  b 1  b 2 2  .......b n 2  b 1 0
1 2  n 1
0.7  b 2 2  b 3 2  .......b n 2
11
1 2  n 1
0.7  b 2 2  b 3 2  .......b n 2
Multiply both sides by 2

1
1.4  b 2  b 3 2  .......b n 2  n 2
 b 2 1
Note that ½+1/4+1/8+……1
1 2  n 2
0.4  b 3 2  b 4 2 .......b n 2
1
0.8  b 3  b 4 2 .......b n 2  n 3  b 3 0

12
Converting decimal to binary number
0.125 = ?
0 . 125
x2
0. 25
x2
0. 5
0.125 = (.001)2 x2
1. 0

0 . 8125
0.8125 = ?
x2
1. 625
x2
1. 25
x2
0.8125 = (.1101)2 0. 5
x2
1. 0 13
decimal 2bit 3bit 4bit 5bit
Binary numbers
0 00 000 0000 00000
1 01 001 0001 00001
Most significant bit or MSB
2 10 010 0010 00010

Least significant bit or LSB 3 11 011 0011 00011


4 100 0100 00100
5 101 0101 00101
1011000111 6 110 0110 00110
7 111 0111 00111
8 1000 01000

Binary digit = bit 9 1001 01001


10 1010 01010
This is a 10 bit number 11 1011 01011
12 1100 01100
N-bit binary number
can represent numbers 13 1101 01101
from 0 to 2N -1 14 1110 01110
15 1111 01111
14
Binary Addition/Subtraction
1
0
1
0 1
0 1 1

101 1101
110 + 1110
1011 11011

15
Complement of a binary number

1’s complement
Binary system:
2’s complement

1’s complement of n-bit number x is 2n -1 -x

2’s complement of n-bit number x is 2n -x


4
1’s complement of 1011 ? 2  1  1011 1111  1011 0100
1’s complement is simply obtained by flipping a bit
(changing 1 to 0 and 0 to 1)

1's complement of 1001101 = ?


0110010 16
2's complement of 1010 = 1's complement of 1010+1
0101  1 0110
2's complement of 110010 =
Leave all least significant 0’s as they are, leave first 1 unchanged
and then flip all subsequent bits

001110

1011  0101

101101100  010010100
17
Advantages of using 2’s complement

x1 S
Adder
x2 CY

10 – 6 = ? 1010   1010  2 610   0110  2

2's complement of 0110=1010


If Carry is 1; then number you get is
1010 positive

+1010  0100  2  410


10100 Answer is +4
18
Advantages of using 2’s complement
x1 S
Adder
x2 CY

6 – 10 = ? 610   0110  2 1010   1010  2


2's complement of 1010=0110
If Carry is 0; then number you get is negative
0110 Take the 2’s complement of number
+0110 2's complement of 1100=0100
01100
 0100  2  410 19

Answer is -4
Representing positive and negative binary numbers
One extra bit is required to carry sign information. Sign bit = 0 represents positive
number and Sign bit = 1 represents negative number
decimal Signed decimal Signed 1’s decimal Signed 2’s
Magnitude complement complement
0 0000 -1 1110 -1 1111
1 0001 -2 1101 -2 1110
2 0010 -3 1100 -3 1101
3 0011 -4 1011 -4 1100
4 0100 -5 1010 -5 1011
5 0101 -6 1001 -6 1010
6 0110 -7 1000 -7 1001
7 0111
-0 1000
-1 1001
-2 1010
-3 1011
-4 1100
-5 1101
-6 1110
-7 1111 20
Example

0101 0101
+5 +0010 +5 +1110
+2 -2
0111 +3 0011
+7

1011 1011
-5 +0010 -5 +1110
+2 -2
-3 1101 -7 1001

2’s complement is 011 = 3 2’s complement is 111 = 7


21
Example

2’s complement is 11111001:


00000111= 7
22
Boolean Algebra

Algebra on Binary numbers


False
A variable x can take two values {0,1} 0 No
Low voltage
Basic operations:
True
AND: y = x1. x 2 1 Yes
High voltage
y is 1 if and only if both x1 and x2 are 1, otherwise zero
x1 x2 y
0 0 0
Truth Table 0 1 0
1 0 0
1 1 1 23
Basic operations:
OR: y = x1 + x 2
y is 1 if either x1 or x2 is 1. y= 0 if and only if both variables are
zero x x y
1 2

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

x y
NOT: y = x
0 1
1 0
24
Boolean Algebra
Basic Postulates
P1.a: x + 0 = x P1.b: x . 1 = x Identity element
P2.a: x +y = y+x P2.b: x . y = y . x Commutative

P3.a: x.(y+z) = x.y+x.z P3.b: x+y.z = (x+y).(x+z)Distributive


P4.a: x + x = 1 P4.b: x . x = 0 Complement

Basic Theorems
T1.a: x + x = x T1.b: x . x = x
T2.a: x + 1 = 1
T2.b: x . 0 = 0
T3.a: ( x ) = x
T4.b: x . (y.z) = (x.y).z
T4.a: x + (y+z) = (x+y)+z
T5.b: (x.y) = x + y (DeMorgan
T5.a: (x+y) = x . y (DeMorgan's theorem)
T6.a: x+ x.y = x T6.b: x.( x+y) = x 25
Proving Theorems P1.a: x + 0 = x P1.b: x . 1 = x
P2.a: x + y = y + x P2.b: x . y = y . x
P3.a: x.(y+z) = x.y+x.z P3.b: x+y.z = (x+y).(x+z)
P4.a: x + x = 1 P4.b: x . x = 0

Prove T1.a: x + x = x Prove T1.b: x . x = x


x + x = (x+x). 1 (P1.b) x . x = x.x+ 0 (P1.a)
= (x+x). (x+x) (P4.a) = x.x + x.x (P4.b)
= x + x.x (P3.b) = x . (x+x ) (P3.a)
=x+0 (P4.b) =x.1 (P4.a)
=x (P1.a) =x (P1.b)
26
Proving Theorems P1.a: x + 0 = x P1.b: x . 1 = x
P2.a: x + y = y + x P2.b: x . y = y . x
P3.a: x.(y+z) = x.y+x.z P3.b: x+y.z = (x+y).(x+z)
P4.a: x + x = 1 P4.b: x . x = 0

Prove : x + 1 = 1 x + x .y = x
x + 1 = x+(x+ x) = x . 1 + x. y
= x. (1+ y)
= (x+x)+ x
=x.1
=x+x =x
=1

DeMorgan’s Theorem (x1  x 2  x 3  ....)  x1 . x 2 .x 3 .

(x1. x 2 . x 3 .....)  ( x1 + x 2  x 3 +.....)


27

You might also like