Digital Logic Design -Switch Logic & Basic Gates- A Simple Switch Instr: Dr. Awais M. Kamboh. 2 Switches in Series Instr: Dr. Awais M. Kamboh. 3 Switches in Parallel Instr: Dr. Awais M. Kamboh. 4 Normal vs Inverting Switch Instr: Dr. Awais M. Kamboh. 5 Boolean Logic Boolean Logic is based on two states, e.g., True (1) or False (0) Boolean Logic is a form of algebra which is based on three simple Operators: “Not”, “Or,” and “And,”. There are different ways to represent Boolean logic • True / False, • 1 / 0, • ON / OFF, • High / Low, • Active / Inactive Instr: Dr. Awais M. Kamboh. 6 The Inverter (NOT Gate) The inverter performs the Boolean NOT operation. When the input is LOW, the output is HIGH; when the input is HIGH, the output is LOW. Input Output A X 0 1 1 0 A X The NOT operation (complement / invert) is shown with an overbar or apostrophe. Thus, the Boolean expression for an inverter is X = A or X = A’ Instr: Dr. Awais M. Kamboh. 7 The Inverter (Not Gate) A X As time passes, we may change the input of the gate if we want to, as a result the output changes. Such changes can be represented as a waveform (also called a timing diagram). The x-axis is the time, the y-axis the value of the input or the output. Example waveforms: A X Instr: Dr. Awais M. Kamboh. 8 Decimal vs Binary Numbers Decimal Numbers Commonly used in our daily lives They have 10 possible symbols (called digits) 0,1,2,3,4,5,6,7,8,9 Binary Numbers Used in all digital systems They have 2 possible symbols (called bits) 0,1 Decimal numbers larger than 9 can be represented by adding more digits Example: 247635, 526, 83474 Binary numbers larger than 1 can be represented by adding more bits Example: 10110, 110, 00110011 Instr: Dr. Awais M. Kamboh. 9 The Inverter (Not Gate) A group of inverters can be used to get the 1’s complement of a binary number: 1 0 Binary number 0 0 1 1 0 1 1 1 0 0 1’s complement 0 1 1 0 1’s complement of a binary number means that we invert each bit of that number. Instr: Dr. Awais M. Kamboh. 10 The AND Gate The AND gate produces a HIGH output when all inputs are HIGH; otherwise, the output is LOW. For a 2-input gate, the truth table is Inputs Output A B X 0 0 1 1 0 1 0 1 0 0 0 1 A X B The AND operation is usually shown with a dot between the variables, but it may be implied (no dot). Thus, the AND operation is written as X = A .B or X = AB. Instr: Dr. Awais M. Kamboh. 11 The AND Gate A X B Example waveforms: A B X If the binary number 1010 0011 Instr: Dr. Awais M. Kamboh. is ANDed with 0000 1111 what is the result? 0000 0011 12 The OR Gate The OR gate produces a HIGH output if any input is HIGH; if all inputs are LOW, the output is LOW. For a 2-input gate, the truth table is Inputs Output A B X 0 0 1 1 0 1 0 1 0 1 1 1 A B X The OR operation is shown with a plus sign (+) between the variables. Thus, the OR operation is written as X = A + B. Instr: Dr. Awais M. Kamboh. 13 The OR Gate A B X Example waveforms: A B X If the binary number 1010 0011 Instr: Dr. Awais M. Kamboh. is ORed with 0000 1111 what is the result? 1010 1111 14 Timing Diagram / Waveform Instr: Dr. Awais M. Kamboh. 15 Logical Operations Assuming A=0101 and B=1001 as inputs and X as output AND Logic Gate X = A.B or AB A= 0101 B= 1001 X= 0001 OR Logic Gate X =A+B A= 0101 B= 1001 X= 1101 NOT Logic Gate X =Ā or A’ (A Complement) A= 0101 X= 1010 Instr: Dr. Awais M. Kamboh. 16 The NAND Gate A X B The NAND gate produces a LOW(0) output when all inputs are HIGH (1); otherwise, the output is HIGH (1). Think of it as AND followed by NOT Inputs For a 2-input gate, the truth table is Input NAND A B AND AND-NOT X 0 0 0 1 1 0 1 1 0 0 0 1 1 1 1 0 1 1 1 0 Output A B X 0 0 1 1 0 1 0 1 1 1 1 0 The NAND operation is written as X = A .B (Also as, X = AB) = (AB)’ pronounced as AB whole complement Instr: Dr. Awais M. Kamboh. 17 The NAND Gate A X B Example waveforms: A B X The NAND gate is particularly useful because it is a “universal” gate – all other basic gates can be constructed from NAND gates. How to build a NOT gate from a 2-input NAND gate? Instr: Dr. Awais M. Kamboh. 18 The NOR Gate A B X The NOR gate produces a LOW (0) output if any input is HIGH (1); if all inputs are HIGH (1), the output is LOW(0) Think of it as OR followed by NOT Inputs For a 2-input gate, the truth table is A B X 0 0 1 1 0 1 0 1 1 0 0 0 Input NOR A B OR OR-NOT X 0 0 0 1 1 0 1 1 0 1 1 1 1 0 0 0 1 0 0 0 The NOR operation is written as X = A + B = (A+B)’ pronounced as A+B whole complement Instr: Dr. Awais M. Kamboh. 19 Output The NOR Gate A B X Example waveforms: A B X The NOR operation will produce a LOW if any input is HIGH. The NOR gate is also a “universal” gate – all other basic gates can be constructed from NOR gates. Only NAND and NOR are called universal gates Instr: Dr. Awais M. Kamboh. 20 The XOR Gate A B X The XOR Exclusive-OR gate produces a HIGH output only when both inputs are at opposite logic levels. The truth table is Inputs Output A B X 0 0 1 1 0 1 0 1 0 1 1 0 The XOR operation is written as X = AB + AB. Alternatively, it can be written with a circled plus sign between the variables as X = A + B. Instr: Dr. Awais M. Kamboh. 21 The XOR Gate A B X Example waveforms: A B X Notice that the XOR gate will produce a HIGH only when exactly one input is HIGH. If the A and B waveforms are both inverted for the above waveforms, how is the output affected? There is no change in the output. Instr: Dr. Awais M. Kamboh. 22 The XNOR Gate A B X The XNOR Exclusive NOR gate produces a HIGH output only when both inputs are at the same logic level. Inputs Think of it as XOR followed by NOT Input XNOR A B XOR XOR-NOT X 0 0 0 1 1 0 1 1 0 1 1 0 1 0 0 1 1 0 0 1 The XNOR operation shown as X = AB + AB. It can be shown as X = A Instr: Dr. Awais M. Kamboh. . B. 23 Output A B X 0 0 1 1 0 1 0 1 1 0 0 1 The XNOR Gate A B X Example waveforms: A B X Notice that the XNOR gate will produce a HIGH when both inputs are the same. This makes it useful for comparison functions. If the A waveform is inverted but B remains the same, how is the output affected? The output will be inverted. Instr: Dr. Awais M. Kamboh. 24 Three Input AND Gate A C B Inputs X Output A B C X=ABC 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 1 Notice that 1 1 • A 1-input inverter has two possible input values: 0, 1. 1 • A 2-input gate has 4 possible input combinations: 00, 01, 10, 11. • A 3-input gate has 8 possible input combinations, for each input the number of combinations is doubled. c Instr: Dr. Awais M. Kamboh. 25 Three Input OR Gate Inputs Outputs A B C 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 Notice that X=A+B+C 1 1 1 To create the input combinations, we use alternating 0s and 1s. • Input C has one 0 followed by one 1. • Input B has two 0s followed by two 1s. • Input A has four 0s followed by four 1s, and so on… Instr: Dr. Awais M. Kamboh. 26 0 1 1 1 1 1 1 1 Three Input XOR Gate X= A + B + C Inputs XOR A B C 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 D=A + B 0 0 1 1 1 1 0 0 For ODD number of 1s, the output is 1. Instr: Dr. Awais M. Kamboh. 27 D+C X 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1