In this lecture: Lecture 3: Basic Logic Gates & Boolean Expressions Dr Pete Sedcole Department of E&E Engineering Imperial College London http://cas.ee.ic.ac.uk/~nps/ (Floyd 3.1 3.6, 4.1) (Tocci 3.1 3.9) What are the basic logic gates? What is Boolean algebra? Boolean variables and expressions Boolean algebra as a way to write down logic Boolean Operators s Relationships between logic gates & Boolean expressions E1.2 Digital Electronics 1 3.1 23 October 2008 E1.2 Digital Electronics 1 3.2 23 October 2008 Boolean Algebra Digital electronics manipulate binary information Designing digital electronics is much easier if we can describe their behaviour mathematically George Boole We can write it down The mathematics of logic invented by English mathematician George Boole is perfect for this Nodes in a circuit are represented by Boolean Variables Boolean Algebra allows us to specify relationships between Boolean variables and so can be used to design digital circuits E1.2 Digital Electronics 1 3.3 23 October 2008 Boolean Variables A Boolean Variable takes the value of either 0 or 1 In digital electronics: Boolean 0 and 1 correspond to binary 0 and 1 In logic, 0 and 1 are sometimes called FALSE and TRUE We use symbols to represent Boolean variables e.g.: A, B, C, X, Y, Z typically a single upper-case letter There are three basic logic operations: AND, OR, NOT E1.2 Digital Electronics 1 3.4 23 October 2008
Boolean Algebra to Describe Logic Example application: Home Heating System Specification: set the required temperature using a thermostat turn on heating if temperature lower than required turn off heating if temperature higher than required turn on heating if heating pipes are in danger of freezing Implementation: use a manual switch to turn on heating system use a room thermostat to detect room temperature use an outdoor frost sensor to warn of freezing use a digital electronic circuit to turn heating on and off intelligently What are the Boolean variables? Three input variables H, R, F and one output S H represents the On/Off switch for whole system H = 0 means the system is off, H = 1 the system is on R room thermostat R = 1 when temperature is lower than required F frost sensor F = 1 when the external temperature is near or below freezing S On/Off switch on the boiler S = 1 when heat should be generated by the boiler E1.2 Digital Electronics 1 3.5 23 October 2008 E1.2 Digital Electronics 1 3.6 23 October 2008 S should be 1 when: (H=1 and R=1) or (F=1 and R=1) In Boolean Algebra: is used for AND is used for OR is used for NOT S = (H R) (F R) If we could build an electronic circuit that implemented this we could sell it as a simple heating system controller Boolean Operators The operator symbols,, are not available on standard keyboards To make things easier to type, in digital electronics we use: Operator Meaning A + B A OR B A B A AND B A NOT A E1.2 Digital Electronics 1 3.7 23 October 2008 E1.2 Digital Electronics 1 3.8 23 October 2008
Boolean Operators Like ordinary algebra, Boolean algebra allows for operations on its variables NOT operator produces the complement (or inverse) of a variable e.g.: NOT K, which is written K if K represents a key on a computer keyboard, and K = 1 means the key is pressed, then K = 0 means the key is not pressed If we look at the complement of K, we can still tell the state of the key, but it will have the opposite sense: K = 1 means the key is not pressed K = 0 means the key is pressed Basic Boolean Operators & Logic Gates Inverter AND gate OR gate NAND gate NOR gate Exclusive-OR gate Exclusive-NOR gate E1.2 Digital Electronics 1 3.9 23 October 2008 E1.2 Digital Electronics 1 3.10 23 October 2008 Truth Tables The OR operation and gate Shows the value of the circuit output for all input values Schematic symbol & Boolean expression Timing diagram The output of the gate is HIGH when ANY of the inputs are HIGH E1.2 Digital Electronics 1 3.11 23 October 2008 E1.2 Digital Electronics 1 3.12 23 October 2008
4-input OR gate Summary of OR operation Output value will be 1 whenever any input is 1 0 otherwise An OR gate is a logic circuit that performs an OR operation on the circuit s inputs The x = A + B is read as x equals A OR B E1.2 Digital Electronics 1 3.13 23 October 2008 E1.2 Digital Electronics 1 3.14 23 October 2008 Example of an OR gate in an alarm system Example 2 E1.2 Digital Electronics 1 3.15 23 October 2008 E1.2 Digital Electronics 1 3.16 23 October 2008
Example 3 Review questions for OR gates What is the only set of input conditions that will produce a LOW output for any OR gate? All inputs LOW Write the for a six-input OR gate X = A + B + C + D + E + F If, for the previous example, the input A is kept permanently at 1, what will the output X be? Also constant 1 E1.2 Digital Electronics 1 3.17 23 October 2008 E1.2 Digital Electronics 1 3.18 23 October 2008 The AND operation and gate Summary of the AND operation The output of the gate is HIGH when ALL of the inputs are HIGH 3-Input AND Gate Output value will be 1 whenever all inputs are 1 0 otherwise An AND gate is a logic circuit that performs an AND operation on the circuit s inputs The x = A B is read as x equals A AND B E1.2 Digital Electronics 1 3.19 23 October 2008 E1.2 Digital Electronics 1 3.20 23 October 2008
Review questions for AND gates The NOT operation and inverter What is the only input combination that will produce a HIGH at the output of a five-input AND gate? All 5 inputs = 1 True or false: an AND gate will always produce an output value that differs from an OR gate for the same input values. False What logic level should be applied to one input of a twoinput AND gate to prevent the second input from making a difference to the output value? A logic LOW will keep the output LOW E1.2 Digital Electronics 1 3.21 23 October 2008 The output of the gate is the COMPLEMENT or OPPOSITE of the input value E1.2 Digital Electronics 1 3.22 23 October 2008 Other names for Boolean operators Since we use the symbols + and for Boolean operators OR and AND, they are often called SUM and PRODUCT The NAND gate SUM (OR) 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 1 PRODUCT (AND) 0 0 = 0 0 1 = 0 1 0 = 0 1 1 = 1 In Boolean algebra these are still Boolean operators, and not the same as + and in ordinary algebra! E1.2 Digital Electronics 1 3.23 23 October 2008 The output of the gate is LOW when ALL of the inputs are HIGH E1.2 Digital Electronics 1 3.24 23 October 2008
The NOR gate Describing logic circuits algebraically Any logic circuit, no matter how complex, can be completely described using the three basic Boolean operations: OR, AND, NOT An example: a logic circuit with its The output of the gate is LOW when ANY of the inputs are HIGH E1.2 Digital Electronics 1 3.25 23 October 2008 E1.2 Digital Electronics 1 3.26 23 October 2008 Precedence There are two ways to interpret A B + C: Is it (A AND B) then ORed with C? Or A ANDed with (B OR C)? In Boolean algebra it is always AND before OR Unless we use parentheses (): Circuits containing inverters Whenever an INVERTER is present in a logic circuit diagram, its output expression is simply equal to the input expression with a bar over it: E1.2 Digital Electronics 1 3.27 23 October 2008 E1.2 Digital Electronics 1 3.28 23 October 2008
More examples Precedence 1. First, perform all inversions of single terms 2. Perform all operations within parentheses 3. Do AND before OR (unless parentheses indicate otherwise) 4. If an expression has a bar over it (inversion), calculate the expression first, then invert the result E1.2 Digital Electronics 1 3.29 23 October 2008 E1.2 Digital Electronics 1 3.30 23 October 2008 Example Determining the output level from a diagram What is the value of Z if: Z = (A B + C)D A = 0, B = 1, C = 0, D = 1? Z = (0 1 + 0)1 = (1 1 + 0)1 = (1 + 0)1 = 1 1 = 0 1 = 0 E1.2 Digital Electronics 1 3.31 23 October 2008 E1.2 Digital Electronics 1 3.32 23 October 2008
A further example Implementing circuits from s We can draw a logic circuit diagram directly from a defining the function of the circuit. E1.2 Digital Electronics 1 3.33 23 October 2008 E1.2 Digital Electronics 1 3.34 23 October 2008 Example Draw the circuit diagram to implement the expression x = (A + B)(B + C) Review question Draw the diagram of a circuit that implements: x = ABC(A+D) using gates having no more than three inputs. E1.2 Digital Electronics 1 3.35 23 October 2008 E1.2 Digital Electronics 1 3.36 23 October 2008