Sie sind auf Seite 1von 73

UNIVERSITY OF GONDAR

INSTITUTE OF TECHNOLOGY
Department of Electrical and Computer Engineering

Course
Logic name: Digital Logic Design
and Computer Design Fundamentals
Course code: ECEg3141
Chapter
Course instructor: Mebtu.F 1 – Digital
Computers
CHAPTER and Information
ONE: Number system ,operations
and codes
Part one: ANALOG AND DIGITAL SYSTEM
Charles Kime & Thomas Kaminski
© 2004 Pearson Education, Inc.
Terms of Use
(Hyperlinks are active in View Show mode)
Introduction to Digital and analogue Systems
Continuous Vs Discrete (Analog Vs Digital)
• Quantities are measured, monitored, recorded, manipulated
arithmetically, observed, or in some other way utilized in most
physical systems(represent their values efficiently and accurately)
• There are basically two way of representing the numerical value of
quantities i.e. Analogue & digital.
1.Analog Representations:
• In analog representation a quantity is represented by a
continuously variable, proportional indicator.
• In the world most quantities having continuous value are analogue.
• In analog representation quantities are continuous range of value
Cont…
• Analog means Continuous (both in time and amplitude)
• Analog information exhibit smooth, gradual changes over
time and assume a continuous (infinite) range of amplitudes.
• Examples:
Body temperature
 Our speech
Room temperature
 Electric current,volt… etc.
Cont…
• automobile speedometer used to measure speed of the car.
• Thermometers use a column of mercury whose height is
proportional to temperature.
• For example, the temperature of an oven settable anywhere from 0
to 100 °C may be measured to be 65 °C or 64.96 °C or 64.958 °C or
even 64.9579 °C and so on, depending upon the accuracy of the
measuring instrument.
• In these two examples the physical quantities (speed and
temperature) are being coupled to an indicator by purely mechanical
means. In electrical analog systems, the physical quantity that is
being measured or processed is converted to a proportional voltage
or current (electrical signal).
• This voltage or current is then used by the system for display,
processing, or control purposes.
Cont…
2.Digital Representations:
• In digital representation the quantities are represented not by
continuously variable indicators but by symbols called digits.
• Digital Discrete, Not continuous.
• Digital information assume a limited (finite) set of “Discrete”
values, not a continuous range of values.
• Values change suddenly (not smoothly) by “Jumping” between
values.
• Examples:
 Energy levels of electrons in atoms.
Digital clock
Cont…
• As an example, consider the digital clock, which provides the time of
day in the form of decimal digits that represent hours and minutes
(and sometimes seconds). As we know, the time
of day changes continuously, but the digital clock reading does not
change continuously; rather, it changes in steps of one per minute (or
per second).
• analog ≡continuous
• digital ≡ discrete (step by step)
Advantages and Limitations of Digital
Techniques
• Advantages
 Digital systems are easier to design: The switching circuits in which
there are only two voltage levels, HIGH and LOW, are easier to design.
The exact numerical values of voltages are not important because they
have only logical significance; only the range in which they fall is
important.
 Information storage is easy: There are many types of semiconductor
and magnetic memories of large capacity which can store data for
periods as long as necessary.
 Accuracy and precision are greater: Digital systems arc much more
