metadata
license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
- arithmetic
- multiplier
threshold-multiplier4x4
4x4 binary multiplier as threshold circuit. Multiplies two 4-bit unsigned integers to produce an 8-bit product.
Circuit
A[3:0] βββ
ββββΊ 4x4 MUL βββΊ P[7:0]
B[3:0] βββ
P = A Γ B
Range: 0-15 Γ 0-15 = 0-225
Architecture
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
Adder Tree Structure
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
Usage
from safetensors.torch import load_file
w = load_file('model.safetensors')
# Verify: 15 Γ 15 = 225
# All 256 input combinations tested
Files
threshold-multiplier4x4/
βββ model.safetensors
βββ create_safetensors.py
βββ config.json
βββ README.md
License
MIT