In this post we will look few basic concepts of logic gates. Before going into it, first we should know what is mean by Binary Logic i.e zero '0' logic and logic '1' .

###

As we know that computer only understand zero's and one's. What actually mean by this? Here zero or one are the representation of the 'low level voltage' and 'high level voltage' . Logic 1 is the high level voltage i.e 3-5v and Logic 0 is the low level voltage i.e 0v in terms of microcontroller (TTL logic). In CMOS logic representation of 'logic1' is around 9v and 'logic0' is 0v.

So, when we say 0 or 1 it purely means that low voltage and high voltage respectively.

###

Now let us look at few important gates and its operation with example. Note that i'm not going to explain all the gates , i just touch few of them whose operation is more frequently used in programming.

Simply remember AND as multiplication (x) 0x0 = 0 , 0x1 = 0, 1x0 = 0, 1x1 = 1.

Example: Perform AND operation on 10101110 , 11100101

10101110

11100101

---------------

10100100

---------------

Simply remember OR operation as addition(+) without carry i.e 0+0=0, 0+1=1, 1+0=1, 1+1=1(without carry)

Example: Perform OR operation on 10101110 , 11100101

10101110

11100101

---------------

11101111

---------------

If input A and B are equal then output is 0 or else 1.

Example: Perform XOR operation on 10101110 , 11100101

10101110

11100101

---------------

01001011

---------------

I have just explained important gates above with its example. If you want to know more gates you can just google it.

###
**BINARY LOGIC:**

As we know that computer only understand zero's and one's. What actually mean by this? Here zero or one are the representation of the 'low level voltage' and 'high level voltage' . Logic 1 is the high level voltage i.e 3-5v and Logic 0 is the low level voltage i.e 0v in terms of microcontroller (TTL logic). In CMOS logic representation of 'logic1' is around 9v and 'logic0' is 0v.So, when we say 0 or 1 it purely means that low voltage and high voltage respectively.

- When we say that register X stored with 01111000 , it means each bit represents each logic level i.e when 0 means 0v is stored in it and 1 means 5v stored in it.
- When we say that register X is stored with 55H (hexadecimal) value, then it simply means register is stored with 01010101 (55h after conversion to binary). Registers dont know which value have been stored but they only concern whether it is 0v or 5v.

Note: Registers are the storage elements whose storage capacity is depended on the number of bits(just say boxes) it have. For example if its an eight bit register then it can store upto 8 boxes i.e each box can have value 1 or 0 i.e high or low voltage level.Maximum value it can store is all 1's i.e 11111111 i.e decimal 255.

###
**LOGIC GATES:**

Now let us look at few important gates and its operation with example. Note that i'm not going to explain all the gates , i just touch few of them whose operation is more frequently used in programming.

**AND GATE:**__Any of of the input is zero then the output will be zero. Look at the symbol and truth table below__

Simply remember AND as multiplication (x) 0x0 = 0 , 0x1 = 0, 1x0 = 0, 1x1 = 1.

Example: Perform AND operation on 10101110 , 11100101

10101110

11100101

---------------

10100100

---------------

__OR GATE:__**If any one of the input is 1 then the output will be 1.**

Simply remember OR operation as addition(+) without carry i.e 0+0=0, 0+1=1, 1+0=1, 1+1=1(without carry)

Example: Perform OR operation on 10101110 , 11100101

10101110

11100101

---------------

11101111

---------------

__XOR GATE:__**When both the inputs are equal then output will be 0 , if both the inputs are not equal then output will be 1.**

If input A and B are equal then output is 0 or else 1.

Example: Perform XOR operation on 10101110 , 11100101

10101110

11100101

---------------

01001011

---------------

**AUTHOR: YOUSTRON SIC**
## 5 comments:

thankxx

welcome :-)

How many gates are there?. Do we use only these three gates or all of them we need to know?

If u red my post carefully you would have understood it

"Note that i'm not going to explain all the gates , i just touch few of them whose operation is more frequently used in programming. "

Binary logical operators are similar to bitwise operators in C programming. C language support AND, OR, XOR and NOT

## Post a Comment