accurate and precise than analog systems, because digital systems can
be easily expanded to handle more digits by adding more switching
circuits. Analog systems will be quite complex and costly for the same
accuracy and precision.
Cont…
Digital systems are more versatile: It is fairly easy to design
digital systems whose operation is controlled by a set of stored
instructions called the program. Any time the system operation
is to be changed, it can easily be accomplished by modifying the
program.
Digital circuits are less affected by noise: Unwanted electrical
signals are called noise. Noise is unavoidable in any system.
Since in analog systems the exact values of voltages are
important and in digital systems only the range of values is
important, the effect of noise is more severe in analog systems.
In digital systems, noise is not critical as long as it is not large
enough to prevent us from distinguishing a HIGH from a LOW.
Cont…
DIGITAL PROCESSING IN THE REAL WORLD
• Analog-to-digital-converters (ADC) are used to digitize raw analog
inputs.
• Digital-to-analog-converters (DAC) are used to regenerate analog
signals from their digitized form.
• To take advantage of digital techniques when dealing with analog
inputs and outputs, four steps must be followed:
1. Convert the physical variable to an electrical signal (analog).
2. Convert the electrical (analog) signal into digital form.
3. Process (operate on) the digital information.
4. Convert the digital outputs back to real-world analog form.
Cont…
Cont…
• The need for conversion between analog and digital forms
of information can be considered a drawback because of
the added complexity and expense.
• Another factor that is often important is the extra time
required to perform these conversions.
• In many applications, these factors are outweighed by the
numerous advantages of using digital techniques, and so
the conversion between analog and digital quantities has
become quite common place in the current technology.
• There are situations, however, where using only analog
techniques is simpler and more economical.
For example, the process of signal amplification is most
easily accomplished using analog circuitry.
Cont…
• It is becoming more and more common to see both digital
and analog techniques employed within the same system
in order to profit from the advantages of each.
• In these hybrid systems, one of the most important parts
of the design phase involves determining what parts of
the system are to be analog and what parts are to be
digital.
Analog electronics system
• Sound wave are
analog in nature.
• Picked by the
microphone and
converted to audio
signal having a
voltage.
• Input to amplifier and
increase the volume
and frequency of audio
signal.
• To speaker and convert
to sound wave having
much greater volume.
Digital and analog system
• CD player is digital converted to analog using ADC.
• After ADC, the same process to analog system,
Comparison chart
• Analog • Digital
 Signal :Analog signal is a  Signal: Digital signals are
continuous discrete time signals
signal which represents generated by digital
physical modulation.
measurements.  Waves: Denoted by square
 Waves: Denoted by sine waves waves.
 Representation: Uses  Representation: Uses discrete
continuous range or discontinuous
of values to represent values to represent information
information.  Example: Computers, CDs,
 Example: Human voice in air, DVDs, and other
analog digital electronic devices.
electronic devices.  Technology: Samples analog
 Technology: Analog waveforms into a
technology records limited set of numbers and
waveforms as they are. records them.
Cont…
 Data transmissions: Subjected to Response to Noise: Less affected
deterioration by noise during since noise response are analog in
transmission and write/read cycle nature.
 Response to Noise: More likely to Flexibility: Digital hardware is
get affected reducing accuracy. flexible in implementation
 Flexibility: Analog hardware is not  Memory: Stored in the form of
flexible binary bit
 Memory: Stored in the form of Power: Digital instrument draws
wave signal. only negligible power.
 Power: Analog instrument draws Cost : Cost is high and not easily
large power. portable
 Cost: Low cost and portable.
 Data transmissions(Digital): Can
be noise-immune without
deterioration during transmission
and write/read cycle.
Binary digit, Logic level & Digital wave form
• Digital electronics involves circuits and systems in which there are
only two possible states. The states are represented by two different
levels:
Digit Values: 0, 1
Logic Levels: True, False
Signal Levels(voltage and current): Low, High
States: ON, OFF
• In digital system such as computers, combination of the two state,
called codes are used to represent numbers, symbols, alphabetic
characters, and other types of information.
• Binary digit:
 Each of the two digit in binary system,1 and 0 is called a bit, which is the
contraction of the word binary digit.
 In digital circuit ,two different voltage level are used to represent the two bits
 Generally one is represented by the higher voltage, which we will refers as to
HIGH and zero is represented by the lower voltage level ,which we will refers
to as a LOW.
 This is called positive logic
HIGH = 1 LOW = 0

 In another system one is represented by LOW and zero is represented by


HIGH, this system is called negative logic.

 A group of bits(combination of 1‟s and 0‟s) are called code


• Logic level:
The voltage used to represent 1 and 0 are called logic level,
ideally one voltage level represents a high and
another voltage level represents low.
In practical HIGH can be any voltage between the specified
maximum value and the specified minimum value. likewise
LOW can be any voltage between the specified maximum value
and the specified minimum value.
• Digital wave form:
Digital wave form is made up of series of pulses.
Digital wave form consists of voltage level that are changing
back and so forth between the high and low level or state.
Positive going pules is generated, the voltage or current goes
from its LOW level to HIGH level.
negative going pules is generated, the voltage or current goes
from its HIGH level to low level
• Waveform characteristic:
Digital wave form are can be classified as periodic or non
periodic.
A periodic pulse waveform is one that repeats itself at a fixed
interval, called a period (T). The frequency (f) is the rate at
which it repeats itself and is measured in hertz (Hz).

Fig: Periodic pulse-train


A nonperiodic pulse waveform, of course, does not repeat itself
at fixed intervals and may be composed of pulses of randomly
differing pulse widths and/or randomly differing time intervals
between the pulses.
Fig: Non-Periodic pulse-train

• An important characteristic of a periodic digital waveform is its


duty cycle. The duty cycle is the ratio of the pulse width (tW) to the
period (T) and can be expressed as a percentage.
• TIMING DIAGRAMS:
• A timing diagram is a graph of digital waveforms showing the actual time
relationship of two or more waveforms and how each waveform changes
in relation to the others.
• By looking at a timing diagram, you can determine the states (HIGH or
LOW) of all the waveforms at any specified point in time and the exact
time that a waveform changes state relative to the other waveforms.
• Figure 1.6 is an example of a timing diagram made up of four waveforms.
From this timing diagram you can see, for example, that the three
waveforms A, B, and C are HIGH only during bit time 7 and they all
change back LOW at the end of bit time 7 (shaded area).

Fig: Example of timing diagram


• DATA TRANSFER:
• Data refers to groups of bits that convey some type of information.
Binary data, which are represented by digital waveforms, must be
transferred from one circuit to another within a digital system or
from one system to another in order to accomplish a given purpose.
• In computer systems, as illustrated in Figure below, binary data are
transferred in two ways: serial and parallel.
• When bits are transferred in serial form from one point to another,
they are sent one bit at a time along a single conductor, as illustrated
in Figure (a) for the case of a computer-to-modem transfer.
• During the time interval from t0 to t1, the first bit is transferred.
During the time interval from t1 to t2 the second bit is transferred,
and so on. To transfer eight bits in series, it takes eight time
intervals.
Cont…
• When bits are transferred in parallel form, all the bits in a group are
sent out on separate lines at the same time. There is one line for each
bit as shown in Figure (b) example of eight bits being transferred
from a computer to a printer.
• To transfer eight bits in parallel, it takes one time interval compared
to eight time intervals for the serial transfer.
• To summarize, an advantage of serial transfer of binary data is that a
minimum of only one line is required. In parallel transfer, a number
of lines equal to the number of bits be transferred at one time is
required.
• A disadvantage of serial transfer is that it takes longer to transfer a
given number of bits than with parallel transfer.
Part two: Number system ,operations and codes
Contents:
• Decimal number & Binary number
• Hexadecimal number
• Octal number
• Number system conversation
Number Systems
• A number system is a system of writing for expressing numbers. It is
the mathematical notation for representing numbers of a given set by
using digits or other symbols in a consistent manner.
• It provides a unique representation to every number and represents
the arithmetic and algebraic structure of the figures. It also allows us
to operate arithmetic operations like addition, subtraction, and
division
• Number systems can be classified into its sub-types on the basis of
base of that system. Base of a number systems plays crucial role in
understanding the number system and to convert it from one sub-
type to other sub-type. Base is also sometimes referred
as radix; both these terms have same meaning.
Cont…
• Computer numeral system:
When we type any letter or word, the computer translates them
into numbers since computers can understand only numbers. A
computer can understand only a few symbols called digits, and
these symbols describe different values depending on the
position they hold in the number.
Number system can be classified based on the basis of the
“base” as shown in figure 1.1:
The binary number system is the most important one in digital
systems.
The decimal system is important because it is universally used
to represent quantities outside a digital system
Cont…
• The value of any digit in a number can be determined by:
The digit
Its position in the number
The base of the number system

Fig1.1: Number system classification


Decimal number system
• The decimal number system uses the symbols 0,1,2,3,4,5,6,7,8
and 9.
• The decimal number system contains 10 symbols and is sometimes called the
base 10 system.
• The decimal system is a positional value system in which the
value of a digit depends on its position.
• In general „‟ Any number is simply the sum of the products of
each digit value and its positional value ‟‟
Decimal Counting:
• When counting in decimal system, we start with 0 in the unit‟s
position and take each symbol (digit) in progression until we reach 9.
• Then we add a 1 to the next higher position and start over with
zero in the first position. This process continues until the count of 99
is reached.
• Then we add a 1 to third position and start over with zeros in first
two positions.
• The same pattern is followed continuously as high as we wish to
count.
• It is important to note that in decimal counting
the units position (LSD) changes up ward with each step in the
count.
 the tens position changes up ward every 10 steps in the count.
