review of number systems and codes
Transcript of review of number systems and codes
![Page 1: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/1.jpg)
The negative number has two representations:
a. complement representation
b. sign magnitude representation
Complement representation:
There are two ways of representing complement
numbers:
a. 1’s Complement
b. 2’s Complement
![Page 2: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/2.jpg)
1’s complement of a binary number is obtained simply
by replacing each 1 by 0 and each 0 by 1. Alternately,
1’s complement of a binary can be obtained by
subtracting each bit from 1.
Example: Find 1’s complement of (i) 011001 (ii)
00100111
Solution. (i) Replace each 1 by 0 and each 0 by 1
0 1 1 0 0 1
↓ ↓ ↓ ↓ ↓ ↓
1 0 0 1 1 0
So, 1’s complement of 011001 is 100110.
![Page 3: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/3.jpg)
(ii) Subtract each binary bit from 1.
1 1 1 1 1 1 1 1
–0 0 1 0 0 1 1 1
1 1 0 1 1 0 0 0 ← 1’s complement
one can see that both the method gives sameresult.
2’s Complement
2’s complement of a binary number can be obtainedby adding 1 to its 1’s complement.
Example 1. Find 2’s complement of (i) 011001 (ii)0101100
![Page 4: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/4.jpg)
Solution. (i) 0 1 1 0 0 1 ← Number
1 0 0 1 1 0 ← 1’s complement
+ 1 ← Add 1 to 1’s complement
1 0 0 1 1 1 ← 2’s complement
(ii) 0 1 0 1 1 0 0 ← Number
1 0 1 0 0 1 1 ← 1’s complement
+ 1 ← Add 1 to 1’s complement
1 0 1 0 1 0 0 ← 2’s complement
![Page 5: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/5.jpg)
![Page 6: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/6.jpg)
Before using any complement method for subtraction
equate the length of both minuendand subtrahend by
introducing leading zeros.
1’s complement subtraction following are the rules for
subtraction using 1’s complement.
1. Take 1’s complement of subtrahend.
2. Add 1’s complement of subtrahend to minuend.
3. If a carry is produced by addition then add this carry to the
LSB of result. This is called as end around carry (EAC).
4. If carry is generated from MSB in step 2 then result is
positive. If no carry generated result is negative, and is in
1’s complement form.
![Page 7: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/7.jpg)
Example. Perform following subtraction using
1’s complement.
(i) 7 – 3 (ii) 3 – 7
Solution. (i) 7 – 3:
binary of 7 = (0111)2
binary of 3 = (0011)2
both numbers have equal length.
Step 1. 1’s complement of (0011)2 = (1100)2
![Page 8: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/8.jpg)
![Page 9: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/9.jpg)
![Page 10: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/10.jpg)
![Page 11: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/11.jpg)
![Page 12: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/12.jpg)
![Page 13: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/13.jpg)
![Page 14: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/14.jpg)
![Page 15: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/15.jpg)
![Page 16: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/16.jpg)
![Page 17: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/17.jpg)
![Page 18: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/18.jpg)
In a broad sense we can classify the codes into
five groups:
(i) Weighted Binary codes
(ii) Non-weighted codes
(iii) Error–detecting codes
(iv) Error–correcting codes
(v) Alphanumeric codes.
![Page 19: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/19.jpg)
In weighted binary codes, each position of a number
represents a specific weight. The bits are multiplied by the
weights indicated; and the sum of these weighted bits gives
the equivalent decimal digit.
(a) Straight Binary coding is a method of representing a
decimal number by its binary equivalent.
![Page 20: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/20.jpg)
In BCD codes, individual decimal digits are coded in
binary notation and are operated upon singly. Thus
binary codes representing 0 to 9 decimal digits are
allowed. Therefore, all BCD codes have at least
four bits (∵ min. no. of bits required to encode to
decimal digits = 4)
For example, decimal 364 in BCD
3 → 0011
6 → 0110
4 → 0100
364 → 0011 0110 0100
![Page 21: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/21.jpg)
There are many binary coded decimal codes(BCD) all of which are used to represent decimaldigits. Therefore, all BCD codes have atleast 4bits and at least 6 unassigned or unused codewords.
Some example of BCD codes are:
(a) 8421 BCD code, sometimes referred to as the Natural Binary Coded Decimal Code (NBCD);
(b)* Excess-3 code (XS3);
(c)** 84 –2 –1 code (+8, +4, –2, –1);
(d) 2 4 2 1 code
![Page 22: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/22.jpg)
![Page 23: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/23.jpg)
Example: Lowest [643]10 into XS3 code
Decimal 6 4 3
Add 3 to each 3 3 3
Sum 9 7 6
Converting the sum into BCD code we have
9 7 6
↓ ↓ ↓
1001 0111 0110
Hence, XS3 for [643]10 = 1001 0111 0110
![Page 24: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/24.jpg)
The excess 3, 8 4–2–1 and 2421 BCD codes are also known
as self complementing codes.
Self complementing property– 9’s complement of the
decimal number is easily obtained by changing 1’0 to 0’s
and 0’s to 1’s in corresponding codeword or the 9’s
complement of self complementing code word is the same
as its logical complement.
Example. The decimal digit 3 in 8.4–2–1 code is coded as
0101. The 9’s complement of 3 is 6. The decimal digit 6 is
coded as 1010 that is 1’s complement of the code for 3. This
is termed as self complementing property.
![Page 25: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/25.jpg)
These codes are not positionally weighted.
This means that each position within a binary
number is not assigned a fixed value.
Excess-3 codes
Gray codes
are examples of nonweighted codes.
![Page 26: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/26.jpg)
Gray code (Unit Distance code or Reflective code)
There are applications in which it is desirable to representnumerical as well as other information with a code thatchanges in only one bit position from one code word to thenextadjacent word.
This class of code is called a unit distance code (UDC).
These are sometimes also called as ‘cyclic’, ‘reflective’ or‘gray’ code.
These codes finds great applications in Boolean functionminimization using Karnaugh map.
![Page 27: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/27.jpg)
![Page 28: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/28.jpg)
Binary information is transmitted from one device toanother by electric wires or other communication medium.
A system that can not guarantee that the data received byone device are identical to the data transmitted by anotherdevice is essentially useless.
Yet anytime data are transmitted from source to destination,they can become corrupted in passage. Many factors,including external noise, may change some of the bits from0 to 1 or viceversa.
Reliable systems must have a mechanism for detecting andcorrecting such errors.
![Page 29: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/29.jpg)
In a single bit error, a 0 is changed to a 1 or a 1 ischanged to a 0.
In a burst error, multiple (two or more) bits arechanged.
The purpose of error detection code is to detect such bitreversal errors.
Error detection uses the concept of redundancy whichmeans adding extra bits for detecting errors at thedestination.
![Page 30: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/30.jpg)
Four types of redundancy checks are used:
Parity check or vertial redundancy check(VRC)
longitudinal redundancy check (LRC)
cyclic redundancy check (CRC) and
checksum
![Page 31: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/31.jpg)
For a single bit error detection, the most common way
to achieve error detection is by means of a parity bit
A parity bit is an extra bit (redundant bit) included with
a message to make the total number of 1’s transmitted
either odd or even.
![Page 32: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/32.jpg)
In LRC, a block of bits is organised in rows and columns
(table). For example, a block of 16 bits can be organised in
two rows and eight columns as shown in Fig.
We then calcualte the parity bit (even parity/odd parity, here
we are using even parity) for each column and create a new
row of 8 bits, which are the parity bits for the whole block.
![Page 33: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/33.jpg)
CRC is most powerful of the redundancy checkingtechniques.Cyclic redundancy check is based onbinary division.
A sequence of redundant bits called CRC or CRCremainder is appended to the end of a data unit.
After adding CRC remainder, the resulting dataunit becomes exactly divisible by anotherpredetermined binary number.
At the destination this data unit is divided by thesame binary number. If there is no remainder,then there is no error.
![Page 34: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/34.jpg)
The CRC generator and CRC checker are
shown in Fig.(a) and Fig.(b) respectively.
Fig.(a) Fig.(b)
![Page 35: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/35.jpg)
![Page 36: review of number systems and codes](https://reader034.fdocuments.us/reader034/viewer/2022042503/55a6c44c1a28ab90428b46fc/html5/thumbnails/36.jpg)
The mechanism that we have covered upto this
point detect errors but do not correct them. Error
correction can be handled in two ways.
In one, when an error is encountered the receiver
can request the sender to retransmit entire data
unit.
In the other, a receiver can use an error correcting
code, which automatically corrects certain errors.