/** * waveform.ts — pure, dependency-free waveform evaluation for signal_gen. * * Why dependency-free: this module is imported by the MNA engine step loop, * which must remain allocation-light and has no access to higher-level modules. * Keeping it self-contained also makes it trivially testable in isolation. * * Unified model: V(t) = offset + amplitude * unit(t) * where unit(t) is normally in [-1, 1] (except dc which fixes unit = 0, * Gaussian noise which is intentionally unbounded, and pwl which bypasses the * model entirely — see the waveform-specific notes below). */ /** A single point in a PWL waveform, pre-parsed from the "t:v,..." string. */ export interface PwlPoint { t: number; v: number; } /** * Validated, clamped, pre-parsed view of signal_gen component params. * parseSignalGenParams() produces this ONCE per load; signalGenVoltage() reads it * many thousands of times per second — keep it a plain object. */ export interface SignalGenParams { waveform: "dc" | "sine" | "square" | "pulse" | "triangle" | "ramp" | "pwl" | "noise"; amplitude: number; offset: number; frequency: number; phaseDeg: number; duty: number; delay: number; tr: number; tf: number; pw: number; pwlPoints: PwlPoint[]; seed: number; } /** Independent Gaussian draws are updated at 10 kSa/s and held between updates. */ export declare const SIGNAL_GEN_NOISE_UPDATE_RATE_HZ = 10000; /** One-sided equivalent noise bandwidth of the 10 kSa/s zero-order hold. */ export declare const SIGNAL_GEN_NOISE_EQUIVALENT_BANDWIDTH_HZ: number; /** * Parse and validate raw params from the component catalog into a typed, * clamped SignalGenParams. Designed to be called once per engine load, not * per-step — but kept allocation-light for cases where the engine calls it * more frequently during adaptive-step retry. */ export declare function parseSignalGenParams(params: Record): SignalGenParams; /** * Returns whether the signal_gen output is enabled (connected). * When `enabled` is 0 the output is Hi-Z (disconnected). * Default is enabled (any value other than 0). */ export declare function signalGenEnabled(params: Record): boolean; /** * Compute the output voltage for a signal_gen component at simulation time t. * * For most waveforms: V = offset + amplitude * unit(t') * where t' = t - delay (the waveform's own time after the delay elapses). * * Special cases: * dc — unit = 0, so V = offset. amplitude is intentionally ignored * because a DC source is fully described by its offset; making * amplitude contribute would surprise users who set it for a * waveform and then switch to dc. * pwl — bypasses the unified model entirely. PWL points specify * absolute voltages chosen by the user; wrapping them in * offset + amplitude * v would double-transform the signal and * produce wrong values. Offset and amplitude are ignored. * pulse — phase is NOT applied (SPICE convention: pulse is defined by * absolute time parameters td/tr/pw/tf/period, not a phase shift; * applying phase would change the initial delay semantics that * SPICE users expect). */ export declare function signalGenVoltage(p: SignalGenParams, t: number): number;