Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
β’
248 items
β’
Updated
β’
1
SEC-DED (8,4) decoder: Single Error Correct, Double Error Detect. Extends Hamming(7,4) with overall parity for double-error detection.
codeword[7:0] βββΊ SEC-DED βββ¬βββΊ data[3:0] (corrected)
ββββΊ error (error detected)
ββββΊ uncorrectable (double error)
Position: 7 6 5 4 3 2 1 0
Bit: d3 d2 d1 p3 d0 p2 p1 p0
p0 = overall parity (all bits)
p1 = parity of positions 1,3,5,7
p2 = parity of positions 2,3,6,7
p3 = parity of positions 4,5,6,7
d0-d3 = data bits
| Syndrome | Overall Parity | Status |
|---|---|---|
| 0 | 0 | No error |
| β 0 | 1 | Single error (correctable) |
| β 0 | 0 | Double error (detected only) |
| 0 | 1 | Single error in p0 (correctable) |
| Component | Function | Neurons |
|---|---|---|
| Syndrome calc (s1,s2,s3) | XOR trees | ~63 |
| Overall parity | XOR tree | ~21 |
| Error logic | AND/OR | ~7 |
| Data correction | Conditional XOR | ~12 |
Total: 95 neurons, 300 parameters, 4 layers
from safetensors.torch import load_file
w = load_file('model.safetensors')
# Example: data=5 (0101)
# Encoded: 01010110 (with parity bits)
# Flip bit 3: 01011110
# Decoder: corrects to data=5, error=1, uncorrectable=0
threshold-sec-ded/
βββ model.safetensors
βββ create_safetensors.py
βββ config.json
βββ README.md
MIT