1 / 112

Digital Systems and Logic Design

Digital Systems and Logic Design. General Overview. This chapter is Number Systems, Operations, and Codes. Decimal numbers Binary numbers Decimal-to-binary numbers Binary arithmetic 1’s and 2’s Complements of Binary numbers Signed number Arithmetic operations with signed numbers

candid
Download Presentation

Digital Systems and Logic Design

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 Systems and Logic Design

  2. General Overview • This chapter is Number Systems, Operations, and Codes. • Decimal numbers • Binary numbers • Decimal-to-binary numbers • Binary arithmetic • 1’s and 2’s Complements of Binary numbers • Signed number • Arithmetic operations with signed numbers • Hexadecimal Numbers • Octal Numbers • Binary Coded Decimal (BCD) • Digital Codes and Parity • Digital System Application

  3. Chapter Objectives • Convert the number between decimal and binary. • Apply arithmetic operation to binary numbers. • Understand Binary Coded Decimal (BCD), Gray Code, ASCII

  4. Decimal Numbers • Decimal numbers has ten digits. (0, 1, 2, 3, …, 9) • The decimal numbering system has a base of 10 with each position weighted by a factor of 10:

  5. Binary Numbers • Binary numbers has two digits, 1 and 0. • The binary numbering system has a base of 2 with each position weight by a factor of 2.

  6. Binary numbers: Example • 10010 in binary is • 1x24 + 0x23 + 0x22 + 1x21 + 0x20 = 18 • Binary is the base 2 number system • Most common in digital electronics • Weight: Most Significant bit (MSB) Least Significant bit (LSB) 10010 MSB LSB

  7. Integers and Fractional Parts • Binary numbers can contain fractional parts as well as integer parts # quantization error.

  8. Conversion: Decimal to Binary(Method 1) • The decimal numbers is simply expressed as a sum of power of 2, and then 1s and 0s are written in the appropriate bit positions. 322 = ? 50 = 32 + 18 = 32 + 16 + 2 = 1x25 + 1x24 + 1x21 5010 = 1100102

  9. Conversion: Decimal to Binary(Method 2) • Repeated division Quotient Remainder 50/2 = 25 0 LSB 25/2 = 12 1 12/2 = 6 0 6/2 = 3 0 3/2 = 1 1 1/2 = 0 1 MSB stop 50 = 110010

  10. Conversion: Binary to Decimal • The simplest way is to represent the binary number as anx2n + .. + a2x22 + a1x21 + a0x20 • The conversion can be done by substituting the a’s with the given bits then multiplying and adding: 110010 = 1x25 + 1x24 + 1x21 = 50

  11. Example Convert the binary whole number 100011012 to decimal 100011012 = 27 + 23 + 22 + 20 = 128 + 8 + 4 + 1 = 14110

  12. Example Convert the fractional binary number 0.10112 to decimal 2-1 + 2-6 0.1011012 = 2-3 + 2-4 + = 0.5 + 0.125 + 0.0625 = 0.687510

  13. ExampleConvert the binary whole number 101.01012 to decimal 101.01012 = 22 + 20 + 2-2 + 2-4 = 4 + 1 +0.25 + 0.125 + 0.0625 = 5.437510

  14. Conversion: Fractional to Binary • เลขทศนิยมฐานสิบเป็นเลขฐานสอง • ผลบวกของค่าน้ำหนัก • การคูณซ้ำด้วยสอง 0.782 = 0.110012 ผลบวกของค่าน้ำหนัก : การคูณซ้ำด้วยสอง : 0.782 = 0.5 + 0.25 + 0.03125 = (0.78125) 0.782 x 2 = 1.564 0.564 x 2 = 1.128 = 2-1 + 2-2 + 2-5 0.128 x 2 = 0.256 = 0.110012 0.256 x 2 = 0.512 0.512 x 2 = 1.024

  15. Binary Number Systems • Unsigned Binary Code • Signed Binary Codes • 2’s Complement System • BCD Code • Excess Codes • Floating-Point System

  16. Unsigned Binary Code • Given a number N in Unsigned Binary code, find the value of N in the decimal system • Use series substitution method • Given a number N in the decimal system, find the value of N in the Unsigned Binary Code. • Use successive division method (for integer part) • Use successive multiplication method (for fraction part)

  17. Unsigned Binary Code • Example 1: Represent (26)10 in Unsigned Binary Code 2610 = 11010 • Example 2: Represent (26)10 in Unsigned Binary Code using 8 bits. 2610 = 00011010 • Example 3:Represent (26)10 in Unsigned Binary Code using 4 bits. Can’t do. Not enough bits.

  18. Unsigned Binary Code ( 4 bits)

  19. Unsigned Binary Code • The Unsigned Binary Code is used to represent positive integer numbers. • What is the range of values that can be represented with n bits in the Unsigned Binary Code? [0, 2n-1] • How many bits are required to represent a given number N? number of bits = smallest integer greater than or equal to log(N)

  20. Unsigned Binary Code: Arithmetic & Logic Operations • Arithmetic Operations: • Addition • Subtraction • Multiplication • Division • Logic Operations • AND CONJUNCTION • OR DISJUNCTION • NOT NEGATION • XOR EXCLUSIVE OR

  21. Signed Binary Codes These are codes used to represent positive and negative numbers. • Sign and Magnitude Code • 1’s Complement Code • 2’s Complement Code

  22. Sign & Magnitude Code • The leftmost bit is the sign bit • 0 for positive numbers • 1 for negative numbers • The remaining bits represent the magnitude of the number Example: Sign & Mag. CodeDecimal 01101 +13 11101 -13 00101 +5 10101 -5

  23. Sign &Magnitude (4 bits) What is the range of values that can be represented in S&M code with n bits?

  24. Sign&Magnitude • Example 1: Represent (26)10 in Sign & Magnitude Code. 2610 = 011010 • Example 2: Represent (26)10 in Sign & Magnitude Code using 8 bits 2610 = 0001 1010 • Example 3: Represent (26)10 in Sign & Magnitude Code using 5 bits. • Need at least 6 bits.

  25. Sign&Magnitude • Example 1: Represent (-26)10 in Sign & Magnitude Code. • 26 = 11010 • -2610 = 111010 • Example 2: Represent (-26)10 in Sign & Magnitude Code using 8 bits • 26 = 00011010 • - 2610 = 10011010 • Example 3: Represent (-26)10 in Sign & Magnitude Code using 5 bits. • Need at least 6 bits.

  26. Binary Arithmetic Addition Subtraction Multiplication Division

  27. Binary Addition • Equation Recall decimal addition Binary addition

  28. Example Add the following binary number: (a) 10010011 + 01001011 (b) 00011111 + 00000111 (a) 1 0 0 1 0 0 1 1 + 0 1 0 0 1 0 1 1 1 1 147 + 75 1 1 0 1 1 1 1 0 = 222 1 1 1 1 1 31 (b) 0 0 0 1 1 1 1 1 + 0 0 0 0 0 1 1 1 + 7 = 3810 0 0 1 0 0 1 1 0

  29. Binary Subtraction 0 - 0 = 0  ผลลบ0ตัวยืม0 0 - 1 = 1  ผลลบ1ตัวยืม 1 1 - 0 = 1  ผลลบ1ตัวยืม0 1 - 1 = 0  ผลลบ0ตัวยืม0 ตารางความจริงการลบ สมการทั่วไป : A0 B0 R0 B0ut 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 0 A0 < B0 ต้องการ ตัวยืม R0 : ผลต่าง Bout : ตัวยืม

  30. Binary Multiplication A Basic Roles for Multiplication

  31. Binary Division

  32. 1’s Complement Code • Positive numbers: • same as in unsigned binary code • pad a 0 at the leftmost bit position • Negative numbers: 1. Represent themagnitudeof the number in unsigned binary system 2. pad a 0 at the leftmost bit position 3. complement every bit

  33. 1’s Complement Code • Example: represent 2610 in 1’s complement code • 2610 = 11010 • Pad a 0: = 011010 • Example: Represent (-26)10 in 1’s complement code. 1. 26= 11010 2. Pad a 0: 011010 3. Complement: 100101(-26)10 = (100101)1’s comp

  34. 1’s Complement Code • Example: Represent (-26)10 in 1’s comp. code using 8 bits 1. Represent magnitude in unsigned binary using 8 bits 26 = 0001 1010 2. Complement every bit 11100101 -2610 = (1110 0101) 1’s comp

  35. 1’s Complement Code (4 bits) What is the range of values that can be represented in S&M code with n bits? [ -(2 (n-1) -1) , 2(n-1) -1]

  36. 2’s Complement Code • This is the code commonly used to represent integer numbers. • Positive Numbers: • same as in unsigned binary code • pad with a 0 leftmost bit position • Negative Numbers 1. represent magnitude in unsigned binary code 2. pad leftmost positions with 0s 3. complement every bit 4. add 1

  37. 2’s Complement Code • Example 1: Represent 26 in 2’s complement code. 26 = 011010 • Example 2: Represent 26 in 2’s complement code using 8 bits 26 = 00011010 • Example 3: Represent 26 in 2’s complement code using 5 bits • Need at least 6 bits.

  38. 2’s Complement Code • Example 3: Represent - 26 in 2’s comp. Code 1. +26 = 11010 2. Pad with a 0: 011010 3. Complement: 100101 4. Add 1: + 1 --------------- 100110

  39. 2’s Complement Code • Example 4: Represent - 26 in 2’s comp. Code using 8 bits 1. +26 = 11010 2. Pad 0s: 00011010 3. Complement: 11100101 4. Add 1: + 1 --------------- 11100110

  40. 2’s Complement Code • More example: represent 65 in 2’s comp. Code. • 65 = (0100 0001)2’s comp • Represent - 65 in 2’s comp • 65 = 0100 0001 • -65 = 1011 1111

  41. Conversion from 2’s comp code to decimal code • How to convert a number in 2’s Comp. Code into the decimal code. There 2 cases: Case 1: If leftmost bit of the number is 0 => number is positive => conversion is the same as in unsigned binary code

  42. Conversion from 2’s comp code to decimal code Case 2: If leftmost bit is 1 => the number is negative step1: complement every bit step2: add 1 step3: convert result to decimal code using same method as in unsigned binary code. Answer = the negative of the result of step 3.

  43. 2’s Complement Code (4 bits) Range of values with n bits: [ -2 (n-1), 2(n-1) -1]

  44. 1’s and 2’s Complement of Binary Numbers

  45. Alternative Method to find 2’s Complement

More Related