Permanently holds either 0 or 1
flip-flop
@/flip-flop
Permanently holds either 0 or 1
MEMboolean
The stored value
node {
void evaluate(Context ctx) {
bool oldState = getValue<output_MEM>(ctx);
bool newState = oldState;
if (isInputDirty<input_RST>(ctx)) {
newState = false;
} else if (isInputDirty<input_SET>(ctx)) {
newState = true;
} else if (isInputDirty<input_TGL>(ctx)) {
newState = !oldState;
}
if (newState == oldState)
return;
emitValue<output_MEM>(ctx, newState);
}
}
SET | TGL | RST | MEM |
---|
no-pulse | no-pulse | no-pulse | false |
pulse | no-pulse | no-pulse | true |
no-pulse | pulse | no-pulse | false |
no-pulse | pulse | no-pulse | true |
no-pulse | no-pulse | no-pulse | true |
no-pulse | no-pulse | pulse | false |
no-pulse | no-pulse | pulse | false |
pulse | pulse | pulse | false |
pulse | pulse | pulse | false |
pulse | pulse | no-pulse | true |
pulse | pulse | no-pulse | true |
no-pulse | pulse | no-pulse | false |