Language Variables, flow & functions

Variables, flow & functions

The software half of a Hover program: variables that either reset every timestep or persist across them, two control-flow constructs, and functions that run at runtime rather than being flattened away.

Local variables

Re-initialised to the given value on every simulation step.

State variables

Initialised once at t = 0, then carried across timesteps — the equivalent of a register or flip-flop.

state is only legal inside a digital module. An analog module runs inside the Newton-Raphson loop, so a state variable there would accumulate once per iteration rather than once per timestep — see Why two computational domains.

If / else if / else

While

Allowed in digital modules and functions, forbidden in analog ones — an unbounded loop inside the convergence loop is a hang, not a slow simulation.

Functions

Functions are called at runtime rather than flattened into the netlist. They take and return logic types only (double, float, int) — wires and physical primitives can't be parameters.

Calling them looks like anything else: