Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE 331 – Digital System Design

Similar presentations


Presentation on theme: "ECE 331 – Digital System Design"— Presentation transcript:

1 ECE 331 – Digital System Design
Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #9) The slides included herein were taken from the materials accompanying Fundamentals of Logic Design, 6th Edition, by Roth and Kinney, and were used with permission from Cengage Learning.

2 ECE 331 - Digital System Design
52 What does this number represent? Consider the “context” within which the number is used. Fall 2010 ECE Digital System Design

3 ECE 331 - Digital System Design
What is the value of this number? Consider the base (or radix) of the number. Fall 2010 ECE Digital System Design

4 ECE 331 - Digital System Design
Number Systems Fall 2010 ECE Digital System Design

5 ECE 331 - Digital System Design
Number Systems R is the radix or base of the number system Must be a positive number R digits in the number system: [0 .. R-1] Important number systems for digital systems: Base 2 (binary): [0, 1] Base 8 (octal): [0 .. 7] Base 16 (hexadecimal): [0 .. 9, A, B, C, D, E, F] Fall 2010 ECE Digital System Design

6 ECE 331 - Digital System Design
Number Systems Positional Notation N = [a4a3a2a1a0.a-1a-2a-3]R N = numeric value ai = ith position in the number R = radix or base of the number Fall 2010 ECE Digital System Design

7 + a-1 x R-1 + a-2 x R-2 + … a-m x R-m
Number Systems Power Series Expansion D = an x R4 + an-1 x R3 + … + a0 x R0 + a-1 x R-1 + a-2 x R-2 + … a-m x R-m D = decimal value ai = ith position in the number R = radix or base of the number Fall 2010 ECE Digital System Design

8 ECE 331 - Digital System Design
Number Systems Examples: Decimal = 9x x x x x10-2 Binary = 1x23 + 0x22 + 1x21 + 1x20 + 1x x2-2 = / /4 = Fall 2010 ECE Digital System Design

9 ECE 331 - Digital System Design
Number Systems Examples: Octal = 3x82 + 4x81 + 7x80 + 2x x8-2 = ? Hexadecimal E61A.D716 = 14x x x x x x16-2 Fall 2010 ECE Digital System Design

10 ECE 331 - Digital System Design
Number Systems Fall 2010 ECE Digital System Design

11 ECE 331 - Digital System Design
Conversion Fall 2010 ECE Digital System Design

12 Conversion of a Decimal Integer
Use repeated division to convert a decimal integer to any other base. Fall 2010 ECE Digital System Design

13 Conversion of a Decimal Integer
Example: Convert the decimal number 57 to a binary (R=2) number and an octal (R=8) number. 57 / 2 = 28: rem = 1 = a0 28 / 2 = 14: rem = 0 = a1 14 / 2 = 7: rem = 0 = a2 7 / 2 = 3: rem = 1 = a3 3 / 2 = 1: rem = 1 = a4 1 / 2 = 0: rem = 1 = a5 5710 = 57 / 8 = 7: rem = 1 = a0 7 / 8 = 0: rem = 7 = a1 5710 = 718 Fall 2010 ECE Digital System Design

14 Conversion of a Decimal Fraction
Use repeated multiplication to convert a decimal fraction to any other base. Fall 2010 ECE Digital System Design

15 Conversion of a Decimal Fraction
Example: Convert the decimal number to a binary (R=2) number and an octal (R=8) number. 0.625 * 2 = 1.250: a-1 = 1 0.250 * 2 = 0.500: a-2 = 0 0.500 * 2 = 1.000: a-3 = 1 = 0.625 * 8 = 5.000: a0 = 5 = 0.58 Fall 2010 ECE Digital System Design

16 Conversion of a Decimal Fraction
Example: Convert the decimal number 0.7 to binary. 0.7 * 2 = 1.4: a-1 = 1 0.4 * 2 = 0.8: a-2 = 0 0.8 * 2 = 1.6: a-3 = 1 0.6 * 2 = 1.2: a-4 = 1 0.2 * 2 = 0.4: a-5 = 0 0.4 * 2 = 0.8: a-6 = 0 0.710 = In some cases, conversion results in a repeating fraction. process begins repeating here! Fall 2010 ECE Digital System Design

17 Conversion of a Mixed Decimal Number
Conversion of a mixed decimal number is implemented as follows: Convert the integer part of the number using repeated division. Convert the fractional part of the decimal number using repeated multiplication. Combine the integer and fractional components in the new base. Fall 2010 ECE Digital System Design

18 Conversion of a Mixed Decimal Number
Exercise: Convert to binary. Confirm the results using the Power Series Expansion. Fall 2010 ECE Digital System Design

