/** * Compiles the 11 W1c combinational ICs (core/README.md's "Kind codes and * records": codes 50-59 and 61) into v3 program records. Every physical * value — power window, thresholds, floating-pull family, propagation delay — * comes from classic's OWN helpers (`specsForComponent`, * `supplyPinsForComponent`, `propagationDelayForComponent`, * `FLOATING_INPUT_FUNCTIONS`, all exported from sim-engine.ts for exactly * this reuse) and classic's own pin-role table (`icPinMap`, digital.ts). * Nothing here re-derives a formula classic already owns; this file only * arranges those values into the wire record's shape. * * PINS are BY ID (README, G7): `vcc`, `gnd` (whatever `supplyPinsForComponent` * resolves — not hardcoded to the strings "vcc"/"gnd", since a catalog part * could in principle name them differently, though none of the 11 kinds's * default-parts.json entries currently do), then `icPinMap(kind)`'s pins in * ITS order. A component whose declared pin set is not exactly those two * supply pins plus the kind's logic pins is declined * (`topology:ic-pins:`) rather than defaulting a missing pin to * node 0 the way `dip_switch`/`spdt_switch` do — see this module's and the * README's own reasoning: catalog parts always carry the full pin set, so a * mismatch here means a stale/kind-mismatched identity or an injected * library missing the kind, and defaulting would read a real node as node 0 * silently instead of falling back to classic. * * PARAMS are the 13-value table CORE_IC_PARAM indexes (kinds.ts), then, for * the two kinds `CORE_IC_DELAY_PAIRS` names (74ls157, 74ls245), the kind's * datasheet delay tail (`resolveDelayTail`, compile/delays.ts) resolved * against the SAME `specsForComponent(component)` call and falling back to * `params[delay]` (param 12, classic's package delay) per pair per direction * when the catalog carries no `switching_ns` figure for it (README's * "Resolution"). Every value is derived straight from * `specsForComponent(component)` — the same `ElectricalSpecs` classic's own * `_icPowerInfo`/`thresholdsFor` read — with no vSupply-dependent computation * done here: the fixed/formula split for thresholds (params 3-6) and the * schmitt/nominal/ioMax params are exactly classic's OWN "what does the * catalog fix, and what does the runtime supply decide" split (spec/README's * kernel semantics point 1), just carried onto the wire instead of evaluated * at compile time. * * BLOB is `[slotBase, pinFlags x L]`. `slotBase` is assigned by the caller * (compile/index.ts owns slot allocation, in component order — see its own * comment on `SlotAllocator`); this module only reports which of a kind's * logic pins are output-capable (so the caller knows how many slots to * claim, and in what order) and, for every logic pin, its two blob flag bits * (README's "IC blob"): * - `FLOATING_INPUT`: classic's own `_shouldTreatOpenPinAsDigitalInput` OR's * two independent tests — the resolved catalog part's `pin_layout` * function (e.g. 74LS245's `a`/`b` pins are catalog function `tri_state`, * which is in FLOATING_INPUT_FUNCTIONS regardless of `icPinMap`'s role for * that pin) and `icPinMap`'s own role (input/clock/control). Neither test * alone is `_shouldTreatOpenPinAsDigitalInput` — both are reproduced here. * - `OPEN_COLLECTOR`: the resolved part's pin function is literally * `"open_collector"` (only 74LS47's 7 segment outputs, in the bundled * catalog). */ import type { SimCircuit } from "../../sim/engine/sim-engine.js"; import { type IcPinDef } from "../../sim/engine/digital.js"; import type { ProgramPinInput } from "../format.js"; import { resolveComponentPart } from "./catalog.js"; import { type CoreNodeBuild } from "./topology.js"; type SimComponent = SimCircuit["components"][number]; export type IcCompileResult = { ok: true; pins: readonly ProgramPinInput[]; params: readonly number[]; /** Per logic pin (icPinMap(kind) order), the blob flag bits — everything AFTER blob[0] (the slot base, which the caller assigns). */ pinFlags: readonly number[]; /** The output-capable logic pins, in icPinMap(kind) order — the caller allocates one digital slot per id, keyed `${componentId}/${pinId}`. */ outputCapablePinIds: readonly string[]; } | { ok: false; reason: string; }; /** * Classic's `_shouldTreatOpenPinAsDigitalInput(comp, pinId)` * (sim-engine.ts), reproduced field for field: the resolved part's own * `pin_layout` function (not `icPinMap`'s role) is checked FIRST, and only * falls back to the role test when the catalog carries no function for that * pin id (or no part resolved at all — unreachable here in practice, since a * resolved `vccPin`/`gndPin` already implies `partFor` found the same part * this module's own `resolveComponentPart` call resolves). * * Exported (beyond this module's own compile-time use) so the equivalence * harness's decision-9 open-input auto-detection (test/core/equivalence/ * open-input.ts) can ask the identical question this module asks at compile * time — "is this pin FLOATING_INPUT" — for a fixture's own circuit, without * re-deriving classic's `_shouldTreatOpenPinAsDigitalInput` rule a second time. */ export declare function isFloatingInput(part: ReturnType, pin: IcPinDef): boolean; /** * The 13 IC params (CORE_IC_PARAM, kinds.ts) of one IC component, straight * from `specsForComponent`: power window, family flags, thresholds, Schmitt * figures, nominal supply, ioMax and classic's package delay. Shared by the * combinational compiler here and the W1d register and memory compilers, * which then zero the Schmitt params and append their delay tail * (core/README.md, "Kind codes and records"). */ export declare function icBaseParams(component: SimComponent): number[]; /** * Compiles one combinational IC component (`component.kind` one of the 11 * codes 50-59/61) into its pins/params/blob-flags. The caller * (compile/index.ts) still owns: dispatching only these 11 kinds here, * allocating digital slots (`outputCapablePinIds`, in order) and assembling * the final blob (`[slotBase, ...pinFlags]`). */ export declare function compileCombinationalIc(built: CoreNodeBuild, openKeys: ReadonlySet, component: SimComponent): IcCompileResult; export {};