You are on page 1of 93

DIGITAL TECHNIQUES

BY MT P Ndoro
INTRODUCTION
• Electronics may be broadly divided into two
categories;
• Analogue electronics
• Digital electronics
• Analogue signals vary gradually and continuously
with time eg sine wave. They may have infinite
number of different magnitudes or values.
• Analogue circuit contains signals that are
constantly changing from one value to another,
such as amplitude or frequency.
INTRODUCTION

• Digital signals are discrete time signals ie they are


not continuous with time.
• Digital circuits process signals that contain just two
voltage levels or states, labelled logic "0" and logic
"1".
• The voltages used to represent a digital circuit are
called "logic levels" and ideally one voltage level
represents a HIGH and another represents a LOW.
Analogue Voltage Output Representation
•The output from the potentiometer
varies as the wiper terminal is rotated
producing an infinite number of voltage
points between 0 volts and V max.
•As the voltage output varies either
slowly or rapidly, there is no sudden
change between two voltage levels
giving a continuous output voltage.
Digital Voltage Output Representation
Digital Voltage Output

• In this example, the potentiometer wiper has


been replaced by a rotary switch which is
connected to each junction of the resistor
chain, forming a potential divider network.
As the switch is rotated from one node to the
next, the output changes quickly in discrete
voltage levels of multiples of 1 volt each, as
shown in the graph. For example, 2 volts, 3
volts, 5 volts but NOT 2.5V, 3.1V or 4.6V.
Analogue versus Digital

• Thus the major difference between an analogue


signal and a digital quantity is that an "Analogue"
signal is continuously changing over time whilst a
"Digital" signal has discrete (step by step) values,
LOW to HIGH or HIGH to LOW.
Analogue versus Digital

• Another example of this could be a light dimmer that


varies the light intensity up or down between fully-ON
and fully-OFF, but with a light switch, the light is either
"ON", (HIGH) or it is "OFF", (LOW).
• Some circuits combine both analogue and digital
signals, so they make use an analogue to digital
converter (ADC) or a digital to analogue converter
(DAC).
• Either way, the digital input or output signal
represents a binary number value of the analogue
signal.
Analogue system versus Digital system
Parameter of Analogue system Digital system
comparison
Type of signal Analogue signal Digital signal
processed
Type of display Analogue meters Digital displays
Accuracy of system Small accuracy High accuracy
Design complexity Difficulty to design Easier to design
Memory attached No memory Memory present
Versatility Small High
Distortion (noise) High Small
Few examples Amplifiers, filters Counters, registers
power supplies
DIGITAL SYSTEM

• Digital systems today find applications in a wide


variety of areas; industrial, commercial, medical,
military, educational fields, air traffic control, Space
guidance etc
• A digital system is one in which all of the signals are
represented by discrete values.
• The term ‘digital’ is derived from the way the
computer performs operations ie counting digits.
DIGITAL SYSTEM

• Characteristic of a digital system is its manipulation


of discrete elements of information.
• Such discrete elements may be decimal digits,
letters of the alphabet, arithmetic operations,
punctuation marks or any other set of meaningful
symbols.
• Discrete elements of information are represented in
a digital system by physical quantities called signals.
Electrical signal such as voltages and currents are
the most common.
DIGITAL SYSTEM

• The best known example of a digital system is the


general purpose computer.
• Digital computers have made possible many
scientific, industrial and commercial advances that
would have been unattainable otherwise. Our space
program would have been impossible without real
time, continuous computer monitoring, and many
business enterprises function efficiently only with
the aid of automatic data processing.
DIGITAL SYSTEM
• Computers are used in scientific calculations,
commercial and business data processing, air traffic
control, space guidance, the educational field and
many others.
• The most striking property of a digital computer is
its generality. It can follow a sequence of
instructions called a program, that operates on
given data.
• The user can specify and change programs and/or
data according to specific need. As a result of this
flexibility, general purpose digital computer can
perform a wide variety of information processing
tasks.
DIGITAL SYSTEM

