1 / 23

Digital Logic CPE231

Digital Logic CPE231. Digital Fundamentals, Ninth Edition By Floyd Instructor: Eng. Tuqa Manasrah. Ch 2: Number Systems. Review the decimal number system Count in the binary number system Convert from decimal to binary and from binary to decimal

verity
Download Presentation

Digital Logic CPE231

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Digital Logic CPE231 Digital Fundamentals, Ninth Edition By Floyd Instructor: Eng. Tuqa Manasrah

  2. Ch 2: Number Systems • Review the decimal number system • Count in the binary number system • Convert from decimal to binary and from binary to decimal • Apply arithmetic operations to binary numbers • Determine the 1's and 2's complements of a binary number • Express signed binary numbers in sign-magnitude, 1's complement, 2's complement • Carry out arithmetic operations with signed binary numbers • Convert between the binary and hexadecimal number systems • Add numbers in hexadecimal form • Convert between the binary and octal number systems • Express decimal numbers in binary coded decimal (BCD) form • Add BCD numbers • Interpret the American Standard Code for Information Interchange (ASCII) Note: Keywords are written in green font

  3. Decimal Numbers • A base-ten system used every day. • The decimal number system express ten different quantities up through 9. to express a quantity greater that 9, you use two or more digits. • Each digit in a decimal number can be assigned a weight. • Weights are positive powers of 10 that increase from right to left. e.g.: 102101100.10-110-210-3 • the value of the number is the sum of digits after have been weighted. • e.g. express 456.25 as a weighted sum: 456.25 = 4X103 + 5X102 + 6X101 + 2X10-1 + 5X10-2

  4. Binary Numbers • It is a base-two system with only two digits (0,1). • The position of a 0, 1 in a binary number (string of bits) indicates its weight or value. • Weights in a binary number are based on powers of 2. e.g. 2423222120.2-12-22-3 • Counting in binary follow the same notion of counting in decimal.. • With n bits you can count up to a number equal to 2n -1.e.g. with 5 bits you can count from 0 to 32. • LSB (least significant bit): the right most bit and has a weight of 20=1. • MSB (most significant bit) the left most bit and its weight is determined by the size of the number. For n bit number the MSB weight is 2n-1. • The decimal equivalent of the a binary number is determined by evaluating the weighted sum of the binary number. e.g. 1011001= 1X26 + 0X25 +1X24 +1X23 + 0X22 + 0X21 +1X20 = 26 + 24 + 23 + 20= 89 0.1011 = 2-1+ 2-3+ 2-4 = 0.6875

  5. Decimal to Binary Conversion • To Convert the Integral Part: Repeatedly divide the number by the 2 until there is a 0 quotient. The generated remainders form the binary number aligned in the reverse order. • To Convert the Fractional Part: Repeatedly multiply the fraction by 2 until the fractional product is zero or the desired decimal number is reached. The generated carries produce the binary number (fraction).

  6. Binary Arithmetic's • Addition, Subtraction, Multiplication Addition • Basic rules: • 0 + 0 = 0 • 0 + 1 = 1 • 1 + 0 = 1 • 1 + 1 = 10 (binary two) • E.g. 011 + 001 = ? • Sum with carry rules: • 1 + 0 + 0 = 01 sum of 1 with zero carry • 1 + 1 + 0 = 10 • 1 + 0 + 1 = 10 • 1 + 1 + 1 = 11 • E.g. 110 + 100 = ?

  7. Binary Arithmetic's Subtraction • Basic rules: • 0 – 0 = 0 • 1 – 1 = 0 • 1 – 0 = 1 • 10 – 1 = 1 • 0 – 1 = ( you need to borrow from the next column to the left) • E.g. 101 – 011 =? Multiplication • E.g. 1101 x 1010 =?

  8. 1’s and 2’s complements • Permits the representation of negative numbers. • 1’s complement of a binary number: changing 1s to 0s and 0s to 1s. • Inverters are used to obtain the 1s complement. • 2’s complement = 1’s complement + 1 • E.g. find 2’ complement of 11001011

  9. Signed Numbers • Computers should be able to handle both positive and negative numbers. • A signed binary number consists of sign and magnitude information. • Three ways to represent signed numbers: sign-magnitude, 1’s complement, 2’s complement. • The last is the most important.

  10. Continue.. • The sign bit in a signed number is the left most bit. 0 indicates positive while 1 indicates negative. • Signed magnitude: the left bit is the sign and the remaining are the magnitude bits. • E.g. 0011 = +3 , 1011 = -3 • 1’s complement: negative numbers are the 1’s complement of the positive number. • E.g. 1100 = -3 • 2’s complement: negative numbers are the 2’s complement of the positive number. • E.g. 1101 = -3

  11. Continue.. • E.g. express the decimal number -45 as an 8-bit signed number using all forms. • Determine the decimal equivalent of the signed binary number 11101011 assuming all the forms

  12. Continue.. • Byte: eight bits. • N bit binary number has 2n different combinations • For in 2’s complement they range from -2n-1 to +2n-1 -1 • E.g. with 4 bits you can represent in 2’s complement numbers ranging from -8 to +7

  13. Arithmetic Operations with Signed Numbers • In computers, the negative numbers are stored in 2’s complement form. • We will cover 2’s complement arithmetic's because it is the most widely used. Addition • Four cases • Both positives: the sum is positive. • +ve & -ve, +ve magnitude is greater: the sum is +ve, discard the last carry. • +ve & -ve, -ve magnitude is greater: the sum is –ve and in the 2’s complement form. • Both negatives: the sum is –ve and in the 2’s complement form. Discard the last carry. • Simply add the two numbers and discard the final carry if any.

  14. Continue… Subtraction • Special case of addition: A + B = A – (-B) • Change the sign of a number by taking its 2’s complement. E.g. –B = 2’s complement of B. • After changing the sign, follow the same procedure of addition. • E.g. perform the following operations: • 01011000 – 00100011 =? • 00110011 + 10111111 = ? • 10111111 + 01100011 = ? • 11111011 + 11101000 =? • 00000111 + 00011001 =? • E.g. Perform the following operations • 6 + 13 • -6 + 13 • 6 + (- 13) • (-6) + (-13) • -6 - (-13) • 6 - (- 13)

  15. Overflow condition • The result can not be represented with the number of bits used. • Two cases of overflow for addition of signed numbers. • Two large positive numbers overflow into sign bit. • Two large negative numbers added. • e.g. use 4-bit representation to evaluate 7 + 7, -7 + -7. e.g. 01111101 + 00111010 = 10110111 (incorrect result)

  16. Hexadecimal numbers • Has a base of 16 and 16 digits (10 numeric and 6 letters). • Used primarily as a compact representation of binary numbers. • Long binary numbers are difficult to read and write. • Each hexadecimal digit represent 4 binary bits. • Hex Digits: 0 – 9, A – F. • Counting in Hexadecimal. • Binary to hexadecimal conversion. • Hexadecimal to binary conversion. • Hexadecimal to decimal conversion: weighted sum. • (6BD)16 = (1725)10 • Decimal to Hex conversion: repeated division by 16. • (650)10 = (28A)16

  17. Hex Addition and Subtraction • Think of the two numbers in terms of their decimal equivalent.. • In subtraction: Hex  binary  2’s complement  add, and drop the carry of any. • E.g.: evaluate the following hexadecimal numbers arithmetic's: • 23 + 16 = 39 • 2B + 84 = AF • DF + AC = 18B • 84 – 2A = 5A • C3 – 0 B = B8

  18. Octal Numbers • Provide a convenient way to express binary numbers. • Used less frequently than Hexadecimal. • Base 8, 8 digits (0 - 8). • Counting in octal. • Binary to octal conversion. • Octal to binary conversion. • Octal to decimal conversion: weighted sum. • (250)8 = (168)10 • Decimal to octal conversion: repeated division by 8. • (359)10 =(547)8

  19. Binary Coded Decimal (BCD) • A way to express each decimal digit with a binary code. • Ten code groups in BCD. • Very easy to convert between decimal and BCD. • Humans prefer to read and write in decimal, BCD provide an excellent interface to binary. • BCD represent each decimal digit with four binary bits. • E.g. (471)10 = (010001110001)BCD • A 4-bit binary number can implement 16 different number. • In BCD we have only 10 valid codes (0000 - 1001), because there are only 10 valid decimal numbers. • 1010 – 1111 : are six invalid codes in BCD. • 110010000101: invalid BCD code

  20. BCD Addition • Procedure: • Use binary addition rules to add two BCD numbers. • If the sum <= 9, it is a valid BCD number. • If the sum >9 or a carry out is generated, it is invalid BCD number. • To correct the result in the last step, add 6 to the sum in order to skip the six invalid states. If a carry is generated from this addition, add it to the next four-bit group. • e.g. 010001010000 + 010000010111 = ? 00010110 + 00010101 = ? 01100111 + 01010011 = ? 01011001 + 01001001 = ?

  21. Digital Codes: ASCII • Stands for American Standard Code for Information Interchange. • Most computer keyboards are standardized with ASCII • 128 characters represented with 7-bit binary code or 8 bits with MSB =0ز

  22. ASCII Table

  23. Error Detection and Correction Code: Parity Code • Methods for adding bits to either detect or detect and correct a single bit error. • Parity method is used for detection only. • A parity bit is attached to a group of bits to make the total number of 1s in a group always even or odd. • Even parity bit  total number of 1s even • Odd parity bit  total number of 1s odd • Examples (0100 0001) with even parity is 00100 0001 (0100 0011) with even parity is 10100 0011 (0100 0001) with odd parity is 10100 0001 (0100 0011) with odd parity is 00100 0011 See book example 2-40

More Related