OpenPELS / docs /architecture /circuit_data_model.md
minjiechen's picture Elvis0001's picture
Add qualified 2:1 SI2, SP2, RSC2, and Buck_Stacked workflows (#1)
0a53b5b
|
Raw History Blame Contribute Delete
13.8 kB

Circuit data model and schematic editor

The three XFLY6S representations

Representation XFLY6S example What the artifact owns
Curated topology catalog and loss model Catalog ID xfly2p, named XFLY6S by the workbench, qualified at 4:1. Reference drawing, model domain, loss coefficients, size allocation and analytical excitation assumptions. The catalog entry contains no editable project graph. models-data.json:4, gallery.js:4, recommend.js:3
Native Analog Canvas project Starter ID xfly6s, loaded from starters/xfly6s.icproj.json. The starter manifest separately names xfly2p as the reference model. Editable component instances, terminals, nets, coupling, layout and source provenance. The companion xfly6s.sp is the structural input used to generate it. starters/index.json:16, project JSON:1, starter SPICE:3
NGSpice simulator preset Preset ID xfly6s, template testbenches/netlists/xfly6s_transient.cir; related original cases include startup, settling and winding DCR mismatch. Executable testbench with device models, parasitics, source/load, gates, initial conditions, probes and transient control. simulator_service.py:105, testbench manifest:8, deck:5

The mapping is explicit in gallery.js. It is not a conversion based on the current project name, switch count, or electrical connectivity. XFLY8S is the clearest counterexample: xfly4p maps to starter and simulator IDs xfly8s, but the gallery labels them as related because the analytical model includes clamp capacitors absent from the starter and simulator. gallery.js:5, gallery.js:11

Native project structure

flowchart TD
    P[CircuitProject]
    C[SchematicDocument or Cell]
    I[Instance and symbol binding]
    T[Terminal reference]
    N[Logical net]
    R[Route and drawing geometry]
    J[Junction]
    K[Coupling and dotted end references]
    F[Formal cell terminals and parameters]
    P --> C
    C --> I
    C --> N
    I --> T
    N --> T
    C --> R
    R --> J
    C --> K
    K --> I
    C --> F
    F --> N
  • Project and cells. CircuitProjectSchema has stable IDs, a top document, documents, structural revision, source and symbol-library manifests, optional user component/model sources, external subcircuit definitions, and simulation folders. A cell has its own revision, instances, netlist interface, nets, routing, junctions, annotations and presentation. An instance can reference a child cell by ID or an external subcircuit. project.ts:115, document.ts:84, instance.ts:86
  • Instances and electrical parameters. The runtime schema separates symbol and placement from electrical binding. An InstanceNetlistDataSchema binding can be primitive, named model, subcircuit, or unresolved. Its parameter values are strings so a value such as 100n or an expression can retain its authored form. Device terminal references carry an instanceId, pinName, and optional signal member ID. Imported terminal ordering and source spans provide provenance. instance.ts:51, instance.ts:120, instance.ts:148
  • Nets, routes, and coupling. NetSchema records terminal membership. Routes and junctions describe drawn connections, with separate connectivity evidence for such things as named claims and imported nets. deriveNetConnectivity() distinguishes physical and logical connectivity. A wire crossing without a junction does not create a join by coordinate alone. InductorCouplingSchema records two winding instance IDs, each dotted pin, and k as value text. connectivity schema:66, connectivity schema:145, routing.ts:58, deriveNetConnectivity():99
  • Portable format. The XFLY6S fixture has portable schemaVersion: 86, one document, 21 instances including formal port symbols, 13 nets, 43 routes, 17 junctions, one coupling, and an empty simulationFolders array. Compact field names and defaults are decoded into the runtime model, whose schema version is 58 in the archive. parseProject() and serializeCompactProject() are the versioned boundary. Use the codec to interpret the JSON rather than treating the compact and runtime fields as interchangeable. xfly6s.icproj.json:1, owned-project-file.ts:21, common.ts:11, load.ts:648, save.ts:100

The structural XFLY6S source makes the topology concrete. Six MOSFETs form two legs. C1 XA YB and C2 XB YA cross-link the legs. L1 YA VOUT and L2 VOUT YB have opposite output-current orientations even though K1 is positive .95; the project records both dotted ends at pin 1. N is an illustrative level-1 MOS model, and formal ports expose A, MA, ABAR, B, MB, and BBAR. The generator imports the subcircuit using importSpiceSources(), attaches bulk and sizing bindings, lays out power paths and ports, and emits a canonical JSON fixture plus the structural .sp source. xfly6s.sp:2, generate-starters.mjs:47, generate-starters.mjs:131, generate-starters.mjs:445

Switching information and timing

Layer Representation Scope
Native starter Gate nets and ports, two phase labels, and a description identifying composite middle-switch commands MA and MB. The starter exposes a circuit interface. It has no executable gate waveforms, transient setup, or period-by-period state schedule. Upstream Canvas can express electrical control bindings, voltage/current source waveforms (dc, pulse, sin, pwl), and separate simulation intent, but the PE starter does not populate these as a converter testbench. starters/index.json:21, xfly6s.sp:3, source-waveform.ts:34, project.ts:139
Analytical reference recommend.js records excitation levels and pulse counts. engine.js maps conversion gain and duty to reference coefficients. The optional state-table evaluator takes fractions and per-device signed normalized current arrays. The excitation metadata supports screening near specified cancellation conditions. The state table is supplied explicitly and belongs to the analysis input, not the schematic or simulator. recommend.js:3, engine.js:8, engine.js:14
Runnable deck SPICE .param statements and behavioral voltage sources compute phase time, pulses, complementary gates, and dead time. .tran governs simulation timing. The original XFLY6S startup deck has FSW=100Meg, TDEAD=50p, and DUTY=0.40. The B phase is shifted by TS/2; source-referenced drivers act on the six MOSFETs. XFLY8S uses quarter-period timing offsets and its own frequency convention. xfly6s_transient.cir:5, xfly6s_transient.cir:43, xfly6s_transient.cir:103, xfly8s_transient.cir:114

The starter uses 1u windings, .95 coupling and 10u input/output capacitances. The original startup deck uses 3n, .70, 1u input and 100n output, plus the models and gating described above. This is concrete evidence that matching the starter's identity or signature does not imply it is the executed testbench. xfly6s.sp:10, xfly6s_transient.cir:19

Load, edit, save, and export

  1. The shell fetches starters/index.json and, on first load with no recovered project or pending request, defaults to XFLY6S. Gallery selection opens reference analysis. Edit schematic explicitly chooses the starter. openStarter() fetches JSON and sends a ticketed pe:load. The editor validates same origin and sender, parses the project, and keeps the existing circuit on parse failure. pe.js:100, pe.js:117, pe.js:185, pe.js:350, editor.tsx:46
  2. The editor owns operations and undo. Its controller invokes the edit engine with revisioned transactions and validates candidates before applying them. App reports the committed project to PowerEditor, which emits pe:snapshot. The shell uses origin, frame identity, and request IDs to ignore unrelated and stale messages. document-controller.ts:426, App.tsx:906, editor.tsx:32, pe.js:239
  3. The shell captures the first accepted signature of the selected starter. The project comparison includes top cell, instance IDs/symbols/netlist data, formal ports/parameters, names and net terminal membership, couplings, no-connects, definitions, and source. It excludes visual placement itself. Equal signatures enable the separate reference action, and a change detected by the signature disables it. This is an equality check over selected serialized fields, so it should not be treated as a graph-equivalence proof. electrical-signature.ts:4, pe.js:268, pe.js:287
  4. saveLocal() stores the current canonical project, starter ID and signature baseline in origin-scoped browser localStorage. The workbench can download openpels.icproj.json and reopen a local JSON project with a 10 MB import limit. A deliberately imported project has no starter assigned. pe.js:126, pe.js:280, pe.js:314
  5. The native editor's file commands export graphics from the current document. Design export goes through exportDesignNetlist() and the design-netlist compiler/printers, using the selected format, project, optional root cell and naming profile. The code exposes SPICE and Spectre (SCS) formats. The starter checker exercised a structural SPICE round trip, and Chrome verified SVG download. Spectre output compatibility was inspected in code; no Spectre run was tested. editor-file-commands.ts:107, editor-file-commands.ts:165, netlist-mode.ts:8, printers.ts:500

Analog Canvas integration boundary

The README pins Analog Canvas upstream commit df9afb17d88a6925cdbf8a6f87e68175029e8280. The reused editor supplies symbols/components, wire editing, hierarchy, transactions, undo, source import and export. OpenPELS adds PowerEditor, a desktop-style browser host, the snapshot/signature bridge, curated starters, workbench navigation and independent reference and simulation views. Its EditorServices has no identity or project store, disables community, agent, native simulation and external links, and retains local components and browser export delivery. The native editor source contains broader capabilities, but these settings define the integrated UI. The Python server never receives a project snapshot or any native schematic connection graph. README.md:32, editor.tsx:12, editor.tsx:86, server.py:68