threshold-fulladder

Adds three 1-bit inputs (a, b, carry_in), producing sum and carry_out. The core of ripple-carry adders.

Circuit

        a       b
        │       │
        └───┬───┘
            ▼
       ┌─────────┐
       │   HA1   │  First half adder
       └─────────┘
        │       │
       s1       c1
        │        \
        │    cin  \
        └──┬──┘    \
           ▼        \
      ┌─────────┐    \
      │   HA2   │     │
      └─────────┘     │
       │       │      │
      sum      c2     │
               │      │
               └──┬───┘
                  ▼
              ┌──────┐
              │  OR  │
              └──────┘
                  │
                  ▼
                cout

Truth Table

a b cin sum cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1

Binary: a + b + cin = (cout × 2) + sum

Architecture

Component Neurons
HA1 (a + b) 4
HA2 (s1 + cin) 4
OR (c1, c2) 1

Total: 9 neurons, 21 parameters, 4 layers

Composition

s1, c1 = HalfAdder(a, b)
sum, c2 = HalfAdder(s1, cin)
cout = OR(c1, c2)

A carry propagates if either half adder produces one.

Usage

from safetensors.torch import load_file

w = load_file('model.safetensors')

def full_adder(a, b, cin):
    # Implementation uses two half adders + OR
    # See model.py for full implementation
    pass

Files

threshold-fulladder/
├── model.safetensors
├── model.py
├── config.json
└── README.md

License

MIT

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

Collection including phanerozoic/threshold-fulladder

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