## Basic logic gates

A logic gate is a physical device implementing a Boolean function. Logics gates instant decisions depending on the inputs. There are three types of logics AND, OR & NOT and can be expressed in Algebraic form

Now, most of the Logic gates are implemented using MOSFETs (metal–oxide–semiconductor field-effect transistors). But can also be constructed using vacuum tubes, electromagnetic relays (relay logic), fluidic logic, pneumatic logic, optics, molecules, or even mechanical elements.

## AND Logic Gate

- AND logic gate is similar to an arithmetic multiplication operation, It performs the following operations
- Produces a logic HIGH output when both the inputs are HIGH
- Produces a logic LOW output when any one input or both the input are LOW

### Truth Table

X | Y | X AND Y |

0 | 0 | 0 |

0 | 1 | 0 |

1 | 0 | 0 |

1 | 1 | 1 |

### Logic diagram

## OR Logic Gate

- OR gate acts as a selector and it always selects the highest possible output from input
- Produces an logic high output when any one input is high
- Produces an logic low output when both the inputs are low

### Truth Table

X | Y | X OR Y |

0 | 0 | 0 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 1 |

### Logic diagram

## NOT Logic Gate

- Produces a complement output for the given input
- produces a 0 when input is 1 and produces an output 1 when input is 0

### Truth Table

X | NOT A |

0 | 1 |

1 | 0 |

### Logic diagram

## NOR Logic Gate

- NOR is a universal gate
- Produces an logic HIGH output when both inputs are LOW
- Produces an logic LOW output when any one input is HIGH

### Truth table and logic diagram

## NAND Logic Gate

- NAND is a universal gate
- Produces an logic HIGH output when any one input is LOW
- Produces an logic LOW output when both the inputs are at logic HIGH

## XOR Logic Gate

The output is HIGH if either input X or input Y is HIGH exclusively LOW when both are the same.

### TRUTH TABLE

Input 1 | Input 2 | Output |
---|---|---|

X | Y | Z |

0 | 0 | 0 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 0 |

### Logic diagram

## XNOR Logic Gate

- If both input X and Y are same then the output is high
- LOW when both are different

### Truth Table

X | Y | 𝒐𝒖𝒕 = 𝑥 ⨀ 𝑦 |

0 | 0 | 1 |

0 | 1 | 0 |

1 | 0 | 0 |

1 | 1 | 1 |