• Internally, most digital systems operate with 2-


valued signals; 0 or 1.(binary form)
• The physical manifestation of these binary
quantities may be any of the following; switch in
the up or down (on/off) position; a light on or off,
one of two voltages 0v/ground for logic 0 and 5v
for logic 1; or etc.
Digital Logic

• Most digital logic gates and logic systems use


"Positive logic", in which a logic level "0" or "LOW"
is represented by a zero voltage (0v) or ground; and
a logic level "1" or "HIGH" is represented by a
higher voltage such as +5 volts.
• However, normally logic 1 level is considered to be
the more positive of the 2 levels and logic 0 is
assigned to more negative of the two levels.
Digital Logic

• There also exists a complementary "Negative Logic"


system in which the values and the rules of a logic
"0" and a logic "1" are reversed.
• In negative logic, a logic level "0" or "LOW" is
represented by 5v, or a higher voltage ; and a logic
level "1" or "HIGH" is represented by a zero voltage
(0V) or a lower voltage.
• In negative logic, the more negative of the two
levels is designated as logic 1 level.
Digital logic
• The exact switching voltage required to produce
either a logic "0" or a logic "1" depends upon the
specific logic group or family of integrated circuit.
• In standard TTL (transistor-transistor logic) IC's
there is a pre-defined voltage range for the input
and output voltage levels which define exactly what
is a logic "1" level and what is a logic "0" level and
these are shown below.
• For example, when using a standard +5 volt supply
any TTL voltage input between 2.0v and 5v is
considered to be a logic "1" or "HIGH" while any
voltage input below 0.8v is recognized as a logic "0"
or "LOW".
Digital logic

• The voltage region in between these two


voltage levels either as an input or as an
output is called the Indeterminate Region
and operating within this region may cause
the logic gate to produce a false output.
NUMBERING
SYSTEMS
Introduction
• Number system is a basis for counting various items.
• We are all familiar with the decimal number system
with ten digits from 0........9.
• Modern computers operate and communicate with
binary numbers which use only two digits, 0 and 1.
• Decimal number 18 can be represented in binary as
10010.
• Thus whilst decimal requires less number of digits (2
in above example), binary requires more (5) .
• So for large decimal numbers, people have to deal
with very large binary strings.
Introduction
•This gave rise to three new number
systems; octal, hexadecimal and binary
coded decimal. These number systems
represent binary number in a compressed
form.
Positional Notation
• It is a system of expressing numbers in which
the digits are arranged in succession and, the
position of each digit has a place value and the
number is equal to the sum of the products of
each digit by its place value.
• All the number systems use the same positional
notation except that;
• Decimal system uses powers of 10
• Binary system uses powers of 2
• Octal system uses powers of 8
• Hexadecimal uses powers of 16
Consider the number
754 in decimal

NB:The value is formed


by the sum of each digit,
multiplied by the base (in
this case it is 10 because
there are 10 digits in
decimal system) in power
digit position (counting
from 0)
Positional Notation
• Each digit position (place) represents different multiples of
a base. This means numbers have positional importance:
.... nB3 nB2 nB1 nB0 . nB-1 nB-2 nB-3 ....
where n=column number, B=base number.
**Examples for all bases.
• Thus the base also determines what the position of the
digits mean.
• The leftmost digit, which has the greatest weight is called
the most significant bit (MSB).
• The rightmost digit which has the least weight is called the
least significant bit (LSB).
Base number system
• The base of number system represents the number of
digits that are used in the system. The digits always
begin with 0 and continue through one less than the
base
• Examples:
• There are two digits in base two
• There are eight digits in base 8
• There are 10 digits in base 10
• There are 16 digits in base 16.
Decimal, Binary, Octal and
Hexadecimal
• Decimal base has 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
• Binary is base 2 and has two digits (0 and 1)
• Octal is base 8 and has 8 digits (0, 1, 2, 3, 4, 5, 6, 7)
• Hexadecimal is base 16 and has 16 digits (0, 1, 2, 3,
4, 5, 6, 7, 8, 9, A, B, C, D, E, F).
• Decimal numbers are used to represent quantities
which are outside the digital system
Decimal, Binary, Octal and Hexadecimal

