Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
•
248 items
•
Updated
•
1
4-bit decrementer. Subtracts 1 from input (modulo 16).
decrementer4bit(a3, a2, a1, a0) = (input - 1) mod 16
| Input | Decimal | Output | Decimal |
|---|---|---|---|
| 0000 | 0 | 1111 | 15 |
| 0001 | 1 | 0000 | 0 |
| 1000 | 8 | 0111 | 7 |
| 1111 | 15 | 1110 | 14 |
y0 = NOT(a0)
y1 = XNOR(a1, a0) = a1 XOR NOT(a0)
y2 = a2 XOR NOR(a1, a0)
y3 = a3 XOR NOR(a2, a1, a0)
Borrow propagation: flip each bit if all lower bits are 0.
Layer 1: Compute NOT(a0), borrow signals (b1=NOR, b2=NOR3), XNOR component Layer 2: Complete XNOR for y1, XOR components for y2 and y3 Layer 3: Final AND gates for y2 and y3
| Inputs | 4 |
| Outputs | 4 |
| Neurons | 11 |
| Layers | 3 |
| Parameters | 56 |
| Magnitude | 33 |
from safetensors.torch import load_file
# See model.py for full implementation
# 8 - 1 = 7
# decrementer4(1, 0, 0, 0) = [0, 1, 1, 1]
# 0 - 1 = 15 (wraps)
# decrementer4(0, 0, 0, 0) = [1, 1, 1, 1]
MIT