Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
•
248 items
•
Updated
•
1
1:16 demultiplexer. Routes data input to one of 16 outputs based on 4-bit select.
DEMUX16(d, s3, s2, s1, s0) -> [y0..y15]
yi = d AND (s == i), where s = 8s3 + 4s2 + 2*s1 + s0
Single layer with 16 neurons. Each output yi fires when d=1 AND select matches i.
Each neuron has:
| Inputs | 5 (1 data + 4 select) |
| Outputs | 16 |
| Neurons | 16 |
| Layers | 1 |
| Parameters | 96 |
| Magnitude | 128 |
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def demux16(d, s3, s2, s1, s0):
inp = torch.tensor([float(d), float(s3), float(s2), float(s1), float(s0)])
return [int((inp * w[f'y{i}.weight']).sum() + w[f'y{i}.bias'] >= 0)
for i in range(16)]
# Route d=1 to output 10 (s=1010)
print(demux16(1, 1, 0, 1, 0)) # [0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0]
MIT