(…)
T. Spruance
Boolean logic, developed by George
Boole (1815-1864), is often used to refine the determination of system
status or to set or clear specific bits. Boolean logic is simply a way
of comparing individual bits. It uses what are called operators to determine how the bits are
compared. They simulate the gates
that you will see in the hardware section you will read shortly.
Think of operators as boxes with multiple inputs and one output. Feed
in various combinations of bit values, and the output will be high or
low depending on the type of operation. The examples show 2 inputs,
although gates can have more. Also, gates are often combined to form
more complex logic. A modern microprocessor contains huge numbers of
them with many inputs and many varying combinations. Please note that
the terms on, high and 1
will be considered the same logical state, and off, low and
0 will be considered the same logical
state in the discussions that follow.
The operators used most often are AND
and OR. The AND operation says if and only if all inputs are on, the output will be on. The
output will be off if any of the inputs are off. The OR operation says if any input is on, the output will be on. It’s
easy to see all of the combinations by using what are called truth tables, illustrated below. At the bottom
of each table is shown the schematic symbol found in circuit diagrams.
|
|
There are two operations that have the same logic as above, but with
an inverted output. The NAND operation
says if and only if all inputs are on, the output will be off. The output will be on if any of
the inputs are off. The NOR
operation says if any input is on, the output will be off. Notice the bubble on the output of the
schematic symbol used to indicate an inversion.
|
NOR (any high = low, else high) | ||
Input 1 | Input 2 | Output |
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 0 |
There is a variation on the OR logic called Exclusive
OR or XOR. Exclusive OR says the output
will be on if the inputs are different.
Another one, the inverter or NOT operation, says that the output will be
opposite in state to the input. It obviously has only one input and one
output. Note that it will change an AND to a NAND, an OR to a NOR and an
XOR to a NXOR if connected to their outputs. It simply changes 1s to 0s
and 0s to 1s.
|
|
One other basic digital device is on the board. It actually performs
no logic. It looks like an inverter without the bubble, and is called a
buffer. It’s a triangle with a single input and output. It is not used
for logic, but to increase the output drive capability of a line, or to
lighten the load seen by circuits outside of ours. This is sometimes
called repowering. Some buffers have a third line entering the side of
the triangle. When it is not activated, the output of the buffer is
removed from the circuit to keep it from interfering with other devices.
The 74LS244 is an example:
In C, symbols are substituted for the full description or
abbreviation of a Boolean operation. They are as follows for the
operations covered:
Logical Operation | Abbreviation | Symbol |
And | AND | & |
Or | OR | | |
Exclusive OR | XOR | ^ |
Inversion | NOT | ~ |