SkillGridLearn computer science by doing

Gates: AND, OR and NOT as real hardware

A gate is not a symbol on paper — it is a few transistors wired so that the output voltage answers a yes-or-no question.

13 min · 42 XP

In the logic track AND, OR and NOT were rules for combining true and false. In hardware each of them is a small component with input wires and one output wire, and the rule is enforced by physics: give it certain voltages and it produces a certain voltage. Feed a gate with two wires carrying 0 and 1 and read the third wire with a voltmeter, and you will see the truth table happen.

The part that does the switching is a transistor. Think of a light switch, except that instead of your finger it is a third wire that flips it. Put voltage on that control wire and current can flow between the other two; take the voltage away and it cannot. One transistor is one switch. A gate like AND is built from a few of them arranged so that the output only goes high when both inputs are high.

A   B  |  A AND B     A   B  |  A OR B     A  |  NOT A
0   0  |     0        0   0  |     0       0  |    1
0   1  |     0        0   1  |     1       1  |    0
1   0  |     0        1   0  |     1
1   1  |     1        1   1  |     1The three truth tables, side by side

A truth table is the complete description of a gate. It lists every combination of inputs and the output for each, so once you have the table you know everything the circuit does — you do not need to know which transistors are inside or how they are arranged. Two different circuits with the same truth table are interchangeable.

Input AAND gateInput BLampboth inputs are 1111, the lamp lights upnow B drops to 000, one zero is enough

Practice

  1. With A = 1 and B = 0, what is (A OR B) AND B?

    Hints
    • Work out the brackets first, exactly like arithmetic.
    • OR needs only one true side; AND then needs both its sides true.

    14 XP

  2. Match each circuit with the behaviour that comes out of it.

    Hints
    • Each row is a different circuit, not a different way of writing the same one.
    • A series chain has a gap as soon as one switch opens; a parallel pair still has a way through.

    13 XP

  3. Order these steps to go from a question about true and false down to a working gate.

    Hints
    • Start with the physical part that does the switching, not with the wire.
    • A transistor is a switch with no moving parts, and that is exactly what makes it reliable.

    13 XP