• Binary system is extensively used by digital systems


which operate on binary information.
• Octal systems has certain advantages in digital work
because it requires less circuitry to get information
into and out of a system. Moreover, it is easier to
read, record and print out octal numbers than
binary numbers.
• Hexadecimal number systems is particularly suited
for microcomputers.
Binary System
• Computers use binary systems, binary uses 2 digits; 0
and1. Thus the base is 2.
• Each digit in a binary number is called a BIT, 4bits form
a NIBLE, 8bits form a BYTE, 2bytes form a WORD.
Binary System

• Bit – is the smallest unit of data. With the single bit,


we can represent any two distinct items like ON/OFF,
TRUE/FALSE, YES/NO, MALE/FEMALE etc.
• Nible – is a combination of four bits. Used in BCD and
hexadecimal numbers because it takes four bits to
represent a single BCD or hexadecimal digit. With a
nible, we can represent up to 16 distinct characters ie
0....15
• Byte – is a combination of 8 binary digits. Number of
distinct values represented by a byte is 256 ie 0....255
Binary System

• Word – a combination of 16 bits or 2 bytes. It can


represent 65,536 characters ie 0.....65,535
• Double word – combination of 32 bits or 4 bytes or
8 nibles.
• NB: An n-bit number can represent positive integers
from 0 to 2n – 1.
Converting Binary to Decimal

• What is the equivalent decimal of the binary


10110 number?
1 x 24 = 1 x 16 = 16
+ 0 x 23 = 0x8 =0
+ 1 x 22 = 1x4 =4
+ 1 x 21 = 1x2 =2
+ 0 x 20 = 0x1 =0
= 22 in base 10

• Remember that binary base has only 2 digits (0, 1)


Converting Binary to Decimal

Example: Convert 1101.1 to decimal


1x23+1x22+0x21+1x20.+1x2-1
8 +4 +2 +1 +0.5 =13.5

Convert 1010.011; 101101.1101 to decimal


Converting Octal to Decimal
• What is the decimal equivalent of octal number
642?

6 x 8² = 6 x 64 = 384
+ 4 x 8¹ = 4 x 8 = 32
+ 2 x 8º = 2 x 1 = 2
= 418 in base 10

• Remember that octal base has only 8 digits


(0, 1, 2, 3, 4, 5, 6, 7)
Converting Octal to Decimal

Example: Convert 630.48 to decimal


630.4 = 5x82+3x81+0x80+4x8-1
= 408.5

Convert 475.258 to decimal


Converting Hexadecimal to Decimal
• What is the decimal equivalent of the hexadecimal
number DEF?

D x 16² = 13 x 256 = 3328


+ E x 16¹ = 14 x 16 = 224
+ F x 16º = 15 x 1 = 15
= 3567 in base 10

• Remember that hexadecimal base has 16 digits (0,


1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F)
Converting Hexadecimal to Decimal

• Convert 9B2.1A16 to decimal; 2AC5.D


Converting Binary to Octal
• Start at the rightmost (LSB) binary digit and mark the digits
in groups of three
• Convert each group individually

10101011 10 101 011

2 5 3
10101011 is 253 in base 8
• The reason that binary can be immediately
converted in octal and vice-versa is because 8 is
power of 2
• There is a similar relationship between binary and
hexadecimal
Converting binary to octal

• Convert 111010101.110011 to octal.


111 010 101 .110 011 = 725.63
7 2 5 . 6 3

• Convert 101111.1101 to octal


Converting Binary to Hexadecimal
• Start at the rightmost binary digit (LSB) and mark the
digits in groups of four going to the left.
• NB**If the last group does not have 4 digits, add
zero(es) to make it a 4-digit group.
• Convert each group individually.

10101011 1010 1011


A B
10101011 is AB in base 16
Converting Binary to Hexadecimal

• Convert 11011011.100101 to base 16


1101 1011 . 1001 0100 = DB.94

Convert 101101.1001
Fraction Conversions between Bases
power of two
• The conversion between bases where one base is
an integer power of the other can be performed for
fractions by grouping the digits in the smaller base
as before
• For fractions, the grouping must be done from the
left to right; the method is otherwise identical
• Example:
• Convert 0.101112 to base 8: 0.101_110 = 0.568
• Convert 0.1110101 to base 16: 0.1110_1010 =
0.EA16
Converting Decimal to Other Bases
• The conversion of a decimal number to other bases
is done by the successive division method. In this
method, the integer is divided repeatedly by the
base until quotient is zero. The remainder of each
division becomes a numeral in the new radix.
• The remainder are taken in the reverse order to
form a new base number.
• Where the decimal number has a fractional part,
then conversion is done in 2 parts, that is successive
division for the integer part and then successive
multiplication for the fractional part.
Converting Decimal to Other Bases

• With the successive multiplication method, the


number to be converted is multiplied by the base of
the new number, producing a product that has an
integer part and a fraction.
• The integer part (carry) of the product becomes a
numeral in the new base number.
Converting Decimal to Other Bases

• The fractional part is again multiplied by the base


and the process is repeated until the fractional part
reaches zero or until the new base number is
carried out to the sufficient digits specified.
• The integer part (carry) of each product is read
downward to represent the new base number.
Converting Decimal to Hexadecimal

The base 10 number 3567 is what number in base 16?

3567 16
32 D E F
36 222 16
32 16
47 62 13
32 48
15 14
Conversion of decimal to binary

0.828125
2
*
0.110101
1.656250 *
The 1 is saved as 2
result then dropped 1.312500 *
and the process 2
repeated 0.625000 *
2
1.250000 *
2
0.500000 *
2
1.000000
Class exercise

Convert following decimal numbers;


1. 24.6 to binary (to 5 decimal places)
2.214,640625 to octal
3. 0.1289062 to base 16
Arithmetic in Binary
• The rules of arithmetic are analogous in other basis as in decimal base

Should read 1+1=0 with a carry of Addition


1 similar to base 10 where 9 + 1 =
0 with a carry of 1 = 10 1 1 0 0

+ + + +

1 0 1 0

10 1 1 0

-1 can be stated as 1 with a Subtraction


borrow of 1.
1 1 0 0

- - - -

1 0 1 0

0 1 11 0
Addition in Binary
• Base 2: 1+1 operation - the rightmost digit reverts to 0 and there is a carry
into the next column.

111 Carry Values


0101
+1011
10000
Subtracting in Binary
• The rules of the decimal base applies to binary as well.
• Example;
101
-011
010
• Do the following;
10102 – 01112
1001102 -111012
11102 – 01012
Binary multiplication
• Example:
• 1110
x 1011
1110
1110
0000
1110
10011010
• 1011x1001; 111x101
Fixed Precision and Overflow.

• So far, in talking about binary numbers, we haven’t


considered the maximum size of the number.
• We have assumed that as many bits are available as
needed to represent the number.
• In most computer systems, this isn’t the case.
Numbers in computers are typically represented
using a fixed number of bits.
• Numbers in which a specific number of bits are
used to represent the value are called fixed
precision numbers.
Fixed Precision and Overflow.
• These sizes are typically 8 bits, 16 bits, 32 bits, 64
bits and 80 bits.
• These sizes are generally a multiple of 8, as most
computer memories are organized on an 8 bit/byte
basis.
Fixed Precision and Overflow.

• For example, there are 256 possible combinations


of 8 bits, therefore an 8 bit number can represent
256 distinct numeric values and the range is
typically considered to be 0-255. Any number larger
than 255 can’t be represented using 8 bits.
• Similarly, 16 bits allows a range of 0-65535.
Fixed Precision and Overflow.

• When fixed precision numbers are used,the concept


of overflow must be considered.
• An overflow occurs when the result of a calculation
can’t be represented with the number of bits
available.
• For example when adding the two eight bit
quantities: 150 + 170, the result is 320.
Fixed Precision and Overflow.
• This is outside the range 0-255, and so the result
can not be represented using 8 bits.
• The result has overflowed the available range.
• When overflow occurs, the low order bits of the
result will remain valid, but the high order bits will
be lost.
• This results in a value that is significantly smaller
than the correct result.
• When doing fixed precision arithmetic (which all
computer arithmetic involves), it is necessary to be
conscious of the possibility of overflow in the
calculations.
Fixed Precision and Overflow.

• Overflow for unsigned numbers occurs when the addition


of 2 n-bit numbers result in an answer with n+1 bits.

Example; 1101 (13+5=18)


+ 0101
10010
• The result is out of range.
Signed and Unsigned Numbers.

• So far, we have only considered positive values for


binary numbers.
• When a fixed precision binary number is used to
hold only positive values, it is said to be Unsigned.
• In this case, the range of positive values that can
be represented is 0 -- 2n-1, where n is the number
of bits used.
Signed and Unsigned Numbers

• It is also possible to represent Signed (negative as


well as positive) numbers in binary.
• In this case, part of the total range of values is used
to represent positive values, and the rest of the
range is used to represent negative values.
Sign Magnitude

• Left most bit used to represent sign


– 0 = positive value
– 1 = negative value.
It is important to decide how many bits will be used to
represent the number
• Example: Representing +5 and -5 on 8 bits:
– +5: 00000101
– -5:10000101
• So the very first step we have to decide on the number
of bits to represent number
Signed Binary Numbers

• The sign bit is the Left Most bit in signed binary


numbers.
• A 0 represents a positive number and a 1
represents a negative number.
• The remaining bits are the Magnitude bits.
• Example:
• Sign bit (MSB) rest Magnitude bits:
00011001 -> positive 25
10011001 -> negative 25
Signed Binary Numbers

• Example: Express the decimal number 39 as an 8 bit


number in sign magnitude.
• Solution; First write the 8-bit binary number for +39
; 00100111
• Change the sign bit to 1; ie 10100111
Signed Binary Numbers
• The unsigned 8-bit numbers cover the decimal range
of 0 to 255.
• Since the MSB is used as a sign bit in sign magnitude
numbers, the range gets modified to -127 to +127 for
an 8 bit number.
• For 16 bit numbers, the range is modified to -32767 to
+32 767 .
Drawback with Sign Magnitude

• Two representations of zero


• Using 8-bit sign-magnitude…
• 0: 00000000
• 0: 1000000
Addition of signed numbers

• The addition of two numbers in the signed magnitude


system follows the ordinary arithmetic.
• If the signs are the same, we add the two magnitudes
and give the sum the common sign. For example: +7
and +12 will result in +19.
• If the signs are different, we subtract the smaller
magnitude from the larger and give the result the sign
of the larger magnitude.
Addition of signed numbers

• For example, a+7 and a -12 will give a -5. This is


done by subtracting the smaller magnitude 7 from
the larger magnitude 12 and using the sign of 12 for
the sign of the result.
• As seen from the above examples, this is a process
that requires the comparison of the signs and the
magnitudes and then performing either addition or
subtraction.
Addition of signed numbers

• The same procedure applies to binary numbers in


sign-magnitude representation.
• In contrast, the rule for adding in the complement
system does not require a comparison or subtraction
but only addition. The procedure is very simple.

• The complements of binary numbers are important


as in many computer systems these complemented
forms of binary digits allow the representation of
signed (negative) numbers.
1’s Binary Complement

