Autosave: 2022-12-20 08:00:07
This commit is contained in:
parent
347314140f
commit
832f04de97
2 changed files with 55 additions and 44 deletions
|
@ -8,9 +8,12 @@ tags: [logic-gates, binary]
|
||||||
|
|
||||||
# Logic gates
|
# Logic gates
|
||||||
|
|
||||||
> [A logic gate consists in] three connections where there may or may not be some electricity. Two of those connections are places where electricity may be put into the device, and the third connection is a place where electricity may come out of the device. (Scott, 2009 p.21)
|
> [A logic gate consists in] three connections where there may or may not be some electricity. Two of those connections are places where electricity may be put into the device, and the third connection is a place where electricity may come out of the device.
|
||||||
|
|
||||||
|
[J.C. Scott. 2009. **But How Do It Know? The Basics of Computers for Everyone**, 21]
|
||||||
|
|
||||||
|
Logic gates are the basic building blocks of digital computing. **A logic gate is an electrical circuit that has one or more than one input and only one output.** The input controls the output and the logic determining which types of input (on/off) lead to specific outputs (on/off) is identical to the truth-conditions of the [Boolean connectives](/Logic/Truth-functional_connectives.md) specifiable in terms of [truth tables](/Logic/Truth-tables.md).
|
||||||
|
|
||||||
Logic gates are the basic building blocks of digital computing. **A logic gate is an electrical circuit that has one or more than one input and only one output.** The input controls the output and the logic determining which types of input (on/off) lead to specific outputs (on/off) is identical to the truth-conditions of the [Boolean connectives](/Logic/Truth-functional_connectives.md) specifiable in terms of [truth-tables](/Logic/Truth-tables.md).
|
|
||||||
Physically, what 'travels through' the gates is electrical current and what constitutes the 'gate' is a [transistor](/Electronics_and_Hardware/Digital_circuits/Transistors.md) responding to the current. At the next level of abstraction it is bits that go into the gate and bits which come out: binary information that may be either 1 or 0.
|
Physically, what 'travels through' the gates is electrical current and what constitutes the 'gate' is a [transistor](/Electronics_and_Hardware/Digital_circuits/Transistors.md) responding to the current. At the next level of abstraction it is bits that go into the gate and bits which come out: binary information that may be either 1 or 0.
|
||||||
|
|
||||||
## NOT gate
|
## NOT gate
|
||||||
|
@ -23,10 +26,10 @@ Physically, what 'travels through' the gates is electrical current and what cons
|
||||||
|
|
||||||
### Truth conditions
|
### Truth conditions
|
||||||
|
|
||||||
| P | ~ P |
|
| $P$ | $\lnot P$ |
|
||||||
| --- | --- |
|
| --- | --------- |
|
||||||
| T | F |
|
| 1 | 0 |
|
||||||
| F | T |
|
| 0 | 1 |
|
||||||
|
|
||||||
### Interactive circuit
|
### Interactive circuit
|
||||||
|
|
||||||
|
@ -40,12 +43,12 @@ Physically, what 'travels through' the gates is electrical current and what cons
|
||||||
|
|
||||||
### Truth conditions
|
### Truth conditions
|
||||||
|
|
||||||
| P | Q | P & Q |
|
| $P$ | $Q$ | $P \land Q$ |
|
||||||
| --- | --- | ----- |
|
| --- | --- | ----------- |
|
||||||
| T | T | T |
|
| 1 | 1 | 1 |
|
||||||
| T | F | F |
|
| 1 | 0 | 0 |
|
||||||
| F | T | F |
|
| 0 | 0 | 0 |
|
||||||
| F | F | F |
|
| 0 | 0 | 0 |
|
||||||
|
|
||||||
### Interactive circuit
|
### Interactive circuit
|
||||||
|
|
||||||
|
@ -59,12 +62,12 @@ Physically, what 'travels through' the gates is electrical current and what cons
|
||||||
|
|
||||||
### Truth conditions
|
### Truth conditions
|
||||||
|
|
||||||
| P | Q | ~(P & Q) |
|
| $P$ | $Q$ | $\lnot(P \land Q)$ |
|
||||||
| --- | --- | -------- |
|
| --- | --- | ------------------ |
|
||||||
| T | T | F |
|
| 1 | 1 | 0 |
|
||||||
| T | F | F |
|
| 1 | 0 | 0 |
|
||||||
| F | T | F |
|
| 0 | 1 | 0 |
|
||||||
| F | F | T |
|
| 0 | 0 | 1 |
|
||||||
|
|
||||||
### Interactive circuit
|
### Interactive circuit
|
||||||
|
|
||||||
|
@ -80,12 +83,12 @@ NAND is a **universal logic gate**: equipped with just a NAND we can represent e
|
||||||
|
|
||||||
### Truth conditions
|
### Truth conditions
|
||||||
|
|
||||||
| P | Q | P v Q |
|
| $P$ | $Q$ | $P \lor Q$ |
|
||||||
| --- | --- | ----- |
|
| --- | --- | ---------- |
|
||||||
| T | T | T |
|
| 1 | 1 | 1 |
|
||||||
| T | F | T |
|
| 1 | 0 | 1 |
|
||||||
| F | T | T |
|
| 0 | 1 | 1 |
|
||||||
| F | F | F |
|
| 0 | 0 | 0 |
|
||||||
|
|
||||||
### Interactive circuit
|
### Interactive circuit
|
||||||
|
|
||||||
|
@ -99,12 +102,12 @@ NAND is a **universal logic gate**: equipped with just a NAND we can represent e
|
||||||
|
|
||||||
### Truth conditions
|
### Truth conditions
|
||||||
|
|
||||||
| P | Q | ~(P <> Q) |
|
| $P$ | $Q$ | $\lnot(P \Leftrightarrow Q)$ |
|
||||||
| --- | --- | --------- |
|
| --- | --- | ---------------------------- |
|
||||||
| T | T | F |
|
| 1 | 1 | 0 |
|
||||||
| T | F | T |
|
| 1 | 0 | 1 |
|
||||||
| F | T | T |
|
| 0 | 1 | 1 |
|
||||||
| F | F | F |
|
| 0 | 0 | 0 |
|
||||||
|
|
||||||
### Interactive circuit
|
### Interactive circuit
|
||||||
|
|
||||||
|
@ -118,15 +121,11 @@ NAND is a **universal logic gate**: equipped with just a NAND we can represent e
|
||||||
|
|
||||||
### Truth conditions
|
### Truth conditions
|
||||||
|
|
||||||
| P | Q | P v Q |
|
| $P$ | $Q$ | $P \lor Q$ |
|
||||||
| --- | --- | ----- |
|
| --- | --- | ---------- |
|
||||||
| T | T | F |
|
| 1 | 1 | 0 |
|
||||||
| T | F | F |
|
| 1 | 0 | 0 |
|
||||||
| F | T | F |
|
| 0 | 1 | 0 |
|
||||||
| F | F | T |
|
| 0 | 0 | 1 |
|
||||||
|
|
||||||
### Interactive circuit
|
### Interactive circuit
|
||||||
|
|
||||||
## References
|
|
||||||
|
|
||||||
Scott, J. Clark. 2009. _But how do it know?: the basic principles of computers for everyone_. Self-published.
|
|
||||||
|
|
|
@ -9,7 +9,9 @@ tags: [logic, propositional-logic, nand-to-tetris]
|
||||||
|
|
||||||
When we looked at [boolean functions](/Logic/Propositional_logic/Boolean_functions.md) we were working in a particular direction: from a function to a truth table. When we do Boolean function synthesis we work in the opposite direction: from a truth table to a function.
|
When we looked at [boolean functions](/Logic/Propositional_logic/Boolean_functions.md) we were working in a particular direction: from a function to a truth table. When we do Boolean function synthesis we work in the opposite direction: from a truth table to a function.
|
||||||
|
|
||||||
This is an important skill that we will use when constructing [logic circuits](/Electronics_and_Hardware/Digital_circuits/Digital_circuits.md). We will go from truth conditions (i.e. what we want the circuit to do and when we want it to do it) to a function expression which is then reduced to its simplest form and implemented with [logic gates](/Electronics_and_Hardware/Digital_circuits/Logic_gates.md).
|
This is an important skill that we will use when constructing [logic circuits](/Electronics_and_Hardware/Digital_circuits/Digital_circuits.md). We will go from truth conditions (i.e. what we want the circuit to do and when we want it to do it) to a function expression which is then reduced to its simplest form and implemented with [logic gates](/Electronics_and_Hardware/Digital_circuits/Logic_gates.md). Specifically, NAND gates.
|
||||||
|
|
||||||
|
We will show here that a complex logical expression can be reduced to an equivalent expression that uses only the NAND operator.
|
||||||
|
|
||||||
## The process
|
## The process
|
||||||
|
|
||||||
|
@ -81,7 +83,7 @@ The upshot is that we now have a simpler expression that uses only NOT, OR and A
|
||||||
|
|
||||||
But even this is too complex. We could get rid of the OR and just use AND and NOT:
|
But even this is too complex. We could get rid of the OR and just use AND and NOT:
|
||||||
|
|
||||||
We can prove this theorem with the following transformation:
|
We can prove this theorem by showing that an expression with AND, NOT, and OR can be formulated as an equivalent expression using just NOT and AND:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
x \lor y = \lnot(\lnot(x) \land \lnot(y))
|
x \lor y = \lnot(\lnot(x) \land \lnot(y))
|
||||||
|
@ -94,8 +96,18 @@ $$
|
||||||
| 1 | 0 | 1 | 1 |
|
| 1 | 0 | 1 | 1 |
|
||||||
| 1 | 1 | 1 | 1 |
|
| 1 | 1 | 1 | 1 |
|
||||||
|
|
||||||
Finally, we can simplify even further by doing away with AND and NOT and using a single [NAND gate](/Electronics_and_Hardware/Digital_circuits/Logic_gates.md#nand-gate) which embodies the logic of both, being true in all instances where AND would be false:
|
Finally, we can simplify even further by doing away with AND and NOT and using a single [NAND gate](/Electronics_and_Hardware/Digital_circuits/Logic_gates.md#nand-gate) which embodies the logic of both, being true in all instances where AND would be false: $\lnot (x \land y)$.
|
||||||
|
|
||||||
|
Let's prove the theorem that every logical expression can be formulated as a NAND function. To do this we need to show that both NOT and AND can be converted to NAND.
|
||||||
|
|
||||||
|
NOT:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\lnot (x \land y)
|
\lnot(x) = x \lnot\land x
|
||||||
|
$$
|
||||||
|
|
||||||
|
AND:
|
||||||
|
|
||||||
|
$$
|
||||||
|
x \land y = \lnot(x \lnot\land y)
|
||||||
$$
|
$$
|
||||||
|
|
Loading…
Add table
Reference in a new issue