Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
β’
269 items
β’
Updated
β’
1
CRC-16 CCITT single-step function using magnitude-optimal XOR components.
This circuit uses proven-optimal XOR decompositions instead of naive OR+NAND+AND:
| Component | Naive Approach | Optimized | Savings |
|---|---|---|---|
| XOR (2-input) | OR+NAND+AND (mag 10) | mag-7 symmetric | 30% |
| XOR3 (3-input) | ge1/ge2/ge3 (mag 19) | mag-10 flat | 47% |
Total magnitude: 74 β 53 (28% reduction)
From the 6 proven-optimal solutions, we use the symmetric opposites family:
h1: [-1, +1], bias=0 (fires when b > a)
h2: [+1, -1], bias=0 (fires when a > b)
out: [-1, -1], bias=1 (NOR of hidden)
Selected for:
From the 18 proven-optimal solutions, we use the selector + full pattern:
h1: [0, 0, -1], bias=0 (selector: fires when c=0)
h2: [-1, +1, -1], bias=0 (full: fires when b > a+c)
h3: [-1, -1, +1], bias=0 (full: fires when c > a+b)
out: [+1, -1, -1], bias=0
Selected for:
0x1021 = x^16 + x^12 + x^5 + 1 (CRC-16-CCITT)
feedback = C[15] XOR D
C'[0] = feedback (tap at x^0) β XOR (mag 7)
C'[1] = C[0]
C'[2] = C[1]
C'[3] = C[2]
C'[4] = C[3]
C'[5] = C[4] XOR feedback (tap at x^5) β XOR3 (mag 10)
C'[6] = C[5]
...
C'[11] = C[10]
C'[12] = C[11] XOR feedback (tap at x^12) β XOR3 (mag 10)
C'[13] = C[12]
C'[14] = C[13]
C'[15] = C[14]
| Inputs | 17 (C[0:15] + D) |
| Outputs | 16 (C'[0:15]) |
| Neurons | 24 |
| Layers | 2 |
| Parameters | 389 |
| Magnitude | 53 |
| Component | Neurons | Magnitude |
|---|---|---|
| 13 pass-throughs | 13 | 26 |
| C'[0] XOR | 3 | 7 |
| C'[5] XOR3 | 4 | 10 |
| C'[12] XOR3 | 4 | 10 |
| Total | 24 | 53 |
| Version | Magnitude | Reduction |
|---|---|---|
| threshold-crc16 (naive) | 74 | baseline |
| threshold-crc16-mag53 | 53 | 28% |
threshold-crc16-mag53/
βββ model.safetensors
βββ model.py
βββ create_safetensors.py
βββ config.json
βββ README.md
from safetensors.torch import load_file
from model import forward
weights = load_file('model.safetensors')
# Single step: 16-bit CRC state + 1 data bit β new 16-bit state
inputs = [c0, c1, ..., c15, d] # 17 binary values
outputs = forward(inputs, weights) # 16 binary values
MIT