on Thursday, 12 September 2013
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.

  • 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.
resistor save value


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.


Any of of the input is zero then the output will be zero. Look at the symbol and truth table below
and gate programming

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

Example: Perform AND operation on 10101110 , 11100101



If any one of the input is 1 then the output will be 1.

or gate programming

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



When both the inputs are equal then output will be 0 , if both the inputs are not equal then output will be 1.

xor gate programing

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

Example: Perform XOR operation on 10101110 , 11100101


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



sajid niaz said...



welcome :-)

Raju said...

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. "

Aman Rustagi said...

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

Post a Comment