/** * R4 digital engine — pure helper functions. * * All functions are side-effect-free so they can be called inside the * Newton iteration loop without mutating any engine state. */ /** * Square-wave clock output at simulation time t (seconds). * Returns vHigh during the duty-cycle fraction, vLow otherwise. */ export declare function clockVoltage(t: number, period?: number, dutyCycle?: number, vHigh?: number, vLow?: number, delay?: number): number; /** * SPICE-style PULSE waveform — piecewise-linear and periodic when `per > 0`. * A non-positive or non-finite period produces one pulse, then holds `v1`. * * v1 : initial (low) value * v2 : pulsed (high) value * td : initial delay (s) * tr : rise time (s) * tf : fall time (s) * pw : pulse width at v2 (s) * per : period (s); <= 0 selects a one-shot pulse */ export declare function pulseVoltage(t: number, v1?: number, v2?: number, td?: number, tr?: number, tf?: number, pw?: number, per?: number): number; export type GateKind = "and" | "or" | "not" | "nand" | "nor" | "xor" | "xnor" | "buf"; export type IcPinRole = "input" | "output" | "clock" | "power" | "control"; export interface IcPinDef { id: string; role: IcPinRole; /** Gate index within the IC package (0-based). */ gate?: number; /** Position within a gate: "a" | "b" for inputs, "y" for output. */ gatePin?: "a" | "b" | "y"; } /** * Pins that must resolve HIGH when left unconnected (open), because the * physical chip drives them from internal pull-ups. * * 74LS47: /LT, /RBI, and /RBO all have on-chip pull-ups. An unconnected /LT * or /RBI defaults HIGH (inactive), ensuring a chip with open control inputs * decodes BCD normally. Without this, the TTL floating model (~70/30 high by * hash) can randomly assert blanking or lamp-test, permanently blanking the * display. * * CD4511: /LT and /BL have on-chip pull-ups (inactive HIGH). LE defaults LOW * (transparent). Leaving /LT or /BL open must not assert test or blank. * * 74HC74: /PRE and /CLR are active-low; leaving them open must default HIGH * (inactive) so the flip-flop operates normally. * * CD4017/CD4060: RESET is active-HIGH. An open RESET pin should default LOW so * the counter is not permanently held in reset. These chips do NOT have an * internal pull-up for RESET in the real hardware, but we resolve it LOW * deterministically to avoid hash-based floating noise locking the counter. */ export declare const IC_OPEN_HIGH_PINS: Partial>>; /** * Evaluate all outputs of a combinational multi-gate IC. * Returns a map of output pin id → boolean level. * Unrecognised kinds return an empty map (not an error). */ export declare function evalCombinationalIC(kind: string, pinV: Record, vth?: number): Record; /** * Evaluate CD4511 segment outputs for a given latched BCD value and control * pin voltages. Called from the engine's stamp and update paths so the latch * state (stored in icState) can be passed in without re-reading pins. * * latchedBcd: the BCD nibble currently latched (0-15). * pinV: map of control pin voltages (lt_n, bl_n, le — used for priority only). * vth: logic threshold (supply-ratioed by caller). * * Returns output pin id → HIGH level (true = segment ON = output HIGH). */ export declare function evalCD4511(latchedBcd: number, ltLow: boolean, blLow: boolean): Record; /** Get the full pin map for a combinational IC (for use in the stamp helper). */ export declare function icPinMap(kind: string): IcPinDef[]; /** * Evaluate which segments are lit on a 7-segment display. * commonAnode = true → segment is ON when pin is LOW * commonAnode = false → segment is ON when pin is HIGH */ export declare function evalSeg7(pinV: Record, commonAnode: boolean, vth?: number): Record<"a" | "b" | "c" | "d" | "e" | "f" | "g" | "dp", boolean>; /** * Evaluate a combinational logic gate. * Input voltages are thresholded at vth (default 2.5 V for 5 V logic). * Returns the boolean output level. */ export declare function evalGate(kind: GateKind, inputs: number[], vth?: number): boolean;