2.1.12 Construct truth tables using the above operators.
2.1.13 Construct a logic diagram using AND, OR, NOT, NAND, NOR and XOR gates.
2.1.11 Define the Boolean operators: AND, OR, NOT, NAND, NOR and XOR.
A device that performs a basic operation on electrical signals
Gates combined to perform more complicated tasks
Uses Boolean algebra, a mathematical notation for expressing two-valued logic
A graphical representation of a circuit
Each gate has its own symbol
A table showing all possible input values and the associated output values
A NOT gate accepts one input signal (0 or 1) and returns the complementary (opposite) signal as output
The example code reverses the value of a using the (!) NOT operator
What is the output of the code segment?
boolean a = true;
boolean x = !a;
System.out.println(x);
An AND gate accepts two input signals
If both are 1, the output is 1; otherwise,
the output is 0
The example code evaluates values of a and b using the AND (&&) operator.
What is the output of the code segment?
boolean a = true;
boolean b = false;
boolean x = a && b;
System.out.println(x);
An OR gate accepts two input signals
If both are 0, the output is 0; otherwise,
the output is 1
The example code evaluates values of a and b using the OR (||) operator.
What is the output of the code segment?
boolean a = true;
boolean b = false;
boolean x = a || b;
System.out.println(x);
An XOR gate accepts two input signals
If both are the same, the output is 0; otherwise, the output is 1
The example code evaluates values of a and b using the XOR (^) operator.
What is the output of the code segment?
boolean a = true;
boolean b = false;
boolean x = a ^ b;
System.out.println(x);
The NAND (“NOT of AND”) gate accepts two input signals
If both are 1, the output is 0; otherwise,
the output is 1
The example code evaluates values of a and b using the AND !(a && b) operator.
What is the output of the code segment?
boolean a = true;
boolean b = false;
boolean x = !(a && b);
System.out.println(x);
The NOR (“NOT of OR”) gate accepts two inputs
If both are 0, the output is 1; otherwise,
the output is 0
The example code evaluates values of a and b using the AND !(a || B) operator.
What is the output of the code segment?
boolean a = true;
boolean b = false;
boolean x = !(a || b);
System.out.println(x);
Some gates can be generalized to accept three or more input values
A three-input AND gate, for example, produces an output of 1 only if all input values are 1
NOT - Inverts its single input
AND - Produces 1 if all input values are 1
OR - Produces 0 if all input values are 0
XOR - Produces 0 if both input values are the same
NAND - Produces 0 if all input values are 1
NOR - Produces 1 if all input values are 0
int X = !(A && B) && (B || C) && !C;
int X = (A || B) || (!B ^ C);
int X = !A ^ !(B && C);