0% found this document useful (0 votes)
116 views56 pages

GATE - DL Number Systems

Uploaded by

palak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views56 pages

GATE - DL Number Systems

Uploaded by

palak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

Digital Logic

ELTP-GATE 1 GATE-CSE-16
Digital Logic

1. Number Representation and Computer Arithmetic


2. Boolean Algebra
3. Minimization of Boolean Functions
4. Logic Gates
5. Design and Synthesis of Combinational Circuits,
Arithmetic Circuits, Code Converters, Multiplexers,
Decoders, PROMs and PLAs.
6. Design and Synthesis Sequential Circuits, Latches
and Flip-Flops, Counters and Shift-Registers.

ELTP-GATE 2 GATE-CSE-16
Number Systems
&
Data Representation

ELTP-GATE 3 GATE-CSE-16
Introduction
Computer words are composed of bits, thus words can be
represented as binary numbers

9 How are negative numbers represented?


9 What is the largest number that can be represented in a
computer word
9 What happens if an operation creates a number bigger than
can be represented?
9 How does hardware really add, subtract, multiply, or divide
numbers?

ELTP-GATE 4 GATE-CSE-16
Number Systems
1. Positional Notation
N = (an-1an-2 ... a1a0 . a-1a-2 ... a-m)b
where . = radix point
b= radix or base
n = number of integer digits to the left of the radix point
m = number of fractional digits to the right of the radix point
an-1 = most significant digit (MSD)
a-m = least significant digit (LSD)
2. Polynomial Notation (Series Representation)
n −1
N = ∑
i= − m
a ib i
ai=integer in range (0<= ai <=b-1)

ELTP-GATE 5 GATE-CSE-16
Number Systems (Cont’d)
1. Binary numbers
– Digits = {0, 1}
– (11010.11)2 = 1 x 24 + 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20 + 1 x 2-1 + 1 x 2-2
= (26.75)10
– 1 K (kilo) = 210 = 1,024, 1M (mega) = 220 = 1,048,576,
1G (giga) = 230 = 1,073,741,824
2. Octal numbers
– Digits = {0, 1, 2, 3, 4, 5, 6, 7}
– (127.4)8 = 1 x 82 + 2 x 81 + 7 x 80 + 4 x 8-1 = (87.5)10
3. Hexadecimal numbers
– Digits = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
– (B65F)16 = 11 x 163 + 6 x 162 + 5 x 161 + 15 x 160 = (46,687)10

ELTP-GATE 6 GATE-CSE-16
Number Systems (Cont’d)
Important Number Systems

Decimal Binary Octal Hexadecimal


0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10

ELTP-GATE 7 GATE-CSE-16
Number Systems (Cont’d)

Complement of a digit A
A’=(b-1)-A

In base 10 9’s Complement


In base 2 1’s Complement

ELTP-GATE 8 GATE-CSE-16
Base Conversion

Convert a number from b1 to b2

Case I: b1<b2

base-b2 arithmetic can be used

Case II: b1>b2

base-b1 arithmetic can be used

ELTP-GATE 9 GATE-CSE-16
Base Conversion (1)
1. Series Substitution Method

– Expanded form of polynomial representation:

N = an-1rn-1 + … + a0r0 + a-1r-1 + … + a-mr-m

Conversation Procedure (base b1 to base b2)

• Represent the number in base b1 in the above format .

• Evaluate the series using base b2 arithmetic.

ELTP-GATE 10 GATE-CSE-16
Base Conversion (2)
Examples 1:

(11010)2 ®( ? )10 Case I: b1<b2


(base-b2 arithmetic can be used)
N = 1´24 + 1´23 + 0´22 + 1´21 + 0´20

= (16)10 + (8)10 + 0 + (2)10 + 0

= (26)10

Examples 1:

(627)8 ® ( ? )10 Case I: b1<b2

(base-b2 arithmetic can be used)


N = 6´82 + 2´81 + 7´80

= (384)10 + (16)10 + (7)10

= (407)10

ELTP-GATE 11 GATE-CSE-16
Base Conversion (3)
2. Radix Divide Method
Examples
(315)10 = (473)8 b1>b2
Case II:
base-b1 arithmetic can be used

8 315 3 LSD
8 39 7
8 4 4 MSD
0

