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

Collection including phanerozoic/threshold-fulladder