19 ECE 331 - Digital System Design
Conversion Conversion between any two bases, A and B, can be carried out directly using repeated division and repeated multiplication. Base A → Base B However, it is generally easier to convert base A to its decimal equivalent and then convert the decimal value to base B. Base A → Decimal → Base B Power Series Expansion Repeated Division, Repeated Multiplication Fall 2010 ECE Digital System Design

20 ECE 331 - Digital System Design
Conversion Conversion between binary and octal can be carried out by inspection. Each octal digit corresponds to 3 bits = = = = Is the number a valid octal number? Fall 2010 ECE Digital System Design

21 ECE 331 - Digital System Design
Conversion Conversion between binary and hexadecimal can be carried out by inspection. Each hexadecimal digit corresponds to 4 bits = 9 A 6 . B 516 = C B 8 . E 716 E D 216 = 1 C F16 = Note that the hexadecimal number system requires additional characters to represent its 16 values. Fall 2010 ECE Digital System Design

22 ECE 331 - Digital System Design
Number Systems Base: 10 2 8 16 What is the value of 12? Fall 2010 ECE Digital System Design

23 ECE 331 - Digital System Design
Binary Arithmetic Fall 2010 ECE Digital System Design

24 ECE 331 - Digital System Design
Binary Addition Sum Carry Fall 2010 ECE Digital System Design

25 ECE 331 - Digital System Design
Binary Addition Examples: Fall 2010 ECE Digital System Design

26 ECE 331 - Digital System Design
Binary Subtraction Difference Borrow Fall 2010 ECE Digital System Design

27 ECE 331 - Digital System Design
Binary Subtraction Examples: Fall 2010 ECE Digital System Design

28 ECE 331 - Digital System Design
Binary Arithmetic Single-bit Addition Single-bit Subtraction s 1 c x y Carry Sum d 1 x y Difference What logic function is this? What logic function is this? Fall 2010 ECE Digital System Design

29 Binary Multiplication
x x x x 1 Product Fall 2010 ECE Digital System Design

30 Binary Multiplication
Examples: 1011 x 0110 1001 x 1101 0110 x 1010 Fall 2010 ECE Digital System Design

31 Binary Multiplication
When doing binary multiplication, a common way to avoid carries greater than 1 is to add in the partial products one at a time as illustrated by the following example: 1111 multiplicand 1101 multiplier st partial product nd partial product (01111) sum of first two partial products rd partial product ( ) sum after adding 3rd partial product (pp)   th partial product final product (sum after adding 4th pp) Fall 2010 ECE Digital System Design

32 Representation of Negative Numbers
Fall 2010 ECE Digital System Design

33 ECE 331 - Digital System Design
What is the value of this number? Is it positive or negative? If negative, what representation are we using? Fall 2010 ECE Digital System Design

34 Unsigned and Signed Binary Numbers
1 Magnitude MSB (a) Unsigned number Sign (b) Signed number 2 0 denotes 1 denotes + Fall 2010

35 Unsigned Binary Numbers
For an n-bit unsigned binary number, all n bits are used to represent the magnitude of the number. ** Cannot represent negative numbers. Fall 2010 ECE Digital System Design

36 Unsigned Binary Numbers
For an n-bit binary number 0 <= D <= 2n – 1 where D = decimal equivalent value For an 8-bit binary number: 0 <= D <= 28 – 1 28 = 256 For a 16-bit binary number: 0 <= D <= 216 – 1 216 = 65536 Fall 2010 ECE Digital System Design

37 Signed Binary Numbers For an n-bit signed binary number,
n-1 bits are used to represent the magnitude of the number; the leftmost bit (MSB) is, generally, used to indicate the sign of the number. 0 = positive number 1 = negative number Fall 2010 ECE Digital System Design

38 Signed Binary Numbers Three representations for signed binary numbers:
1. Sign and Magnitude 2. 1's Complement 3. 2's Complement Fall 2010 ECE Digital System Design

39 ECE 331 - Digital System Design
Sign and Magnitude For an n-bit signed binary number, The MSB (leftmost bit) is the sign bit. The remaining n-1 bits represent the magnitude. - (2n-1 - 1) <= D <= + (2n-1 – 1) Includes a representation for -0 and +0. The design of arithmetic circuits for Sign and Magnitude binary numbers is difficult. Fall 2010 ECE Digital System Design

40 ECE 331 - Digital System Design
Sign and Magnitude Example: What is the Sign and Magnitude representation for the following decimal values, using 8 bits: + 97 - 68 Fall 2010 ECE Digital System Design

41 ECE 331 - Digital System Design
Sign and Magnitude Example: Can the following decimal numbers be represented using 8-bit Sign and Magnitude representation? - 212 - 127 +128 +255 Fall 2010 ECE Digital System Design

42 ECE 331 - Digital System Design
Questions? Fall 2010 ECE Digital System Design


Download ppt "ECE 331 – Digital System Design"

Similar presentations


Ads by Google