ELTP-GATE 12 GATE-CSE-16
Base Conversion (4)
3. Radix Multiply Method Case II: b1>b2
Examples 1: base-b1 arithmetic can be
(0.479)10 = (0.3651…)8
MSD 3.832 ← 0.479 × 8
used
6.656 ← 0.832 × 8
5.248 ← 0.656 × 8
LSD 1.984 ← 0.248 × 8

Examples 2:
(0.479)10 = (0.0111…)2
MSD 0.9580 ← 0.479 × 2
1.9160 ← 0.9580 × 2
1.8320 ← 0.9160 × 2
LSD 1.6640 ← 0.8320 × 2

ELTP-GATE 13 GATE-CSE-16
Base Conversion (4)
General Conversion Algorithm

Algorithm 1

To convert a number N from base b1 to base b2, use

(a) the series substitution method with base b2 arithmetic, or

(b) the radix divide or multiply method with base b1 arithmetic.

ELTP-GATE 14 GATE-CSE-16
Base Conversion (5)
General Conversion Algorithm

Algorithm 2

To convert a number N from base b1 to base b2, use

(a) the series substitution method with base 10 arithmetic to convert N


from base b1 to base 10, and

(b) the radix divide or multiply method with decimal arithmetic to convert
N from base 10 to base b2.

ELTP-GATE 15 GATE-CSE-16
Base Conversion (6)
Example
(18.6)9 = ( ? )11

(a) Convert to base 10 using series substitution method:

N10 = 1 × 91 + 8 × 90 + 6 × 9-1
= 9 + 8 + 0.666…
= (17.666…)10
(b) Convert from base 10 to base 11 using radix divide and multiply
method:
. 7.326 ← 0.666 × 11
11 17 6
11 1 1 3.586 ← 0.326 × 11
0 6.446 ← 0.586 × 11

N11 = (16.736 …)11

ELTP-GATE 16 GATE-CSE-16
Base Conversion (7)

Algorithm 3

When b2 = b1k

Examples

– (001 010 111. 100)2 = (127.4)8 (group bits by 3)

– (1011 0110 0101 1111)2 = (B65F)16 (group bits by 4)

ELTP-GATE 17 GATE-CSE-16
Q1.
(1217)8 is equivalent to
(A)(1217)16
(B)(028F)16
(C)(2297)10
(D)(0B17)16

ELTP-GATE 18 GATE-CSE-16
Q2.

ELTP-GATE 19 GATE-CSE-16
Q3.
The hexadecimal representation of 6578 is:
(A)19B2
(B)D782
(C)D712
(D)32F3

ELTP-GATE 20 GATE-CSE-16
Q4.
Given √(224)r = (13)r The value of the radix r is:
(A)10
(B)8
(C)5
(D) 6

ELTP-GATE 21 GATE-CSE-16
Q5.
Let r denote number system radix. The only value(s) of
r satisfy the equation √(121)r =(11)r is/are
(A)decimal 10
(B)decimal 11
(C)Decimal 10 & 11
(D) any value>2

ELTP-GATE 22 GATE-CSE-16
Q6.
If 73x (in base x number system) is equal to 54y (in base y number
system), the possible values of x and y are
(A)8,16
(B)10,12
(C)9,13
(D) 8,11

ELTP-GATE 23 GATE-CSE-16
Number Representation

ELTP-GATE 24 GATE-CSE-16
Negative Number Representation

Options
– Sign-magnitude
– One’s Complement
– Two’s Complement

ELTP-GATE 25 GATE-CSE-16
Sign and Magnitude Representation
9 Computer programs calculate both positive & negative numbers and thus the number
representation has to distinguish both

9 In sign and magnitude representation, a single bit is designated either on the left or
the right of the number to indicate its sign

Example:

(+ 13)10 = (01101)2 sign/magnitude (- 13) 10 = (11101)2 sign/magnitude

ELTP-GATE 26 GATE-CSE-16
Sign-magnitude

Problem +0 000

– Representing zeros? +1 001


– Do not work in computation
+2 010

+3 011

-3 111

-2 110

-1 101

-0 100

ELTP-GATE 27 GATE-CSE-16
One’s Complement (Diminished radix complements)

• Complement (flip) each bit in a binary +0 000


number +1 001
• Problem
+2 010
– Representing zeros?
+3 011

-3 100

-2 101

-1 110

-0 111

ELTP-GATE 28 GATE-CSE-16
Two’s Complement Representation

q The two's complement of a number X represented in n bits is 2n - X

q Negative numbers would always have a one in the most significant bit
Æ easy to be tested by hardware

