Basic Digital Logic Systems Review Basic Digital Logic Systems Digital Design Review
Outline Number Systems / Binary Encoding Boolean Algebra Combinational Circuits Sequential Circuits Digital Design Review
1. Number Systems Digital Design Review
Positional Number System For base-10 numbers: 289 = 2x102 + 8x101 + 9x100 Works for other bases Base 6: (we indicate base explicitly) 2356 = 2x62 + 3x61 + 5x60 Fractional Numbers: 73.502 = 7x101 + 3x100 + 5x10-1 + 0x10-2 + 2x10-3 52.18 = 5x81 + 2x80 + 1x8-1 = 40 + 2 + 1/8 = 42.12510 Digital Design Review
Binary Numbers Digital Systems Everything must be represented internally using {0,1} Base 2 or “binary” 10112 = 1x23 + 1x21 + 1x20 = 8 + 2 + 1 = 1110 Binary digits = “bits” k-bit unsigned number represents values 0 to 2k-1 Convention: 111010110111 Most significant bit (MSB) Least significant bit (LSB) Digital Design Review
Conversion Between Bases Like long division: Example: convert 11210 to base 6 112 -108 (3x62) 4 - 0 (0x61) => 3046 - 4 (4x60) Digital Design Review
Conversion Between Bases 12.625 - 8 (1x23) 4.625 - 4 (1x22) 0.625 - 0 (0x21) - 0 (0x20) - 0.500 (1x2-1) 0.125 - 0 (0x2-2) - 0.125 (1x2-3) => 1100.1012 Other bases Example: convert 12.62510 to binary Should be able to do this to understand meaning In practice: use a calculator (except simple conversions) Digital Design Review
Hexadecimal Base 16 is Hexadecimal (“Hex” for short) Run out of numbers for digits, so use letters For example 1A2F16 = 1x163 + 10x162 + 2x161 + 15x160 = 670310 Why are hex numbers useful? Shorthand for binary. Going back and forth equally easy Worthwhile to memorize hex digits and binary equivalents Hex 1 2 3 4 5 6 7 8 9 A B C D E F Dec Equiv. 10 11 12 13 14 15 0000|1010|0110|1000 binary 0 A 6 8 hex Digital Design Review
Other Codes Binary Coded Decimal (BCD) Gray Codes ASCII Single decimal digit maps to 4 bits Simplifies display / conversion of decimal numbers Example: 26310 = 0010 0110 0011BCD More bits needed, but it is still often useful Gray Codes Adjacent numbers differ only by one bit ASCII “American Standard Code for Information Interchange” 7-bit code for alphabet and some control characters ‘A’ = 4116 or 6510, ‘.’ = 2E16 ... Decimal Gray 000 1 001 2 011 3 010 4 110 5 111 6 101 7 100 Digital Design Review
Unsigned Arithmetic Addition of unsigned (non-negative) of any base can be done with “elementary school” method Add 2 binary numbers, just need simple rules 0+0+0=00, 0+0+1=01, 0+1+1=10, 1+1+1=11 C = “carry” bit Addition of two k-bit numbers Can lead to k+1 bit number Carry in the left-most position means “overflow” has occurred 0 0 1 1 310 +0 1 0 0 + 410 0 1 1 1 710 1 0 0 1 1 310 +0 0 1 0 + 210 0 1 0 1 510 1 1 1 0 0 1 1 310 +0 1 1 1 + 710 1 0 1 0 1010 Digital Design Review
Signed Magnitude How do we represent negative numbers? How about usual thing with written numbers? Use one bit to mean + (0) or – (1) Digital systems: called the “sign” bit Example: +310 =+ (0112) = 0011SM -310 =- (0112) = 1011SM Advantages: Simple. Sign and number separate Digital Design Review
Signed Magnitude Disadvantages Arithmetic with signed magnitude Two representations of 0 Arithmetic more complicated Arithmetic with signed magnitude 5 + (-2) = 5 – 2 = 3 5 – (-2) = 5 + 2 = 7 -5 – 1 = - (5 + 1) = -6 Must consider signs and do add/sub accordingly Digital Design Review
2s Complement Use the usual positional notation, but we invert sign of leftmost weight Note: MSB can still be considered a “sign” bit indicating if number is + or – For + number, remaining bits can be interpreted as unsigned number 11112C = -1x23 + 1x22 + 1x21 + 1x20 = -8 + 4 + 2 + 1 = -110 10112C = -1x23 + 0x22 + 1x21 + 1x20 = -8 + 0 + 2 + 1 = -510 01112C = -0x23 + 1x22 + 1x21 + 1x20 = -0 + 4 + 2 + 1 = +710 Digital Design Review
2s Comp: Sign Extension How do we make 2’s complement number longer? (maybe need more bits) Answer: duplicate the sign bit. 00112C = 000112C = 000000112C = 310 10112C = 110112C = 111110112C = -510 Digital Design Review
2s Comp: Negating How do we flip the sign of a 2s complement number? With signed magnitude: just flip bit. For 2s complement, invert all bits and add 1 (use modulo unsigned arithmetic) Why does this last conversion fail? +510 = 01012C =>(inv)=> 1010 + 1 = 10112C = -510 -510 = 10112C =>(inv)=> 0100 + 1 = 01012C = -510 +0 = 00002C =>(inv)=> 1111 + 1 = 00002C = 0 -810 = 10002C =>(inv)=> 0111 + 1 = 10002C = -810 !? Digital Design Review
2s Comp: Addition This is the main advantage of 2s complement Just do normal arithmetic (regardless of sign bit) We can also have overflow when we add 2s complement numbers. How do we detect it? Only possible for same sign. Check sign bit, if it changes => overflow. How do we avoid it? Sign extend, then add 0 0 1 1 310 +0 1 0 0 + 410 0 1 1 1 710 1 1 1 1 0 1 1 -510 +0 1 0 1 + 510 0 0 0 0 010 1 1 1 1 1 1 1 - 110 +0 1 1 1 + 710 0 1 1 0 610 Digital Design Review
2. Boolean Algebra Digital Design Review
Boolean Algebra Named after George Boole in 19th century Map: TRUE 1, FALSE 0 Operators: AND a·b or just ab OR a+b NOT a’ or a DeMorgan’s (DM) Rules (AB)’ = A’ + B’ (A+B)’ = A’B’ Easily proven using a truth table ... Digital Design Review
Truth Tables Simple 2-variable truth tables Can obviously extend to more than 2 input variables (output variables) A B F 1 A B F 1 A B F 1 A B F 1 A=B F=1 OR F=AB’ Digital Design Review
Truth Tables Boolean Alg. Sum of Products (SOP) form OR the true rows in the truth table F = A’B + A B’ A B F 1 A’B’ A’B AB’ AB Digital Design Review
Truth Tables Boolean Alg. Product of Sums (POS) form AND the false rows in the truth table F’ = A’B’ + AB F’ = [(A’B’)’ (AB)’]’ (DM) F = (A+B) (A’ + B’) (DM) A B F 1 A’B’ A’B AB’ AB Digital Design Review
Boolean Eq. Truth Table Repeatedly evaluate expression for all combinations. Can be more efficient to fill just TRUE terms F = A’B + A B F = A + A’B A’B AB A B F 1 A’B A A B F 1 Digital Design Review
Boolean Identities Single Variable Two Variable useful for reducing # of terms on complex exp. Simplification Theorems Consensus Theorem difficult to find opportunities to use cons. thm. A · 0 = 0 A · 1 = A A + 0 = A A + 1 = 1 A · A’ = 0 A + A’ = 1 A · A = A A + A = A A + A’B = A + B A(A’ + B) = AB AB’ + AB = A (A+B’)(A+B) = A AC + A’B + BC = AC + A’B Redundant (A+C)(A’+B)(B+C) = (A+C)(A’+B) Digital Design Review
Boolean Identities (cont’d) Communitive, Associative, Distributive Thms AB = BA A+B=B+A Communitive (AB)C = A(BC) (A+B)+C = A+(B+C) Associative A(B+C)=AB + AC Distributive A+BC = (A+B)(A+C) Distributive Duality: For a valid equality, its “dual” is also true Dual: Replace AND ↔ OR 1 ↔ 0 Example: A(B+C) = AB + AC know this is valid, then ... A + BC = (A+B)(A+C) Note: An expression is not equivalent to its dual! Be careful of precedence. Digital Design Review
Canonical Forms Purpose SOP form “minterm” expansion Means: “Write a an expression in most standard way.” Trivial to tell if two expressions are identical SOP form “minterm” expansion “minterm” = product term having all variables A B F 1 m0 m1 m2 m3 F = A’B’ + A’B + AB = m0 + m1 + m3 = ∑m(0,1,3) Digital Design Review
Canonical Forms POS form “maxterm” expansion A B F 1 M0 M1 M2 M3 1 M0 M1 M2 M3 F = (A’ + B)(A’ + B’) = M2 · M3 = π M(2,3) Digital Design Review
Proving Boolean Expressions Methods Truth table Minterm/maxterm expansion (same terms?) Manipulate one side to = other (identities) Manipulate both sides with identical operations Digital Design Review
Boolean Minimization Make expression as “simple” as possible (low number of terms) AB’ = AB = A(B’ +B) = A· 1 = A Less complicated expression Fewer gates, less area, runs faster Attempt to find minimal cost solution What is minimal representation? Depends on technology and contraints. Digital Design Review
Boolean Minimization Example technologies MSI - 7400 Min. chip count One type of gate preferable NMOS NOR gates Literal count (count # of terms) *CMOS NAND gates FPGA Minimum number of Lookup Tables (LUTs) Digital Design Review
Incompletely Specified Funcs A B C F X Y Z W A B C F 1 X Suppose we know N1 will never generate 101 or 111 Can pick don’t cares to help minimize logic. “Don’t cares” Digital Design Review
K-Maps Karnaugh Map (K-Map for short) Graphical way of obtaining minimal solutions Take advantage of logical adjacency to reduce exp. Consider: F = A’B’ + A’B = A’ From simplification theorem AB’ + AB = A Terms A’B’ and A’B are adjacent in gray code (differ by 1 bit) See adj. terms Immediately use simp. thm. F = ABCD + AB’CD = ACD A B F 1 Digital Design Review
K-Maps (cont’d) 2 Variable Rearrange truth table (gray code) B A K-map more compact (can see adjacent bits) A B F 1 A B F 1 F = B F = B B A 1 F = A’B + AB = B Can write F=B from K-map without using simplification theorem Digital Design Review
K-Maps (cont’d) Minterm (SOP) Method - Draw rectangles (ovals) to group as many 1s as possible. - Repeat until all 1s circled - Now OR the resulting terms (1 per oval) A B F 1 B A 1 F = B A B F 1 B A 1 F = A + B Digital Design Review
K-Maps: Don’t cares Can put X’s (don’t cares) in K-map What do we do with them? Doesn’t matter! We can circle them or not, in order to have as few terms (biggest ovals) as possible. B A 1 X Digital Design Review
K-Maps: 3 Variable BCA BCA BCA 1 0 0 m0 m4 0 1 m1 m5 1 1 m3 m7 1 0 m2 1 0 0 m0 m4 0 1 m1 m5 1 1 m3 m7 1 0 m2 m6 BCA 1 0 0 X 0 1 1 1 1 0 X = 0 F = A’C + BC A B C F X 1 BCA 1 0 0 X 0 1 1 1 1 0 Exploit don’t cares F = C Digital Design Review