# Pulse gate

Process

Conditionally passes or blocks a pulse signal based on the state of an enable input. When a rising edge arrives on the input and enable is true, the pulse is forwarded to the output. When enable is false, the pulse is suppressed.

Pulse gate
I
E
O

# Inputs

IDAbbrevNameTypeDefaultDescription
inputIInputBOOLEANfalsePulse signal. A rising edge triggers evaluation of the enable state to decide whether to forward the pulse.
enableEEnableBOOLEANtrueLevel input checked at the moment a pulse arrives. When true, pulses pass through. When false, pulses are blocked. Changing this input does not trigger output on its own.

# Outputs

IDAbbrevNameTypeDefaultDescription
outputOOutputBOOLEANfalseForwarded pulse. Mirrors the input pulse when the gate is enabled.

# State

IDNameTypeDefaultUnitDescription
prev_inputPrevious input stateBOOLEANfalseStores the previous state of the input to detect rising and falling edges.

# Source Code

View Volang source
channel = input::channel()
value = input::value()

if (channel == "input") {
    prev_input = state::get("prev_input")

    if (value and !prev_input) {
        if (input::get("enable")) {
            output::set("output", true)
        }
    }

    if (!value and prev_input) {
        output::set("output", false)
    }

    state::set("prev_input", value)
}
Conditionally passes or blocks a pulse signal based on the state of an enable input. When a rising edge arrives on the input and enable is true, the pulse is forwarded to the output. When enable is false, the pulse is suppressed.