File size: 1,649 Bytes
81725db | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | ---
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
|