the hundreds position changes upward every 100 steps in the
count and so on.
Binary number system
• A binary system is a code that uses only two basis symbols, 0 &1
and is sometimes called the base 2 system. Therefore, it is less
complicated compared to decimal numbers.
• This base 2 system can be used to represent any quantity that can be
represented in decimal or other number systems.
• The binary system is also a positional value system, where in each
binary digit has its own value or weight expressed as a power of 2.
• The most significant bit (MSB) is the left most bit (largest weight).
The least significant bit (LSB) is the right most bit (Smallest
weight).
Binary Counting:
• Let us use 4 bit binary numbers to illustrate the method for
counting in binary. The sequence (shown on the right side) begins
with all bits at 0, this is called the Zero count.
• For each successive count the units (20) position toggles; that is, it
changes from one binary value to the other. Each time the units bits
changes from a 1 to 0, the twos (21) position will toggle (change
states).
• Each time the twos position changes from 1 to 0, the fours
(22)position will toggle (change states).
• Like wise, each time the fours position goes from 1to 0, the
eights (23) position toggles……..from table1.1
• In general, with “n” bits we can count up to a number equal to 2n-1
Table1.1
Hexadecimal Number Systems
• The hexadecimal (base-16) number system has become a very
standard way of communicating numeric values in digital systems.
• Hexadecimal numbers are one of the most important numbers in
digital systems, as “Assembly” language (machine language) uses
this number to program a micro processor system.
• It uses sixteen characteristics, but easy to read as each of its 4 bits
are used to represent a number between 0-16.
• It uses the digits
0 through 9 plus
‰ the letters A, B, C, D, E and F as the 16 digit symbols.
• The digit positions are weighted as powers of 16 as shown below,
rather than as powers of 10 as in the decimal system.
Cont…

• Table1.2 shows the relationships among hexadecimal, decimal, and


binary. Note that each hexadecimal digit represents a group of four
binary digits.
• It is important to remember that hex (abbreviation for
“hexadecimal”) digits A through F are equivalent to the decimal
values 10 through 15
Cont…
Counting: • Table1.2
• in Hexadecimal When counting
in hex, each digit position can be
incremented (increase by 1) from
0 to F.
• Once a digit position reaches the
value F, it is reset to 0 and the next
digit position is incremented.
• This is illustrated in the following
hex counting sequences.
• 10, 11, 12, ....., 1f, 20, 21, ..., 28,
29, 2A, 2B, 2C, 2D, 2E, 2F,30,
31,… 6F9,6FA, 6FB,6FC,
6FD,6FE, 6FF, 700
Cont…
Here are some advantages of using the hexadecimal system:
• It is very concise and by using a base of 16 means that the number of
digits used to signify a given number is usually less than in binary or
decimal. It allows you to store more information using less space.
• It is fast and simple to convert between hexadecimal numbers and
binary. Hexadecimal can be used to write large binary numbers in just a
few digits.
• It makes life easier as it allows grouping of binary numbers which
makes it easier to read, write and understand. It is more human-friendly,
as humans are used to grouping together numbers and things for easier
understanding. Also, writing in less digits lowers the possibility of error
occurring.
• Higher information density. With 2 hexadecimal digits, we can express
any number from 0 to 255. To do the same in binary, we need 8 digits.
As we get bigger and bigger numbers, we start needing more and more
digits and it becomes harder to deal with.
Octal Number System
• The octal number system is very important in digital
Computer work.
• The octal number system has a base of eight, meaning
that it has eight possible digits: 0,1,2,3,4,5,6 and 7.
• Thus, each digit of an octal number can have any value
from 0 to 7.
• The advantage of the octal system is its usefulness in
converting directly from a 3 bit binary number.
• The digit positions in an octal number have weights as
follows
Cont…
Counting: • Table1.3: r/ship b/n octal,
• in Octal The largest octal digit decimal and binary
is 7, so that in counting in
octal, a digit position is
incremented up ward form 0 to
7.
• Once it reaches 7, it recycles to
0 on the next count and causes
the next higher digit position
to be incremented.
• For example: 0,1, ..7, 10,
11,..17, 20, …27….
Conversion of one Number System to Another
1) Binary-to-decimal Conversions:
• Any binary number can be converted to its decimal equivalent
simply by summing together the weights of the various positions in
the binary number, which contain a 1 and discarding the weights of
all bits that are 0.
• Fore example:

• Note that the MSB has a weight of 27 even though it is the eighth
bit this is because the LSB is the first bit and has a weight of 20 .
2) Decimal – to – Binary conversions :
• There are two ways to convert a decimal whole number to its
equivalent binary system representation.
• The 1st method (Sum-of-Weights)
The decimal number is simply expressed as a sum of power of 2
and then 1s and 0s are written in the appropriate bit positions.
Example:
a. 5710 =32+16+8+1=25+24+23+0+0+20 =1110012
b. 13210 =
c. 39810 =
d. 415310 =
• The 2nd method („‟Repeated Division‟‟):
This method uses repeated division by 2. Requires repeatedly
dividing the decimal number by 2 and writing down the
remainder after division until the quotient of 0 is obtained.
Cont…
• Example:
a. 2510=?2

a. 39810 =?2
Cont…
• Flow chart for Repeated Division
3) Hex –to- decimal Conversion:
• A hex number can be converted to its decimal equivalent by
using the fact tat each hex digit position has a weight that is
a power of 16.
• The LSD has a weight of 160 = 1,the next higher digit position
has a weight of 161=16, the next has a weight of 162= 256,
and so on.
Example:
a. 35616=3*162+5*161+6*160=768+80+6=85410
b. A3F16 =?10
c. 1BD516=? 10
d. C9A16=? 10
4) Decimal-to-Hex conversion:
• Recall that we did decimal –to- binary conversion using
repeated division by 2. Like wise decimal-to-hex conversion can
be done using repeated division by 16.
Example:
a. Convert the decimal number 378 in to hex.

378 10 =17A16
b. 234 10 =? 16
c. 445 10 =? 16
5) Hex-to-Binary conversion:
• The Hexadecimal number system is used primarily as a
„‟Shorthand‟‟ method for representing binary numbers.
• It is a relatively simple method to convert a hex number to
binary.
• Each hex digit is converted to its 4 bit binary equivalent. (see
table 1.2 „‟Hexadecimal Number system‟‟).
Example: a) 9F216=?2

b) BA616 =?2
6) Binary-to- Hex conversion:
• The binary number is grouped into groups of four bits, and each
group is converted to its equivalent hex digit.
• Zeros (shown shaded) are added, as needed, to complete a four-bit
group.
Example: a) convert 11101001102 =?16

=34616
b) 0101 0010 10112 =? 16
7) Octal to decimal Conversion:
• An octal number, can easily be converted to its decimal equivalent
by multiplying each octal digit by it positional weight i.e. a power
of 8.
E.g. a) 4158 = 4*82 + 1*81 + 5*80 = 256 + 8 + 5 = 26910
b) 23748=? 10
8) Decimal –to – Octal Conversion:
• Decimal integer can be converted to octal by using repeated
division with a division factor of 8.
E.g. a) 35910=? 8
9) Octal to Binary Conversion:
• The conversion from octal to binary is presented by converting
each octal digit to its 3- bit binary equivalent.
E.g. a) 48 8 = ?2

b) 305 8 =?2
10) Binary to Octal Conversion:
• The bits of the binary number are grouped into groups of three bits
starting at the LSB.
• The each group is converted to its octal equivalent.
E.g.a) 1011110012 to Octal

b) 010 011 1102 =?8


Summary of Conversions
• When converting from binary [or octal, or hex] to
decimal, use the method of taking the weight sum of
each digit position.
• When converting from decimal to binary [or octal or
hex] use the method of repeatedly dividing by 2 [or 8
or 16] and collecting remainders.
• When converting from binary to octal [or hex], group the bits in
groups of the three [or four], and convert each group into the
correct octal [or hex] digit.
• From Hexadecimal OR Octal to Binary – Change each symbol to
binary and you are done!
• From Octal to Hexadecimal OR from Hexadecimal to Octal –
Change the higher base to binary and then use #1 or #2 above to
change the binary number to the base desired.
Cont…
• Exercises
67.8210= ---------2
=---------8
=---------16
Binary ARITHMETIC
• Binary arithmetic is essential in all digital computers and in any
other digital systems.
Binary addition:
• The four basic rules for adding binary digits are as follows:

Binary subtraction:
• The four basic rules for subtracting bites are as follows:
0-0=0
1-0=1
1-1=0
0-1=1, with a borrow of 1
Cont…
Binary multiplication:
• The four basic rules for multiplying bites are as follows:
0*0=0 0*1=0
1*0=0 1*1=1
Binary division:
• division in binary follow the same procedure as division in decimal.
Binary CODES
• In the coding, when numbers, letters or words are represented by a
specific group of symbols, it is said that the number, letter or word
is being encoded.
• The group of symbols is called as a code. The digital data is
represented, stored and transmitted as group of binary bits. This
group is also called as binary code.
• When a decimal number is represented by its equivalent binary
number, we call it straight binary coding.
• We have seen that the conversing between decimal and
binary can be come long and complicated for large
numbers.
• For this reason, a means of encoding decimal numbers
that combines some features of both the decimal and binary system
is used in certain situations.
Classification of binary codes

• The codes are broadly categorized into following


four categories:
Weighted Codes
Non-Weighted Codes
Binary Coded Decimal Code
Alphanumeric Codes
Error Detecting Codes
Error Correcting Codes
Cont…
Weighted Codes:
 Weighted binary codes are those binary codes which obey the
positional weight principle. Each position of the number
represents a specific weight. Several systems of the codes are
used to express the decimal digits 0 through 9. In these codes
each decimal digit is represented by a group of four bits.
Binary Coded Decimal (BCD) code
• If each digit of a decimal number is represented by its 4- bit
binary equivalent the result is a code called binary-coded decimal (here
after abbreviated BCD).
• Examples a) The decimal number 437 is changed to its BCD equivalent as
follows:

b) 958010 =? In BCD
• Clearly, only the 4- bit binary numbers from 0000 through 1001 are used.
‰The BCD Code does not use the numbers 1010, 1011, 1100, 1101, 1110
and 1111.
• In other words only 10 of the 16 possible 4 bit binary code groups are used.
• If any of the „‟forbidden‟‟ 4 bit numbers ever occurs in machine using the
BCD code, it is usually an indication that an error has occurred.
Comparison of BCD and Binary
• It is important to realize that BCD is not another number system like
binary, decimal, and hexadecimal. In fact, it is the decimal system
with each digit encoded in its binary equivalent.
• It is also important to understand that a BCD number is not the same
as a straight binary number.
• A straight binary number takes the complete decimal number and
represents it in binary; the BCD code converts each decimal digit to
binary individually.
• To illustrate, take the number 137 and compare its straight binary
and BCD codes:
13710 = 100010012 (binary)
13710 = 0001 0011 0111 (BCD)
25310 =? In BCD and binary
Cont…
• The BCD code requires 12 bits, while the straight binary code
requires only eight bits to represent 137.
• BCD requires more bits than straight binary to
represent decimal numbers of more than one digit because BCD
does not use all possible four-bit groups, as pointed out earlier, and
is therefore somewhat inefficient.
• The main advantage of the BCD code is the relative ease of
converting to and from decimal. Only the four-bit code groups for
the decimal digits 0 through 9 need to be remembered.
• This ease of conversion is especially important from a hardware
standpoint because in a digital system, it is the logic circuits that
perform the conversions to and from decimal.
Example:a) Convert the BCD number 011111001000 to its decimal
equivalent.
Non-Weighted Codes
• In this type of binary codes, the positional weights are not assigned.
The examples of non-weighted codes are Excess-3 code and Gray
code
Gray code :
• It is the non-weighted code and it is not arithmetic codes i.e. there
are no specific weights assigned to the bit position.
• The Gray code belongs to a class of codes called minimum change
codes, in which only one bit in the code group changes when going
from one step to the next.
• Because of this, the gray code is not suitable for arithmetic
operations but finds application in input/out put devices and some
types of analog-to digital converters.
• The most common application of the Gray code is in shaft position
encoders. A shaft position encoder produces a code word which
represents the angular position of the shaft
Cont…
• If we examine the Gray code groups for
each decimal number, it can be seen that
in going from any one decimal number
to the next, only one bit of Gray code changes.

