Download presentation
Presentation is loading. Please wait.
1
ECE – III SEM BINARY CODES
Manav Rachna University Manav Rachna College of Engineering
2
BINARY CODES Electronic digital systems use signals that have two distinct values and circuit elements that have two stable states. There is a direct analogy among binary signals, binary circuit elements, and binary digits. A binary number of n digits, for example, may be represented by n binary circuit elements, each having an output signal equivalent to a 0 or a 1. Digital systems represent and manipulate not only binary numbers, but also many other discrete elements of information. Any discrete element of information distinct among a group of quantities can be represented by a binary code. For example, red is one distinct color of the spectrum. The letter A is one distinct letter of the alphabet. A bit, by definition, the binary digit. When used in conjunction with a binary code, it is better to think of it as denoting a binary quantity equal to 0 or 1. To represent a group of 2n distinct elements in a binary code requires a minimum of n bits. This is because it is possible to arrange n bits in 2n distinct ways. For example, a group of four distinct quantities can be represented by a two-bit code, with each quantity assigned one of the following bit combinations: 00, 01, 10, 11. Manav Rachna University
3
A group of eight elements requires a three-bit code, with each element assigned to one of the following: 000, 001, 010, 011, 100, 101, 110, 111. The examples show that the distinct bit combinations of an n- bit code can be found by counting in binary from 0 to (2n-1). Some bit combinations of n-bit code can be found by the number of elements of the group to be coded is not a multiple of the power of 2. The ten decimal digits 0, 1, 2, 3, …., 9 are an example of such a group. A binary code that distinguishes among ten elements must contain at least four bits; three bits can distinguish a maximum of eight elements. Four bits can form 16 distinct combinations, but since only ten digits are coded, the remaining six combinations are unassigned and not used Although the minimum number of bits required to code 2n distinct quantities is n, there is no maximum number of bits that may be used for a binary code.] For example, the ten decimal digits can be coded with ten bits, and each decimal digit assigned a bit combination of nine 0’s and a 1.In this particular binary code, the digit 6 is assigned the bit combination Manav Rachna University
4
Binary Codes Binary codes are codes which are represented in binary system with modification from the original ones. Below we will be seeing the following: Weighted Binary Systems Non Weighted Codes Manav Rachna University Manav Rachna College of Engineering
5
Weighted Binary Systems
Weighted binary codes are those which obey the positional weighting principles, each position of the number represents a specific weight. The binary counting sequence is an example Manav Rachna University
6
Decimal 8421 2421 5211 Excess-3 0000 0011 1 0001 0100 2 0010 0101 3 0110 4 1010 0111 5 1011 1000 6 1001 7 1101 1100 8 1110 9 1111 Manav Rachna University
7
Manav Rachna College of Engg.
Binary Codes A binary code is a group of n bits that assume up to 2n distinct combinations of 1’s and 0’s with each combination representing one element of the set that is being coded. Manav Rachna University Manav Rachna College of Engg. BCD – Binary Coded Decimal ASCII – American Standard Code for Information Interchange
8
BCD – Binary Coded Decimal
Decimal BCD Number Number When the decimal numbers are represented in BCD, each decimal digit is represented by the equivalent BCD code.(4-BITS PER DIGIT) Example :BCD Representation of Decimal 6349 Manav Rachna University
9
8421/BCD Codes Binary codes for decimal digits require a minimum of four bits. Numerous different codes can be obtained by arranging four or more bits in ten distinct possible combinations. The BCD (Binary Coded Decimal) is a straight assignment of the binary equivalent. It is possible to assign weights to the binary bits according to their positions. The weights in the BCD code are 8,4,2,1. Example: The bit assignment 1001, can be seen by its weights to represent the decimal 9 because: 1x8+0x4+0x2+1x1 = 9 Manav Rachna University
10
When specifying data, the user likes to give the data in decimal form.
The BCD (binary-coded decimal) is a straight assigned of the binary equivalent. It is possible to assign weight to the binary bits according to their position. The weights in the BCD code are 8,4,2,1. The weights in the BCD code are 8,4,2,1. The bit assignment 0110 for example can be interpreted by the weights to represent the decimal digit 6 because 0X8+1X4+1X2+0X1=6. Numbers are represented in digital computers either in binary or in decimal through a binary code. When specifying data, the user likes to give the data in decimal form. The input decimal numbers are stored internally in the computer by means of decimal code. Each decimal digit requires at least four binary storage elements. The decimal numbers are converted to binary when arithmetic operations are done internally with numbers represented in binary. Manav Rachna University
11
It is possible to perform the arithmetic operations directly in decimal with all numbers left in a coded form throughout. For example, the decimal number 395, when converted to binary, is equal to and consists of nine binary digits. The same number, when represented internally in the BCD code, occupies four bits of each decimal digit, for a total of 12 bits The first four bits represent a 3, the next four a 9 and the last four a 5. It is every important to understand the difference between conversion of a decimal number to binary and the binary coding of a decimal number. In each case the final results is a series of bits. The bits obtained from conversion are binary digits. Bits obtained from coding are combinations of 1’s and 0’s in the digital system may sometimes represent a binary number and at other times represent some other discrete quantity of information as specified by a given binary code. Manav Rachna University
12
The BCD code, for example, has been chosen to be both a code and a direct binary conversion, as long as the decimal numbers are integers from 0 to 9. For numbers greater than 9, the conversion and the coding are completely different. This concept is so important that it is worth repeating with another example. The binary conversion of decimal 13 is 1101, the coding of decimal 13 with BCD is Manav Rachna University
13
Binary Codes for the decimal digits
(BCD) 8421 Excess-3 84-2-1 2421 (Biquinary) 0000 0011 1 0001 0100 0111 2 0010 0101 0110 3 4 5 1000 1011 6 1001 1010 1100 7 1101 8 1110 9 1111 Binary Codes for the decimal digits Manav Rachna University The components used to construct digital systems are enclosed within IC packages. It is important that the digital designer be familiar w/ the various digital components encountered in IC form
14
BINARY CODES It is possible to assign weights to the binary bits according to their positions. BCD code, , 2421, Weighted codes Numbers are represented in digital computers either in binary or in decimal through a binary code. Manav Rachna University When specifying data, the user likes to give the data in decimal form.
15
2421 Code This is a weighted code, its weights are 2, 4, 2 and 1. A decimal number is represented in 4-bit form and the total four bits weight is = 9. Hence the code represents the decimal numbers from 0 to 9. Manav Rachna University
16
5211 Code This is a weighted code, its weights are 5, 2, 1 and 1. A decimal number is represented in 4-bit form and the total four bits weight is = 9. Hence the 5211 code represents the decimal numbers from 0 to 9. Manav Rachna University
17
REFLECTION CODES A code is said to be reflective when code for 9 is complement for the code for 0, and so is for 8 and 1 codes, 7 and 2, 6 and 3, 5 and 4. Codes 2421, 5211, and excess-3 are reflective, whereas the code is not. Manav Rachna University
18
Sequential Codes A code is said to be sequential when two subsequent codes, seen as numbers in binary representation, differ by one. This greatly aids mathematical manipulation of data. The and Excess-3 codes are sequential, whereas the and 5211 codes are not Manav Rachna University
19
Non Weighted Codes Non weighted codes are codes that are not positionally weighted. That is, each position within the binary number is not assigned a fixed value. Manav Rachna University
20
WHAT ARE GRAY CODES Manav Rachna University
21
REFLCETED CODES Reflected Code(also known as the Gray code)
Digital systems can be designed to process data in discrete form only. Many physical systems supply continuous output data. These data must be converted into digital or discrete form before they are applied to a digital system. Advantage: A number in the reflected code changes by only one bit as it proceeds from one number to the next. Manav Rachna University
22
Forming a Gray Code Start with all 0's
Change the least significant bit that forms a new code word a b c d e Manav Rachna College of Engg.
23
Binary Reflected Gray Code
Manav Rachna College of Engg.
24
Reflected Gray and Binary Codes
Binary Gray Manav Rachna College of Engg.
25
Why Gray Codes? Single output changes at a time
Asynchronous sampling Permits asynchronous combinational circuits to operate in fundamental mode Potential for power savings Multiphase, multifrequency clock generator Manav Rachna College of Engg.
26
Why Gray Codes? Manav Rachna College of Engg.
27
Why Gray Codes? Manav Rachna College of Engg.
28
BINARY CODES Reflected Code Decimal Equivalent 0000 0001 1 0011 2 0010
0001 1 0011 2 0010 3 0110 4 0111 5 0101 6 0100 7 1100 8 Manav Rachna College of Engg.
29
BINARY CODES 1101 9 1111 10 1110 11 1010 12 1011 13 1001 14 1000 15 Manav Rachna College of Engg.
30
The Reflected Code Digital system can be designed to process data in discrete form only. Many physical systems supply continuous output data. These data must be converted into digital or discrete form before they are applied to a digital system. Continuous or analog information is converted to use the reflected code shown in table 1-4 to represent the digital data converted from the analog data. The advantage of the reflected code over pure binary numbers is that a number in the reflected code changes by only one bit as it proceeds from one number to the next. A typical application of the reflected code occurs when the analog data are represented by a continuous change of a shaft position. The shaft is partitioned into segments, and each segment is assigned a number. Manav Rachna College of Engg.
31
APPLICATION OF GRAY CODE
Manav Rachna College of Engg.
32
APPLICATION OF GRAY CODE
Manav Rachna College of Engg.
33
GRAY CODES Manav Rachna College of Engg.
34
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
35
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
36
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
37
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
38
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
39
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
40
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
41
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
42
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
43
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
44
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
45
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
46
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
47
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
48
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
49
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
50
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
51
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
52
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
53
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
54
CONVERTING BETWEEN GRAY & BINARY CODES
Manav Rachna College of Engg.
55
Excess-3 Code Excess-3 is a non weighted code used to express decimal numbers. The code derives its name from the fact that each binary code is the corresponding 8421 code plus 0011(3). Example: 1000 of 8421 = 1011 in Excess-3 Manav Rachna College of Engg.
56
EXCESS-3 CODE Manav Rachna College of Engg.
57
Alphanumeric Codes Many applications of digital computers require the handling of data that consist not only of numbers, but also of letters. For instance, an insurance company with millions of policy holders may use a digital computer to process its files. To represent the policy holder’s name in binary form, it is necessary to have a binary code for the alphabet. In addition, the same binary code must represent decimal numbers and some other special characters. An alphanumeric (sometimes abbreviated alphanumeric) code is binary code of a group of element consisting of special symbol such as $. The total number of elements in an in alphanumeric group is greater than 36. Manav Rachna College of Engg.
58
Therefore, it must be coded with a minimum of six bits (26=64, but 25 = 32) is insufficient.
One possible arrangement of six –bit alphanumeric code is shown in Table1-5 under the name “internal code”. With few variations, it is used in many computers to represent alphanumeric characters internally. The need to represent more than 64 characters (the lowercase letters and special control characters for the transmission of digital information) gave rise to seven and eight-bit alphanumeric codes. One such code is known as ASCII (American Standard Code for Information Interchange); another is known as EBCDIC (Extended BCD Interchange Code). Manav Rachna College of Engg.
59
The ASCII code listed in table 1-5 consists of seven bits but is, for all practical purposes, an eight-bit code because an eighth bit is invariably added for parity. Most computers translate the input code into an internal six-bit code. As an example, the internal code representation of the name “John Doe” is: J O H N blank D O E Manav Rachna College of Engg.
60
ASCII CODES The Problem
Representing text strings, such as “Hello, world”, in a computer Manav Rachna College of Engg.
61
Codes and Characters Each character is coded as a byte
Most common coding system is ASCII (Pronounced ass-key) ASCII = American National Standard Code for Information Interchange Defined in ANSI document X Manav Rachna College of Engg.
62
ASCII Features 7-bit code 8th bit is unused (or used for a parity bit)
27 = 128 codes Two general types of codes: 95 are “Graphic” codes (displayable on a console) 33 are “Control” codes (control features of the console or communications channel) Manav Rachna College of Engg.
63
ASCII Chart Manav Rachna College of Engg.
65
Most significant bit Least significant bit
66
e.g., ‘a’ =
67
95 Graphic codes
68
33 Control codes
69
Alphabetic codes
70
Numeric codes
71
Punctuation, etc.
72
“Hello, world” Example = Binary 01001000 01100101 01101100 01101111
Hexadecimal 48 65 6C 6F 2C 20 77 67 72 64 Decimal 101 108 111 44 32 119 103 114 100 H e l o , w r d Manav Rachna College of Engg.
73
Common Control Codes CR 0D carriage return LF 0A line feed
HT 09 horizontal tab DEL 7F delete NULL 00 null Manav Rachna College of Engg. Hexadecimal code
75
Terminology Learn the names of the special symbols [ ] brackets
{ } braces ( ) parentheses @ commercial ‘at’ sign & ampersand ~ tilde Manav Rachna College of Engg.
77
Escape Sequences Extend the capability of the ASCII code set
For controlling terminals and formatting output Defined by ANSI in documents X and X The escape code is ESC = 1B16 An escape sequence begins with two codes: ESC [ Manav Rachna College of Engg. 5B16 1B16
78
Examples Erase display: ESC [ 2 J Erase line: ESC [ K
Manav Rachna College of Engg.
79
EBCDIC Extended BCD Interchange Code (pronounced ebb’-se-dick)
8-bit code Developed by IBM Rarely used today IBM mainframes only Manav Rachna College of Engg.
80
THE END Manav Rachna College of Engg.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.