• In the 1’s complement format, the positive


numbers remain unchanged.
• The negative numbers are obtained by taking
the 1’s complement of the positive
counterparts.
• To obtain the 1’s compliment of a binary
number, simply change all of the 1’s to 0’s and
0’s to 1’s:
• Example;
10110010 Binary number
01001101 1’s compliment
1’s Complement
• In other words, the 1’s compliment of a binary number is
the number that results when we compliment each bit.
• This complimented value represents the negative value of
the original number.
Represented Number

10000000 11111111 00000000 ... 01111111

-12710 -010 010 ... 12710

Original Number

1's binary complement for 8 digit numbers


1’s Complement

•One of the difficulties of using the 1’s


complement is its representation of
zero.
•Like the sign magnitude, it has a positive
zero and a negative zero. (0000 -
positive zero; 1111- negative zero.)
2’s complement

• Two's complement notation is the most commonly


used for integer arithmetic (since it simplifies binary
subtraction).
• The other benefit it offers is that it possesses only
one code for zero.
• Note that the most significant bit (MSB) acts as a
sign bit and the positive values' codes are the same
as for sign magnitude. The negative values are in
two's complement notation
2’s Complement

• Positive magnitudes are represented in the


same way as in the case of sign-bit or 1’s
complement representation.
• Negative magnitudes are represented by the
2’s complement of their positive
counterparts.
• To obtain the 2’s compliment of a binary digit
add 1 to the 1’s compliment.
• 2’s compliment = (1’s compliment) + 1
2’s Complement
• Find 2’s complement of 10110010.
 10110010 Binary number
 01001101 1’s complement
+ 1 Add 1
01001110
• The 2’s complement format is very popular
because arithmetic operations are relatively easier
to perform when the numbers are represented in
the 2’s complement format.
2’s Complement
• With 2’s complement, there is one unique zero (unlike 1’s
complement and sign magnitude.)
• The most positive number is given by 2n-1-1 and the most
negative numbers is given by -2n-1.
• The range for a 4 bit number is from -8 to 7.

Represented Number

10000000 11111111 00000000 ... 01111111

-12810 -110 010 ... 12710

Original Number

2's complement for 8 digit numbers


2’s complement subtraction

• Binary subtraction can be performed directly (as for


base-10) but it is tricky due to the 'borrowing'
process. The two's complement approach is easier,
less error prone, and is therefore recommended.
• It is based upon the fact that for two numbers A
and B, then A-B=A+(-B) where -B is the 2’s
complement of B.
• So rather than subtracting B directly from A, the
complement of B is added to A.
• All that is needed is a way of generating the
complement of a number.
2’s complement subtraction

• If the subtraction of 2 binary numbers A and B is to


be performed using 2’s compliment, then the
following steps must be followed;
i) First add A to 2’s compliment of B
ii) If a carry is generated, then the result is
positive and in its true form.
iii) If a carry is not produced, then the result is
negative and is in it’s 2’s compliment form. It
has to be converted to its true form.
2’s complement subtraction

• A carry out of the sign –bit position is discarded.


NB; The negative numbers must be initially in 2’s
complement and the sum obtained after the
addition if negative, is in 2’s complement form.
• The can be explained with the help of the
following examples:
2’s complement subtraction

i) A = + 7 00000111 iii) A=+7 00000111


B = +12 + 00001100 B = -12 +11110100
+19 00010011 -5 11111011
NB; answer is negative and is
ii) B – A (12 -7) in 2’s compliment. It has
12 00001100 to be changed to its true
- 7 + 11111001(2’ form.
comple) 1111011
5 (1)00000101
0000100
+ 1
- 0000101 (true form)
Class exercise

Given 2 binary numbers a) X=1010100


and b) Y=1000011: perform the
following subtractions using 2’s
complements.
(a) X – Y
(b) Y - X
Introduction to binary codes

• Usually, the digital data is represented, stored and


