Digital Logic Design: Lecture 2 - Number Systems

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 50

Digital Logic Design

Lecture 2 - Number Systems


Syllabus.
Syllabus
Grading (relative grading system):
• Exams: 80% MTE1-20 marks
MTE2-20 marks
ETE-40 marks

• Assignment / quizzes / project: 15% (15 marks)

• Attendance etc: 5% (5 marks)


Lecture 3:
Number system continued.
1.(101101.011)2 = (?)10 2. (14.125)10 = (?)2
3. (743)8 = (?)10
4. (92)16 = (?)2 = = (?)8
5. Perform the arithmetic operation as below considering the
numbers to be in the (a) octal and (b) hexadecimal system.

a) 1776 + 1432 b) 57734 - 1066


6. Each of the following arithmetic operations is correct in at
least one number system. Determine possible radix of the
numbers in each operation.
(i) 1234 + 5432 = 6666 (ii) 41 / 3 = 13
• Ans1 = 45.375
• Ans2 = 1101.001
• Ans3 = 483
• Ans4 = 10010010 & 222
• Ans5 = 3430 & 56646
• Ans6 = >= 7 & 8
Lecture - 3
Complements
Complements are used for

Simplifying the subtraction operation

Logical Manipulation
Types:
• r’s complement

• (r-1)’s complement
r’s complement:
Given a positive number N in base r with an integer part of n digits:

{
𝑛
𝑟 𝑠 𝑐𝑜𝑚𝑝𝑙𝑒𝑚𝑒𝑛𝑡 = 𝑟 − 𝑁 𝑓𝑜𝑟 𝑁 ≠ 0

0 𝑓𝑜𝑟 𝑁 =0
10’s complement of (52520)10?

(10)5 – 52520 = 47480

10’s complement of (0.3267)10?

(10)0 – 0.3267 = 0.6733

10’s complement of (25.639)10?

(10)2 – 25.639 = 74.361


2’s complement of (101100)2?

(2)6 – 101100 = 010100

2’s complement of (0.0110)2?

(2)0 – 0.0110 = 0.1010


Shortcut to find out 10’s & 2’s complement:
• 10’s complement of a decimal number can be formed
by leaving all significant zeros unchanged. Subtracting
the first nonzero least significant digit from 10 and
then subtracting all other higher significant digits from
9.

• The 2’s complement can be formed by leaving all least


significant zeros and the first nonzero digit unchanged
and then replacing 1’s by 0’s and 0’s by 1’s in all other
higher significant digits.
The (r-1)’s complement:
Given a positive number N in base r with an integer part of n digits and a fractional part
of m digits:

The (r-1)’s complement of N is defined as: rn-r-m-N


9’s complement of (52520)10?

(10)5 - (10)0– 52520 = 47479

9’s complement of (0.3267)10?

(10)0 – (10)-4 - 0.3267 = 0.6732

10’s complement of (25.639)10?

(10)2 – (10)-3 - 25.639 = 74.360


1’s complement of (101100)2?

(2)6 –(2)-0 - 101100 = 010011

1’s complement of (0.0110)2?

(2)0 – (2)-4- 0.0110 = 0.1001


Shortcut to find out 9’s & 1’s complement:
• 9’s complement of a decimal number can be formed
simply by subtracting every digit from 9.

• The 1’s complement of a binary number can be formed


by replacing 1’s by 0’s and 0’s by 1’s.
Complement of the complement
It restores the original value

The r’s complement of N is rn-N

And the complement of (rn-N) is rn- (rn-N) = N


Subtraction with r’s complement
The subtraction of two positive numbers (M-N) both of base
r, may be done as follows

• Add the minuend M to the (r)’s complement of N.


• Inspect the resultant for the end carry.
a. if an end carry occurs, add 1 to the lsd (end around
carry)
b. If an end carry doesn’t occur, take the (r)’s complement
of the number obtained in step 1 and place a negative
sign in front.
(72532 - 3250)10 using 10’s complement
(1010100 - 1000100)2 using 2’s complement
Subtraction with r-1’s complement
The subtraction of two positive numbers (M-N) both of
base r, may be done as follows

• Add the minuend M to the (r-1)’s complement of N.


• Inspect the resultant for the end carry.
a. if an end carry occurs discard it,
b. If an end carry doesn’t occur, take the (r-1)’s
complement of the number obtained in step 1 and
place a negative sign in front.
(72532 - 3250)10 using 9’s complement
(1010100 - 1000100)2 using 1’s complement
Lecture 4:
Binary Codes
Digital systems all use some form of binary numbers
for their internal operations, but the external world
is decimal in nature. This means that conversion
between decimal and binary systems are performed
often.

We have seen that the conversion between decimal


and binary can become long and complicated for
large numbers.
Binary codes:

When numbers, letters or words are represented by a special group of symbol, we say
that they are being encoded. And the group of symbols is known as “code”.
which obey the
positional weight
principle
Binary and Weighted Codes
• Although binary systems have advantages in digital computers (to
control the switches), humans work in decimal systems.
• It is convenient to represent decimal digits by sequence of binary
digits.
• Several coding techniques have been developed to do so.
• Decimal digits: 0, 1, …, 9 (10) can be represented by 4 bits.
• Since, we need 10 out of 16 values, several codes possible.
• Weighted Codes: If x1, x2, x3, x4 are the binary digits, with weights w1,
w2, w3, w4, then the decimal digit is:
N=w4x4+w3x3+w2x2+w1x1
We say, the sequence (x1, x2, x3, x4) denotes the code word for N.
35
Binary Codes

Is this
unique?

BCD Self-complementing Codes


Self-complementing code: Code word of 9’s complement of N obtained
by interchanging 1’s and 0’s in the code word of N
36
Nonweighted Codes

Can you see some Add 3 to Successive code words


interesting BCD differ in only one digit
properties in the
excess-3 code? 37
Warning: Conversion or Coding?

• Do NOT mix up conversion of a decimal number to a


binary number with coding a decimal number with a
BINARY CODE. 
• 1310 = 11012 (This is conversion) 
• 13  0001|0011 (This is coding)

Chapter 1 38
BCD Arithmetic
Given a BCD code, we use binary arithmetic to add the digits:
8 1000 Eight

+5 +0101 Plus 5

13 1101 is 13 (> 9)
Note that the result is MORE THAN 9, so must be

represented by two digits!


To correct the digit, subtract 10 by adding 6 modulo 16.
8 1000 Eight

+5 +0101 Plus 5

13 1101 is 13 (> 9)

+0110 so add 6

carry = 1 0011 leaving 3 + cy

0001 | 0011 Final answer (two digits)

If the digit sum is > 9, add one to the next significant digit
Chapter 1 39
BCD Addition Example
• Add 2905BCD to 1897BCD
showing carries and digit
corrections. 0

0001 1000 1001 0111

+ 0010 1001 0000 0101

Chapter 1 41
Gray Code

42
Reflection of Gray Codes
00 0 00 0 000
01 0 01 0 001
11 0 11 0 011
10 0 10 0 010
1 10 0 110
1 11 0 111
1 01 0 101
1 00 0 100
1 100
1 101
1 111
1 110
1 010
1 011
1 001
1 000

43
Optical Shaft Encoder

Does this special Gray code property have any

value?

An Example: Optical Shaft Encoder

Chapter 1 44
Shaft Encoder (Continued)
• How does the shaft encoder work?

• For the binary code, what codes may be produced if


the shaft position lies between codes for 3 and 4 (011
and 100)?

• Is this a problem?

Chapter 1 45
Shaft Encoder (Continued)
• For the Gray code, what codes may be produced if the
shaft position lies between codes for 3 and 4 (010 and
110)?

• Is this a problem?

• Does the Gray code function correctly for these


borderline shaft positions for all cases encountered in
octal counting?

Chapter 1 46
Binary to Gray

The 4 bit combination assigned to Binary Code


to Gray. four bits to represent a decimal digit.
There are four inputs and four outputs. The
input variable are defined as B3, B2, B1, B0
and the output variables are defined as G3, G2,
G1, G0. from the truth table, combinational
circuit is designed.

B3 = G3

B2 ⊕ B3 = G2

B1 ⊕ B2 = G1

B0 ⊕ B1 = G0
47
Gray to Binary
The 4 bit combination assigned to Gray to
Binary Code. four bits to represent a decimal
digit. There are four inputs and four outputs.
The input variable are defined as G3, G2, G1,
G0 and the output variables are defined as
B3, B2, B1, B0. from the truth table,
combinational circuit is designed.

G0 ⊕ G1 ⊕ G2 ⊕ G3 = B0

G1 ⊕ G2 ⊕ G3 = B1

G2 ⊕ G3 = B2

G3 = B3
Hamming Code Construction
As we go through the example, the first step is to identify the bit position of the data
& all the bit positions which are powers of 2 are marked as parity bits (e.g. 1, 2, 4, 8,
etc.).

parity bit P1, use check one and skip one

for P2, we will use check two and skip two

for P4, we will use check four and skip four method

Select p1 to establish even parity in positions: 1, 3, 5, 7


Select p2 to establish even parity in positions: 2, 3, 6, 7
Select p3 to establish even parity in positions: 4, 5, 6, 7 49

You might also like