0% found this document useful (0 votes)
5 views

Digital Logic Design- Chapter Two - Modified - Copy (1)

Chapter Two of 'Digital Logic Design' by Getahun N. covers various number systems including decimal, binary, hexadecimal, and octal, detailing their structure, conversion methods, and arithmetic operations. It explains Binary-Coded Decimal (BCD) and introduces digital codes such as Gray code and ASCII, emphasizing their applications in digital systems. The chapter provides examples and exercises for converting between these systems and codes.

Uploaded by

Caleb fikadu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Digital Logic Design- Chapter Two - Modified - Copy (1)

Chapter Two of 'Digital Logic Design' by Getahun N. covers various number systems including decimal, binary, hexadecimal, and octal, detailing their structure, conversion methods, and arithmetic operations. It explains Binary-Coded Decimal (BCD) and introduces digital codes such as Gray code and ASCII, emphasizing their applications in digital systems. The chapter provides examples and exercises for converting between these systems and codes.

Uploaded by

Caleb fikadu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 39

Chapter TWO

Number System, Operations and


Codes

DIGITAL LOGIC DESIGN

By Getahun N.
Decimal Numbers SYSTEM
 The decimal system is Composed of 10 numerals or symbols.
 These 10 symbols are 0, 1, 2, 3,….., 9;
 Using these 10 symbols as digits of a number, we can express any
quantity.
 The decimal system, also called the base-10 system because it has 10
digits.
 The position of each digit in a decimal number indicates the
magnitude of the quantity represented and can be assigned a weight.
Decimal Numbers SYSTEM
 The weights for whole numbers are positive powers of 10 that
increase from right to left, beginning with 10° = 1.

 For fractional numbers, the weights are negative powers of ten that
decrease from left to right beginning with 10-1.

 The value of a decimal number is the sum of the digits after each
digit has been multiplied by its weight.
Decimal Numbers SYSTEM
 .
Binary Numbers SYSTEM
 The binary number system has two digits (bits).
 The two binary digits (bits) are 1 and 0.
 The position of a 1 or 0 in a binary number indicates its weight.
 The weights in a binary number are based on powers of two.
 The right-most bit is the LSB (least significant bit) in a binary whole
number and has a weight of 20 = 1.
 The weights increase from right to left by a power of two for each bit.
Binary Numbers SYSTEM
 The left-most bit is the MSB (most significant bit).
 The left-most bit is the MSB in a binary fractional number and has a
weight of 2-1 = 0.5.
 The fractional weights decrease from left to right by a negative power
of two for each bit.
 Generally, the weight structure of a binary number is

 where n is the number of bits from the binary point


Binary to Decimal Conversion
 The decimal value of any binary number can be found by adding the
weights of all bits that are 1 and discarding the weights of all bits that
are 0.
 Example:- Convert the binary whole number 1101101 to decimal.
Binary to Decimal Conversion
 Example:- Convert the fractional binary number 0.1011 to decimal.

 Example:-
 ..
Decimal to Binary Conversion
A. SUM-OF-WEIGHTS METHOD:
 One way to find the binary number that is equivalent to a given
decimal number is to determine the set of binary weights whose
sum is equal to the decimal number.
 Example: Convert the decimal number 49 to binary.
 Solution: Write down column weights until the last number is larger
than the one you want to convert.

 Example:- Convert the following decimal numbers to binary:


Decimal to Binary Conversion
B. REPEATED DIVISION-BY-2 METHOD
 To get the binary number for a given decimal number, divide
the decimal number by 2 until the quotient is 0.
 Note the remainders form the binary number.
 The first remainder to be produced is the LSB in the binary
number, and the last remainder to be produced is the MSB.
 Example: Convert the decimal number 49 to binary.
Decimal to Binary Conversion
 REPEATED DIVISION
 Divide the decimal number by
2.
 Write the remainder after each
division until a quotient of zero
is obtained.
 The first remainder is the LSB.
 The last is the MSB.
