580 likes | 595 Views
This chapter provides an introduction to digital electronics, specifically combinational logic. Topics covered include binary number concepts, Boolean algebra, gates, and Karnaugh maps.
E N D
ECA1212Introduction to Electrical &Electronics EngineeringChapter 8: Digital Electronics– Combinational Logicby Muhazam Mustapha, November 2011
Learning Outcome • By the end of this chapter, students are expected to understand • binary number concepts • Boolean algebra and minimization
Chapter Content • Motivation • Number Systems • Negative Numbers • Boolean Algebra • Gates • Karnaugh Map
Motivations CO3
Definition & Nature • Field of electronics that represents signals by DISCRETE bands of analog levels, rather than by a continuous range • Work of digital electronics: • estimates analog values as numbers (binary) • math is more in boolean and integer mode • deals more with algorithms and timing • Opposite: Analog electronics • represents signals as continuous range • works on manipulating signal shape • math is real valued and may involve calculus • deals more with transfer functions and models CO3
Definition & Nature Digital amplifier DSP Analog amplifier 32 bits 32 bits Analog view Digital view F X X F Y Y CO3
Number Systems CO3
Binary System (Base-2) Binary (short as ‘bin’) system is the positional number system that uses only 2 symbols (b): 0 and 1 (N = 2) ...b3b2b1b0 . b−1b−2b−3... Number value = ... + b3×23 + b2×22 + b1×21 + b0×20 + b−1×2−1 + b−2×2−2 + b−3×2−3 + ... • For binary system, bn, which is either 0 or 1, is also called BIT • The above formula is used to get the decimal (base-10) values from non-base-10 numbers CO3
Octal & Hexadecimal Base-2 (binary) is too small which makes the number tends to be very long Larger bases are needed so that the number is shorter and more handy Octal (short as ‘oct’) numbers are base-8, using 8 symbols: 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal (short as ‘hex’) numbers are base-16, using 16 symbols (10 digits and 6 first alphabets either lower or upper case): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F CO3
Oct & Hex to Dec Conversion Similar conversion rule as bin to dec (short for decimal) applies Octal: ...d3d2d1d0 . d−1d−2d−3... Number value = ... + d3×83 + d2×82 + d1×81 + d0×80 + d−1×8−1 + d−2×8−2 + d−3×8−3 + ... • Hexadecimal: ...d3d2d1d0 . d−1d−2d−3... Number value = ... + d3×163 + d2×162 + d1×161 + d0×160 + d−1×16−1 + d−2×16−2 + d−3×16−3 + ... CO3
Conversion from Dec (Integer) If the dec number has fraction part, we have to split it into integer and fraction To convert from integer dec, M, to any base do the following algorithm: • DIVIDE the integer M with the base (N) • Keep the REMAINDER of the division (in sequence) – these are the digits of the base-N number • Also keep the integer value of the division – this will be the new value of M • If M is more than 0, repeat step 1-4 • The base-N number is the remainders kept in step 2 written from the last one to the first one (reversed) CO3
Conversion from Dec (Integer) Example: Convert 62 dec to bin Remainder 2 62 0 2 31 1 2 15 1 6210 = 1111102 2 7 1 2 3 1 2 1 1 0 Try yourself to convert 62 dec to oct and hex CO3
Conversion from Dec (Fraction) To convert from dec fraction, m, to any base do the following algorithm: • MULTIPLY the fraction m with the base (N) • Keep and remove the INTEGER PART of the multiplication (in sequence) – these are the digits of the base-N number • Also keep the fraction value of the multiplication – this will be the new value of m • If m is more than 0, repeat step 1-4, or continue to step 5 until the required no. fraction digits are obtained • The base-N number is the integer parts kept in step 2 written from the first one to the last one (in order) CO3
Conversion from Dec (Fraction) Example: Convert 0.62 dec to bin Integer Part 1 .24 = 2 × 0.62 0 .48 = 2 × 0.24 0 .96 = 2 × 0.48 0.6210 = 0.1001112 1 .92 = 2 × 0.96 1 .84 = 2 × 0.92 1 .68 = 2 × 0.84 Try yourself to convert 0.62 dec to oct and hex CO3
Bin, Oct & Hex Conversions • Groups mapping: CO3
Bin, Oct & Hex Conversions Example: Convert 1101001011 bin to oct and hex 11010010112 11010010112 = 15138 1 5 1 3 11010010112 11010010112 = 34B16 3 4 B CO3
Bin, Oct & Hex Conversions Example: Convert 526 oct to bin 5268 5268 = 1010101102 1010101102 Example: Convert 52C hex to bin 52C16 52C16 = 101001111002 0101001111002 CO3
Negative Numbers CO3
Representing Negative Number For our course we will only consider integer negative numbers Sign-magnitude representation: the magnitude is represented like positive number the sign will be kept as 1 bit flag straight-forward but requires more circuit Complement method: less direct but results in simpler circuit we will study complement methods for bin numbers – 1’s and 2’s complement there are complement methods for dec numbers – 9’s and 10’s complement, but we won’t go into details CO3
Motivation In digital processing we will be doing a lot of binary arithmetic Most of the arithmetic will be additive (addition or subtraction) because multiplicative arithmetic can always be converted to additive ones The motivation to have complement method in binary numbers is to convert subtraction into addition so that both operations (and all operations) can homogeneously handled as one type of operation CO3
1’s and 2’s Complement 1’s and 2’s complements (comp) are negative number representation for binary numbers The size of the number must be known The negative number (1’s or 2’s comp) is then indicated by a 1 in the MSB (most significant bit) 1’s complement is constructed by: toggling (change 1 to 0, or 0 to 1) each bit in the number there will be 2 ways to represent 0 (zero): 0000 0000 – positive zero, or 1111 1111 – negative (1’s comp) zero CO3
1’s and 2’s Complement 2’s complement is constructed by: Constructing the 1’s complement, then Add 1 to the result Differences from 1’s comp: there is only 1 way to represent zero: 0000 0000 zero is considered positive since the MSB is 0 the number with only MSB as 1 and the rest is zero (1000 0000) is the largest negative number that has NO matching positive number (check for yourself why) CO3
1’s and 2’s Complement 4 bits 1’s and 2’s comp: CO3
1’s and 2’s Complement Example: Compute 53 dec 1’s and 2’s comp for bin number of 8 bits long 53 dec = 0011 0101 bin −53 dec = −0011 0101 bin = 1100 1010 1’s comp = 1100 1011 2’s comp • Example: Compute the following 1’s and 2’s comp numbers’ sign-magnitude dec 1111 1001 1011 1’s comp = -0000 0110 0100 bin = -100 dec 1100 1101 0101 2’s comp = 1100 1101 0100 1’s comp = -0011 0010 1011 bin = -811 dec CO3
2’s Comp Arithmetic We shall cover only 2’s complement arithmetic Take place only when it involves SUBTRACTION or NEGATIVE numbers Represent any negative number with the corresponding 2’s comp Replace subtraction with addition of its negative Subtraction of 2’s complement is the addition with the corresponding positive number CO3
2’s Comp Arithmetic Both addition and subtraction are performed as ADDITION Even though the MSB can be considered as sign flag, but the addition is done disregarding that fact, i.e. MSB is involved in the addition Ignore any carry beyond MSB: OVERFLOW happens when addition of 2 positive numbers results in a negative number UNDERFLOW happens when addition of 2 negative numbers results in a positive number CO3
2’s Comp Arithmetic • 2’s comp example: −3−2 dec = −0011−0010 bin = 1101+1110 bin = 1011 bin = −5 dec 5+5 dec = 0101+0101 bin = 1010 bin = −6 dec ⇒ wrong answer due to overflow overflow indication CO3
Boolean Algebra CO3
Definition Boolean algebra has 2 similar but different definitions for mathematician and engineers Mathematician: Boolean algebra is part of the so called abstract mathematics that involves structures and lattice Wikipedia: http://en.wikipedia.org/wiki/Boolean_algebra_(structure) Engineers: Boolean algebra is calculus of truth values that is used as a means to facilitate the design of logic and digital systems Wikipedia: http://en.wikipedia.org/wiki/Boolean_algebra_(logic) CO3
Boolean Values • Boolean expressions represent the 2 levels of binary system in the digital systems • In real digital systems the levels can be ON/OFF states, LOW/HIGH voltage levels • In Boolean expressions the levels (values) are TRUE/FALSE or 1/0 CO3
Boolean Operation Boolean algebra has 3 fundamental operations: AND, OR, NOT (also called inverter) AND: Operates on 2 operands Gives true (1) if both operands are true Symbol: ‘·’ (dot) - optional Example: Assume A = True, B = FalseThen A AND B = FalseWritten as: A·B = AB = False = 0 CO3
Boolean Operation OR: Operates on 2 operands Gives true (1) if either or both operands are true Symbol: ‘+’ Example: Assume A = True, B = FalseThen A OR B = TrueWritten as: A+B = True = 1 CO3
Boolean Operation NOT: Operates on 1 operand Gives 1 if the operand is 0, otherwise it gives 0 symbol: ‘‾’ (bar / overline) Example: Assume A = TrueThen NOT A = FalseWritten as: A = False = 0 CO3
Boolean Function & Expression Boolean Expressions: Composed of any combination of Boolean variables and operations Example: Boolean Functions: Function with Boolean values and defined by Boolean valued variables (parameters) Example: Function f of a, b and c CO3
Truth Table Since Boolean functions are Boolean valued, and composed of Boolean valued parameters, all possible values of the function with respect to all possible combinations of the parameter can be listed in a table Such a table is called Truth Table Truth table is a way to define a Boolean function that is not available in other mathematical functions – truth table can be applied to Boolean functions only CO3
Truth Table Truth table of the 3 fundamental Boolean operations: NOT OR AND • Truth table can also be built for any Boolean function CO3
Truth Table • Example of step by step construction of truth table of function: CO3
Boolean Expression from Truth Table Since truth table is constructed from Boolean functions, it is also possible to construct Boolean function from a given truth table By MINTERM Sum of Product (SOP) Create minterms by AND-ing all variables where the outputs (function values) are 1 The variables that have value of 0 will be inverted The variables that have value of 1 will not be inverted The minterms will then be combined by OR operation CO3
Boolean Expression from Truth Table By MAXTERM Product of Sum (POS) Create maxterms by OR-ing all variables where the outputs (function values) are 0 The variables that have value of 1 will be inverted The variables that have value of 0 will not be inverted The maxterms will then be combined by AND operation CO3
Boolean Expression from Truth Table The SOP and POS of minterms and maxterm, respectively, are also called the CANONICAL form of the boolean function The form is the one with the smallest no. terms and all variables appear in each term Canonical also means ‘standard’ CO3
Boolean Expression from Truth Table Minterm example: Truth Table Sum of Product (SOP) short notation CO3
Boolean Expression from Truth Table Maxterm example: Truth Table Product of Sum (POS) short notation CO3
DeMorgan’s Theorem • Used to split groups of large inversion CO3
Other Boolean Operations • NOR • OR followed by NOT • A NOR B = A+B • NAND • AND followed by NOT • A NAND B = AB • XOR • true if either one, but not both, is true • symbol: ‘⊕’ • XNOR • true if both parameters are the same • XOR followed by NOT • symbol: ‘⊙’ CO3
Other Boolean Operations NAND XOR NOR XNOR CO3
Gates CO3
Boolean Operators as Gates A NOT A A XOR B A A A A AND B A OR B B B B A XNOR B A NOR B A A NAND B A A B B B CO3
Gate Tree For more general and complicated boolean functions B+C B C A(B+C) A A(B+C)+AD A D AD CO3
Karnaugh Map CO3
Karnaugh Map K-Map is a transformation of truth table into a table that arranges the terms in such a way that the adjacent terms have ONLY 1 VARIABLE CHANGE The mapping from truth table to K-map is a one-to-one mapping, but the counting sequence in K-map is changed to maintain 1 variable change between the neighboring (adjacent) box CO3