transmitted as groups of binary digits (bits).
• The group of bits, known as binary code, represent
both numbers and letters of the alphabet as well as
many special characters and control functions.
• They are classified as numeric or alphanumeric
codes.
• Numeric codes are used to represent numbers.
• Alphanumeric codes are used to represent
characters: alphabetic letters and numerals.
Classification of codes

• Alphanumeric codes: This is a code which consists


of both numeric and alphabetic characters. Most of
these codes, however, also represent symbols and
various instructions necessary for conveying
intelligible information. The most commonly used
alphanumeric codes are ASCII (American Standard
Code for Information Interchange) and EBCDIC
(Extended Binary Coded Decimal Interchange Code.
• While the former is popular with microcomputers
and is used on nearly all personal computers and
workstations, the latter is mainly used with larger
systems.
Classification of codes

• Weighted codes: In weighted codes, each digit


position of the number represents a specific weight.
Eg decimal code ,binary, BCD (8421)
• Non-weighted codes: Non-weighted codes are not
assigned with any weight to each digit position ie
each digit position within the number is not
assigned fixed value. Eg gray code, excess 3
Binary Coded Decimal
• The binary coded decimal (BCD) is a type of binary
code used to represent a given decimal number in
an equivalent binary form.
• A problem of binary arithmetic is that direct
conversion from binary to decimal (for numbers of
many digits) requires a quite complex digital circuit.
• Therefore, often when a number is being held ia a
digital circuit, immediately before output to a
display (in decimal form), binary coded decimal
(BCD) rather than straight binary code is used.
• BCD encodes each decimal digit with its binary
equivalent using four bits. So decimal digits are
simply represented in four bits by their direct binary
values.
Binary Coded Decimal

• A disadvantage of this is that only 10 of the possible


16 (2 4) codes that four bits can produce are used.
• The BCD equivalent of a decimal number is written
by replacing each decimal digit in the integer and
fractional parts with its four-bit binary equivalent.
As an example, the BCD equivalent of (23.15)10 is
written as (0010 0011.0001 0101)BCD.
Binary Coded Decimal

• Example ; How would 91610 be represented in


binary coded decimal?
• Solution
• Since the binary codes for 9, 1 and 6 are 1001, 0001
and 0110 respectively, then
• 91610 = 100100010110BC D.
• Note that the BCD code is 12 bits long since each of
the decimal digits is coded by four bits.
Binary Coded Decimal
• The BCD code described above is more precisely
known as the 8421 BCD code, with 8, 4, 2 and 1
representing the weights of different bits in the four-
bit groups, starting from MSB and proceeding
towards LSB.
• This feature makes it a weighted code, which means
that each bit in the four-bit group representing a
given decimal digit has an assigned weight.
• Other weighted BCD codes include the 4221 BCD and
5421 BCD codes. Again, 4, 2, 2 and 1 in the 4221 BCD
code and 5, 4, 2 and 1 in the 5421 BCD code
represent weights of the relevant bits.
Gray Code

• The gray code is used in applications where the


normal sequence of binary numbers may produce
an error during the transition from one number to
the next.
• With gray code, only one bit changes in value
during any transition between two numbers.
• See table below
Gray Code
Classification of codes

• Error detecting and correcting codes: When digital


information in binary form is transmitted from one
circuit/system to another circuit/system, an error
may occur. This means that a signal corresponding
to 0 may change to 1 or vice versa due to presence
of noise. To maintain the data integrity between
transmitter and receiver, a bit or more than 1 bit
are added in the data.
Classification of codes
• These extra bit/bits form the code. Codes which allow
only error detection are called error detecting codes,
and code which allow error detecting and correction
are called error detecting and correction codes. Eg
parity
• A parity bit is an extra bit included with a message to
make the total number of 1’s transmitted either odd
or even. The parity bit is helpful in detecting errors
during the transmission of information from one
location to another.
THE END

You might also like