Logic Gates

Alyona Avagyan - Sep 22 - - Dev Community

Have you ever wondered how your devices work? What’s going on inside them? To run a simple app, your devices, whether that be a laptop, a smartphone or smth else, there happens to be a world of incredibly speedy binary decisions. These decisions are made by fundamental components called logic gates. In this post we will discuss the types of logic gates and understand how they perform addition and subtraction through circuits called full adders, half adders, full subtractors, and also half subtractors.

To begin with, in our computers, every arithmetic operation is broken down into basic logic operations. The digital circuit responsible for these operations is the Arithmetic Logic Unit which represents building blocks of the Central Processing Unit (CPU) of a computer. Thus, logic gates are the building blocks of digital circuits that allow our computers to do everything from basic operations to complex data processing.

Now let’s go further into the types of logic gates. They can be classified into the following types: Basic logic gates (AND, OR, NOT); Universal logic gates (NOR, NAND); Derived logic gates (XOR, XNOR).

  1. The AND gate takes two binary inputs (0 and 1), and returns 1 only if both inputs are 1.
  2. The OR gate also takes two inputs and gives an output 0 only if both inputs are 0.
  3. The NOT gate is a simple negation of the two inputs. NOT 1 is 0, and NOT 0 is 1.
  4. The NOR gate is the inverse of the OR gate. It returns 1 if both inputs are 0.
  5. The NAND gate is the inverse of the AND gate. It returns 0 if both inputs are 1.
  6. The XOR gate (also known as Exclusive OR) returns 0 if both inputs are the same.
  7. The XNOR gate (also known as Exclusive NOR) returns 0 if the outputs are different.

These are all the rules to remember for the types of logic gates. However, they are not just for basic comparisons, but also for arithmetic operations called addition and subtraction.

For addition and subtraction, as mentioned above, we have:
1. Half Adder, which is a simple circuit for adding two binary numbers and producing a sum and a carry. So, it has two inputs (A and B) and two outputs (Sum and Carry). It also uses logic gates, such as the XOR gate (for the sum) and the AND gate (for the carry).
2. Full Adder, which extends the half adder by using carry inputs from the previous calculations. Thus, it has three inputs (A, B, and Carry in) and two outputs (Sum and Carry out). The logic gates used by the full adder are two XOR gates, two AND gates, and an OR gate.
3. Half Subtractor, responsible for an operation of subtracting one binary number from another and for producing a difference and a borrow. It also works with two inputs (A and B) and two outputs (Difference and Borrow). Half subtractor uses two logic gates, which are the XOR gate (for the difference) and the NAND gate (for the borrow).
4. Full Subtractor, which handles the two binary numbers and borrow input from the previous calculations. Accordingly, its three inputs are the numbers (A, B, and Borrow in) and the two outputs are the Difference and the Borrow out. Full subtractor uses XOR, AND, and OR gates.

To sum up, these are the basic circuits for all the devices we use every day. Without them, none of our technologies would work. Furthermore, by learning these fundamentals we get the understanding of how our computers think, make some decisions, and process information.

I hope this post will help you to better understand the world of computers, the world of binary numbers, operations with them, as well as the logic gates and circuits. If you found this post useful or helpful, feel free to leave a comment below or ask any question at any time. Thank you for reading !!!

.
Terabox Video Player