Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
•
248 items
•
Updated
•
1
8-bit population count. Counts the number of 1 bits in an 8-bit input.
popcount8(a7..a0) = count of 1 bits (0 to 8)
Output is 4 bits: y3y2y1y0 representing count in binary.
| Input | Count | Output |
|---|---|---|
| 00000000 | 0 | 0000 |
| 00000001 | 1 | 0001 |
| 01010101 | 4 | 0100 |
| 11110000 | 4 | 0100 |
| 11111111 | 8 | 1000 |
The parity computation uses a tree of XOR gates: XOR pairs, then XOR the results.
| Inputs | 8 |
| Outputs | 4 |
| Neurons | 31 |
| Layers | 5 |
| Parameters | 177 |
| Magnitude | 163 |
from safetensors.torch import load_file
# See create_safetensors.py for full implementation
# popcount8(1,0,1,0,1,0,1,0) = [0,1,0,0] = 4
MIT