Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
β’
248 items
β’
Updated
β’
1
CRC-4 generator using polynomial x^4 + x + 1 (CRC-4-ITU).
crc4(d3, d2, d1, d0) -> (crc3, crc2, crc1, crc0)
Computes 4-bit CRC for 4-bit input data.
G(x) = x^4 + x + 1 = 10011 (binary)
This is the ITU-T standard CRC-4 polynomial.
For 4-bit input, the CRC bits are:
| Data | CRC |
|---|---|
| 0000 | 0000 |
| 0001 | 0011 |
| 1000 | 1101 |
| 1111 | 0010 |
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)
| Inputs | 4 |
| Outputs | 4 |
| Neurons | 15 |
| Layers | 4 |
| Parameters | 61 |
| Magnitude | 50 |
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
MIT