Converting Decimal Fractions to Binary
A. SUM-OF-WEIGHTS:-
 The sum-of-weights method can be applied to fractional decimal
numbers.

B. REPEATED MULTIPLICATION BY 2 :-
 Multiplying each resulting fractional part of the product by 2 until
the fractional product is zero or until the desired number of
decimal places is reached.
 The carry digits, or carries, generated by the multiplications
produce the binary number.
 The first carry produced is the MSB, and the last carry is the LSB.
Converting Decimal Fractions to Binary
 EXAMPLE: Convert the decimal fraction 0.188 to binary by
repeatedly multiplying the fractional results by 2.
 SOLUTION:

 EXERCISE: Convert each decimal number to binary by using


the repeated multiplication-by-2 for fractions.
a) 0.625 b) 0.375
Binary Arithmetic
 BINARY ADDITION:
Binary Arithmetic
 BINARY SUBTRACTION:

 EXAMPLE:- Subtract the binary number 00111 from 10101 and show
the equivalent decimal subtraction.
 SOLUTION:-

 EXERCISE: Perform the following binary subtraction:


Hexadecimal Numbers
 Hexadecimal uses sixteen characters to
represent numbers:
 The numbers 0 through 9 and the
alphabetic characters A through F.
Binary-to-Hexadecimal Conversion
 Large binary number can easily be converted to hexadecimal by
grouping 4-bits at a time and writing the equivalent hexadecimal
character.
 Simply break the binary number into 4-bit groups, starting at the LSB
and replace each 4-bit group with the equivalent hexadecimal symbol.
 EXAMPLE:- Convert the following binary to hexadecimal:
 SOLUTION:
Hexadecimal-to-Binary Conversion
 To convert from a hexadecimal number to a binary number, reverse
the process and replace each hexadecimal symbol with the appropriate
four bits.
 Hexadecimal is a convenient way to represent binary numbers.
Hexadecimal-to-Decimal Conversion
 One way to find the decimal equivalent of a hexadecimal number is to
first convert the hexadecimal number to binary and then convert from
binary to decimal.
 .

 Another is to multiply the decimal value of each hexadecimal digit by


its weight and then take the sum of these products.
 Example:- Convert the following hexadecimal numbers to decimal:

 Solution:
OCTAL NUMBERS
 The octal number system is composed of eight digits, which are 0, 1,
2, 3, 4, 5, 6, 7
 The octal number system has a base of 8.
 Octal-to-Decimal Conversion:
 The evaluation of an octal number in terms of its decimal
equivalent is accomplished by multiplying each digit by its weight
and summing the products.
 Octal-to-Binary Conversion:-
 Because each octal digit can be represented by a 3-bit binary
number, it is very easy to convert from octal to binary.
OCTAL TO BINARY
 To convert an octal number to a binary number, simply replace
each octal digit with the appropriate three bits.
 Example:- Convert each of the following octal numbers to
binary:
Binary-to-Octal Conversion
 Conversion of a binary number to an octal number is the reverse of
the octal-to-binary conversion.
 Start with the right-most group of three bits and, moving from right to
left, convert each 3-bit group to the equivalent octal digit.
 Example:- Convert each of the following binary numbers to octal:
QUIZ 1 [5%]

Convert to binary
Binary-Coded Decimal CODE (BCD)
 Human Perception:
 We naturally live in a base 10 environment(decimal number
system)
 Computer exist in a base 2 environment (binary number system)
 So give the computer/digital system the task of doing the
conversions for us.
Binary-Coded Decimal CODE (BCD)
 Binary coded decimal means that each decimal digit, 0 through 9, is
represented by a binary code of four bits.
 Binary coded decimal (BCD) is a weighted code that is commonly
used in digital systems when it is necessary to show decimal numbers
such as in clock displays.
 The 8421 code is a type of BCD (binary coded decimal) code.
 The designation 8421 indicates the binary weights of the four bits (23 ,
22 , 21 ,20 ).

 Invalid Codes:-The six code combinations that are not used in BCD.