ELTP-GATE 29 GATE-CSE-16
Two’s Complement (Radix complements)

• Complement (flip) each bit in a binary number and adding 1,


1 with
overflow ignored
• Work in computation perfectly 0 000

+1 001

100 -1 111

One’s complement +2 010

011 -2 110
Add 1
+3 011
100
-3 101

-4 100

ELTP-GATE 30 GATE-CSE-16
Quick negation for Two's Complement
Method 1:
• Convert every 1Æ0 and every 0Æ1 and then add 1 to the rest
Method 2:
•Move from right to left leave every leading 0's until reaching the first 1
•Convert every 0Æ1 and 1Æ0 afterward until reaching the right end
Example: Negate (2)10
(2) 10 = (0000 0000 0000 0000 0000 0000 0000 0010)2

Method 1: 1111 1111 1111 1111 1111 1111 1111 1101


+ 1
------------------------------------------------------------
1111 1111 1111 1111 1111 1111 1111 1110

Method 2: 0000 0000 0000 0000 0000 0000 0000 0010

1111 1111 1111 1111 1111 1111 1111 1110

ELTP-GATE 31 GATE-CSE-16
Range of Numbers
An N-bit number
N
– Unsigned: 0 .. (2 -1)
N-1 N-1
– Signed: -2 .. (2 -1)

Example: 4-bit
0000 (0) Unsigned numbers 1111 (15)

1110 (-8) 0111 (7)


Signed numbers

ELTP-GATE 32 GATE-CSE-16
Schematic representation of 4-bit 2’s-complement code for
integers in [–8, +7].

ELTP-GATE 33 GATE-CSE-16
Sign extension

When loading numbers in a wide register, the empty bits will be filled with the
value of the sign bit

For example, going from 4-bit to 8-bit numbers:


0101 (+5) should become 0000 0101 (+5).
But 1100 (-4) should become 1111 1100 (-4).

Example: Convert 8-bit versions of (2)10 and (-2)10 to 16-bits


binary numbers

ELTP-GATE 34 GATE-CSE-16
Computer Arithmetic

ELTP-GATE 35 GATE-CSE-16
Unsigned Arithmetic (Addition) without overflow
010001 (17=16+1)
101011 (43=32+8+2+1)
--------------------------------
111100 (60=32+16+8+4)

ELTP-GATE 36 GATE-CSE-16
Unsigned Arithmetic (Addition) with overflow

Unsigned arithmetic
101111 (47)
The carry is 011111 (31)
Not discarded ---------------
1001110 (78) Due to overflow, note that
78 cannot be represented
by a 6-bit unsigned number)

ELTP-GATE 37 GATE-CSE-16
Signed Arithmetic (Addition) without overflow

Signed arithmetic (w/ 2’s complement)


010001 (17=16+1)
101011 (-21: 2’s complement=010101=21)
---------------
111100 (2’s complement=000100=4, i.e. -4)

ELTP-GATE 38 GATE-CSE-16
Add : 4 Combinations
9 (-9)
Negative / Positive
Positive / Positive + 5 + 5
14 -4

9 (-9)
Positive / Negative + (-5) Negative / Negative + (-5)
4 - 14

ELTP-GATE 39 GATE-CSE-16
Sub : 4 Combinations
9 (-9)
Positive / Positive - 5 Negative / Positive - 5
4 - 14

9 (-9)
Positive / Negative - (-5) Negative / Negative - (-5)
14 - 4

ELTP-GATE 40 GATE-CSE-16
Compare Signed Number

For signed comparisons, the S(Sign) and OF(overflow) , taken


together, have the following meaning;

If ((S=0) and (OF=1)) or ((S=1) and (OF=0)) then

Oprnd1 < Oprnd2

If ((S=0) and (OF=0)) or ((S=1) and (OF=1)) then

Oprnd1 >= Oprnd2

ELTP-GATE 41 GATE-CSE-16
Compare Signed Number

Consider the following examples: Assume 8 bits signed number


Oprnd1 minus Oprnd2 Sign OF
Op1 >= Op2 FF(-1) - FE (-2) 0 0
Op1 < Op2 80(-128) - 01(+1) 0 1
Op1 < Op2 FE (-2) - FF (-1) 1 0
Op1 >= Op2 7F(127) - FF (-1) 1 1

ELTP-GATE 42 GATE-CSE-16
Binary Code
Type of code

