Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.

Similar presentations


Presentation on theme: "1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19."— Presentation transcript:

1 1 EENG 2710 Chapter 1 Number Systems and Codes

2 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19

3 3 Number Systems

4 4 Binary Number System Uses two digits, 0 and 1. Represents any number using the positional notation.

5 5 Positional Notation The value of a digit depends on its placement within a number. In base 10, the positional values are (starting to the left of the decimal) – 1 (10 0 ), 10 (10 1 ), 100 (10 2 ), 1000 (10 3 ), etc. In base 2, the positional values are 1 (2 0 ), 2 (2 1 ), 4 (2 2 ), 8 (2 3 ), etc.

6 6 Binary Weights 2727 2626 2525 2424 23232 2121 2020 1286432168421

7 7 Fractional Binary Weights 2 -1 2 -2 2 -3 2 -4 ½¼1/81/16 0.50.250.1250.0625

8 8 Bit Shorthand for binary digit, a logic 0 or 1. The most significant bit (MSB) is the leftmost bit of a binary number. The least significant bit (LSB) is the rightmost bit of a binary number.

9 9 Binary Inputs Digital circuits operate by accepting logic levels (0,1) at their input(s). The corresponding output(s) logic level will change (0,1).

10 10 Binary Inputs

11 11 4-Input Digital Circuit

12 12 Base Conversions Methods Series substitution method Sum powers of 2 Radix method –Repeated Division –Repeated Multiplication

13 13 Series Substitution Method (Binary to Decimal)

14 14 Sum Powers of 2 (Decimal to Binary) Step 1: –Determine the largest power of 2 less than or equal to the number to be converted. – Place a 1 in that positional location. Convert 57 10 to binary 64 10  57 10  32 10

15 15 Sum Powers of 2 Step 2: –Subtract the number found in Step 1 from the number to be converted. 57 – 32 = 25 –For the new number, determine if the next lowest power of 2 is less than or equal to that number. 25 – 16 = 9

16 16 Sum Powers of 2 Step 3: –If the new power of two from Step 2 is larger, place a 0 in that positional location. –If the new value is less than or equal, place a 1 in that positional location.

17 17 Sum Powers of 2 Step 4: –Repeat Steps 2 and 3 until there is nothing left to subtract. –All remaining bits are set to 0. 57 10 = 111001 2

18 18 Radix Method (Repeated Division by 2) 46 10 = 101110 2

19 19 Fractional Binary Numbers Radix point: –The generalized decimal point. The dividing line between positive and negative powers for positional multipliers. Binary point: –The radix point for binary numbers.

20 20 Fractional Binary Values The value immediately to the right of the binary point is 2 –1 = 0.5. The next value to the right is 2 –2 = 0.25. The next value to the right is 2 –4 = 0.125, and so on.

21 21 Series Substitution Method (Binary Fraction to Decimal Fraction)

22 22 Radix Method for 0.2 10 to Binary (Repeated Multiplication by 2) Step 1:Multiply the decimal fraction by 2. Step 2: Integer part is 0 or 1 left of decimal point. 0.2 x 2 = 0.4 Integer part = 0 0.4 x 2 = 0.8 Integer part = 0 0.8 x 2 = 1.6 Integer part = 1 0.6 x 2 = 1.2 Integer part = 1 0.2 x 2 = 0.4 Integer part = 0 (stop 0011repeats) Read integer parts from top to bottom Therefore, 0.2 10 = 0.0011 0011 0011

23 23 Hexadecimal Numbers Base 16 number system. Primarily used as a shorthand form of binary numbers.

24 24 Counting in Hexadecimal Values range from 0 to F with the letters A to F used to represent the values 10 to 15 respectively. Positional multipliers are powers of 16: 16 0 = 1, 16 1 = 16, 16 2 = 256, etc.

25 25 Hexadecimal vs. Decimal Numbers Decimal 0123456789101112131415 Hexadecimal 0123456789ABCDEF

26 26 Counting In Hexadecimal 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F 20,21,22,23,24,25,26,27,28,29,2A,2B,2C,2D,2E,2F 30,31,32,33,34,35,36,37,38,39,3A,3B,3C,3D,3E,3F

27 27 Decimal-to-Hexadecimal Conversion ( Repeated division by 16) 31581 10 = 7B5DH

28 28 Hex-Decimal-Binary Table HexDecimalBinaryHex (Cont) DecimalBinary 000000881000 110001991001 220010A101010 330011B111011 440100C121100 550101D131101 660110E141110 770111F151111