These are: 1010, 1011, 1100, 1101, 1110, and 1111
BCD
 The table illustrates the difference
between straight binary and BCD.
 BCD represents each decimal digit
with a 4-bit code.
 Notice that the codes 1010 through
1111 are not used in BCD.
DECIMAL TO BCD CONVERSTION
 To express any decimal number in BCD, simply replace each decimal
digit with the appropriate 4-bit code, as shown by Example:
 Example:- Convert each of the following decimal numbers to BCD:

(a) 35 (b) 98 (c) 170 (d) 2469


BCD TO DECIMAL CONVERSION
 It is equally easy to determine a decimal number from a BCD number.
 Start at the right most bit and break the code into groups of 4-bits.
 Then write the decimal digit represented by each 4-bit group.
 Example:- Convert each of the following BCD codes to decimal:

 It is important to realize that BCD numbers are decimal numbers and


not binary numbers, although they use bits in their representation.
Digital Codes
 Many specialized codes are used in digital systems. You have just
learned about the BCD code; now let's look at a few others.
 Some codes are strictly numeric, like BCD, and others are
alphanumeric;
 That is, they are used to represent numbers, letters, symbols, and
instructions.
 The codes introduced in this section are:
 The Gray code and
 The ASCII code
THE GRAY CODE :
 Is unweighted and is not an arithmetic code; that is, there
are no specific weights assigned to the bit positions.
 The important feature of the Gray code is that it exhibits
only a single bit change from one code word to the next in
sequence.
 Like binary numbers, the Gray code can have any number
of bits. Notice the single-bit change between successive
Gray code words.
 Gray code is used to avoid problems in systems where an
error can occur if more than one bit changes at a time.
Digital Codes
 THE GRAY CODE :
 The following table is listing of the 4-
bit Gray code for decimal numbers
0,1,2,…15.
.
Binary-to-Gray Code Conversion
 The following rules explain how to convert from a binary number to a
Gray code word:
1. The most significant bit (left-most) in the Gray code is the same
as the corresponding MSB in the binary number.
2. Going from left to right, add each adjacent pair of binary code
bits to get the next Gray code bit. Discard carries.
 Example: Convert the binary number 11000110 to Gray code.
 Solution:
GRAY CODE -to- BINARY
Conversion
 Gray-to-Binary Conversion to convert from Gray code to binary, use a
similar method; however, there are some differences.
 The following rules apply:
1. The most significant bit (left-most) in the binary code is the same
as the corresponding bit in the Gray code.
2. Add each binary code bit generated to the Gray code bit in the
next adjacent position. Discard carries.
 Example: Convert the gray code 11000110 to binary numbr.
 Solution:
Digital Codes
 .
Alphanumeric Codes
 Alphanumeric codes are codes that represent numbers and alphabetic
characters (letters).
 Most such codes, however, also represent other characters such as
symbols and various instructions necessary for conveying information
that are found on a computer keyboard.
 The ASCII is the most common alphanumeric code.
 ASCII:-
 Is the abbreviation for American Standard Code for Information
Interchange.
ASCII
 ASCII is a universally accepted alphanumeric code used in most
computers and other electronic equipment.
 Most computer keyboards are standardized with the ASCII.
 When you enter a letter. a number, or control command, the
corresponding ASCII code goes into the computer.
 ASCII has 128 characters and symbols represented by a 7-bit binary
code.
 Actually, ASCII can be considered an 8-bit code with the MSB always
0. This 8-bit code is 00 through 7F in hexadecimal.
 The following table is a listing of partial ASCII code showing the
decimal, hexadecimal, and binary representations for each character
and symbol.
ASCII
 .
ASCII
 Example:- The following is a message encoded in ASCII code. What
is the message? 1001000 1000101 1001100 1010000
 Solution:- Convert each seven-bit code to its hex equivalent.
 The results are 48 45 4C 50
 Now locate these hex values in Table above and determine the
character represented by each.
 The results are HELP
 Example:- Write your full name using ASCII Code.
 Example:-
Exercise
 Perform each of the following conversions.

You might also like