Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
•
248 items
•
Updated
•
1
2-bit equality comparator. Outputs 1 if 2-bit A equals 2-bit B.
equals2(a1, a0, b1, b0) = 1 if (a1,a0) == (b1,b0), else 0
Checks if each bit pair matches using XNOR, then ANDs the results.
XNOR(x, y) = (x AND y) OR (NOT x AND NOT y)
Layer 1: (4 neurons on raw inputs)
Layer 2: (2 neurons)
Layer 3: (1 neuron)
| Inputs | 4 (a1, a0, b1, b0) |
| Outputs | 1 |
| Neurons | 7 |
| Layers | 3 |
| Parameters | 31 |
| Magnitude | 18 |
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
# Check if 2 == 2 (binary 10 == 10)
# a1=1, a0=0, b1=1, b0=0
# Result: 1 (equal)
MIT