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

Downloads last month
1
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including phanerozoic/threshold-multiplier4x4

Free AI Image Generator No sign-up. Instant results. Open Now