# Logic Gates, Level I

Logic gates, in an abstract sense, perform a Boolean function on one or more binary inputs. They take in binary data, decide if that data equals a 0 or 1, and then outputs that binary result.

In a physical sense, they can be transistors, diodes, or any number of physical objects with an “on” and “off” state. The “on” state is the binary 1, and an “off” state is the binary 0.

So let us start with a simple logic gate as an example. We will use the “AND” logic gate, which is a common and foundational piece of logic in general.

Assuming we have two binary bits of data coming into the “AND” gate, the gate will output a 1 if both inputs are 1 as well; otherwise, it will output a 0. Here is the truth table that represents these possible results:

Input A = 0 | Input B = 0 | Output Q = 0
Input A = 0 | Input B = 1 | Output Q = 0
Input A = 1 | Input B = 0 | Output Q = 0
Input A = 1 | Input B = 1 | Output Q = 1

Only in the final row, where both input 1 and input 2 are 1, does the “AND” gate output a 1 as well. Remember this.

Now, we can check if one or the other input is a 1 using the “OR” gate. Only if both inputs are 0 does the output equal 0. Here is the truth table for these results:

Input A = 0 | Input B = 0 | Output Q = 0
Input A = 0 | Input B = 1 | Output Q = 1
Input A = 1 | Input B = 0 | Output Q = 1
Input A = 1 | Input B = 1 | Output Q = 1

Notice the contrast with the “AND” table. Now, even if one of the inputs is a 0, the result can still be 1 if the other input is a 1 as well.