Truth Table:
|
||||||||||||||||
| Click on the A or B labels to change the input values. |
Some words on OR gates
Remember that an OR gate's output (labeled C) is set to 1 if EITHER ONE OF inputs (labeled A and B) are set to 1. That's why we call it an OR gate.
The truth table tells us which values we expect on the output of the OR gate for any combination of values found on the inputs A and B.
For example, if A=1 and B=0, C will be 1. If A = 0 and B = 0, C will be 0.
Note: an OR gate will only produce a zero on the output of both inputs are 0. In all other case,
it will produce a 1. We generally hold a 0 to represent "false" and 1 to represent "false".
Exercise 1
Clicking on the gate labels A and B (in the diagram above) switches their values. Take a piece of paper and make a three column
table. The first column represents input A. The second input B. The third column represents input C.
Try all possible values of input A and B by switching their values on the logic gate above (click their labels: A and B). Write the values of A and B down in the table, in the same row. Record the resulting value of the OR gate's output C in the third column.
Your table should match the one listed above.
Excercise 2
Logic gates implement what we call "Boolean logic". The OR operation is part of that logic.
In Boolean logic, an OR operation combines two statement into one. The resulting statement is true when
either of the combined statements are true, and false only when both statements are false.
For example, let's agree that we say we have precipitation when "it snows" OR when "it rains". The OR in this statement thus means we have precipitation when it either snows OR rains. When it snows nor rains, we do not have precipitation (I know that in reality there are probably other forms of precipitation, but pretend for a moment that rain or snow are the only ones we know). So again, to be able to say we did not have precipitation it must both not rain and not snow. Snow or rain is sufficient on its own.
Try the following exercise. Look at the logic gate above. Pretend input A's values indicate
whether it snows. When A is 1 it snows, or in other words, it is true that it snows. When input A's value is 0 it does not snow, or it is false to say it snows.
Similary, the value of input B indicates whether it rains or not. When input B is 1, it rains.
When it is 0 it does not rain.
Output C then tells us whether we have precipitation. When its value is 1, we have precipitation.
When it is 0 we do not.
List all possible combinations of values of A (0 or 1) and B (0 or 1) and write down for which combination you can conclude we have precipitation.
Exercise 3
Let's try something different (and more complicated). Computer programs often have to make decisions based on the values of variables. We have two variables, x and y, which can have any value between 0 and 65536. The program is calculating values for a third variable z which can also range from 0 to 65536. z is defined as z = 1/(x*y).
When either x or y is zero, the value of z would exceed its range, so when those values of x and y occur we do not want to calculate z. It would lead to an error.
This is where Boolean logic comes in. Let's say you have three statements: A, B and C, and C = A OR B.
When C is true we calculate z=1/(x*y), when C isn't true, we don't. As an exercise define statement A and B so that z will not exceed its range of allowable values.