Works on this device
Logic Gate Calculator
Work with logic gates: see the truth table of one gate, work out a circuit typed one gate per row, build the gates for an expression with AND, OR and NOT or with NAND or NOR gates only, or build a circuit from a truth table.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Calculate.
Your result
How it was worked out
How to use this calculator
- Choose what you want: one gate, a circuit of gates, gates for an expression, or a circuit from a truth table.
- For a circuit, type one gate on each row: a name for its output, the gate, and its inputs, such as
S, XOR,P, Cin. A name that is not the output of a gate is an input of the circuit. You can also paste a list such asS = XOR(P, Cin). - For an expression, type it as in the Boolean Logic Calculator, such as
AB + A'C, and choose the gates to use. - Choose Calculate. You get the truth table, the expression of each output, and the gates in rows.
The gates
- NAND only: NOT x = NAND(x, x); AND is a NAND followed by such a NOT; OR is a NAND of the inverted inputs; XOR takes 4 NAND gates.
- NOR only: NOT x = NOR(x, x); OR is a NOR followed by such a NOT; AND is a NOR of the inverted inputs; XNOR takes 4 NOR gates and XOR one more.
- Gate inputs (the number of wires into gates) is the usual measure of the cost of a circuit. Levels is the most gates a signal passes through.
| Gate | Output is 1 when | Expression (two inputs) |
|---|---|---|
| AND | all inputs are 1 | A·B |
| OR | at least one input is 1 | A + B |
| NOT | the input is 0 | A' |
| NAND | at least one input is 0 | (A·B)' |
| NOR | all inputs are 0 | (A + B)' |
| XOR | an odd number of inputs are 1 | A ⊕ B |
| XNOR | an even number of inputs are 1 | (A ⊕ B)' |
| Buffer (YES) | the input is 1 | A |
Worked examples
- The full adder in the starting rows: P = XOR(A, B), S = XOR(P, Cin), Q = AND(A, B), R = AND(P, Cin), Cout = OR(Q, R). The page finds S = A ⊕ B ⊕ Cin and Cout = AB + (A ⊕ B)·Cin. With A = 1, B = 1, Cin = 0 it gives S = 0 and Cout = 1.
- AB + A'C with NAND gates only: G1 = NAND(A, B), G2 = NAND(A, A) (this is NOT A), G3 = NAND(G2, C), Y = NAND(G1, G3). That is 4 NAND gates and 8 gate inputs.
- The output column 0001 0111 (1 when at least two of A, B, C are 1) gives the minimal form AB + AC + BC: three AND gates and one OR gate, or four NAND gates.
Limits you should know
- A circuit has at most 30 gates and 8 inputs, and no feedback (no gate output may come back to its own inputs). Flip-flops and timing are not worked out.
- Gates for an expression follow the expression as written; the page does not shorten it first. For the shortest form use the Boolean Expression Simplifier, or build from a truth table here.
- The circuit is listed as gates in rows. The page does not draw a diagram.