29 29 Conversion Between Hexadecimal and Binary Each hexadecimal digit represents 4 binary bits. F D 6 9 1111 1101 0110 1001 FD69H = 1111110101101001 2

30 30 Signed/Unsigned Binary Numbers Signed Binary Number: –A binary number of fixed length whose sign (+/–) is represented by one bit (usually MSB) and its magnitude by the remaining bits. Unsigned Binary Number: –A binary number of fixed length whose sign is not specified by a bit. All bits are magnitude and the sign is assumed +.

31 31 Unsigned Binary Arithmetic Sum: –Result of an Addition Operation of two (or more) binary numbers (operands). Carry: –A digit (or bit) that is carried over to the next most significant bit during an n-Bit addition operation. The carry bit is a 1 if the result was too large to be expressed in n bits.

32 32 Basic Rules (Unsigned)

33 33 Basic Subtraction Basic Subtraction of x = a – b, with a = minuend, b = subtrahend, and x = difference or result. Requires a Borrow Bit if a < b. There are other forms of subtraction such as 2’s Complement Addition used by microprocessors (such as in a PC).

34 34 Binary Subtraction with Borrow Examples

35 35 Signed Binary Numbers Sign Bit: –A bit (usually the MSB) that indicates whether a number is positive (= 0) or negative (= 1). Magnitude Bits: –The bits of a signed binary number that tell how large it is in value.

36 36 Signed Binary Numbers True-Magnitude Form: –A form of signed binary whose magnitude bits are the TRUE binary form (not complements). 1’s Complement: –A form of signed binary in which negative numbers are created by complementing all bits. 2’s Complement: –A form of signed binary in which the negative numbers are created by complementing all the bits and adding a 1 (1’s Complement + 1).

37 37 True-Magnitude Form 5-Bit Numbers Negative Sign (S = 1) +25 = 011001 (Note sign bit (MSB) Sign = 0) –25 = 111001 (Same as +25 with sign = 1) +12 = 001100 –12 = 101100

38 38 1’s Complement Form 8-Bit 1’s Complement Negative (S = 1) +57 = 00111001 –57 = 11000110 (All Bits Inverted) +72 = 01001000 –72 = 10110111

39 39 2’s Complement Form 57 = 0011 1001 -57 = 1100 0110 + 1 1100 0111

40 40 Signed Binary Addition (8-Bit) Signed Addition Positive (S = 0) +30 = 00011110 +75 = 01001011 105 01101001

41 41 Subtraction with 1’s Complement Add the 1’s Complement and then Carry. Uses an End around carry addition method. (80 – 65)

42 42 2’s Complement Subtraction Add 2’s Complement to Minuend. Discord Carry Bit From Results (80 – 65)

43 43 2’s Complement Subtraction 200 10 – 5 10 = 195 10 (Use 16 bit word) 200 10 = 0000000011001000 2 5 10 = 0000000000000101 2 -5 10 = 1111111111111010 2 = 1’s complement + 1 1111111111111011 2 0000000011001000 2 + 1111111111111011 2 10000000011000011 2 = 0000000011000011 2 = 195 10

44 44 Negative Results If the True-Magnitude Form is used for subtraction, the results are incorrect. If the result is from 1’s or 2’s Complement and the result is negative (S = 1), the magnitude is found by taking the complement of the result.

45 45 Negative Result Example Thus, = -15 10

46 46 More Binary Addition

47 47 More Binary Subtraction

48 48 Binary Multiplication

49 49 Binary Division

50 50 Range of Signed Numbers Range of Positive Numbers is 0 to 2 n – 1 for a number with n magnitude bits. Range of Negative Numbers is –1 to –2 n for a number with n magnitude bits. 8-Bit Example: 8-Bit Number Range is –2 n  x  +2 n – 1 or –128 to +127

51 51 Sign Bit Overflow Overflow: –An erroneous carry into the sign bit of a signed binary number –Results from a sum or difference that is larger than can be represented by the magnitude bits. Results in a False Positive or False Negative Number.

52 52 False Negative Overflow Addition of two 8-Bit Positive Numbers: Two positive numbers added with a result greater than the range of +127 for 8-bit numbers causes an overflow.

53 53 False Positive Overflow Addition of two 8-Bit Negative Numbers: Two Negative numbers were added to produce a False Positive Result due to overflowing the negative range of 8-bit numbers (0 to –128).

