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
13
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including phanerozoic/threshold-multiplier4x4