File size: 1,791 Bytes
b0a7ed2 | 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 93 94 95 | ---
license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
- sequential
- latch
---
# threshold-sr-latch
SR (Set-Reset) latch next-state logic as threshold circuit. Computes next state given current inputs and previous state.
## Circuit
```
S βββ
R βββΌβββΊ SR Latch βββ¬βββΊ Q
Q_prev βββ ββββΊ Qn
```
## Truth Table
| S | R | Q_prev | Q | Qn | Mode |
|---|---|--------|---|----|----|
| 0 | 0 | 0 | 0 | 1 | Hold |
| 0 | 0 | 1 | 1 | 0 | Hold |
| 0 | 1 | X | 0 | 1 | Reset |
| 1 | 0 | X | 1 | 0 | Set |
| 1 | 1 | X | 0 | 0 | Invalid |
## Classic NOR Implementation
```
S βββ¬βββΊ[NOR]βββΊ Qn
β β²
β β
β βββββββ
β β
R βββ΄βββΊ[NOR]βββΊ Q
β² β
β β
βββββββββ
```
Cross-coupled NOR gates create feedback loop.
## Combinational Representation
This circuit models the **next-state function**:
- Input: S, R, and Q_prev (previous Q)
- Output: Q_next, Qn_next
True latch behavior requires feeding Q output back to Q_prev over time.
## Architecture
| Component | Neurons |
|-----------|---------|
| Input inversions | 6 |
| Hold logic | 2 |
| Output gates | 3 |
**Total: 11 neurons, 39 parameters, 4 layers**
## Usage
```python
from safetensors.torch import load_file
w = load_file('model.safetensors')
# Simulate latch over time:
q = 0
for s, r in [(1,0), (0,0), (0,1), (0,0)]:
q_next = compute_q(s, r, q, w)
q = q_next
```
## Files
```
threshold-sr-latch/
βββ model.safetensors
βββ create_safetensors.py
βββ config.json
βββ README.md
```
## License
MIT
|