Top Banner
Slide 1 Digital Fundamentals Digital Fundamentals CHAPTER 1 (CONT…) CHAPTER 1 (CONT…) Number Systems, Operations, and Codes Number Systems, Operations, and Codes
55
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Digital Fundamentals

Slide 1

Digital FundamentalsDigital Fundamentals

CHAPTER 1 (CONT…)CHAPTER 1 (CONT…)

Number Systems, Operations, and CodesNumber Systems, Operations, and Codes

Page 2: Digital Fundamentals

Slide 2

1. Number Systems1. Number Systems

1.1 Decimal Numbers 1.1 Decimal Numbers

• The decimal number system has ten digits: The decimal number system has ten digits:

0, 1, 2, 3, 4, 5, 6, 7, 8, and 90, 1, 2, 3, 4, 5, 6, 7, 8, and 9

• The decimal numbering system has a base The decimal numbering system has a base

of 10 with each position weighted by a factor of 10 with each position weighted by a factor

of 10:of 10:

Page 3: Digital Fundamentals

Slide 3

1.2 Binary Numbers1.2 Binary Numbers

• The binary number system has two digits: The binary number system has two digits: 0 and 10 and 1

• The binary numbering system has a base of 2 The binary numbering system has a base of 2 with each position weighted by a factor of 2:with each position weighted by a factor of 2:

Page 4: Digital Fundamentals

Slide 4

2.2. ConversionConversion

2.1 Binary to Decimal Conversion2.1 Binary to Decimal Conversion

• Convert binary to decimal by summing the Convert binary to decimal by summing the positions that contain a 1.positions that contain a 1.

1 0 0 1 0 12

10012345 371432222222

Page 5: Digital Fundamentals

Slide 5

2.2 Decimal to Binary Conversion2.2 Decimal to Binary Conversion

• Two methods to convert decimal to Two methods to convert decimal to binary:binary:

– Reverse process described in 2.1Reverse process described in 2.1– Use repeated divisionUse repeated division

Page 6: Digital Fundamentals

Slide 6

Decimal to Binary Conversion (cont…)Decimal to Binary Conversion (cont…)

• Reverse process described in 2.1Reverse process described in 2.1– Note that all positions must be accounted forNote that all positions must be accounted for

02510 20200237

1 0 0 1 0 21

Page 7: Digital Fundamentals

Slide 7

• Repeated division steps:Repeated division steps:– Divide the decimal number by 2Divide the decimal number by 2– Write the remainder after each division until a Write the remainder after each division until a

quotient of zero is obtained.quotient of zero is obtained.– The first remainder is the LSB and the last is The first remainder is the LSB and the last is

the MSBthe MSB• Note, when done on a calculator, a fractional Note, when done on a calculator, a fractional

answer indicates a remainder of 1.answer indicates a remainder of 1.

Decimal to Binary Conversion (cont…)Decimal to Binary Conversion (cont…)

Page 8: Digital Fundamentals

Slide 8

• Repeated division – Repeated division – This flowchart This flowchart describes the describes the process and can be process and can be used to convert from used to convert from decimal to any other decimal to any other number system.number system.

Decimal to Binary Conversion (cont…)Decimal to Binary Conversion (cont…)

Page 9: Digital Fundamentals

Slide 9

3. Hexadecimal Number System3. Hexadecimal Number System

• Decimal, binary, and hexadecimal Decimal, binary, and hexadecimal numbersnumbers

Page 10: Digital Fundamentals

Slide 10

• Most digital systems deal with groups Most digital systems deal with groups of bits in even powers of 2 such as 8, of bits in even powers of 2 such as 8, 16, 32, and 64 bits.16, 32, and 64 bits.

• Hexadecimal uses groups of 4 bits.Hexadecimal uses groups of 4 bits.

• Base 16Base 16– 16 possible symbols16 possible symbols– 0-9 and A-F0-9 and A-F

Hexadecimal Number System (cont….)Hexadecimal Number System (cont….)

Page 11: Digital Fundamentals

Slide 11

• Convert from hex to decimal by Convert from hex to decimal by multiplying each hex digit by its multiplying each hex digit by its positional weight.positional weight.

