2022-06-04 16:00:04 +01:00
---
2022-08-20 12:30:04 +01:00
categories:
2022-08-21 11:00:04 +01:00
- Computer Architecture
2022-06-04 16:00:04 +01:00
- Electronics
- Hardware
2022-08-20 15:30:04 +01:00
tags: [logic-gates, binary]
2022-06-04 16:00:04 +01:00
---
# NAND gate
A NAND gate is a logic gate that inverts the truth-conditions for `AND` .
2022-09-07 20:00:05 +01:00
Diagram representing NAND gate:
2022-06-04 16:00:04 +01:00
2022-09-07 20:00:05 +01:00
< img src = "/home/thomas/repos/computer_science/img/NAND.png" width = "180" / >
2022-06-04 16:00:04 +01:00
The diagram below shows how the circuit models the truth conditions for `NAND`
2022-09-07 20:00:05 +01:00
< img src = "/home/thomas/repos/computer_science/img/NAND.gif" width = "400" / >
2022-09-07 21:00:04 +01:00
- When both switches are off (corresponding to `false` `false` ) the output is on (the bulb lights up).
- If either one of the switches are on, the output remains on (corresponding to `true` `false` or `false` `true` )
- It is only when both switches are on, that the output is off (corresponding to `true` `true` )
2022-06-04 16:00:04 +01:00
2022-06-05 09:30:04 +01:00
This is the exact opposite to the truth-conditions for AND.
2022-06-04 16:00:04 +01:00
2022-06-05 09:30:04 +01:00
## Transliterating the logic truth-table to the switch behaviour
2022-06-04 16:00:04 +01:00
2022-09-07 20:00:05 +01:00
We can now present a truth table for NAND along side that for AND:
2022-06-04 16:00:04 +01:00
```
A B Output
_ _ _____
2022-09-07 20:00:05 +01:00
f f t
t f t
f t t
t t f
2022-06-04 16:00:04 +01:00
A B Output
_ _ _____
t t t
t f f
f t f
f f f
```
2022-09-07 20:00:05 +01:00
2022-06-04 16:00:04 +01:00
We can see that it inverts the value of AND.
## Significance of the NAND gate: functional completeness
2022-06-05 10:30:04 +01:00
2022-06-04 16:00:04 +01:00
> **Equipped with just a NAND we can represent every other possible logical condition within a circuit.**
2022-09-07 20:00:05 +01:00
In practice, it is more efficient to use specific dedicated gates (i.e OR, AND, NOT etc) for the other Boolean connectives but in principle the same output can be achieved through NANDs alone.
2022-06-04 16:00:04 +01:00
When we add more NAND gates and combine them with each other in different ways we can create more complex output sequences and these too will have corresponding truth tables.