Welcome to the Geek Author series on Computer Organization and Design Fundamentals. I’m David Tarnoff, and in this series we are working our way through the topics of Computer Organization, Computer Architecture, Digital Design, and Embedded System Design. If you’re interested in the inner workings of a computer, then you’re in the right place. The only background you’ll need for this series is an understanding of integer math, and if possible, a little experience with a programming language such as Java. And one more thing. Our topics involve a bit of figuring, so it might help to keep a pencil and paper handy.
By themselves, logic gates are not very practical. Their power comes when you combine them to create combinational logic. Combinational logic connects multiple logic gates by connecting the outputs from some of the gates to the inputs of others.
In Episode 4.01 – Intro to Logic Gates, we used a security system as an example of an OR gate application: the alarm goes off if the door opens or the glass breaks or motion is detected. This circuit description is incomplete though; it doesn’t take into account the fact that at some point, people are going to have to use the room for legitimate purposes, which means the door will be opened, and hopefully, there will be a bit of movement inside. To facilitate this, security systems can be disarmed and Armed. We still want to set off the alarm if glass is broken at any time, but if the system isn’t Armed, neither the door sensor nor the motion sensor should trip the alarm. Let’s see if we can create a system description that incorporates these new requirements. We want the alarm to go off if the glass is broken or if the system is Armed and either the door opens or motion is detected. Note that the Door open or motion detected signals are “combined” so to speak with the parenthesis implied by the word either. These parentheses are added to remove any ambiguity in the precedence of the logical operations.
The operation of this circuit can also be represented with a truth table, which we’re going to try to walk through now in order to define the output Alarm. With four inputs, Armed, Door, Motion, and Glass, the truth table has sixteen rows. If Armed is the first column of our truth table, and if the rows of the truth table are identified using ascending patterns of ones and zeros, then Armed equals zero for the top eight rows of the truth table. When the Armed signal equals 0, neither the Door open nor the Motion detected signals affect the output. If glass is broken, however, we want to turn on the alarm. That means that the output, Alarm, follows the value of the Glass broken input for the top eight rows of the truth table. If Glass broken is the rightmost column of the inputs, then its alternates from zero to one as it goes down the rows of the truth table, and Alarm is 0-1-0-1-0-1-0-1 for the top eight rows.
When the system is armed, in other words Armed equals one, any alarm input equal to a one will set off the alarm. In other words, the only way the alarm isn’t activated is if none of the alarm inputs are set to one. This describes an OR gate, and the truth table of an OR gate has a zero for the output in the top row where all inputs equal zero and ones for the output for all the remaining rows. That means that when the system is armed, the Alarm output is 0-1-1-1-1-1-1-1 for the last eight rows of the truth table.
We figured out the pattern of ones and zeros for the output column of this truth table by examining the verbal description of this security system. Alternatively, we could have done this by examining the circuit itself. At this point, a piece of paper and a pencil may come in handy.
In our circuit diagram, all four inputs, Armed, Door, Motion, and Glass, come in from the left side. If we break down the sentence we used to describe the circuit’s operation, “The alarm goes off if glass breaks or if the system is armed and either the door opens or motion is detected,” we see that the Glass sensor is OR-ed with the result of the operation, “the system is armed and either the door opens or motion is detected.” This expression is further broken down by AND-ing the OR of Door open and Motion detected. This gives us our order of operations.
First, we OR Door open and Motion detected. The output of this OR is then AND-ed with Armed. The output of this AND is then OR-ed with the Glass sensor signal. We can use this order of operations as a second method to create the truth table. Note also that we see from this circuit that the longest path from input to output is three gates. In other words, any change on Door open or Motion detected must pass through the OR gate, the AND gate with Armed, and the OR gate with Glass sensor signal before the effect is seen on the output.
Let’s see how we can use this circuit description to create the truth table. What we are going to do is work our way from the inputs on the left side toward the output on the right side by creating a column for each gate’s output along the way.
Begin by creating the truth table with the inputs labeled Armed, Door, Motion, and Glass. There should be sixteen rows starting at the top with 0-0-0-0 and ending at the bottom with 1-1-1-1. Be sure to leave some room on the right side of the truth table for the columns we’re going to create. Now look at the circuit. What’s the first gate that the signals pass through going from left to right? It’s the OR gate that ORs Door open and Motion detected, so let’s make a column representing the output of this OR gate. The output of an OR gate is one if any of its inputs are one. Going down this column then, we see that the gate outputs a 1 if Door is 1 or if Motion is 1. The only rows where both Door and Motion are zero are the first and second rows and the ninth and tenth rows. This gives us a pattern of 0-0-1-1-1-1-1-1-0-0-1-1-1-1-1-1 down the column for the OR gate.
Continuing to go left to right, the next gate that the signals pass through, in other words, the next gate for which we have all the inputs defined in our truth table, is the AND gate that combines the column Armed with the column representing the output of the OR gate. The only time an AND gate outputs a one is if all its inputs equal one. That means that for the first eight rows where Armed equals zero, it clears the output of the OR gate to zero. For the last eight rows where Armed equals one, it simply copies the output of the OR gate to the output of the AND gate. This gives us a pattern where the top ten rows are equal to zero and the bottom six rows are equal to one for the output of this AND gate.
Now that we have a column in the truth table that represents the output of the AND gate and a column that represents the Glass sensor signal, we can create the last column of the truth table representing the output of the OR gate that ORs Glass with the output of the AND gate.
Since the OR gate passes any ones that it receives at its inputs to the output, then whenever Glass equals one, the output equals one, and whenever the AND gate output equals one, the output equals one. This means that the output of the circuit for the first eight rows, where the system is disarmed, alternates 0-1-0-1-0-1-0-1, following the Glass break input. Both the Glass signal and the output of the AND are zero on the ninth row, so the circuit output is a zero and the alarm is off. This, by the way, represents the condition where the system is Armed, but no sensors have been tripped. All the remaining rows have the system Armed and at least one of the alarm points has been tripped. This gives us the output for the last eight rows of the truth table as 0-1-1-1-1-1-1-1.
In our next episode, we’re going to look at the simplest of combinational logic circuits – the circuits made by inverting the output of ANDs, ORs, and exclusive-ORs. Despite their simplicity, these gates are vital. In fact, any truth table can be realized in hardware using a circuit made only from AND gates with inverted outputs or OR gates with inverted outputs. For transcripts, links, or other podcast notes, please visit us at intermation.com where you will also find links to our Instagram, Twitter, Facebook, and Pinterest pages. Until the next episode remember that while the scope of what makes a computer is immense, it’s all just ones and zeros.