Homework #6 Logic Gates

The Exclusive-Or (XOR) gate, discussed in section 7.4.3 of Gingrich, has a very practical application - a two-way light switch. Before we discuss this, we need to see how the XOR gate can be realized using conventional switches.


When switch A is closed then NOT A is open, when switch B is open then NOT B is closed and vice versa. The truth table for this configuration of switches is the same as the truth table for the XOR gate shown on page 138 of Gingrich. Suppose that a room has two doors, where switch A is next to one door and switch B is next to the other door. Begin with both switches open (A=B=0) and the room light off (Q=0). Someone enters door A and throws the switch (A=1, B=0) and the light goes on (Q=1). If they leave by the same door after turning off the light, the initial conditions will be reproduced. However, if they leave by door B and throw that switch (A=B=1) the light will also go off (Q=0). If after someone leaves by door B, another person enters door A and throws the switch, the result (A=0, B=1) also turns the light on (Q=1). Leaving by either door and throwing the corresponding switch will again turn off the light. On the New Scientist website there is a short but somewhat confusing discussion of the next level of switch, called the three-way switch. In the discussion there, one switch is at the door of a bedroom and two switches are on either side of a bed. If we want any switch to be able to change the state of the room light, and we assume that the light is off when A=B=C=0, generate the truth table for this situation.

To check your answer, you should be able to realize this operation with the following combination of gates where the two switch positions are labeled as 0 and 1. Connect A and B to an XOR gate. Connect the output (Q) of the XOR to an inverter. Connect the output of the inverter (NOT Q) and switch C to an AND gate. Also connect switch C to an inverter to produce NOT C. Connect the output of the inverter (NOT C) and the output of the XOR (Q) to a second AND gate. Finally connect the outputs of the two AND gates to an OR gate. The output of the OR gate should be the state of the room light. You might want to try to generate the Boolean expression for this combination. The Boolean expression for the XOR has two forms. Use equation (7.30) for the combination of the XOR and inverter (NOT Q) connected with C to the first AND gate and use equation (7.29) for the connection of the XOR (Q)and inverted C (NOT C) to the second AND gate.