Skip to main content

Module dsl_expand

Module dsl_expand 

Source
Expand description

File-based subcircuit expansion (flatten pass).

Front-end only: turns a PedalDef containing use("path.pedal") instances (declared in the components { ... } block, collected into PedalDef::uses) into ONE flat PedalDef that the existing compile_pedal accepts unchanged. The WDF/SPQR compiler and runtime are never touched.

A use(...) instance is FLATTENED into the parent’s single component / net / control list (unlike inline subcircuit { ... } blocks, which partition the graph into separate rate-domain processors via [crate::compiler::subcircuit] — file-based uses must NOT route through that path).

§Namespacing

For an instance id:

  • component R3 → id.R3; every ComponentPin { component, .. } is rewritten to id.component.
  • a bare internal node Reserved(name) (not gnd, not a supply rail, not a declared port) → Reserved("id.name").
  • gnd stays global.
  • a supply rail (vcc or a named supply of the sub) stays global by default, UNLESS the parent explicitly maps id.<rail> to a node — then it unifies with that node (implicit-global, overridable).
  • a declared port P (from the sub’s ports { }, plus in/out) unifies with whatever node the parent wired to id.P. A used-but-unmapped non-rail port is a loud error.

§Controls

A sub control on component C becomes a control on id.C. A parent control referencing id.<subctrl> re-targets/renames the namespaced sub control.

Functions§

expand_uses
Expand all file-based use(...) subcircuit instances in pedal into a single flat PedalDef.
parse_and_expand_pedal_file
Path-aware entry point: read path, parse, and expand its use(...) instances relative to the file’s own directory.