1 / 88

EEL 3705 / 3705L Digital Logic Design

EEL 3705 / 3705L Digital Logic Design. Fall 2006 Instructor: Dr. Michael Frank Module #3: Base- b Number Systems. Topics for Today (Wed. 9/6). Administrivia: This week’s labs, prereq reminder Logic review/preview: AND, OR, XOR gates Topic #1: Base- b number systems

harper
Download Presentation

EEL 3705 / 3705L Digital 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. EEL 3705 / 3705LDigital Logic Design Fall 2006Instructor: Dr. Michael FrankModule #3: Base-b Number Systems M. Frank, EEL3705 Digital Logic, Fall 2006

  2. Topics for Today (Wed. 9/6) • Administrivia: This week’s labs, prereq reminder • Logic review/preview: AND, OR, XOR gates • Topic #1: Base-b number systems • Base-b number representations • Commonly used bases in digital logic: 2, 8, 16 • Arithmetic in base-b number systems • Conversion between different bases • And, time permitting: • Demonstration of the design & programming of a simple circuit to display the word “HI.” on the MAX 7000’s 7-segment LED display. M. Frank, EEL3705 Digital Logic, Fall 2006

  3. Logic Review / Preview Basic logic gates: NOT, OR, AND, XOR M. Frank, EEL3705 Digital Logic, Fall 2006

  4. Why Bits (Binary Digits)? • As we’ll learn, computers represent all information using bits. • A bit means a binary (i.e., base 2) digit, 0 or 1. • This is done for several reasons: • Two states (digit values) is all that is really needed. • Any desired information can be represented using sequences of bits. • Encoding information using 2-state systems offers the best noise immunity for a given energy/information ratio. • Computers based on bits tend to be the most energy-efficient. • A bit conveniently can represent the truth value of any given proposition in Boolean logic. • That is, “true” (1) or “false” (0). • Bits can be simply and easily manipulated by simple hardware elements called “logic gates.” • These implementing the basic operators of Boolean logic. M. Frank, EEL3705 Digital Logic, Fall 2006

  5. Boolean Logic: Review • For reasoning about whether propositions (statements) are true (T) or false (F). • The truth value of the proposition. • The important functional operators of Boolean logic include: • NOT(x) = {T iff x=F (otherwise F)} • AND(x,y) = {T iff both x=T and y=T} • OR(x,y) = {T iff either x=T or y=T, or both} • XOR(x,y) = {T iff either x=T or y=T, but not both} George Boole1815-1864 iff = “ifand only if”  “exclusive OR” M. Frank, EEL3705 Digital Logic, Fall 2006

  6. Boolean Logic Notations • You should be aware that any given expression of Boolean logic could be written in several styles: • Writing operators as functions: • XOR(OR(AND(a,b),NOT(c)),d) • Using operator names “infix” (between their operands): • ((a AND b) OR (NOT c)) XOR d • Using mathematical logic operator symbols: • [(a b)  ¬c]  d • Using C programming language operators: • ((a & b) | ~c) ^ d • Using Boolean algebra notation: Preferred in this course M. Frank, EEL3705 Digital Logic, Fall 2006

  7. Logic Gate Icons • Inverter • Logical NOT,Boolean complement • AND gate • Boolean product • OR gate • Boolean sum • XOR gate • exclusive-OR, sum mod 2 x x x·y y x+y x y x xy y M. Frank, EEL3705 Digital Logic, Fall 2006

  8. Multi-input AND, OR, XOR • Can extend these gates to arbitrarilymany inputs. • Two commonlyseen drawing styles: • Note that the second style keeps the gate icon relatively small. x1 x1x2x3 x2 x3 x1⋮ x5 x1…x5 M. Frank, EEL3705 Digital Logic, Fall 2006

  9. NAND, NOR, XNOR • Just like the earlier icons,but with a small circle onthe gate’s output. • Denotes that the output is complemented. • Circles could also be placed on inputs. • Means, input is complementedbefore being used. x y x y x y M. Frank, EEL3705 Digital Logic, Fall 2006

  10. CMOS NAND gate implementation • A NAND gate is particularly easyto implement in CMOS: • Simple 4-transistor circuit  • A NOR gate is equally simple, • but slower, • due to series pFETs • If we wanted to, we could buildany computer using nothingbut NAND gates and wires! Vdd x y xy Vss = GND M. Frank, EEL3705 Digital Logic, Fall 2006

  11. Topic #1 Base-b Number Systems(with emphasis on bases 2, 8, 16) M. Frank, EEL3705 Digital Logic, Fall 2006

  12. 1. Base-b Number Systems • List of subtopics: 1.1. Integers in base-b number systems 1.2. Arithmetic in alternative bases 1.3. Methods for converting between different bases 1.4. Fixed-width binary arithmetic and overflow 1.5. Signed number representations & overflow 1.6. Fixed-point representation of fractional numbers M. Frank, EEL3705 Digital Logic, Fall 2006

  13. Base-b Number Systems • Our ordinary decimal (base ten) number system can be used to represent any number while using only ten different digits: • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 • But, there’s nothing special about the number ten! • We only use base ten because we have ten fingers! • Given any integer b > 1, we can describe an alternative base b (or radixb) number system, in which: • There are exactly b different digit symbols • The values of the digits are 0, 1, …, b1 • An arbitrary integer N > 0 can be written uniquely as a sequence of k digits like (dk1dk2…d2d1d0)b, • where 0 ≤ di < b and the first digit dk1 > 0. • This is called the base b expansion of N. • The value of N is given by the expression: M. Frank, EEL3705 Digital Logic, Fall 2006

  14. Alternate Bases Most Widely Used in Computer Engineering • Base 2 (binary): • The only digit values are 0 and 1 • Used internally in all modern computers • Base 8 (octal): • Digits are 0, 1, 2, 3, 4, 5, 6, 7 • Each octal digit represents a sequence of 3 bits • Base 16 (hexadecimal or just “hex”): • Digits are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F • Where A=ten, B=eleven, …, F=fifteen. • Each hex digit represents a sequence of 4 bits M. Frank, EEL3705 Digital Logic, Fall 2006

  15. Four Representations of The First Sixteen Non-negative Integers M. Frank, EEL3705 Digital Logic, Fall 2006

  16. Subtopic #1.2 Arithmetic in Alternative Bases M. Frank, EEL3705 Digital Logic, Fall 2006

  17. Arithmetic in Alternative Bases • Procedures for doing arithmetic in any arbitrary base are essentially identical to those you already know for doing arithmetic in base ten… • Only the number of digit values is different! • This affects the basic addition/multiplication tables, but not much else… M. Frank, EEL3705 Digital Logic, Fall 2006

  18. Binary Addition/Multiplication Tables Note that here, “+” means ordinary addition, not logical OR. Note: Read this digit sequence as “one-zero” or “one-zero base two” or “binary 2”Don’tcall this a “ten!” The English word ten refers to the number 1+1+1+1+1+1+1+1+1+1. In binary, that number is written 1010. M. Frank, EEL3705 Digital Logic, Fall 2006

  19. Topics for Today (Mon. 9/11) • Administrivia: HW#1 is posted. • Topic #1: Base-b number systems (cont.) • Finish arithmetic in base-b number systems • Conversion between different bases • Fixed-width and signed arithmetic and overflows • And, time permitting: • Demonstration of the design & programming of a simple circuit to display the word “HI.” on the MAX 7000’s 7-segment LED display. M. Frank, EEL3705 Digital Logic, Fall 2006

  20. Binary Addition Example • Here we will use the facts that 1+1 = 2 = 102 and 1+1+1 = 3 = 112. Check work in decimal: Carry bits 1 1 1 1 1 0 12 + 1 1 12 = 8 + 4 + 1 = 1310 = 4 + 2 + 1 = 710 1 0 1 0 02 = 1610 + 4 = 2010  = 1310 + 710 M. Frank, EEL3705 Digital Logic, Fall 2006

  21. Binary Subtraction Example • Here we use the fact that 102 1 = 2  1 = 1. 1 0 0 1 1 1 0 12 − 1 1 12 13  7  1 1 02 6 M. Frank, EEL3705 Digital Logic, Fall 2006

  22. Binary Multiplication Example • Very easy, since all rows are either ×0 or ×1: 1 1 0 1 × 1 0 1 13 5 1 1 0 1 Partial Products 0 0 0 0 + 1 1 0 1  1 0 0 0 0 0 1 65 M. Frank, EEL3705 Digital Logic, Fall 2006

  23. Binary Division Example • Subtract the divisor at each position, if possible… 1 1 0 Quotient 1 0 1 1 0 1 Divisor Dividend − 1 0 1 0 − 1 0 0 1 Check:13/2 = 6 r 1  − 0 1 Remainder M. Frank, EEL3705 Digital Logic, Fall 2006

  24. Octal Addition/Multiplication Tables M. Frank, EEL3705 Digital Logic, Fall 2006

  25. Hexadecimal Addition Table M. Frank, EEL3705 Digital Logic, Fall 2006

  26. Hexadecimal Multiplication Table • Exercise for the student: • Figure out and fill in the rest of this table! M. Frank, EEL3705 Digital Logic, Fall 2006

  27. Hexadecimal Arithmetic Examples • Hex addition and multiplication: 1 3E42× D86 3E42+ D86 1758C 4 C B 8 1F210 + 3295A 349F08C M. Frank, EEL3705 Digital Logic, Fall 2006

  28. Base Powers to Memorize • For base conversion and checking of results, as well as many other purposes, you should try to memorize the following: • Powers of 2 up to at least 216: • 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536 • Powers of 8 up to at least 85: • 1, 8, 64, 512, 4096, 32768 • Powers of 16 up to 168: • 1; 16; 256; 4,096; 65,536; 1,048,576; 16,777,216; 268,435,456; 4,294,967,296 One “K” (kibi) One “Meg” (mebi) Four “Gigs” (gibis) M. Frank, EEL3705 Digital Logic, Fall 2006

  29. Subtopic #1.3 Base Conversion Methods M. Frank, EEL3705 Digital Logic, Fall 2006

  30. Base Conversions • Some procedures for converting a number N from an old base b to a new base B: • Method 0: If one of the bases is a power of the other, can do direct substitution of (groups of) digits. • E.g., octal ↔ binary↔ hex conversions work like this • Otherwise: • Two methods for conversion using arithmetic in the new base B: • Method 1: Directly evaluate the polynomial expression for Nb. • Method 2: (Horner’s rule) Repeatedly multiply by b and add digits of N, reading from left to right. • Two methods for conversion using arithmetic in the old base b: • Method 3: Repeatedly divide N by B, the remainders are the new digits, reading from right to left. • Method 4: Repeatedly divide N by the largest power of B less than N; the quotients are the new digits, reading from left to right. Naturalif new baseis 10 Naturalif old baseis 10 M. Frank, EEL3705 Digital Logic, Fall 2006

  31. Example of Method 0 • Convert 3F616 to octal. • We’ll first convert to binary, then binaryoctal. • Hex to binary groups of 4 bits: • 3  00112, F  11112, 6  01102. • The complete binary representation is: • 11111101102 • Binary groups of 3 bits to octal: • 1  1, 111  7, 110  6, 110  6 • The complete octal representation is: • 17668 M. Frank, EEL3705 Digital Logic, Fall 2006

  32. Examples of Method 1 • Convert 1011010112 to base 10. • 1011010112 = (taking the sum from right to left) = 1×20 + 1×21 + 0×22 + 1×23 + 0×24 + 1×25 + 1×26 + 0×27 + 1×28 = 1·1 + 1·2 + 0·4 + 1·8 + 0·16 + 1·32 + 1·64 + 0·128 + 1·256 = 1 + 2 + 8 + 32 + 64 + 256 = 36310. • Convert 3D9616 to base 10. • 3D9616 = 3×163 + 13×162 + 9×161 + 6×160 = 3×4,096 + 13×256 + 9×16 + 6×1 = 12,288 + 3,328 + 144 + 6 = 15,76610 M. Frank, EEL3705 Digital Logic, Fall 2006

  33. Examples of Method 2 • Convert 1011010112 to base 10. • 1×2 + 0 = 2, ×2 + 1 = 5, ×2 + 1 = 11,×2 + 0 = 22, ×2 + 1 = 45, ×2 + 0 = 90,×2 + 1 = 181, ×2 + 1 = 36310. • Convert 3D9616 to base 10. • 3×16 = 48; +13 = 61;×16 = 976; +9 = 985;×16 = 15,760; +6 = 15,76610. M. Frank, EEL3705 Digital Logic, Fall 2006

  34. Example of Method 3 (Dec.  Binary) • Convert 36310 to binary. • 363 ÷ 2 = 181 r 1181 ÷ 2 = 90 r 190 ÷ 2 = 45 r 045 ÷ 2 = 22 r 122 ÷ 2 = 11 r 011 ÷ 2 = 5 r 15 ÷ 2 = 2 r 12 ÷ 2 = 1 r 01 ÷ 2 = 0 r 1. 1011010112 M. Frank, EEL3705 Digital Logic, Fall 2006

  35. Method 3 Variation: Tower Drawing Style • Same algorithm,but withoutrewriting ofquotients: 1011010112 0 r 1 2 1 r 0 2 2 r 1 2 5 r 1 2 11 r 0 2 22 r 1 2 45 r 0 2 90 r 1 2 181 r 1 2 363 M. Frank, EEL3705 Digital Logic, Fall 2006

  36. Example of Method 3 (Dec.  Hex) • Convert 15,76610 to hexadecimal. • 15,766 ÷ 16 = 985 r 6;985 ÷ 16 = 61 r 9;61 ÷ 16 = 3 r 13;3 ÷ 16 = 0 r 3. 3D9616 M. Frank, EEL3705 Digital Logic, Fall 2006

  37. Example of Method 4 (Dec.  Binary) • Convert 36310 to binary. • 363 ÷ 256 = 1 r 107107 ÷ 128 = 0 r 107107 ÷ 64 = 1 r 4343 ÷ 32 = 1 r 1111 ÷ 16 = 0 r 1111 ÷ 8 = 1 r 33 ÷ 4 = 0 r 33 ÷ 2 = 1 r 11 ÷ 1 = 1 r 0 1011010112 M. Frank, EEL3705 Digital Logic, Fall 2006

  38. Method 4 Variation • When converting from binary, the divides in method 4 can be replaced by simple subtraction of the powers of 2. Example: • Convert 36310 to binary. • 363  256 = 107 • 107  64 = 43 • 43  32 = 11 • 11  8 = 3 • 3  2 = 1 • 1  1 = 0 256 128 64 32 16 8 4 2 1 1 0 1 0 1 1 1 0 1 M. Frank, EEL3705 Digital Logic, Fall 2006

  39. Example Where Neither Base is 10 or a Power of the Other • Convert 2103 ___5 using each of methods 1-4. • Method 1: • N = 2·32 + 1·31 + 0·30 = 2·145 + 1·3 + 0 • 2·145 = 2·105 + 2·4 = 205 + 135 = 335 • N = 335 + 3 = 305 + 115 = 415. • Method 2: • 2 · 3 = 115, + 1 = 125, · 3 = 305 + 115 = 415. • Method 3: • 2103 / 123 = 113 r 1, 113 / 123 = 0 r 113  415 • Method 4: • 2103 / 123 = 113 r 1, 1 / 1 = 1 r 0  415 Doing additionand multiplicationin base 5 1112 21012020121 Doing division in base 3 M. Frank, EEL3705 Digital Logic, Fall 2006

  40. Another Way (Method 5) • When converting between two bases neither of which is base 10 or a power of the other, you might find the following strategy easier than using any of methods 1-4 directly: • First, convert from the old base to base 10 using either method 1 or 2 • Next, convert from base 10 to the new base using either method 3 or 4. M. Frank, EEL3705 Digital Logic, Fall 2006

  41. Example of Method 5 • Convert 2103 ___5 using method 5. • First use method 1 to convert to base 10: • 2103 = 2·32 + 1·31 + 0·30 = 2·9 + 3 + 0 =18+3= 2110 • Next use method 4 to convert to base 5: • 2110 ÷ 5 = 4 r 1  415 M. Frank, EEL3705 Digital Logic, Fall 2006

  42. Topics for Today (Fri. 9/15) • Administrivia: HW#1 is due Monday. • Topic #1: Base-b number systems (finish) • Fixed-width and signed arithmetic and overflows • Fixed-point and floating-point binary fractions • Topic #2, Miscellaneous Codes • BCD, ASCII, Parity codes, Gray codes, Hamming codes • And, time permitting: • Demonstration of the design & programming of a simple circuit to display the word “HI.” on the MAX 7000’s 7-segment LED display. M. Frank, EEL3705 Digital Logic, Fall 2006

  43. Subtopic #1.4 Fixed-Width Binary Arithmetic and Overflow M. Frank, EEL3705 Digital Logic, Fall 2006

  44. Fixed-Width Binary Arithmetic • In digital systems, usually there is only a fixed number n of bits of storage immediately available to represent a given arithmetic result. • What happens if the numeric value of the desired result doesn’t fit in the given number of bits? • The usual behavior of hardware is just to truncate the result, in other words to discard some of the extra bits, usually on the left… • This is equivalent to using “modulo 2n” arithmetic. • We should be aware of when this procedure will lead to a different numeric result than regular arithmetic. • In other words, we should know the overflow conditions. M. Frank, EEL3705 Digital Logic, Fall 2006

  45. Modulo-m arithmetic • In modulo-m arithmetic, all numeric results are projected onto a value in the range [0,m). • Namely, the remainder when dividing by m. • Example: 4+3 = 7 ≡ 2 (mod 5) • Since 7/5 = 1 r 2. • We can visualize the ordinary number line as laid out along a spiral straddling lines representing the different possible mod-m values. ≡ 0(mod 5) 20 15 ≡ 1(mod 5) 10 ≡ 4(mod 5) 21 19 5 14 16 9 11 0 4 6 1 3 2 8 7 13 12 18 17 22 ≡ 2(mod 5) ≡ 3(mod 5) Visualization of number line in modulo-5 arithmetic M. Frank, EEL3705 Digital Logic, Fall 2006

  46. Modulo 2n arithmetic • Fixed-width binary arithmetic with n bits is equivalent to modulo 2n arithmetic. • Discarding the leftmost bits projects us onto one of the arms of the spiral. • An “overflow” happens when we wrap around and leave the innermost arm of the spiral. • Crossing the dotted red line… • It’s like how your car odometer rolls over after 100,000 miles. 00 100 00 11 111 11 01 101 01 10 110 10 2-bit truncation spiral M. Frank, EEL3705 Digital Logic, Fall 2006

  47. Number Wheel Diagrams • We can represent modulo arithmetic using a “number wheel” picture • Think of this as similar to a roulette wheel, or the face of a clock • As you wrap around past the overflow marker, you start repeating the same numbers over again. overflowmarker 0 1 7 000 111 001 6 2 110 010 011 101 3 5 100 4 M. Frank, EEL3705 Digital Logic, Fall 2006

  48. Unsigned Overflow Example • Suppose we are doing fixed-width, unsigned binary arithmetic in three bits, and we add the numbers 5 and 3. What is the result, and is there an overflow? • Expressed in 3 bits, 5 = 1012, 3 = 0112. • Carry out the addition shown at right. • The result is 10002 = 8, which does not fit in 3 bits. • The leftmost 1 gets truncated away, leaving 000 as the result. • So yes, there is an overflow! • Addition causes an overflow whenever there is a carry out of the highest-order bit position. 1 1 1 101+ 0111000 M. Frank, EEL3705 Digital Logic, Fall 2006

  49. Subtopic #1.5 Signed Number Representations,Signed Arithmetic, & Signed Overflow Conditions M. Frank, EEL3705 Digital Logic, Fall 2006

  50. Signed Number Representations • In digital systems, we often need to represent signed (positive or negative) numbers. • On paper, a signed base-b number can of course be denoted by just writing down a + or  sign in front of it. • But, how are signed numbers to be coded using bits? • There are many possible methods. We’ll discuss: • Sign-magnitude representations • Biased representations • One’s-complement representations • Two’s-complement representations • This is the one that is most commonly used today in digital systems, due to the simplicity of its implementation M. Frank, EEL3705 Digital Logic, Fall 2006

More Related