metadata
license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
- error-correction
- ecc
threshold-sec-ded
SEC-DED (8,4) decoder: Single Error Correct, Double Error Detect. Extends Hamming(7,4) with overall parity for double-error detection.
Circuit
codeword[7:0] βββΊ SEC-DED βββ¬βββΊ data[3:0] (corrected)
ββββΊ error (error detected)
ββββΊ uncorrectable (double error)
Codeword Format
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
Error Handling
| 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) |
Architecture
| 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
Capabilities
- Correct: Any single-bit error
- Detect: Any double-bit error
- Miss: Triple+ errors may be miscorrected
Test Coverage
- 16 no-error cases: All pass
- 128 single-error cases: All corrected
- 448 double-error cases: All detected
Usage
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
Applications
- ECC RAM (Error-Correcting Code memory)
- Data storage systems
- Communication channels
- Safety-critical systems
Files
threshold-sec-ded/
βββ model.safetensors
βββ create_safetensors.py
βββ config.json
βββ README.md
License
MIT