Building blocks of logic
Manas Paul
A logic gate is an elementary building block of a digital circuit. Any arithmetic operation in a computer system can be implemented using basic logical operations. Three of the most common logical operations are NOT, OR and AND. The part of a digital logic circuit which performs one of these operations is called a gate. Signals enter these gates (inputs), and the gate generates new signals (outputs) depending on the signals it receives.
The NOT gate simply inverts the signal. When it receives a low input, the output is high and vice versa. So it is also called an inverter or buffer.
Both the AND gate and the OR gate have two or more inputs and one output. Every gate has a symbol and a corresponding truth table. The truth table at a glance tells us what the output will be for different inputs or combination of inputs. The inputs to the logic gates are in binary form, that is, either a 0 or a 1. (In physical terms, 1 means a square wave of 3 to 5 Volts and 0 means anything less than 2 volts)
So for a NOT gate, if the input is 1, the output is 0 and vice versa. The symbol and truth table for a NOT gate are as follows:
In an OR gate, the output is 1 if any one of the inputs is 1. In an AND gate, the output is 1 if all the inputs are 1. If any one of the inputs is 0, the output will be 0. The symbol and truth table of the two gates are as follows:
OR Gate
The OR gate gets its name from the fact that it behaves after the fashion of the logical inclusive “or”. The output is “true” if either or both of the inputs are “true”. If both inputs are “false”, then the output is “false”.
The combination of an OR gate and a NOT gate will give a NOR gate. Similarly the combination of an AND gate and a NOT gate will yield a NAND gate.
The outputs of the NOR gate and the NAND gate will be the reverse of the OR gate and the AND gate.
An XOR gate implements an exclusive OR, that is, a true output result if one, and only one, of the inputs to the gate is true. If both inputs are false (0/LOW) or both are true, a false output results. XOR represents the inequality function, i.e., the output is true if the inputs are not alike otherwise the output is false. A way to remember XOR is “one or the other but not both”. So the truth table of the XOR gate is:
If there are three inputs, the truth table of an XOR gate will be:
Only when one of the three inputs is 1, is the output 1.
All logical operations are possible with the combination of these basic building blocks.
For example one can think of an XNOR gate that will have the truth table:
Burglar alarms, thermostats in our refrigerators, automatic watering systems, fire alarms – all have logic gates built into them.
A central heating system operates with a NOT gate. When the temperature outside is low, it switches on. Similarly, street lighting system can automatically come on when sunlight fades out.
The switch of your staircase light, which can be switched on either from above or from below, is like an OR gate.
A burglar alarm is activated if the person sensor and the alarm switch are on. So when you go out of the house, switch on the alarm. When the burglar enters, the person sensor is triggered and the alarm rings.
Imagine designing a washing machine so that the water only turns on when the washing is loaded (logic-1), the door is closed (logic-1) but the clothes are not yet wet (logic-0). This can be done by ANDing the first two conditions, and inverting the third. Now, AND these together, and you get a high only when all three conditions are satisfied. The truth table will be as follows:
- Now here is an exercise for you. Using the symbols of AND gate and NOT gate, design a circuit for the washing machine sensor.
- Here is one more exercise. Suppose you want to design an alarm at a traffic signal that starts sounding whenever a pedestrian crosses the road while the green traffic signal is on. What will be the design and truth table for this alarm?
A logic circuit consists of a combination of logic gates. Logic circuits are found in ALUs (Arithmetic and Logic Units) of computers, in computer memories and registers, multiplexers, encoders and decoders.
Logic circuits can consist of as many as 100 million gates. Every digital product including PCs, mobile phones, tablets, calculators and digital watches have logic circuits. In calculators, the operation of addition is equivalent to an OR gate and the operation of multiplication is equivalent to an AND gate.
Our phones have thousands, if not millions of logic gates. Everything from the CPU to the display screen to power management and alarm works on logic gates.
The author is head of Media Science Department, iLEAD, Kolkata. He can be reached at manaspaul@rediffmail.com.