Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CS151 Introduction to Digital Design Chapter 1 Lecture 3.

Similar presentations


Presentation on theme: "1 CS151 Introduction to Digital Design Chapter 1 Lecture 3."— Presentation transcript:

1 1 CS151 Introduction to Digital Design Chapter 1 Lecture 3

2 CS 151 2 Octal to Binary and Back Octal to Binary:  Restate the octal as three binary digits starting at the radix point and going both ways. Binary to Octal :  Group the binary digits into three bit groups starting at the radix point and going both ways, padding with zeros as needed in the fractional part.  Convert each group of three bits to an octal digit.

3 CS 151 3 Hexadecimal to Binary and Back Hexadecimal to Binary:  Restate the hexadecimal as four binary digits starting at the radix point and going both ways. Binary to Hexadecimal:  Group the binary digits into four bit groups starting at the radix point and going both ways, padding with zeros as needed in the fractional part.  Convert each group of three bits to a hexadecimal digit.

4 CS 151 4 Octal to Hexadecimal via Binary Convert octal to binary. Use groups of four bits and convert as above to hexadecimal digits. Example: Octal to Binary to Hexadecimal 6 3 5. 1 7 7 8 Why do these conversions work? Answer in notes page for this slide…

5 CS 151 5 Conversion Between Bases  Method 2  To convert from one base to another: 1) Convert the Integer Part 2) Convert the Fraction Part 3) Join the two results with a radix point

6 CS 151 6 Conversion Details To Convert the Integer Part: Repeatedly divide the number by the new radix and save the remainders. The digits for the new radix are the remainders in reverse order of their computation. If the new radix is > 10, then convert all remainders > 10 to digits A, B, … To Convert the Fractional Part: Repeatedly multiply the fraction by the new radix and save the integer digits that result. The digits for the new radix are the integer digits in order of their computation. If the new radix is > 10, then convert all integers > 10 to digits A, B, …

7 CS 151 7 Example: Convert 46.6875 10 To Base 2 1. Convert 46 to Base 2 2. Convert 0.6875 to Base 2: 3. Join the results together with the radix point: Answer in notes page for this slide…

8 CS 151 8 Additional Issue - Fractional Part Note that in this conversion, the fractional part became 0 as a result of the repeated multiplications. In general, it may take many bits to get this to happen or it may never happen. Example: Convert 0.65 10 to N 2  0.65 = 0.10 1001 1001 1001 …  The fractional part begins repeating every 4 steps yielding repeating 1001 forever! Solution: Specify number of bits to right of radix point and round or truncate to this number.

9 CS 151 9 Checking the Conversion To convert back, sum the digits times their respective powers of r. From the prior conversion of 46.6875 10 101110 2 = 1*32 + 0*16 +1*8 +1*4 + 1*2 +0*1 = 32 + 8 + 4 + 2 = 46 0.1011 2 = 1/2 + 1/8 + 1/16 = 0.5000 + 0.1250 + 0.0625 = 0.6875

10 CS 151 10 Number Ranges 624 Consider a 3-digit counter. What is the minimum number it can show? What is the maximum number it can show? What is it’s number range? position Each position has 10 possibilities: 0,1,2,3,4,5,6,7,8,9. 10 * 10 * 10 = 10 3 Radix # Positions 000 999 Range: 0  999 0  (10 3 -1)

11 CS 151 11 Number Ranges 010 What if the counter was a 3-bit binary counter? What is the minimum number it can show? What is the maximum number it can show? What is it’s number range? position Each position has 2 possibilities: 0,1. 2 * 2 * 2 = 2 3 Radix # positions (bits) (000) 2 (111) 2 = 7 10 Range: 0  7 0  (2 3 -1)

12 CS 151 12 Given n digits in radix r, there are r n distinct elements that can be represented. These elements range from 0 to r n -1 Number Ranges BONUS: What is the minimum number of bits, n, needed to represent a binary code of M elements ???

13 CS 151 13 Number Ranges Range of numbers is based on the number of bits available in the hardware structure that store and process information. (E.g. registers). Usually, size of these structures is a power of 2. (8 bits, 16 bits, 32 bits, 64 bits and 128 bits).

14 CS 151 14 Binary Arithmetic Single Bit Addition with Carry Multiple Bit Addition Single Bit Subtraction with Borrow Multiple Bit Subtraction Multiplication BCD Addition When working with base-r, use ONLY r allowable digits (0..r-1) and perform all computations with base r digits.

15 CS 151 15 Single Bit Binary Addition with Carry Z 0 0 0 0 X 0 0 1 1 + Y + 0 + 1 + 0 + 1 C S 0 0 1 1 0 Z 1 1 1 1 X 0 0 1 1 + Y + 0 + 1 + 0 + 1 C S 0 1 1 0 1

16 CS 151 16 Extending this to two multiple bit examples: Carries 0 0 Augend 01100 10110 Addend +10001 +10111 Sum Note: The 0 is the default Carry-In to the least significant bit. Multiple Bit Binary Addition Kindly view notes page for answer.

17 CS 151 17 Given two binary digits (X,Y), a borrow in (Z) we get the following difference (S) and borrow (B): Borrow in (Z) of 0: Borrow in (Z) of 1: Single Bit Binary Subtraction with Borrow Z 1 1 1 1 X 0 0 1 1 - Y -0 -0 BS 11 1 0 0 1 Z 0 0 0 0 X 0 0 1 1 - Y -0 -0 BS 0 1 0 1 0

18 CS 151 18 Extending this to two multiple bit examples: Borrows 0 0 Minuend 10110 10110 Subtrahend - 10010 - 10011 Difference Notes: The 0 is a Borrow-In to the least significant bit. If the Subtrahend > the Minuend, interchange and append a – to the result. Multiple Bit Binary Subtraction Kindly view notes page for answer.

19 CS 151 19 Binary SubtractionBorrows: Minuend:10011 Subtrahend: -11110 Difference: 19 - 30  Swap 0 0110 11110 -10011 -01011 30 - 19 -11 Multiple Bit Binary Subtraction

20 CS 151 20 Binary Multiplication +

21 CS 151 21 Octal Multiplication Multiplicand:762 Multiplier: x 45 4672 3710 - Product: 43772 OctalDecimalOctal 5x2 =10= 8+21212 5x6 +1=31= 24+73737 5x7 +3=38= 32+646 4x2=8 = 8+01010 4x6 +1=25= 24+13131 4x7 +3=31= 24+737 Form a table to calculate sums and products of 2 digits in base-r (in this case, base-8)

22 CS 151 22 Hexadecimal Addition 15 6 9 4 5 14 HexDecimal +++ Carry 1 121 =16+ 5 Carry 1 14 = E19 =16+ 3 1 3 E 51 3 E 5 5 9 F E 4 6 +


Download ppt "1 CS151 Introduction to Digital Design Chapter 1 Lecture 3."

Similar presentations


Ads by Google