ece124: add gates
This commit is contained in:
parent
b84c76c1b4
commit
78d9667aca
@ -4,6 +4,44 @@
|
||||
|
||||
Please see [ECE 150: C++#Non-decimal numbers](/1a/ece150/#non-decimal numbers) for more information.
|
||||
|
||||
## Logic gates
|
||||
## Binary logic
|
||||
|
||||
!!! definition
|
||||
A **binary logic variable** is a variable that has exactly two states:
|
||||
|
||||
- 0, or false (switch open)
|
||||
- 1, or true (switch closed)
|
||||
|
||||
**Binary logic functions** are any function that satisfies the following type signature:
|
||||
|
||||
```python
|
||||
BoolFunc = Callable[[bool | BoolFunc, ...], bool]
|
||||
```
|
||||
|
||||
In other words:
|
||||
|
||||
- it must accept a number of booleans and/or other logic functions, and
|
||||
- it must return exactly one boolean.
|
||||
|
||||
These can be expressed via truth table inputs/outputs, algebraically, or via a logical circuit schematic.
|
||||
|
||||
### Logical operators
|
||||
|
||||
Operator precedence is () > NOT > AND > OR.
|
||||
|
||||
The **AND** operator returns true if and only if **all** arguments are true.
|
||||
|
||||
$$A\cdot B \text{ or }AB$$
|
||||
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/b/b9/AND_ANSI_Labelled.svg" width=200>(Source: Wikimedia Commons)
|
||||
|
||||
The **OR** operator returns true if and only if **at least one** argument is true.
|
||||
|
||||
$$A+B$$
|
||||
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/1/16/OR_ANSI_Labelled.svg" align="middle" width=200>(Source: Wikimedia Commons)</img>
|
||||
|
||||
The **NOT** operator returns the opposite of its singular input.
|
||||
|
||||
$$\overline A \text{ or } A'$$
|
||||
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/6/60/NOT_ANSI_Labelled.svg" width=200>(Source: Wikimedia Commons)</img>
|
||||
|
Loading…
Reference in New Issue
Block a user