1. Weighted Code(arithmetic code) : Each Binary digit is


assigned a weight whose digit is 1 is equal to the decimal
digit which they represent.

N=w4x4+w3x3+w2x2+w1x1

Binary Sequence => x4x3x2x1

Weight => w4w3w2w1

Example : 8421(BCD),2421,642-3 etc.

ELTP-GATE 43 GATE-CSE-16
Binary Code

Type of code

2. Non-weighted Code: not an arithmetic code.

Example : Excess-3 ,Cyclic code(Gray code) etc.

ELTP-GATE 44 GATE-CSE-16
Binary Code (Non-weighted Code)
Cyclic code => In which all successive codeword differ in
only one digit
Example : Gray code (reflected code)
Decimal Binary Gray Code Decimal Binary Gray code
0 0000 0000 8 1000 1100
1 0001 0001 9 1001 1101
2 0010 0011 10 1010 1111
3 0011 0010 11 1011 1110
4 0100 0110 12 1100 1010
5 0101 0111 13 1101 1011
6 0110 0101 14 1110 1001
7 0111 0100 15 1111 1000

ELTP-GATE 45 GATE-CSE-16
Self complement code

Self complementing can be obtained from the code


word of N using (b-1)-N

Weighted code to be self complemented code is that


the sum of the weights must equal to 9

ELTP-GATE 46 GATE-CSE-16
Binary-to-Gray Code Conversion
ƒ Retain most significant bit.
ƒ From left to right, add each adjacent pair of binary code
bits to get the next Gray code bit, discarding carries.

gi=bi ⊕ bi+1 for 0<=i<=n-1 and gn=bn

ƒ Example: Convert binary number 10110 to Gray code.


1 0 1 1 0 Binary 1 + 0 1 1 0 Binary 1 0 + 1 1 0 Binary
↓ ↓ ↓
1 Gray 1 1 Gray 1 1 1 Gray

1 0 1 + 1 0 Binary 1 0 1 1 + 0 Binary
↓ ↓
1 1 1 0 Gray 1 1 1 0 1 Gray

(10110)2 = (11101)Gray

ELTP-GATE 47 GATE-CSE-16
Gray-to-Binary Conversion
ƒ Retain most significant bit.
ƒ From left to right, add each binary code bit generated to the Gray code
bit in the next position, discarding carries.

bi=gi if number of 1’s preceding gi is even (Left most to Right most)

bi=gi’(complement of gi)if number of 1’s preceding gi is odd (Left


most to Right most)

ƒ Example: Convert Gray code 11011 to binary.


1 1 0 1 1 Gray 1 1 0 1 1 Gray 1 1 0 1 1 Gray
↓ + ↓ + ↓
1 Binary 1 0 Binary 1 0 0 Binary

1 1 0 1 1 Gray 1 1 0 1 1 Gray
+ ↓ + ↓
1 0 0 1 Binary 1 0 0 1 0 Binary

(11011)Gray = (10010)2
ELTP-GATE 48 GATE-CSE-16
Q7.
Addition of three base 4 numbers “321” ,“122” and “111”
results is ________

a)1210
b)1220
c)1211
d)220

ELTP-GATE 49 GATE-CSE-16
Q8.
Addition of two octal numbers “36” and “71” results in
________

a)213
b)123
c)127
d)345

ELTP-GATE 50 GATE-CSE-16
Q9.
The decimal “17” in BCD will be represented as _________
a)11101
b)11011
c)10111
d)11110

ELTP-GATE 51 GATE-CSE-16
Q10.
Consider the number given by the decimal expression:
163 * 9 + 162 * 7 + 16 * 5 + 3
The number of 1’s in the unsigned binary representation of
the number is ___________.
a)7
b)9
c)8
d)6

ELTP-GATE 52 GATE-CSE-16
Q11.
The number of 1’s in the binary representation of
(3*4096+15*256+5*16+3) are:
(A)8
(B) 9
(C)10
(D)12

ELTP-GATE 53 GATE-CSE-16
Q12.
The octal representation of an integer is (342)8, if this were to
be treated as an eight-bit signed integer, in computer system,
its decimal equivalent is:
(A)226
(B)-98
(C) 76
(D) -30

ELTP-GATE 54 GATE-CSE-16
Q13.

Ans: D

ELTP-GATE 55 GATE-CSE-16
Q14.

Ans: B

ELTP-GATE 56 GATE-CSE-16

You might also like