Numeric Codes


Definition of Numeric Codes:

Representing numbers within the computer circuits, registers and the memory unit by means of Electrical signals or Magnetism is called NUMERIC CODING. In the computer system, the numbers are stored in the Binary form, since any number can be represented by the use of 1’s and O’s only. A binary 1 can be represented by the presence of a voltage or current pulse or magnetism and the binary 0, by the absence of it. Some of the Memory units use eight tiny Magnetic rings of Ferrite material in each of their locations. A magnetised ring represents 1 and a de-magnetised ring, 0. Each such ring is called a BIT, which is an abbreviation for BINARY DIGIT.

Classification of the Numeric Codes:

The Numeric Codes are broadly classified as:

(i) Weighted Codes, and

(ii) Non-weighted Codes.

In the Weighted Code, each bit in the number has a value depending upon its position or location within the number and this value is called the Weight. The Decimal value of the number will be equal to the sum of the product of the bits and their respective weights. In the Non-weighted Codes the decimal number stored will not be equal to the bit configuration value.

a. Weighted Codes:

The different type of the Weighted Codes are:

(i) BCD Code,

(ii) 2-4-2-1 Code,

(iii) 4-2-2-1 Code,

(iv) 5-2-1-1 Code,

(v) 7 – 4 – 2 – 1 Code, and

vi) 8-4-2-1 Code.

BCD Code:

BCD means BINARY CODED DECIMAL. In this code a Decimal digit is expressed in the form of 4 BITS (Binary Digits). The least significant Bit has a Weight of 2°, the next Bit to the left 21, the next to the left 22 and the most significant Bit 23 (refer Table 3.1). Some of the very early versions of the computers used this code for storing the digits 0 to 9.

Later on it was found that using 4 Bits, numbers up to 15 (F in Hexadecimal) can be stored. So the practice of storing in the Hexadecimal form started. Larger numbers can be stored in the given locations if they are in Hexadecimal form than in the Decimal form.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image002_thumb-4.webp

Other Weighted Codes:

The other types of Weighted Codes are given in the Table 3.2. Of these the 8 4 2 1 code has two bits, namely 2 and 1 which have negative weights.

The above codes were some of the codes that were tested during the evolution of the digital computers. These are of very little significance now.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image004_thumb-1.webp

b. Non-Weighted Codes:

The Non-Weighted Codes are of two types, namely:

(i) Non-Error Detecting Codes and,

(ii) Error Detecting Codes.

Non-Error Detecting Codes:

The Non-Error Detecting Codes are:

(i) RING COUNTER Code,

(ii) EXCESS THREE Code, and

(iii) GRAY Code.

Ring Counter Code:

This type of code was used in the first-ever Electronic Digital Computer, ENIAC. This uses totally TEN Bits to represent any digit 0 to 9 (refer Table 3.3). It may be noted that, though 10 Bits are used, only one Bit will be ‘on’ at a time.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image006_thumb-1.webp

Excess Three Code:

This is a Binary code in which each decimal number is expressed in excess of three, i.e, 3 is added to the decimal number and then coded into Binary digits, e.g, to get the Excess Three Code of 4, 3 is added to it which gives 7. The BCD code of 7, namely 0111 will be 4 in the Excess Three Code (refer Table 3.4). The Excess Three Code is said to be Self-Complementing code.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image008_thumb-1.webp

The complement of any single digit in any number system is the difference between the maxi­mum value of a discrete character in that system and the number under consideration, (e.g.,) In the Decimal system, the complement, of 6 is 3 (i.e.,) (9 — 6). So also the complement of 3 will be 6.

In a Binary Code, 1 and 0 are each complement to the other. The BCD code is not a self- complementing code in the sense that the Binary Form complement of a decimal number will not be its Decimal form complement, (e.g,) 6 in BCD Code is 0110; complement of this Binary form is obtained by replacing all l’s by 0’s and vice versa. In this case, it will be 1001, which is 9 in the Decimal system and not 3. The decimal digit 6 will be expressed in the Excess Three code as 1001. Its Binary complement is 0110. This represents 3 in the Excess Three Code itself. This applies to all decimal digits 0 to 9 (refer Table 3.4). Because of this, Excess Three Code is said to be self-complementing.

Gray Code:

The other names for this code are:

(i) UNIT DISTANCE CODE,

(ii) CYCLIC CODE, and

(iii) REFLECTED CODE.

It is called Unit Distance Code because the HAMMING DISTANCE between the Binary forms of any two adjacent numbers will always be one. The Hamming Distance of any two numbers of equal length in the Binary form is defined as the number of positions by which they differ. For example, the BCD code of 7 is 0111 and of 8 is 1000. The Hamming Distance between them is 4 since they differ in all the four digits. The same 7 in the Gray Code will be 0100 and 8 will be 1100 and the Hamming Distance between them in this code is 1 only. It will be seen from Table 3.5 that the Hamming Distance of any consecutive two numbers (0 to 9) in the Gray Code is always 1.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image010_thumb-1.webp

Gray code of a Decimal can be obtained from its BCD code as follows:

(i) Write down its BCD Code form;

(ii) The most significant Bit in the Gray Code is the same as in the BCD Code;

(iii) The second and the successive bits in the Gray Code will be the sum of the Bit in the position and the previous position in the BCD Code.

While calculating the sum, the following guidelines should be observed:

(i) 0 + 0 = 0;

(ii) 0 + 1 = 1;

(iii) 1 + 1 = 0 (with a carry of 1, which is to be neglected).

Example 3.1:

Find the Gray Code of the Decimal number 5.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image012_thumb-1.webp

Please note this method is not applicable to the Decimal number 9. Its Gray Code will be 1000 and not 1101. This is adopted to maintain a Hamming Distance of 1 between 9 and 0.

In Electronic circuits, devices known as XOR Gates are used for the conversion of BCD Code into Gray Code.

To convert a number from the Gray Code to the BCD Code the following steps are to be used:

(i) The most significant Bit in the BCD Code is the same as that in the Gray Code.

(ii) The second and the succeeding bits will each be the sum of the corresponding bit in the Gray Code and the previous bit in the BCD Code. The rules of addition are the same as for the conversion of BCD to Gray Code.

Example 3.2:

Find the Decimal value of the Gray Code Number 1100.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image014_thumb-1.webp

Gray Code is useful in converting varying analog signals into Digital form since only one bi varies from one Code to the next.

Error Detecting Codes:

These are of 2 types, namely:

(i) ERROR CHECKING CODES, and

(ii) ERROR CORRECTIN CODES.

Error Checking Codes:

These are of 2 categories, namely:

(i) SELF-CHECKING CODES, and

(ii) PARITY CHECKIN CODES.

In this type of Code, though the configuration of the Bits will be different for different digits (0 to 9), the number of 1 Bits will be the same for all the digits. The BIQUINARY CODE and the ‘2 out of 5 Code’ belong to this category. In them, the total number of 1 Bits in the configuration of any number is always 2 (refer Table 3.6). Because of this, any error due to the failure or absence of any Bit can easily be recognised. The Biquinary Code was adopted in the Japanese ABACUS which was called SOROBAN. But it is not in use now since it has a bit of weight 5. So also the ‘2 out of 5 code’ is not in use since it has a bit of weight 7.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image016_thumb-1.webp

Parity Checking Codes:

There are 2 types of PARITY CHECKING Codes, namely:

(i) ODD PARITY CODE, and

(ii) EVEN PARITY CODE.

In both these codes, in addition to the Numeric Bits, an additional bit is used. This bit is called the PARITY BIT or the CHECK BIT. The coding system can be designed either for Odd Parity or for Even Parity. If designed for the Odd Parity, the parity bit will be automatically generated in case the number of 1 bits in the numeric code is even. Similarly, if designed for Even Parity, the Parity bit will be automatically generated if the number of l’s in the numeric bits is odd (refer Table 3.7). Most of the computers are designed for Odd Parity. In the Table 3.7, D0,D1,D2 and D3 stand for the numeric bits of weights 2°,21,22 and 23respectively. P0 denotes Odd Parity bit and Pe Even Parity bit. It may be noted that zero is represented as 8 2 in the Even bit configuration.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image018_thumb-1.webp

Error Checking Codes:

The following types of codes come under this classification:

(i) Simple Error Correcting Code,

(ii) Self Correcting Code, and

(iii) Hamming Code.

Simple Error Correcting Code:

This is adopted for recording Data in the Magnetic Tapes. Data is recorded in them in 7 or 9 tracks. In a 9 track system, characters are recorded by energised Magnetic Spots on 8 tracks. The configuration of these spots will be different for different characters. The 9th track functions as the Parity track. In a system designed for Odd Parity, the 9th track will be energised, if necessary, in a column to maintain Odd Parity. Besides this, for each element of Data across each track a CHECK BIT is designed to be generated to maintain Odd Parity along each track also. Table 3.8 gives the way the Decimal number 5384 will be recorded on Tape in the EBCDIC code and how the Parity and the Check bits will b6 generated along the column and track/row, respectively.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image020_thumb-1.webp

Self-Correcting Code:

This code has also application in the case of recording data on Magnetic tapes. Each character is recorded odd number of times (3 or 5 times) in adjacent columns. In case the character in any one of the columns is not intelligible—due to the scratches or formation of dust on the tape-surface OR it is different from the character in the adjacent columns—the computer is designed to accept the data in the majority of the columns. For example, Table 3.9 shows recording of Character 7 in ASCII Code in successive 3 columns instead of only once. If the recording at any spot is blurred (spot marked as X) the processor will read the data from the majority configuration.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image022_thumb-1.webp

Hamming Code:

Hamming Codes are named after R W Hamming who formulated the method of Multiple Parity Checks. Let P0,P1– – etc. Pn be the parity bits used in the code. These will be scattered through the message (i.e,) among the weighted bits, say, D0,D1 – – etc. Dm representing the character. The Desired Odd or Even Parity configuration will be designed to be maintained for different combinations. Example 3.3 illustrates a method of formulating a type of Hamming Code.

Example 3.3:

Three Parity bits are to be designed for error checking in the BCD coded decimal numbers. These bits are to be distributed among the weighted bits. If the weighted bits are denoted as D0, D1, D2 and D3 and the Parity bits Po, P1 and P2, the Hamming Code is to be designed for ODD Parity for each one of the following combinations—(i) P0, P1,P2 and D2, (ii) P1,Do,D2and D3, and (iii) P1,D1, D2 and D3.

Solution:

Since the Parity Bits are to be distributed among the weighted bits, the configuration will be D3,P2,D2,P1,D1,P0 and D0.

The way the Decimal numbers are represented by the above bits, maintaining the Odd Parity for the given combinations, is given in Table 3.10.

Description: Description: Description: http://cdn.yourarticlelibrary.com/wp-content/uploads/2016/07/clip_image024_thumb-1.webp

Related Posts

© 2024 Instrumentation Engineering - Theme by WPEnjoy · Powered by WordPress