For example:
Decimal Gray code
3 to 4 0010 to 0110
14 to 15 1001 to 1000
• Compare this with the binary code,
where anywhere from one to all of the
bits changes in going from one step to
the next.
For example:
Decimal Binary code Gray code
7 to 8 0111 to 1000 0100 to 1100
• The Gray code is often used in situations where
other codes, such as binary, might produce
erroneous or ambiguous results during those
translations in which more that one bit of the code
is changing.
Binary-to-Gray code Conversion
• Conversion between binary code and Gray code is sometimes useful.
• The following rules explain how to convert from a binary number to a
Gray code word:
The most significant bit (left-most) in the Gray code is the same as
the corresponding MSB in the binary number.
Going from left to right, add each adjacent pair of binary code bits
to get the next Gray code bit. Discard carries.

a) Gray b) Binary
Figure 1-2 Converting (a) binary to Gray and (b) Gray to binary
Cont…
Example: a) convert binary 10110 to gray code

The Gray code is 1 1 101


Gray -to- Binary Conversion:
• The following rules explain how to convert from gray code to a
binary number :
The most significant bit (left-most) in the binary code is the
same as the corresponding bit in the Gray code.
Add each binary code bit generated to the Gray code bit in the
next adjacent position. Discard carries.
Cont…
Example:a) the conversion of the Gray code word 11011 to binary

The binary number is 10010


Exercise: a) convert the binary number 11000110 to gray code
b) convert the gray code 10101111 to binary
Cont…
Excess-3 code:
• The Excess-3 code is also called as XS-3 code. It is non-weighted
code used to express decimal numbers.
• The Excess-3 code words are derived from the 8421 BCD code
words adding (0011)2 or (3)10 to each code word in 8421.
• To encode a decimal number to the excess –3 form, we add 3 to
each digit of the decimal number and convert to binary form.

• Note that both BCD and Excess-3 use only 10 of the 16 possible 4
bit code groups.
• The Excess-3 code, however, does not use the same code groups.
• For Excess-3 code, the invalid code groups are 0000, 0001, 0010,
1101,1110, and 1111
Cont…
• Excess-3 code representation of decimal number.

Example: a) convert decimal 4 to excess 3 code


b) 3910 =? In excess 3
Alphanumeric Codes
• A binary digit or bit can represent only two symbols as it has only two
states '0' or '1'. But this is not enough for communication between two
computers because there we need many more symbols for
communication.
• Computer should recognize “codes” that represent letters of the alphabet,
punctuation marks, and other special characters as well as numbers.
• These codes are called ‟‟alphanumeric codes‟‟.
• A complete alphanumeric code would include:
 The 26 lower case letters;
 26 upper case letters,
 10 numeric digits,
 7 punctuation marks, and
 anywhere from 20 to 40 other characters, such as +, /, #, %,
*, and so on
Cont…
• The following three alphanumeric codes are very commonly used for the data
representation.
 American Standard Code for Information Interchange (ASCII).
 Extended Binary Coded Decimal Interchange Code 8 bit representation
(EBCDIC).
 Five bit Baudot Code.
• The most widely used alphanumeric code, the America standard code for
Information Interchange (ASC II), is used in most micro computers and mini
computers, and in many mainframes.
• The ASCII code (pronounced „‟ask-ee‟‟) is a 7- bit code, and so it has 2 7= 128
possible code groups.
• We can say that an alphanumeric code represents all of the various characters
and functions that are found on a computer keyboard.
• Note that a 0 was added to the leftmost bit of each ASCII code because the
codes must be stored as bytes (eight bits). This adding of an extra bit is
called padding with 0s.
Cont…
Cont…
Example: a) Determine the binary ASCII codes that are entered from
the computers keyboard when the following basic program statement
is typed in. also express each code in hexadecimal.
20 PRINT “A=”;X
b) write your name and ID number using binary ASCII codes
and equivalent hexadecimal code? Like
ABEBE KEBEDE
ID=GUR/0000/09

Das könnte Ihnen auch gefallen