DEV Community

Anna Terteryan
Anna Terteryan

Posted on

Logic Gates

Logic gates are the basic building blocks of any digital system. They are electronic circuits that have one or more inputs and only one output. The relationship between the inputs and the outputs is based on certain logic and that is why they are referred to as logic gates. There are AND, OR, XOR, NOT, NAND, NOR and XNOR gates.

Image description

When you go to the inner workings of the computer it deals with binary digits: 0 and 1. So, the inputs and outputs for these logic gates are combinations of zeros and ones. A NOT gate inverts its input. If the input is 1, the output will be 0, and if the input is 0, the output will be 1. It is usually called as negation or inversion. The AND gate takes two inputs and gives one output. It outputs 1 when both of the inputs are 1, but in other cases, the output is 0. The OR gate, on the other hand outputs 1 when at least one of the inputs is 1. When there are two zeros, the output is always 0. The NAND gate flips the results of AND gate (1 to 0 and 0 to 1) and is equal to the AND gate followed by the NOT gate. The same method is used with OR gates with the name of NOR. XOR gate outputs 1 if only one of its inputs is 1. If both of the inputs are 1 or 0, the output is always 0. XOR also has its inverse gate which is called XNOR. This gate works same as NAND and NOR.

Image description

Top comments (0)