Explore complex logic gates that allow for sophisticated decision-making in hardware.
Imagine a smart lock that only opens if exactly one of two keys is turned—not both, and not neither. How does a computer handle these 'strictly one' decisions without getting confused?
In our previous lesson, we met the 'Big Three': AND, OR, and NOT. But what happens when we combine them? A NAND gate is simply an AND gate followed by a NOT gate. Its name stands for 'NOT-AND.' Similarly, a NOR gate is an OR gate followed by a NOT gate. In circuit diagrams, these are represented by adding a small circle (a 'bubble') to the output of the standard gate symbol. This bubble signifies inversion. If the standard AND gate would output a , the NAND gate flips it to a . This simple flip creates entirely new logic patterns for hardware designers.
Let's look at how the NAND gate behaves compared to an AND gate for inputs and : 1. If : AND is , so NAND is . 2. If : AND is , so NAND is . 3. If : AND is , so NAND is . 4. If : AND is , so NAND is .
Essentially, NAND is only when both inputs are .
Quick Check
If a NOR gate receives inputs A=0 and B=0, what is the output?
Answer
1
The standard OR gate is inclusive, meaning it outputs if is true, is true, or both are true. However, computers often need to make an 'either-or' choice. This is where the XOR (Exclusive OR) gate comes in. The XOR gate outputs a only if the inputs are different. If both inputs are the same (both or both ), the XOR gate outputs a . This is the logic used in binary addition—when you add in binary, the result in that column is (with a carry to the next), which perfectly matches the XOR behavior.
Imagine a hallway with a light switch at both ends. 1. If both switches are DOWN (), the light is OFF (). 2. If you flip one switch UP (), the light turns ON (). 3. If you walk to the other end and flip that switch UP (), the light turns OFF (). 4. This 'difference-detecting' logic is exactly how an XOR gate operates: Output only when .
Quick Check
Which gate outputs a 0 when both inputs are 1: an OR gate or an XOR gate?
Answer
The XOR gate.
Why do we bother with NAND gates if we already have AND and NOT? In the world of manufacturing, NAND is a Universal Gate. This means that any other logic gate (AND, OR, NOT, XOR) can be built using only NAND gates. For a factory, it is much cheaper and more efficient to mass-produce millions of identical NAND gates and wire them together in different ways than to create many different types of specialized gates. This 'Lego-brick' approach is the foundation of modern microprocessor design.
How can we turn a NAND into a NOT gate? 1. Take a single NAND gate. 2. Connect the same input signal to both input pins of the NAND gate. 3. If , the NAND sees and outputs . 4. If , the NAND sees and outputs . 5. Result: The output is always the opposite of , effectively creating a NOT gate using only NAND hardware!
What does the 'bubble' on the end of a logic gate symbol represent?
If an XOR gate has inputs and , what is the output?
A NAND gate can be used to create the functionality of an OR gate.
Review Tomorrow
In 24 hours, try to sketch the truth table for a NOR gate from memory and compare it to an OR gate.
Practice Activity
Try to draw a diagram showing how you would connect two inputs to a NAND gate to make it act like a NOT gate.