threshold-jk-flipflop

JK flip-flop next-state logic as threshold circuit. Most versatile flip-flop with Set, Reset, Hold, and Toggle modes.

Circuit

J      ──┐
K      ──┼──► JK-FF ──┬──► Q
Q_prev β”€β”€β”˜           └──► Qn

Truth Table

J K 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 0 1 0 Toggle
1 1 1 0 1 Toggle

Modes

J=0, K=0: Hold    - Q stays same
J=0, K=1: Reset   - Q becomes 0
J=1, K=0: Set     - Q becomes 1
J=1, K=1: Toggle  - Q flips

Logic

Q  = JΒ·~Q_prev + ~KΒ·Q_prev
Qn = ~JΒ·~Q_prev + KΒ·Q_prev

Architecture

Component Neurons
Input inversions 4
AND gates 4
OR outputs 2
Passthroughs 2

Total: 12 neurons, 42 parameters, 3 layers

Advantage Over SR

Unlike SR flip-flop, JK has no invalid state. When both inputs are high, it toggles instead of producing undefined behavior.

Usage

from safetensors.torch import load_file

w = load_file('model.safetensors')

# Counter using toggle mode:
q = 0
for _ in range(4):
    q_next = compute(j=1, k=1, q_prev=q, w)
    q = q_next  # q toggles: 0,1,0,1,...

Files

threshold-jk-flipflop/
β”œβ”€β”€ model.safetensors
β”œβ”€β”€ create_safetensors.py
β”œβ”€β”€ config.json
└── README.md

License

MIT

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

Collection including phanerozoic/threshold-jk-flipflop