threshold-crc4 / README.md
phanerozoic's picture
Upload folder using huggingface_hub
81725db verified
---
license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
- error-detection
- crc
---
# threshold-crc4
CRC-4 generator using polynomial x^4 + x + 1 (CRC-4-ITU).
## Function
crc4(d3, d2, d1, d0) -> (crc3, crc2, crc1, crc0)
Computes 4-bit CRC for 4-bit input data.
## Polynomial
G(x) = x^4 + x + 1 = 10011 (binary)
This is the ITU-T standard CRC-4 polynomial.
## Parallel CRC Equations
For 4-bit input, the CRC bits are:
- crc0 = d3 XOR d0
- crc1 = d2 XOR d1 XOR d0
- crc2 = d3 XOR d1
- crc3 = d3 XOR d2
## Truth Table (selected)
| Data | CRC |
|------|-----|
| 0000 | 0000 |
| 0001 | 0011 |
| 1000 | 1101 |
| 1111 | 0010 |
## Architecture
Each CRC bit is computed using XOR gates:
```
d3 d2 d1 d0
β”‚ β”‚ β”‚ β”‚
β”œβ”€β”€β”Όβ”€β”€β”Όβ”€β”€β”Όβ”€β”€β–Ί XOR ──► crc0 (d3^d0)
β”‚ β”‚ β”‚ β”‚
β”‚ β”œβ”€β”€β”Όβ”€β”€β”Όβ”€β”€β–Ί XOR ──► crc3 (d3^d2)
β”‚ β”‚ β”‚ β”‚
β”œβ”€β”€β”Όβ”€β”€β”Όβ”€β”€β”Όβ”€β”€β–Ί XOR ──► crc2 (d3^d1)
β”‚ β”‚ β”‚ β”‚
β”‚ └──┴──┴──► XOR3 ─► crc1 (d2^d1^d0)
```
## Parameters
| | |
|---|---|
| Inputs | 4 |
| Outputs | 4 |
| Neurons | 15 |
| Layers | 4 |
| Parameters | 61 |
| Magnitude | 50 |
## CRC Properties
- Detects all single-bit errors
- Detects all odd numbers of bit errors
- Detects burst errors up to length 4
## Usage
```python
from safetensors.torch import load_file
w = load_file('model.safetensors')
# Append CRC to data for transmission
# Receiver recomputes CRC; if non-zero, error detected
```
## License
MIT