Logic Gate
Vahagn Ghantarchyan
Posted on September 21, 2024
- Logic gates (AND, OR, XOR, NAND, NOR, XNOR)
Every digital system is based on logic gates. By using Logical gates computers can make decisions based on inputs. Logical gate takes input or multiple inputs and produce an output and since we are talking about computers the possible inputs can only be 1 and 0 and also the output is also either 1 or 0. At first, let's understand what 1 or 0 means in computers. A computer main memory is made of billions of transistors that switch between either high and low voltage levels. The value 0 has a weak or non-existent electricity flow and the value 1 has a strong electricity flow and for computer 1 is true or "on" and 0 is false or "off". Today we are going to learn about key logic gates which are AND, OR, XOR, NAND, NOR, XNOR.
Lets start from a AND gate(also called conjuction in Boolean algebra).
Returns true (1) if both conditions are true(1), otherwise the output is false(0)
We see that there is only one case when output is true which occurs when both inputs are true. In other words, the output is 1 only when both inputs are 1
The OR gate(also called disjunction in Boolean algebra)
Returns true(1) if either one of the conditions are true. The output only be false(0) if both inputs are false(0)
We see that for the output to be 1(true), at least one input must be 1(true).
The XOR gate
Returns false if both inputs are "false" or if both inputs are true.
we see that output is 1(true) if the inputs are different but, output is 0(false) if the inputs are the same.
The NOT gate(also called negation in Boolean algebra)
Takes one input and reverses it
we see that if the input is 1(true) then the output is 0(false). If the input is 0(false), then the output is 1(true).
The NAND gate
operates as an AND gate followed by a NOT gate.Imagine if we get an output from AND gate then put result into NOT gate the final output is NAND gate
We see taht output is 0(false) if both inputs are 1(true) otherwise, the output is 1(true).
The NOR gate
operates as an or gate followed by a NOT gate.Imagine if we get an output from OR gate then put result into NOT gate the final output is NOR gate
We see that output is 1(true) if both inputs are 0(false). Otherwise, the output is 0(false).
The XNOR gate
operates as an NOR gate followed by a NOT gate.Imagine if we get an output from NOR gate then put result into NOT gate the final output is XNOR gate
We see that output is 1(true) if the inputs are the same, and output is 0(false) if the inputs are different.
Now that we already know about logic gates let's move on and learn about half adder and full adder.
It is the simplest form of a digital circuit that performs binary addition of two bits.
A Half Adder is used for adding two single-bit binary numbers. It has two inputs A and B and two outputs Sum and Carry. The sum is produced using an XOR gate: S = A ⊕ B and the carry is produced using an AND gate: C = A ∧ B
Truth table of the half adder(S it the sum and C is the Carry)
Half Adder Circuit Example: We want to add two binary digits, A = 1 and B=1
Sum (S): A ⊕ B = 1 ⊕ 1 = 0 (because XOR of 1 and 1 is 0).
Carry (C): A ∧ B = 1 ∧ 1 = 1 (because AND of 1 and 1 is 1).
the result is Sum = 0 and Carry = 1, meaning the binary addition result is 10 (which is 2 in decimal)
A Full Adder is a more advanced version of the half adder. A full adder is a circuit that adds two binary digits (A and B) plus a carry-in from the previous addition. It calculates the Sum using two XOR gates and calculates the Carry-out using two AND gates and an OR gate:
Inputs:
- A (first bit)
- B (second bit)
- Cin (carry-in from a previous addition)
Outputs:
- Sum (the result of adding A, B, and Cin)
- Carry-out (which is the carry to the next higher bit if needed)
The truth table for Full Adder
A Full Adder can be built using two Half Adders circuits and an OR gate
Full Adder Circuit Example: Add A = 1, B = 1, and Cin = 1:
• First XOR (A ⊕ B): 1 ⊕ 1 = 0
• First AND (A ∧ B): 1 ∧ 1 = 1
• Second XOR ((A ⊕ B) ⊕ Cin): 0 ⊕ 1 = 1
• Second AND ((A ⊕ B) ∧ Cin): 0 ∧ 1 = 0
• OR Gate: 1 ∨ 0 = 1
Result: Sum = 1 and Cout = 1, which is 11 in binary or 3 in decimal.
In examining the half adder, we have examined a style of operation for elementary addition. The transition to the full adder provides us with a method of carrying over and handling multiple inputs for additional complexity.
Posted on September 21, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.