Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
•
248 items
•
Updated
•
1
4-bit incrementer. Adds 1 to input (modulo 16).
incrementer4bit(a3, a2, a1, a0) = (input + 1) mod 16
| Input | Decimal | Output | Decimal |
|---|---|---|---|
| 0000 | 0 | 0001 | 1 |
| 0001 | 1 | 0010 | 2 |
| 0111 | 7 | 1000 | 8 |
| 1111 | 15 | 0000 | 0 |
y0 = NOT(a0)
y1 = a1 XOR a0
y2 = a2 XOR (a1 AND a0)
y3 = a3 XOR (a2 AND a1 AND a0)
Layer 1: Compute NOT(a0), carries (c2, c3), and XOR components for y1 Layer 2: Compute y1, XOR components for y2 and y3 Layer 3: Final AND gates for y2 and y3
| Inputs | 4 |
| Outputs | 4 |
| Neurons | 12 |
| Layers | 3 |
| Parameters | 52 |
| Magnitude | 41 |
from safetensors.torch import load_file
# See model.py for full implementation
# 7 + 1 = 8
# incrementer4(0, 1, 1, 1) = [1, 0, 0, 0]
MIT