Digital Logic Design: Lecture 2 - Number Systems
Digital Logic Design: Lecture 2 - Number Systems
Digital Logic Design: Lecture 2 - Number Systems
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?
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?
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
+5 +0101 Plus 5
13 1101 is 13 (> 9)
+0110 so add 6
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
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
value?
Chapter 1 44
Shaft Encoder (Continued)
• How does the shaft encoder work?
• 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?
Chapter 1 46
Binary to Gray
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.).
for P4, we will use check four and skip four method