Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
•
248 items
•
Updated
•
1
Hamming(15,11) encoder. Adds 4 parity bits to 11 data bits for single-error correction.
encode(d1..d11) -> [p1, p2, d1, p4, d2, d3, d4, p8, d5, d6, d7, d8, d9, d10, d11]
| Position | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Bit | p1 | p2 | d1 | p4 | d2 | d3 | d4 | p8 | d5 | d6 | d7 | d8 | d9 | d10 | d11 |
Each parity bit covers positions where its position number (in binary) has a 1 in that bit:
Each parity bit requires a 7-way XOR, implemented as a tree of 2-way XORs:
XOR7(a,b,c,d,e,f,g) = XOR(XOR4(a,b,c,d), XOR3(e,f,g))
XOR4(a,b,c,d) = XOR(XOR(a,b), XOR(c,d))
XOR3(e,f,g) = XOR(XOR(e,f), g)
Each XOR2 requires 3 neurons (OR, NAND, AND).
| Inputs | 11 |
| Outputs | 15 |
| Neurons | 86 |
| Layers | 6 |
| Parameters | 591 |
| Magnitude | 272 |
When decoded, the receiver computes syndrome bits by XORing received bits at parity positions. The syndrome directly indicates the bit position of any single-bit error (0 = no error).
| Code | Data | Parity | Total | Efficiency |
|---|---|---|---|---|
| Hamming(7,4) | 4 | 3 | 7 | 57% |
| Hamming(15,11) | 11 | 4 | 15 | 73% |
Larger Hamming codes are more efficient but require more complex circuits.
from safetensors.torch import load_file
w = load_file('model.safetensors')
# See model.py for reference implementation
MIT