On this page we'll see how logic gates work: the basic functions computers use to carry out operations, and with which we can build our own electronic circuits.
Under each symbol you will find its truth table, which tells us how the gate’s output behaves depending on the various input signals.
Try it yourself by clicking on gates A – B and check the output of gate Q to see how it really behaves.

Once you understand how they work, you can build your own schematic by connecting them and testing them on this page.

How Logic Gates Work 💡

AND

Simbolo Porta AND
Q

Truth Table

TObQ
000
010
100
111
The AND function needs all inputs to be active to produce an output.

OR

Simbolo Porta OR
Q

Truth Table

TObQ
000
011
101
111
The OR function needs any one input to be active to give an output.

NOT (Inverter)

Simbolo Porta NOT
Q

Truth Table

TOQ
01
10
The NOT function inverts the input signal.

NAND

Simbolo Porta NAND
Q

Truth Table

TObQ
001
011
101
110
The NAND function is a negated AND (NOT+AND). It will always be active until all the inputs are high.

NOR

Simbolo Porta NOR
Q

Truth Table

TObQ
001
010
100
110
The NOR (NOT+OR) function stays active as long as all inputs are low.

XOR

Simbolo Porta XOR
Q

Truth Table

TObQ
000
011
101
110
The XOR function is activated if only one of the inputs is high.

XNOR

Simbolo Porta XNOR
Q

Truth Table

TObQ
001
010
100
111
The XNOR (NOT+XOR) function switches off if only one of the inputs is high.

If you find gates on integrated circuits marked as Q̄ (note the bar above), it means the output is negated, i.e. it is inverted compared with how it would normally behave. In electronic schematics you may find these signals to indicate that a signal is negated or active low. Take an EPROM as an example: its Chip Enable pin (CE), which enables the memory, would by default be activated when the signal is high, i.e. 1 (5V in the case of a TTL signal). If instead the symbol has a bar above it, or the pin name is written as !CE or ~CE, it means that to activate that signal we have to give it an inverted signal, so the chip will be enabled when we supply a low signal, GND (0V).
If we look at the symbols of the various logic gates, we can see that some have a small circle on the output: this indicates that the output works the other way round, i.e. it is negated, so if according to the symbol the output should be 0, it will be driven to 1 and vice versa, exactly as if a NOT gate were connected after the output.

All these logic gates can be cascaded to form a circuit able to count or store data (with the help of a flip-flop).