460 likes | 483 Views
Learn about analog and digital systems, common number systems, and conversion among bases in digital logic design. Explore binary, decimal, hexadecimal, octal, BCD, gray code, and signed binary representation.
E N D
Digital Logic Design By: Assistant Lecturer: Bnar Faisal A. Daham
Analog versus Digital • Analog means continuous • Analog parameters have continuous range of values • Example: temperature is an analog parameter • Temperature increases/decreases continuously • Digital means using numerical digits • Digital parameters have fixed set of discrete values • Example: month number {1, 2, 3, …, 12} • Thus, the month number is a digital parameter (cannot be 1.5!)
Analog versus Digital System • Are computers analog or digital systems? Computer are digital systems • Which is easier to design an analog or a digital system? Digital systems are easier to design, because they deal with a limited set of values rather than an infinitely large range of continuous values • The world around us is analog • It is common to convert analog parameters into digital form • This process is called digitization
Conversion Among Bases • The possibilities:
Decimal to Any Number Base • Take the decimal number, and divide by the new number base • Keep track of the quotient and remainder • Repeat until quotient = 0 • Read number from the bottom to the top
Decimal to Binary • Binary is base 2 • Example: convert 35 (decimal) to binary Quotient Remainder 35 / 2 = 17 1 17 / 2 = 8 1 8 / 2 = 4 0 4 / 2 = 2 0 2 / 2 = 1 0 1 / 2 = 0 1 • So 3510 = 1000112 • Left hand side is the Most Significant Bit (MSB) and right hand side is the Least Significant Bit (LSB).
Any Number Base to Decimal • From right to left, multiply the digit of the number-to-convert by its baseposition • Sum all results
Binary to Decimal • Binary is base 2 • Example: convert 10110 (binary) to decimal 101102 = 1x24 + 0x23 + 1x22 + 1x21 + 0x20 = 1x16 + 0x8 + 1x4 + 1x2 + 0x1 = 16 + 0 + 4 + 2 + 0 = 22 • So 101102 = 2210
Hexadecimal to Decimal • Hexadecimal is base 16 • Example: convert 16 (hex) to decimal 1616 = 1x161 + 6x160 = 1x16 + 6x1 = 16 + 6 = 22 • So 1616 = 2210
Octal to Binary • Technique • Convert each octal digit to a 3-bit equivalent binary representation 7058 = ?2 7 0 5 111 000 101 7058 = 1110001012
1 0 A F 0001 0000 1010 1111 Hexadecimal to Binary • Technique • Convert each hexadecimal digit to a 4-bit equivalent binary representation 10AF16 = ?2 10AF16 = 00010000101011112
Binary to Octal • Technique • Group bits in threes, starting on right • Convert to octal digits 10110101112 = ?8 1 011 010 111 1 3 2 7 10110101112 = 13278
Binary to Hexadecimal • Technique • Group bits in fours, starting on right • Convert to hexadecimal digits 10101110112 = ?16 • 10 1011 1011 • B B 10101110112 = 2BB16
2 3 E Octal to Hexadecimal • Technique • Use binary as an intermediary 10768 = ?16 • 1 0 7 6 • 001 000 111 110 10768 = 23E16
1 F 0 C • 0001 1111 0000 1100 1 7 4 1 4 Hexadecimal to Octal • Technique • Use binary as an intermediary 1F0C16 = ?8 1F0C16 = 174148
Binary Coded Decimal • To express any decimal number in BCD, simply replace each decimal digit with the appropriate 4bit code. • Example: 0 1 2 …………. 0000 0001 0010 ………….
Binary to Gray Code • Going from left to right, add each adjacent pair of binary code bits to get the next gray code bit. • Discard carries. • Example:
Gray Code to Binary • Add each binary code bit generated to the gray code bit in the next adjacent position. • Discard carries • Example:
What is the value of “k”, “M”, and “G”? Use binary as an intermediary • In computing, particularly w.r.t. memory, the base-2 interpretation generally applies
Review – multiplying powers • For common bases, add powers ab ac = ab+c 26 210 = 216 = 65,536 or… 26 210 = 64 210 = 64k
Binary Addition • Example 10101 21+ 11001 + 25 101110 46
Binary Subtraction • Example 101 - 011 010 10001 17 - 111 7 01010 10
Multiplication • Example 1110 x 1011 1110 1110 0000 111010011010
Division • Binary Division = Decimal Division • Example: 110/11 = 10 6/3 = 2 • Another Examples: • 1100/100 • 1100/011
Fractions • Decimal to decimal (just for fun) 3.14 => 4 x 10-2 = 0.04 1 x 10-1 = 0.1 3 x 100 = 3 3.14
Fractions • Binary to decimal • MSB LSB. MSB LSB 10.1011 => 1 x 2-4 = 0.0625 1 x 2-3 = 0.125 0 x 2-2 = 0.0 1 x 2-1 = 0.5 0 x 20 = 0.0 1 x 21 = 2.0 2.6875
Fractions • Decimal to binary .14579x 20.29158x 20.58316x 21.16632x 20.33264x 20.66528x 21.33056 etc. 3.14579 11.001001...
Signed Binary Number • We have three methods to represent the negative numbers in binary: • Sign – Magnitude. • 1’s Complement. • 2’s Complement.
Signed Numbers • The sign bit: The left-most bit in a signed binary number is the sign bit, which tells you weather the number is positive or negative. • A (0) signed bit indicates a positive number, and a (1) signed bit indicates a negative number.
Sign-Magnitude 00010111 00010111 S M
Sign-Magnitude 11101000 1 1101000 S M
One’s Complement • The 1’s complement of a binary number is found by changing all 1s to 0s and all 0s to 1s as shown bellow: 1 0 1 1 0 0 1 0 Binary number 0 1 0 0 1 1 0 1 1’s complement
Two’s Complement Two’s Complement = One’s Complement + 1 1 0 1 1 0 0 1 0 0 1 0 0 1 1 0 1 One’s complement + 1 0 1 0 0 1 1 1 0 Two’s complement
Signed Binary to Decimal Conversion • Sign – Magnitude: Decimal values of positive and negative numbers in the sign-magnitude form are determined by summing the weights in all the magnitude bit positions where there are ones and ignoring those position where are zeros. The sign is determined by examination of the sign bit.
Signed Binary to Decimal Conversion • Example: Determine the decimal value of this signed binary number expressed in sign – magnitude: 10010101 0 0 1 0 1 0 1 26 25 24 23 22 21 20 Summing the weights where there are 1s 16 + 4 + 1 = 21 The sign bit is 1; therefore, the decimal number is -21
Signed Binary to Decimal Conversion • 1’s Complement: • Decimal values of positive numbers are determined by summing the weights in all bit positions where there are 1s and ignoring those positions where there are zeros. • Decimal values of negative numbers are determined by assigning a negative value to the weight of the sign bit, summing all the weights where there are 1s, and finally adding 1 to the result.
Signed Binary to Decimal Conversion • Example: Determine the decimal values of the signed binary numbers expressed in 1’s complement: a. 00010111 b. 11101000 a. 0 0 0 1 0 1 1 1 -27 26 25 24 23 22 21 20 16 + 4 + 2 + 1= +23 b. 1 1 1 0 1 0 0 0 -27 26 25 24 23 22 21 20 -128 + 64 + 32 + 8 =-24 -24 + 1 = -23
Signed Binary to Decimal Conversion • 2’s Complement: Decimal values of positive and negative numbers in the 2’s complement form are determined by summing the weights in all bit positions where there are 1s and ignoring those positions where there are zeros. The weight of the sign bit in a negative number is given a negative value.
Signed Binary to Decimal Conversion • Example: Determine the decimal values of the signed binary numbers expressed in 2’s complement: • 01010110 • 10101010 a. 0 1 0 1 0 1 1 0 -27 26 25 24 23 22 21 20 64 + 16 + 4 + 2= +86 b. 1 0 1 0 1 0 1 0 -27 26 25 24 23 22 21 20 -128 + 32 + 8 + 2 =-86
Examples • Convert the binary whole number 1101101 to decimal. • Convert the fractional binary number 0.1011 to decimal. • Convert the decimal number 82 to binary using sum of weights method. • Convert the decimal number 45 to binary. • Find the 2’s complement of 10110010. • Find the 2’s complement of 10111000 using the alternative method • Express the decimal number -39 as an 8-bit number in the sign-magnitude, 1’scomplement, and 2’s complement forms. • Convert (111111000101101001)2 into hexadecimal. • Determine the binary number for the following hexadecimal number 9742. • Convert the hexadecimal number B2F8 to decimal.
Examples 11. Convert the decimal number 650 to hexadecimal by repeated division by 16. 12. Convert the octal number 2374 to decimal. 13. Convert the decimal number 35 to BCD. 14. Convert the 10000110 BCD code to decimal. 15. Convert the binary number 11000110 to gray code. 16. Convert the 11010000100 binary number to octal. 17. Convert the 7526 octal to binary number. 18. Convert the A85 hexadecimal number to decimal. 19. Determine the decimal value of the signed binary number 11101000 expressed in 1’s complement. 20. Determine the decimal value of the signed binary number 01010110 expressed in 2’s complement.