threshold-tristate

4-bit tristate buffer with enable control.

Function

tristate4(E, D3, D2, D1, D0) -> (Y3, Y2, Y1, Y0)

  • When E=1: Yi = Di (data passes through)
  • When E=0: Yi = 0 (high-impedance, modeled as 0)

Truth Table

E D Y
0 XXXX 0000
1 0000 0000
1 0101 0101
1 1010 1010
1 1111 1111

Architecture

Single-layer AND gates:

E ─────┬─────┬─────┬─────┐
       β”‚     β”‚     β”‚     β”‚
D3 ────┼──┐  β”‚     β”‚     β”‚
D2 ────┼──┼──┼──┐  β”‚     β”‚
D1 ────┼──┼──┼──┼──┼──┐  β”‚
D0 ────┼──┼──┼──┼──┼──┼──┼──┐
       β”‚  β”‚  β”‚  β”‚  β”‚  β”‚  β”‚  β”‚
       β–Ό  β–Ό  β–Ό  β–Ό  β–Ό  β–Ό  β–Ό  β–Ό
     β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”
     β”‚ AND β”‚ AND β”‚ AND β”‚ AND β”‚
     β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”˜
       β”‚     β”‚     β”‚     β”‚
       β–Ό     β–Ό     β–Ό     β–Ό
       Y3    Y2    Y1    Y0

Each Yi = E AND Di.

Parameters

Inputs 5
Outputs 4
Neurons 4
Layers 1
Parameters 24
Magnitude 16

Note on High-Impedance

True tristate outputs have three states: 0, 1, and high-Z (disconnected). In threshold logic, we model high-Z as 0. For bus arbitration, ensure only one tristate buffer is enabled at a time.

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def tristate(e, d3, d2, d1, d0):
    inp = torch.tensor([float(e), float(d3), float(d2), float(d1), float(d0)])
    y0 = int((inp @ w['y0.weight'].T + w['y0.bias'] >= 0).item())
    y1 = int((inp @ w['y1.weight'].T + w['y1.bias'] >= 0).item())
    y2 = int((inp @ w['y2.weight'].T + w['y2.bias'] >= 0).item())
    y3 = int((inp @ w['y3.weight'].T + w['y3.bias'] >= 0).item())
    return y3, y2, y1, y0

# tristate(1, 1, 0, 1, 0) = (1, 0, 1, 0)  # enabled, data passes
# tristate(0, 1, 0, 1, 0) = (0, 0, 0, 0)  # disabled, output zeros

License

MIT

Downloads last month
6
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including phanerozoic/threshold-tristate