--- license: mit tags: - pytorch - safetensors - threshold-logic - neuromorphic --- # threshold-min2 Minimum of two 2-bit unsigned integers. ## Function min2(a, b) = min(a, b) where a, b are 2-bit unsigned integers (0-3) Inputs: a1, a0, b1, b0 (MSB first) Outputs: m1, m0 = binary representation of min(a, b) ## Truth Table | a | b | min | |---|---|-----| | 0 | 0 | 0 | | 0 | 1 | 0 | | 0 | 2 | 0 | | 0 | 3 | 0 | | 1 | 0 | 0 | | 1 | 1 | 1 | | 1 | 2 | 1 | | 1 | 3 | 1 | | 2 | 0 | 0 | | 2 | 1 | 1 | | 2 | 2 | 2 | | 2 | 3 | 2 | | 3 | 0 | 0 | | 3 | 1 | 1 | | 3 | 2 | 2 | | 3 | 3 | 3 | ## Architecture 7-layer circuit: 1. Layer 1: Bit comparisons and passthrough (10 neurons) 2. Layer 2: Equality detection (9 neurons) 3. Layer 3: Partial comparison (8 neurons) 4. Layer 4: Full a > b and a == b (6 neurons) 5. Layer 5: a <= b computation (5 neurons) 6. Layer 6: MUX selection (4 neurons) 7. Layer 7: Final OR (2 neurons) ## Parameters | | | |---|---| | Inputs | 4 | | Outputs | 2 | | Neurons | 44 | | Layers | 7 | | Parameters | 186 | | Magnitude | 95 | ## Usage ```python from safetensors.torch import load_file import torch w = load_file('model.safetensors') # Use model.py for full implementation from model import min2, load_model w = load_model() m1, m0 = min2(1, 0, 0, 1, w) # min(2, 1) = 1 print(2*m1 + m0) # 1 ``` ## License MIT