File size: 1,016 Bytes
76be67c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
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