Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks. • 270 items • Updated • 1
4x4 binary multiplier as threshold circuit. Multiplies two 4-bit unsigned integers to produce an 8-bit product.
A[3:0] ──┐
├──► 4x4 MUL ──► P[7:0]
B[3:0] ──┘
P = A × B
Range: 0-15 × 0-15 = 0-225
Partial Products (16 AND gates):
b3 b2 b1 b0
× a3 a2 a1 a0
─────────────────────────
a0b3 a0b2 a0b1 a0b0
a1b3 a1b2 a1b1 a1b0
a2b3 a2b2 a2b1 a2b0
+ a3b3 a3b2 a3b1 a3b0
─────────────────────────────────────
p7 p6 p5 p4 p3 p2 p1 p0
| Component | Count | Neurons |
|---|---|---|
| AND (partial products) | 16 | 16 |
| Half Adders | 4 | 16 |
| Full Adders | 8 | 56 |
Total: 88 neurons, 368 parameters, 6 layers
Column 1: HA(pp10, pp01) → p1, c1
Column 2: FA(pp20, pp11, pp02) → s, c
HA(s, c1) → p2, c
Column 3: FA(pp30, pp21, pp12) → s, c
FA(s, pp03, c) → s', c'
HA(s', c) → p3, c
Column 4-6: Similar carry-propagate structure
Column 7: Final carry → p7
from safetensors.torch import load_file
w = load_file('model.safetensors')
# Verify: 15 × 15 = 225
# All 256 input combinations tested
threshold-multiplier4x4/
├── model.safetensors
├── create_safetensors.py
├── config.json
└── README.md
MIT