Example:Example:

)16(3)16(6)16(1163 01216

131662561

10355

Hexadecimal Number System (cont….)Hexadecimal Number System (cont….)

Page 12: Digital Fundamentals

Slide 12

• Convert from decimal to hex by using the Convert from decimal to hex by using the repeated division method used for decimal repeated division method used for decimal to binary and decimal to octal conversion.to binary and decimal to octal conversion.

• Divide the decimal number by 16Divide the decimal number by 16

• The first remainder is the LSB and the last The first remainder is the LSB and the last is the MSB.is the MSB.– Note, when done on a calculator a decimal remainder Note, when done on a calculator a decimal remainder

can be multiplied by 16 to get the result. If the can be multiplied by 16 to get the result. If the remainder is greater than 9, the letters A through F remainder is greater than 9, the letters A through F are used.are used.

Hexadecimal Number System (cont….)Hexadecimal Number System (cont….)

Page 13: Digital Fundamentals

Slide 13

• Example of hex to binary conversion:Example of hex to binary conversion:

9F29F216 16 = 9= 9 F 2F 2

1001 1111 0010 = 1001111100101001 1111 0010 = 10011111001022

Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

Hexadecimal Number System (cont….)Hexadecimal Number System (cont….)

Page 14: Digital Fundamentals

Slide 14

• Convert from binary to hex by Convert from binary to hex by grouping bits in four starting with the grouping bits in four starting with the LSB.LSB.

• Each group is then converted to the Each group is then converted to the hex equivalenthex equivalent

• Leading zeros can be added to the Leading zeros can be added to the left of the MSB to fill out the last left of the MSB to fill out the last group.group.

Hexadecimal Number System (cont….)Hexadecimal Number System (cont….)

Page 15: Digital Fundamentals

Slide 15

• Example of binary to hex conversion.Example of binary to hex conversion. (Note the addition of leading zeroes)(Note the addition of leading zeroes)

1110100110111010011022 = 0011 1010 0110 = 0011 1010 0110

= 3 A 6= 3 A 6

= 3A6= 3A61616

• Counting in hex requires a reset and carry after Counting in hex requires a reset and carry after reaching F.reaching F.

Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

Hexadecimal Number System (cont….)Hexadecimal Number System (cont….)

Page 16: Digital Fundamentals

Slide 16

• Hexadecimal is useful for Hexadecimal is useful for representing long strings of bits.representing long strings of bits.

• Understanding the conversion Understanding the conversion process and memorizing the 4 bit process and memorizing the 4 bit patterns for each hexadecimal digit patterns for each hexadecimal digit will prove valuable later.will prove valuable later.

Hexadecimal Number System (cont….)Hexadecimal Number System (cont….)

Page 17: Digital Fundamentals

Slide 17

4. Binary Coded Decimal (BCD)4. Binary Coded Decimal (BCD)

• Binary Coded Decimal (BCD) is another Binary Coded Decimal (BCD) is another way to present decimal numbers in binary way to present decimal numbers in binary form.form.

• BCD is widely used and combines BCD is widely used and combines features of both decimal and binary features of both decimal and binary systems.systems.

• Each digit is converted to a binary Each digit is converted to a binary equivalent.equivalent.

Page 18: Digital Fundamentals

Slide 18

Binary Coded Decimal (cont…)Binary Coded Decimal (cont…)

Decimal and BCD digitsDecimal and BCD digits

Page 19: Digital Fundamentals

Slide 19

• To convert the number 874To convert the number 8741010 to BCD: to BCD:

88 77 44

0100 0111 0100 = 0100011101000100 0111 0100 = 010001110100BCDBCD

• Each decimal digit is represented using 4 Each decimal digit is represented using 4 bits.bits.

• Each 4-bit group can never be greater Each 4-bit group can never be greater than 9.than 9.

• Reverse the process to convert BCD to Reverse the process to convert BCD to decimal.decimal.

Binary Coded Decimal (cont…)Binary Coded Decimal (cont…)

Page 20: Digital Fundamentals

Slide 20

• BCD is not a number system.BCD is not a number system.• BCD is a decimal number with each BCD is a decimal number with each

digit encoded to its binary equivalent.digit encoded to its binary equivalent.• A BCD number is not the same as a A BCD number is not the same as a

straight binary number.straight binary number.• The primary advantage of BCD is the The primary advantage of BCD is the

relative ease of converting to and from relative ease of converting to and from decimal.decimal.

Binary Coded Decimal (cont…)Binary Coded Decimal (cont…)

Page 21: Digital Fundamentals

Slide 21

5. Digital Codes5. Digital Codes

• Gray code:Gray code: The gray code is The gray code is

used in applications used in applications where numbers where numbers change rapidly.change rapidly.

In the gray code, In the gray code, only one bit changes only one bit changes from each value to from each value to the next.the next.

Page 22: Digital Fundamentals

Slide 22

• ASCII – American Standard Code for ASCII – American Standard Code for Information Interchange.Information Interchange.– Seven bit code: 2Seven bit code: 277 = 128 possible code = 128 possible code

groupsgroups– Table 2-4 lists the standard ASCII codesTable 2-4 lists the standard ASCII codes– Examples of use are: to transfer information Examples of use are: to transfer information

between computers, between computers and between computers, between computers and printers, and for internal storage.printers, and for internal storage.

Digital Codes (cont…)Digital Codes (cont…)

Page 23: Digital Fundamentals

Slide 23

Digital Codes (cont…)Digital Codes (cont…)

• ASCII code (control characters)ASCII code (control characters)

Page 24: Digital Fundamentals

Slide 24

Digital Codes (cont…)Digital Codes (cont…)

• ASCII code (graphic symbols 20h – 3Fh)ASCII code (graphic symbols 20h – 3Fh)

Page 25: Digital Fundamentals

Slide 25

• ASCII code (graphic symbols 40h – 5Fh)ASCII code (graphic symbols 40h – 5Fh)

Digital Codes (cont…)Digital Codes (cont…)

Page 26: Digital Fundamentals

Slide 26

• ASCII code (graphic symbols 60h – 7Fh)ASCII code (graphic symbols 60h – 7Fh)

Digital Codes (cont…)Digital Codes (cont…)

Page 27: Digital Fundamentals

Slide 27

Extended ASCII code (80h – FFh)Extended ASCII code (80h – FFh)

• Non-English alphabetic charactersNon-English alphabetic characters

• Currency symbolsCurrency symbols

• Greek lettersGreek letters

• Math symbolsMath symbols

• Drawing charactersDrawing characters

• Bar graphing charactersBar graphing characters

• Shading charactersShading characters

Digital Codes (cont…)Digital Codes (cont…)

Page 28: Digital Fundamentals

Slide 28

6. Putting It All Together6. Putting It All TogetherDecimal Binary Hexadecimal BCD Gray

0 0 0 0 01 1 1 0001 00012 10 2 0010 00113 11 3 0011 00104 100 4 0100 01105 101 5 0101 01116 110 6 0110 01017 111 7 0111 01008 1000 8 1000 11009 1001 9 1001 110110 1010 A 0001 0000 111111 1011 B 0001 0001 111012 1100 C 0001 0010 101013 1101 D 0001 0011 101114 1110 E 0001 0100 100115 1111 F 0001 0101 1000

Page 29: Digital Fundamentals

Slide 29

7. Complements of Binary Numbers7. Complements of Binary Numbers

• 1’s complements1’s complements

• 2’s complements2’s complements

Page 30: Digital Fundamentals

Slide 30

Complements of Binary Numbers (cont…)Complements of Binary Numbers (cont…)

• 1’s complement1’s complement

Page 31: Digital Fundamentals

Slide 31

Complements of Binary Numbers (cont…)Complements of Binary Numbers (cont…)

• 2’s complement2’s complement

Page 32: Digital Fundamentals

Slide 32

8. Signed Numbers8. Signed Numbers

• Signed-magnitude formSigned-magnitude form

• 1’s and 2’s complement form1’s and 2’s complement form

• Decimal value of signed numbersDecimal value of signed numbers

• Range of valuesRange of values

• Floating-point numbersFloating-point numbers

Page 33: Digital Fundamentals

Slide 33

Signed Numbers (cont…)Signed Numbers (cont…)

• Signed-magnitude formSigned-magnitude form

– The sign bit is the left-most bit in a The sign bit is the left-most bit in a signed binary numbersigned binary number

– A 0 sign bit indicates a positive A 0 sign bit indicates a positive magnitudemagnitude

– A 1 sign bit indicates a negative A 1 sign bit indicates a negative magnitudemagnitude

Page 34: Digital Fundamentals

Slide 34

Signed Numbers (cont…)Signed Numbers (cont…)

• 1’s complement form1’s complement form– A negative value is the 1’s complement of A negative value is the 1’s complement of

the corresponding positive valuethe corresponding positive value

• 2’s complement form2’s complement form– A negative value is the 2’s complement of A negative value is the 2’s complement of

the corresponding positive valuethe corresponding positive value

Page 35: Digital Fundamentals

Slide 35

Signed Numbers (cont…)Signed Numbers (cont…)

• Decimal value of signed numbersDecimal value of signed numbers– Sign-magnitudeSign-magnitude– 1’s complement1’s complement– 2’s complement2’s complement

• Range of ValuesRange of Values2’s complement form:2’s complement form:

– – (2(2n n – – 11) to + (2) to + (2n – 1 n – 1 – – 1)1)

Page 36: Digital Fundamentals

Slide 36

Signed Numbers (cont…)Signed Numbers (cont…)

• Floating-point numbersFloating-point numbers– Single-precision (32 bits)Single-precision (32 bits)– Double-precision (64 bits)Double-precision (64 bits)– Extended-precision (80 bits)Extended-precision (80 bits)

Page 37: Digital Fundamentals

Slide 37

8.1 Arithmetic Operations with 8.1 Arithmetic Operations with Signed Numbers Signed Numbers

• AdditionAddition

• SubtractionSubtraction

• MultiplicationMultiplication

• DivisionDivision

Page 38: Digital Fundamentals

Slide 38

Arithmetic Operations with Signed Arithmetic Operations with Signed Numbers (cont…)Numbers (cont…)

Addition of Signed NumbersAddition of Signed Numbers

• The parts of an addition function are:The parts of an addition function are:– AddendAddend– AugendAugend– SumSum

Numbers are always added two at a timeNumbers are always added two at a time..

Page 39: Digital Fundamentals

Slide 39

Arithmetic Operations with Signed Arithmetic Operations with Signed Numbers (cont…)Numbers (cont…)

Four conditions for adding numbers:Four conditions for adding numbers:

• Both numbers are positive.Both numbers are positive.

• A positive number that is larger than a A positive number that is larger than a negative number.negative number.

• A negative number that is larger than a A negative number that is larger than a positive number.positive number.

• Both numbers are negative.Both numbers are negative.

Page 40: Digital Fundamentals

Slide 40

Arithmetic Operations with Signed Arithmetic Operations with Signed Numbers (cont…)Numbers (cont…)

Signs for AdditionSigns for Addition

• When both numbers are positive, the When both numbers are positive, the sum is positive.sum is positive.

• When the larger number is positive and When the larger number is positive and the smaller is negative, the sum is the smaller is negative, the sum is positive. The carry is discarded.positive. The carry is discarded.

Page 41: Digital Fundamentals

Slide 41

Arithmetic Operations with Signed Arithmetic Operations with Signed Numbers (cont…)Numbers (cont…)

Signs for AdditionSigns for Addition

• When the larger number is negative and When the larger number is negative and the smaller is positive, the sum is the smaller is positive, the sum is negative (2’s complement form).negative (2’s complement form).

• When both numbers are negative, the When both numbers are negative, the sum is negative (2’s complement form). sum is negative (2’s complement form). The carry bit is discarded.The carry bit is discarded.

Page 42: Digital Fundamentals

Slide 42

Subtraction of Signed NumbersSubtraction of Signed Numbers

• The parts of a subtraction function are:The parts of a subtraction function are:– SubtrahendSubtrahend– MinuendMinuend– DifferenceDifference

Subtraction is addition with the sign of the Subtraction is addition with the sign of the subtrahend changed.subtrahend changed.

Arithmetic Operations with Signed Arithmetic Operations with Signed Numbers (cont…)Numbers (cont…)

Page 43: Digital Fundamentals

Slide 43

SubtractionSubtraction

• The sign of a positive or negative binary The sign of a positive or negative binary number is changed by taking its 2’s number is changed by taking its 2’s complementcomplement

• To subtract two signed numbers, take To subtract two signed numbers, take the 2’s complement of the subtrahend the 2’s complement of the subtrahend and add. Discard any final carry bit.and add. Discard any final carry bit.

Arithmetic Operations with Signed Arithmetic Operations with Signed Numbers (cont…)Numbers (cont…)

Page 44: Digital Fundamentals

Slide 44

Multiplication of Signed NumbersMultiplication of Signed Numbers

• The parts of a multiplication function are:The parts of a multiplication function are:– MultiplicandMultiplicand– MultiplierMultiplier– ProductProduct

Multiplication is equivalent to adding a Multiplication is equivalent to adding a number to itself a number of times equal to number to itself a number of times equal to the multiplier.the multiplier.

Arithmetic Operations with Signed Arithmetic Operations with Signed Numbers (cont…)Numbers (cont…)

Page 45: Digital Fundamentals

Slide 45

There are two methods for multiplication:There are two methods for multiplication:

• Direct additionDirect addition

• Partial productsPartial products

The method of partial products is the most The method of partial products is the most commonly used.commonly used.

Arithmetic Operations with Signed Arithmetic Operations with Signed Numbers (cont…)Numbers (cont…)

Page 46: Digital Fundamentals

Slide 46

Multiplication of Signed NumbersMultiplication of Signed Numbers

• If the signs are the same, the product is If the signs are the same, the product is positive.positive.

• If the signs are different, the product is If the signs are different, the product is negative.negative.

Arithmetic Operations with Signed Arithmetic Operations with Signed Numbers (cont…)Numbers (cont…)

Page 47: Digital Fundamentals

Slide 47

Division of Signed NumbersDivision of Signed Numbers

• The parts of a division operation are:The parts of a division operation are:– DividendDividend– DivisorDivisor– QuotientQuotient

Division is equivalent to subtracting the Division is equivalent to subtracting the divisor from the dividend a number of divisor from the dividend a number of times equal to the quotient.times equal to the quotient.

Arithmetic Operations with Signed Arithmetic Operations with Signed Numbers (cont…)Numbers (cont…)

Page 48: Digital Fundamentals

Slide 48

Division of Signed NumbersDivision of Signed Numbers

• If the signs are the same, the quotient is If the signs are the same, the quotient is positive.positive.

• If the signs are different, the quotient is If the signs are different, the quotient is negative.negative.

Arithmetic Operations with Signed Arithmetic Operations with Signed Numbers (cont…)Numbers (cont…)

Page 49: Digital Fundamentals

Slide 49

• Binary data and codes are frequently moved Binary data and codes are frequently moved between locations. For example:between locations. For example:– Digitized voice over a microwave link.Digitized voice over a microwave link.– Storage and retrieval of data from magnetic and Storage and retrieval of data from magnetic and

optical disks.optical disks.– Communication between computer systems over Communication between computer systems over

telephone lines using a modem.telephone lines using a modem.

• Electrical noise can cause errors during Electrical noise can cause errors during transmission.transmission.

• Many digital systems employ methods for error Many digital systems employ methods for error detection (and sometimes correction).detection (and sometimes correction).

9. Parity Method for Error Detection9. Parity Method for Error Detection

Page 50: Digital Fundamentals

Slide 50

Parity Method for Error Detection Parity Method for Error Detection (cont…)(cont…)

• The parity method of error detection The parity method of error detection requires the addition of an extra bit to a requires the addition of an extra bit to a code group.code group.

• This extra bit is called the parity bit.This extra bit is called the parity bit.

• The bit can be either a 0 or 1, depending The bit can be either a 0 or 1, depending on the number of 1s in the code group.on the number of 1s in the code group.

• There are two methods, even and odd.There are two methods, even and odd.

Page 51: Digital Fundamentals

Slide 51

• Even parity method – the total Even parity method – the total number of bits in a group including number of bits in a group including the parity bit must add up to an even the parity bit must add up to an even number.number.– The binary group 1 0 1 1 would require The binary group 1 0 1 1 would require

the addition of a parity bit the addition of a parity bit 11 1 0 1 11 0 1 1• Note that the parity bit may be added at Note that the parity bit may be added at

either end of a group.either end of a group.

Parity Method for Error Detection Parity Method for Error Detection (cont…)(cont…)

Page 52: Digital Fundamentals

Slide 52

• Odd parity method – the total number Odd parity method – the total number of bits in a group including the parity of bits in a group including the parity bit must add up to an odd number.bit must add up to an odd number.– The binary group 1 1 1 1 would require The binary group 1 1 1 1 would require

the addition of a parity bit the addition of a parity bit 11 1 1 1 1 1 1 1 1

Parity Method for Error Detection Parity Method for Error Detection (cont…)(cont…)

Page 53: Digital Fundamentals

Slide 53

• The transmitter and receiver must The transmitter and receiver must “agree” on the type of parity checking “agree” on the type of parity checking used.used.

• Two bit errors would not indicate a Two bit errors would not indicate a parity error.parity error.

• Both odd and even parity methods are Both odd and even parity methods are used, but even seems to be used used, but even seems to be used more often.more often.

Parity Method for Error Detection Parity Method for Error Detection (cont…)(cont…)

Page 54: Digital Fundamentals

Slide 54

• Parity error codesParity error codes

Parity Method for Error Detection (cont…)Parity Method for Error Detection (cont…)

Page 55: Digital Fundamentals

Slide 55

• Hamming error codesHamming error codes– Hamming code wordsHamming code words– Hex equivalent of the Hex equivalent of the

data bitsdata bits

00000000000000

00001110000111

0011011 0011011

00111100011110

01010100101010

01011010101101

01100110110011

01101000110100

10010111001011

10011001001100

10100101010010

10101011010101

11000011100001

11001101100110

11110001111000

11111111111111

00

11

22

33

44

55

66

77

88

99

AA

BB

CC

DD

EE

FF

Parity Method for Error Detection (cont…)Parity Method for Error Detection (cont…)