54 54 Hexadecimal Addition Similar to decimal addition with a range of digits of 0 to 9 and A to F. Examples: F + 1 = 10 F + F = 1E F + F + 1 = 1F

55 55 Hexadecimal Addition For sums greater than 15, subtract 16 and carry 1 to the next position.

56 56 Hexadecimal Subtraction

57 57 Hexadecimal Subtraction 2F00H – 4000H Convert 4000H to hexadecimal equivalent of 2’s complement: FFFF 4000 BFFF + 1 C000 Add numbers: 2F00 + C000 EF00H

58 58 Hexadecimal Subtraction 2F00H – 4000H a.Converting 4000 to binary = 0100 0000 0000 0000 b.Take 1’s complement = 1011 1111 1111 1111 c.Take 2’s complement = +1 +1 +1 +1 1100 0000 0000 0000 d.Change to Hexadecimal = C000H e.Add numbers: 2F00 + C000 EF00H

59 59 More Hexadecimal Addition

60 60 More Hexadecimal Subtraction

61 61 Hexadecimal Multiplication

62 62 Hexadecimal Division

63 63 Octal Addition

64 64 Octal Subtraction

65 65 Octal Multiplication

66 66 Octal Division

67 67 Excess 8 code

68 68 Floating-point Number Formats

69 69 Developing a Floating Point number If n = 1101.0101, convert n to a floating point number. n = (0.11010101) x 2 4 The mantissa M = 0.11010101 2sm The exponent E = 011 + 10000 = 10011 2 E = (1, 0011) exess 16 Combining M & E: N = 0, 1, 0011, 11010101) fp

70 70 BCD Codes BCD Code (Binary-Coded Decimal): A code used to represent each decimal digit of a number by a 4-Bit Binary Value. Valid Digits for 0 to 9 are 0000 to 1001. –The binary codes 1010 to 1111 are invalid Called an 8421 Code due to the decimal weight of each bit position.

71 71 BCD Examples Each digit is a 4-Bit Binary group: (84) 10 = 1000 0100 (4987) 10 = 0100 1001 1000 0111 BCD

72 72 Gray Code A binary code that progresses so that only one bit changes between two successive codes. 000 001 011 010 110 111 101 100

73 73 How to build a 4-bit Gray Code Table ( A binary code that progresses so that only one bit changes between two successive codes.)

74 74 4-bit Gray Code Table

75 75 A Gray Code Disk

76 76 ASCII Code American Standard Code for Information Interchange. A seven-bit alphanumeric code used to represent text letters, numerals, punctuation, and special controls. An expanded 8-bit form is becoming more widespread.

77 77 ASCII Code

78 78 Error Detection and Correction Codes

79 79 Error Detection and Correction Codes Definitions Parity Codes –Odd parity –Even parity Hamming Codes –Code 1 –Code 2

80 80 Error Detection and Correction Codes Definitions Error – an incorrect value of one or more binary bits. Single Error - an incorrect value of one binary bits. Multiple Error - incorrect values of many binary bits. Distance between code words – d –Code word I = 01101100 –Code word J = 11000100 – d (I,J) =3

81 81 Definitions Continued d min – minimum distance between two code word –If code provides t error correction plus detection of s additional errors, then 2t + s + 1  d min –At least d min errors are needed to transform one code word to another –Less than d min errors, then a detectable non-code word results. Thus, if the non-code word is closer to a valid code word, then the original code word can be deduced and the error can be corrected.

82 82 Parity Basics Parity: A digital system that checks for errors in a n-Bit Binary Number or Code. Even Parity: A parity system that requires the binary number and the parity bit to have an even # of 1s. Odd Parity: A parity system that requires the binary number and the parity bit to have an Odd # of 1s.

83 83 Parity Basics Parity Bit: A bit appended on the end of a binary number or code to make the # of 1s odd or even depending on the type of parity in the system. Parity is used in transmitting and receiving data by devices in a PC called UARTs, that are on the COM Port. UART = Universal asynchronous Receiver/Transmitter

84 84 Parity Basics

85 85 Parity Calculation N 1 = 0110110: –It has four 1s (an even number). –If Parity is ODD, the Parity Bit = 1 to make it an odd number (5). N = 1110110 –If Parity is EVEN, the Parity Bit = 0 to keep it an even number (4). N = 0110110

86 86 Hamming Code Table

87 87 Hamming Code Problem Error Word = 1100110, Use Hamming Code 1 to determine the code word. Code word


Download ppt "1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19."

Similar presentations


Ads by Google