| license: mit | |
| tags: | |
| - pytorch | |
| - safetensors | |
| - threshold-logic | |
| - neuromorphic | |
| # threshold-incrementer4bit | |
| 4-bit incrementer. Adds 1 to input (modulo 16). | |
| ## Function | |
| incrementer4bit(a3, a2, a1, a0) = (input + 1) mod 16 | |
| ## Truth Table (selected rows) | |
| | Input | Decimal | Output | Decimal | | |
| |-------|---------|--------|---------| | |
| | 0000 | 0 | 0001 | 1 | | |
| | 0001 | 1 | 0010 | 2 | | |
| | 0111 | 7 | 1000 | 8 | | |
| | 1111 | 15 | 0000 | 0 | | |
| ## Architecture | |
| ``` | |
| y0 = NOT(a0) | |
| y1 = a1 XOR a0 | |
| y2 = a2 XOR (a1 AND a0) | |
| y3 = a3 XOR (a2 AND a1 AND a0) | |
| ``` | |
| Layer 1: Compute NOT(a0), carries (c2, c3), and XOR components for y1 | |
| Layer 2: Compute y1, XOR components for y2 and y3 | |
| Layer 3: Final AND gates for y2 and y3 | |
| ## Parameters | |
| | | | | |
| |---|---| | |
| | Inputs | 4 | | |
| | Outputs | 4 | | |
| | Neurons | 12 | | |
| | Layers | 3 | | |
| | Parameters | 52 | | |
| | Magnitude | 41 | | |
| ## Usage | |
| ```python | |
| from safetensors.torch import load_file | |
| # See model.py for full implementation | |
| # 7 + 1 = 8 | |
| # incrementer4(0, 1, 1, 1) = [1, 0, 0, 0] | |
| ``` | |
| ## License | |
| MIT | |