Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
β’
248 items
β’
Updated
β’
1
Adds three 1-bit inputs (a, b, carry_in), producing sum and carry_out. The core of ripple-carry adders.
a b
β β
βββββ¬ββββ
βΌ
βββββββββββ
β HA1 β First half adder
βββββββββββ
β β
s1 c1
β \
β cin \
ββββ¬βββ \
βΌ \
βββββββββββ \
β HA2 β β
βββββββββββ β
β β β
sum c2 β
β β
ββββ¬ββββ
βΌ
ββββββββ
β OR β
ββββββββ
β
βΌ
cout
| 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
| Component | Neurons |
|---|---|
| HA1 (a + b) | 4 |
| HA2 (s1 + cin) | 4 |
| OR (c1, c2) | 1 |
Total: 9 neurons, 21 parameters, 4 layers
s1, c1 = HalfAdder(a, b)
sum, c2 = HalfAdder(s1, cin)
cout = OR(c1, c2)
A carry propagates if either half adder produces one.
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
threshold-fulladder/
βββ model.safetensors
βββ model.py
βββ config.json
βββ README.md
MIT