Spaces:
Running
Running
Publish OpenPELS workspace
Browse files- README.md +4 -7
- simulator_bridge.js +3 -142
- simulator_frame.py +3 -16
- static/index.html +2 -100
- static/openpels-source.zip +2 -2
- static/pe.css +0 -284
- static/pe.js +5 -10
- static/simulator.js +3 -21
- static/testbenches.js +0 -153
README.md
CHANGED
|
@@ -12,20 +12,17 @@ license: agpl-3.0
|
|
| 12 |
# OpenPELS: Open Source Power Electronics Librarian Systems
|
| 13 |
|
| 14 |
Editable power-electronics schematics and a loss-mechanism scoreboard.
|
| 15 |
-
Circuit editing, analytical comparison and
|
| 16 |
|
| 17 |
Start from coupled buck, XFLY6S or XFLY8S; edit components and wires, undo,
|
| 18 |
and download portable projects, SVG and SPICE design netlists. Compare
|
| 19 |
curated 2:1 / 4:1 topology models with die-area and passive constraints.
|
| 20 |
6:1, 8:1 and 16:1 numerical models remain explicitly pending.
|
| 21 |
|
| 22 |
-
The
|
| 23 |
-
long settling and DCR mismatch for XFLY6S, XFLY8S and C3L. View parameters
|
| 24 |
-
and complete source, download individual decks or all nine with a local
|
| 25 |
-
NGSpice runner. Their operating points remain independent of canvas edits.
|
| 26 |
-
The integrated Simulator tab runs the original cases or parameterized models
|
| 27 |
with NGSpice and displays voltage/current/capacitor waveforms, measurements,
|
| 28 |
-
and executed-circuit downloads within the same workbench.
|
|
|
|
| 29 |
|
| 30 |
The integrated runtime has no foundry PDK. Generic
|
| 31 |
MOSFET starters describe connectivity; the scoreboard is a reference model,
|
|
|
|
| 12 |
# OpenPELS: Open Source Power Electronics Librarian Systems
|
| 13 |
|
| 14 |
Editable power-electronics schematics and a loss-mechanism scoreboard.
|
| 15 |
+
Circuit editing, analytical comparison and integrated NGSpice simulation.
|
| 16 |
|
| 17 |
Start from coupled buck, XFLY6S or XFLY8S; edit components and wires, undo,
|
| 18 |
and download portable projects, SVG and SPICE design netlists. Compare
|
| 19 |
curated 2:1 / 4:1 topology models with die-area and passive constraints.
|
| 20 |
6:1, 8:1 and 16:1 numerical models remain explicitly pending.
|
| 21 |
|
| 22 |
+
The Simulator tab compares parameterized XFLY6S, XFLY8S and C3L models
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
with NGSpice and displays voltage/current/capacitor waveforms, measurements,
|
| 24 |
+
and executed-circuit downloads within the same workbench. Simulator controls
|
| 25 |
+
are independent of canvas edits and analytical comparison inputs.
|
| 26 |
|
| 27 |
The integrated runtime has no foundry PDK. Generic
|
| 28 |
MOSFET starters describe connectivity; the scoreboard is a reference model,
|
simulator_bridge.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
| 1 |
/* Same-origin asynchronous jobs, while retaining the original XFLY controls. */
|
| 2 |
async function openpelsSimulationFetch(path, options) {
|
| 3 |
-
const kind = path.endsWith("sweep-case")
|
| 4 |
-
? "sweep-case"
|
| 5 |
-
: path.endsWith("source")
|
| 6 |
-
? "source"
|
| 7 |
-
: "run";
|
| 8 |
const response = await fetch("/api/simulation/jobs", {
|
| 9 |
method: "POST",
|
| 10 |
headers: { "Content-Type": "application/json" },
|
|
@@ -59,141 +55,6 @@ function openpelsRenderArtifacts(result) {
|
|
| 59 |
target.style.display = target.childElementCount ? "flex" : "none";
|
| 60 |
}
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)(meg|[tgkmunpf]?)$/i,
|
| 65 |
-
);
|
| 66 |
-
if (!match) return null;
|
| 67 |
-
const scales = {
|
| 68 |
-
"": 1,
|
| 69 |
-
t: 1e12,
|
| 70 |
-
g: 1e9,
|
| 71 |
-
meg: 1e6,
|
| 72 |
-
k: 1e3,
|
| 73 |
-
m: 1e-3,
|
| 74 |
-
u: 1e-6,
|
| 75 |
-
n: 1e-9,
|
| 76 |
-
p: 1e-12,
|
| 77 |
-
f: 1e-15,
|
| 78 |
-
};
|
| 79 |
-
return Number(match[1]) * scales[match[2].toLowerCase()];
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
window.addEventListener("DOMContentLoaded", async () => {
|
| 83 |
-
const select = document.getElementById("sourceCase"),
|
| 84 |
-
button = document.getElementById("runOriginal");
|
| 85 |
-
const cases = new Map();
|
| 86 |
-
let running = false;
|
| 87 |
-
try {
|
| 88 |
-
const response = await fetch("/testbenches/index.json");
|
| 89 |
-
if (!response.ok) throw Error("Source case library unavailable");
|
| 90 |
-
const catalog = await response.json();
|
| 91 |
-
for (const group of catalog.circuits) {
|
| 92 |
-
for (const bench of group.cases) {
|
| 93 |
-
cases.set(bench.id, { group, bench });
|
| 94 |
-
const option = document.createElement("option");
|
| 95 |
-
option.value = bench.id;
|
| 96 |
-
option.textContent = group.name + " · " + bench.title;
|
| 97 |
-
select.append(option);
|
| 98 |
-
}
|
| 99 |
-
}
|
| 100 |
-
function selectOriginal(id) {
|
| 101 |
-
const source = cases.get(id);
|
| 102 |
-
if (!source) return false;
|
| 103 |
-
select.value = id;
|
| 104 |
-
const p = source.bench.parameters;
|
| 105 |
-
const values = {
|
| 106 |
-
vin: openpelsScalar(p.VIN),
|
| 107 |
-
targetVout: openpelsScalar(p.VOUT_TARGET),
|
| 108 |
-
iout: openpelsScalar(p.IOUT_NOM),
|
| 109 |
-
lout: openpelsScalar(p.LOUT) * 1e9,
|
| 110 |
-
cfly: openpelsScalar(p.CFLY) * 1e9,
|
| 111 |
-
k: openpelsScalar(p.KCOUP),
|
| 112 |
-
dcr1: openpelsScalar(p.LDCR1 ?? p.LDCR) * 1e3,
|
| 113 |
-
dcr2: openpelsScalar(p.LDCR2 ?? p.LDCR) * 1e3,
|
| 114 |
-
gateDrive: openpelsScalar(p.VDRV),
|
| 115 |
-
gateCap: 0,
|
| 116 |
-
ron: 2,
|
| 117 |
-
coff: openpelsScalar(p.COFF) * 1e12,
|
| 118 |
-
stop: Number.parseFloat(source.bench.duration),
|
| 119 |
-
step: 50,
|
| 120 |
-
};
|
| 121 |
-
for (const [key, value] of Object.entries(values)) {
|
| 122 |
-
const input = document.getElementById(key);
|
| 123 |
-
input.value = value;
|
| 124 |
-
input.dispatchEvent(new Event("input", { bubbles: true }));
|
| 125 |
-
}
|
| 126 |
-
document
|
| 127 |
-
.querySelectorAll('input[name="topology"]')
|
| 128 |
-
.forEach((input) => (input.checked = input.value === source.group.id));
|
| 129 |
-
document.getElementById("sourceMode").textContent =
|
| 130 |
-
source.group.name +
|
| 131 |
-
" · " +
|
| 132 |
-
source.bench.title +
|
| 133 |
-
" uses its original circuit and timing. Run Simulation below uses the editable controls.";
|
| 134 |
-
return true;
|
| 135 |
-
}
|
| 136 |
-
async function runOriginal() {
|
| 137 |
-
if (running || document.getElementById("runButton").disabled) return;
|
| 138 |
-
const source = cases.get(select.value);
|
| 139 |
-
if (!source) return;
|
| 140 |
-
running = true;
|
| 141 |
-
document.getElementById("sourceMode").textContent =
|
| 142 |
-
source.group.name +
|
| 143 |
-
" · " +
|
| 144 |
-
source.bench.title +
|
| 145 |
-
" · original circuit and timing";
|
| 146 |
-
button.disabled = true;
|
| 147 |
-
document.getElementById("runButton").disabled = true;
|
| 148 |
-
openpelsRenderArtifacts({ artifacts: [] });
|
| 149 |
-
const stopProgress = showProgress([source.group.id]);
|
| 150 |
-
resetSweep();
|
| 151 |
-
try {
|
| 152 |
-
const response = await openpelsSimulationFetch("/api/source", {
|
| 153 |
-
body: JSON.stringify({ case_id: source.bench.id }),
|
| 154 |
-
});
|
| 155 |
-
const data = await response.json();
|
| 156 |
-
if (!response.ok) throw Error(data.error ?? "Simulation failed");
|
| 157 |
-
stopProgress();
|
| 158 |
-
const image = document.createElement("img");
|
| 159 |
-
image.src = data.plot_url;
|
| 160 |
-
image.alt =
|
| 161 |
-
"NGSpice source-case voltage, current and flying-capacitor waveforms";
|
| 162 |
-
document.getElementById("plotWrap").replaceChildren(image);
|
| 163 |
-
renderMetrics(data.metrics);
|
| 164 |
-
setSummary(data.metrics, data.settings, data.elapsed_s);
|
| 165 |
-
openpelsRenderArtifacts(data);
|
| 166 |
-
document.getElementById("status").textContent =
|
| 167 |
-
"Completed original " + source.bench.id;
|
| 168 |
-
} catch (error) {
|
| 169 |
-
stopProgress();
|
| 170 |
-
document.getElementById("status").textContent = error.message;
|
| 171 |
-
document.getElementById("plotWrap").textContent = error.message;
|
| 172 |
-
} finally {
|
| 173 |
-
running = false;
|
| 174 |
-
button.disabled = false;
|
| 175 |
-
document.getElementById("runButton").disabled = false;
|
| 176 |
-
}
|
| 177 |
-
}
|
| 178 |
-
select.onchange = () => selectOriginal(select.value);
|
| 179 |
-
button.onclick = runOriginal;
|
| 180 |
-
window.addEventListener("message", (event) => {
|
| 181 |
-
if (
|
| 182 |
-
event.origin !== location.origin ||
|
| 183 |
-
event.source !== parent ||
|
| 184 |
-
event.data?.type !== "pe:simulate-source"
|
| 185 |
-
)
|
| 186 |
-
return;
|
| 187 |
-
if (running || document.getElementById("runButton").disabled) {
|
| 188 |
-
parent.postMessage({ type: "pe:simulator-busy" }, location.origin);
|
| 189 |
-
return;
|
| 190 |
-
}
|
| 191 |
-
if (selectOriginal(event.data.caseId) && event.data.run)
|
| 192 |
-
void runOriginal();
|
| 193 |
-
});
|
| 194 |
-
parent.postMessage({ type: "pe:simulator-ready" }, location.origin);
|
| 195 |
-
} catch (error) {
|
| 196 |
-
button.disabled = true;
|
| 197 |
-
document.getElementById("status").textContent = error.message;
|
| 198 |
-
}
|
| 199 |
});
|
|
|
|
| 1 |
/* Same-origin asynchronous jobs, while retaining the original XFLY controls. */
|
| 2 |
async function openpelsSimulationFetch(path, options) {
|
| 3 |
+
const kind = path.endsWith("sweep-case") ? "sweep-case" : "run";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
const response = await fetch("/api/simulation/jobs", {
|
| 5 |
method: "POST",
|
| 6 |
headers: { "Content-Type": "application/json" },
|
|
|
|
| 55 |
target.style.display = target.childElementCount ? "flex" : "none";
|
| 56 |
}
|
| 57 |
|
| 58 |
+
window.addEventListener("DOMContentLoaded", () => {
|
| 59 |
+
parent.postMessage({ type: "pe:simulator-ready" }, location.origin);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
});
|
simulator_frame.py
CHANGED
|
@@ -1,12 +1,4 @@
|
|
| 1 |
"""Host adaptation for the pinned simulator UI; numerical source stays unchanged."""
|
| 2 |
-
import re
|
| 3 |
-
|
| 4 |
-
SOURCE_PANEL = '''<div class="source-bench-panel">
|
| 5 |
-
<div><strong>Original testbench</strong><span id="sourceMode">Run a source case or use the controls below for a parameterized model.</span></div>
|
| 6 |
-
<div><select id="sourceCase" aria-label="Original source testbench"></select>
|
| 7 |
-
<button type="button" id="runOriginal">Run original case</button></div>
|
| 8 |
-
</div><div id="runArtifacts" class="run-artifacts"></div>'''
|
| 9 |
-
|
| 10 |
|
| 11 |
def simulator_html(original):
|
| 12 |
html = original.replace('<title>Xfly / C3L Comparison GUI - Chen / Kudva</title>', '<title>OpenPELS · NGSpice simulator</title>')
|
|
@@ -25,23 +17,18 @@ def simulator_html(original):
|
|
| 25 |
html = html.replace('<div class="actions">\n <button id="runButton"', '<label class="check optional-sweep"><input type="checkbox" id="includeSweep"> Include optional 45-point efficiency sweep</label>\n <div class="actions">\n <button id="runButton"')
|
| 26 |
html = html.replace('Runs after the comparison plot.', 'Optional · enable in the controls before running.')
|
| 27 |
html = html.replace('<table id="metricsTable" hidden>', '<div class="metrics-scroll"><table id="metricsTable" hidden>').replace('</table>', '</table></div>', 1)
|
| 28 |
-
html = html.replace('<main>',
|
| 29 |
html = html.replace('<script>\n const form', '<script src="/simulator/bridge.js"></script>\n <script>\n const form', 1)
|
| 30 |
-
html = html.replace(' runButton.disabled = true;', " runButton.disabled = true;\n openpelsRenderArtifacts({artifacts:[]});
|
| 31 |
html = html.replace('Efficiency (%)', 'Modeled efficiency (%)').replace('Best Efficiency', 'Best modeled efficiency')
|
| 32 |
html = html.replace('</head>', '''<style>
|
| 33 |
body{background:#f5f6f8}header{position:static;padding:14px 22px}h1{font-size:17px}
|
| 34 |
:root{--blue:#e15c34;--line:#e3e7eb;--shadow:none}button{background:#e15c34}
|
| 35 |
-
.source-bench-panel{padding:16px 22px;background:white;border-bottom:1px solid #e3e7eb;display:flex;align-items:center;justify-content:space-between;gap:15px;font-size:12px}
|
| 36 |
-
.source-bench-panel>div{display:flex;align-items:center;gap:12px}.source-bench-panel span{color:#8793a0;font-size:10px;max-width:460px}
|
| 37 |
-
#sourceCase{font:11px inherit;padding:8px;border:1px solid #dce0e5;border-radius:6px;background:white;max-width:260px}
|
| 38 |
-
#runOriginal{border:0;border-radius:6px;color:white;padding:9px 12px;font:11px inherit;white-space:nowrap}
|
| 39 |
.run-artifacts{display:none;padding:12px 22px;background:#fff7f1;border-bottom:1px solid #eddfd7;font-size:11px;gap:8px;flex-wrap:wrap}
|
| 40 |
.run-artifacts a{color:#af502e;border:1px solid #e4cabb;border-radius:4px;padding:6px 8px;text-decoration:none;background:#fff}
|
| 41 |
section.results{min-width:0}.metrics-scroll{max-width:100%;overflow-x:auto}
|
|
|
|
| 42 |
.optional-sweep{font-size:11px;color:#74818e;margin:10px 0} .optional-sweep input{width:auto}
|
| 43 |
-
@media(max-width:1000px){.source-bench-panel,.source-bench-panel>div{align-items:flex-start;flex-direction:column}.source-bench-panel span{max-width:none}}
|
| 44 |
-
@media(max-width:600px){main{display:flex;flex-direction:column}.topology-strip{grid-template-columns:repeat(3,minmax(0,1fr))}.source-bench-panel{padding:14px}.status{white-space:normal}}
|
| 45 |
</style></head>''')
|
| 46 |
if 'includeSweep' not in html or '/simulator/bridge.js' not in html:
|
| 47 |
raise ValueError('Pinned simulator layout contract changed')
|
|
|
|
| 1 |
"""Host adaptation for the pinned simulator UI; numerical source stays unchanged."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
def simulator_html(original):
|
| 4 |
html = original.replace('<title>Xfly / C3L Comparison GUI - Chen / Kudva</title>', '<title>OpenPELS · NGSpice simulator</title>')
|
|
|
|
| 17 |
html = html.replace('<div class="actions">\n <button id="runButton"', '<label class="check optional-sweep"><input type="checkbox" id="includeSweep"> Include optional 45-point efficiency sweep</label>\n <div class="actions">\n <button id="runButton"')
|
| 18 |
html = html.replace('Runs after the comparison plot.', 'Optional · enable in the controls before running.')
|
| 19 |
html = html.replace('<table id="metricsTable" hidden>', '<div class="metrics-scroll"><table id="metricsTable" hidden>').replace('</table>', '</table></div>', 1)
|
| 20 |
+
html = html.replace('<main>', '<div id="runArtifacts" class="run-artifacts"></div>\n<main>', 1)
|
| 21 |
html = html.replace('<script>\n const form', '<script src="/simulator/bridge.js"></script>\n <script>\n const form', 1)
|
| 22 |
+
html = html.replace(' runButton.disabled = true;', " runButton.disabled = true;\n openpelsRenderArtifacts({artifacts:[]});")
|
| 23 |
html = html.replace('Efficiency (%)', 'Modeled efficiency (%)').replace('Best Efficiency', 'Best modeled efficiency')
|
| 24 |
html = html.replace('</head>', '''<style>
|
| 25 |
body{background:#f5f6f8}header{position:static;padding:14px 22px}h1{font-size:17px}
|
| 26 |
:root{--blue:#e15c34;--line:#e3e7eb;--shadow:none}button{background:#e15c34}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
.run-artifacts{display:none;padding:12px 22px;background:#fff7f1;border-bottom:1px solid #eddfd7;font-size:11px;gap:8px;flex-wrap:wrap}
|
| 28 |
.run-artifacts a{color:#af502e;border:1px solid #e4cabb;border-radius:4px;padding:6px 8px;text-decoration:none;background:#fff}
|
| 29 |
section.results{min-width:0}.metrics-scroll{max-width:100%;overflow-x:auto}
|
| 30 |
+
@media(max-width:600px){main{display:flex;flex-direction:column}.topology-strip{grid-template-columns:repeat(3,minmax(0,1fr))}.status{white-space:normal}}
|
| 31 |
.optional-sweep{font-size:11px;color:#74818e;margin:10px 0} .optional-sweep input{width:auto}
|
|
|
|
|
|
|
| 32 |
</style></head>''')
|
| 33 |
if 'includeSweep' not in html or '/simulator/bridge.js' not in html:
|
| 34 |
raise ValueError('Pinned simulator layout contract changed')
|
static/index.html
CHANGED
|
@@ -24,7 +24,6 @@
|
|
| 24 |
<button class="active" data-view="design">Schematic</button
|
| 25 |
><button data-view="simulator">Simulator</button
|
| 26 |
><button data-view="compare">Loss scoreboard <span>↗</span></button>
|
| 27 |
-
<button data-view="testbenches">Testbenches</button>
|
| 28 |
</nav>
|
| 29 |
<div class="file-actions">
|
| 30 |
<button id="open-project">Open project</button
|
|
@@ -136,7 +135,7 @@
|
|
| 136 |
<details>
|
| 137 |
<summary>Model limits</summary>
|
| 138 |
<p class="fineprint">
|
| 139 |
-
NGSpice runs available
|
| 140 |
Editable schematic starters use structural MOSFET placeholders. No
|
| 141 |
foundry PDK is connected. Coupling values are illustrative. The TSMC
|
| 142 |
180 nm figure of merit is user-supplied; Ron × area is editable and
|
|
@@ -159,101 +158,6 @@
|
|
| 159 |
data-src="./compare/index.html"
|
| 160 |
></iframe>
|
| 161 |
</section>
|
| 162 |
-
<section
|
| 163 |
-
id="testbench-view"
|
| 164 |
-
class="testbench-view"
|
| 165 |
-
hidden
|
| 166 |
-
aria-label="Original XFLY testbenches"
|
| 167 |
-
>
|
| 168 |
-
<div class="bench-intro">
|
| 169 |
-
<div>
|
| 170 |
-
<div class="eyebrow">SIMULATION LIBRARY</div>
|
| 171 |
-
<h1>Start from a working testbench.</h1>
|
| 172 |
-
<p>
|
| 173 |
-
Nine original NGSpice decks from the XFLY Space, with gate drives,
|
| 174 |
-
device models, parasitics and measurements.
|
| 175 |
-
</p>
|
| 176 |
-
</div>
|
| 177 |
-
<div class="bench-actions">
|
| 178 |
-
<a
|
| 179 |
-
class="bench-link primary"
|
| 180 |
-
href="./testbenches/xfly-testbenches.zip"
|
| 181 |
-
download
|
| 182 |
-
>↓ Download all 9 + runner</a
|
| 183 |
-
>
|
| 184 |
-
</div>
|
| 185 |
-
</div>
|
| 186 |
-
<p class="bench-scope">
|
| 187 |
-
These standalone source circuits use their original 3.6 V input, 0.65 V
|
| 188 |
-
output target and 4 A current target. Canvas edits and scoreboard inputs
|
| 189 |
-
have separate settings. Pure buck, 2SBUCK, boost and isolated
|
| 190 |
-
testbenches are not supplied by this source.
|
| 191 |
-
</p>
|
| 192 |
-
<div id="testbench-circuits" class="testbench-circuits"></div>
|
| 193 |
-
<section class="bench-detail" aria-label="Selected testbench source">
|
| 194 |
-
<div class="bench-detail-heading">
|
| 195 |
-
<div>
|
| 196 |
-
<span class="eyebrow">SELECTED CASE</span>
|
| 197 |
-
<h2 id="bench-title">Loading testbenches…</h2>
|
| 198 |
-
</div>
|
| 199 |
-
<div class="bench-actions">
|
| 200 |
-
<a
|
| 201 |
-
id="bench-source"
|
| 202 |
-
class="bench-link"
|
| 203 |
-
target="_blank"
|
| 204 |
-
rel="noopener"
|
| 205 |
-
>Source ↗</a
|
| 206 |
-
><button id="bench-copy" disabled>Copy source</button
|
| 207 |
-
><button id="bench-simulate" class="primary">
|
| 208 |
-
▶ Simulate this case</button
|
| 209 |
-
><a id="bench-download" class="bench-link primary" hidden
|
| 210 |
-
>↓ Download .cir</a
|
| 211 |
-
>
|
| 212 |
-
</div>
|
| 213 |
-
</div>
|
| 214 |
-
<div id="bench-summary" class="bench-summary"></div>
|
| 215 |
-
<div class="bench-content">
|
| 216 |
-
<aside>
|
| 217 |
-
<h3>Gating sequence</h3>
|
| 218 |
-
<p id="bench-gating"></p>
|
| 219 |
-
<p>
|
| 220 |
-
The complete source includes local gate-source drives,
|
| 221 |
-
complementary switches and the original dead time. Four-clock
|
| 222 |
-
cases use DUTY/2 sub-phase pulses.
|
| 223 |
-
</p>
|
| 224 |
-
<h3>Run locally</h3>
|
| 225 |
-
<p>
|
| 226 |
-
Download and extract the full bundle, install NGSpice, then run:
|
| 227 |
-
</p>
|
| 228 |
-
<pre id="bench-run-command"></pre>
|
| 229 |
-
<p>
|
| 230 |
-
The runner creates the output folders required by the source
|
| 231 |
-
decks. Run original cases directly in the workbench Simulator tab.
|
| 232 |
-
</p>
|
| 233 |
-
<details>
|
| 234 |
-
<summary>All source parameters</summary>
|
| 235 |
-
<table>
|
| 236 |
-
<tbody id="bench-parameters"></tbody>
|
| 237 |
-
</table>
|
| 238 |
-
</details>
|
| 239 |
-
<details>
|
| 240 |
-
<summary>Source revision and checksum</summary>
|
| 241 |
-
<p>Revision <code id="bench-revision"></code></p>
|
| 242 |
-
<code id="bench-sha" class="bench-sha"></code>
|
| 243 |
-
</details>
|
| 244 |
-
<p class="fineprint">
|
| 245 |
-
Generic Level-1 NMOS models are illustrative. Each download
|
| 246 |
-
preserves the original circuit, initial conditions and transient
|
| 247 |
-
analysis.
|
| 248 |
-
</p>
|
| 249 |
-
</aside>
|
| 250 |
-
<div class="bench-source-code">
|
| 251 |
-
<div id="bench-file-name">Original NGSpice source</div>
|
| 252 |
-
<pre><code id="bench-code">Select a testbench above.</code></pre>
|
| 253 |
-
</div>
|
| 254 |
-
</div>
|
| 255 |
-
</section>
|
| 256 |
-
</section>
|
| 257 |
<section
|
| 258 |
id="simulator-view"
|
| 259 |
hidden
|
|
@@ -261,9 +165,7 @@
|
|
| 261 |
>
|
| 262 |
<div class="simulator-caption">
|
| 263 |
<strong>Transient simulation</strong
|
| 264 |
-
><span
|
| 265 |
-
>Source testbenches and parameterized variants · independent of canvas
|
| 266 |
-
edits</span
|
| 267 |
><span id="simulator-status" role="status"></span>
|
| 268 |
</div>
|
| 269 |
<iframe id="simulator" title="OpenPELS NGSpice simulator"></iframe>
|
|
|
|
| 24 |
<button class="active" data-view="design">Schematic</button
|
| 25 |
><button data-view="simulator">Simulator</button
|
| 26 |
><button data-view="compare">Loss scoreboard <span>↗</span></button>
|
|
|
|
| 27 |
</nav>
|
| 28 |
<div class="file-actions">
|
| 29 |
<button id="open-project">Open project</button
|
|
|
|
| 135 |
<details>
|
| 136 |
<summary>Model limits</summary>
|
| 137 |
<p class="fineprint">
|
| 138 |
+
NGSpice runs the available circuit models in the Simulator tab.
|
| 139 |
Editable schematic starters use structural MOSFET placeholders. No
|
| 140 |
foundry PDK is connected. Coupling values are illustrative. The TSMC
|
| 141 |
180 nm figure of merit is user-supplied; Ron × area is editable and
|
|
|
|
| 158 |
data-src="./compare/index.html"
|
| 159 |
></iframe>
|
| 160 |
</section>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
<section
|
| 162 |
id="simulator-view"
|
| 163 |
hidden
|
|
|
|
| 165 |
>
|
| 166 |
<div class="simulator-caption">
|
| 167 |
<strong>Transient simulation</strong
|
| 168 |
+
><span>XFLY6S, XFLY8S and C3L · independent of canvas edits</span
|
|
|
|
|
|
|
| 169 |
><span id="simulator-status" role="status"></span>
|
| 170 |
</div>
|
| 171 |
<iframe id="simulator" title="OpenPELS NGSpice simulator"></iframe>
|
static/openpels-source.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:530ec9b56a68ac8789c349f89a354b54fa79e01c502e79b9807a5d4054970106
|
| 3 |
+
size 24793563
|
static/pe.css
CHANGED
|
@@ -534,287 +534,6 @@ footer a + a {
|
|
| 534 |
height: 1000px;
|
| 535 |
}
|
| 536 |
}
|
| 537 |
-
/* Original standalone NGSpice case library. */
|
| 538 |
-
.testbench-view {
|
| 539 |
-
max-width: 1460px;
|
| 540 |
-
min-height: calc(100vh - 114px);
|
| 541 |
-
margin: auto;
|
| 542 |
-
padding: 30px 32px 40px;
|
| 543 |
-
}
|
| 544 |
-
.bench-intro {
|
| 545 |
-
display: flex;
|
| 546 |
-
align-items: center;
|
| 547 |
-
justify-content: space-between;
|
| 548 |
-
gap: 20px;
|
| 549 |
-
}
|
| 550 |
-
.bench-intro h1 {
|
| 551 |
-
font-size: 27px;
|
| 552 |
-
margin: 10px 0;
|
| 553 |
-
}
|
| 554 |
-
.bench-intro p,
|
| 555 |
-
.bench-scope {
|
| 556 |
-
font-size: 12px;
|
| 557 |
-
line-height: 1.7;
|
| 558 |
-
color: #7e8995;
|
| 559 |
-
}
|
| 560 |
-
.bench-scope {
|
| 561 |
-
padding: 13px 16px;
|
| 562 |
-
background: #f0f2f5;
|
| 563 |
-
border-left: 3px solid #d9dfe5;
|
| 564 |
-
margin: 20px 0;
|
| 565 |
-
}
|
| 566 |
-
.bench-actions {
|
| 567 |
-
display: flex;
|
| 568 |
-
align-items: center;
|
| 569 |
-
gap: 9px;
|
| 570 |
-
flex-wrap: wrap;
|
| 571 |
-
}
|
| 572 |
-
.bench-link {
|
| 573 |
-
font-size: 11px;
|
| 574 |
-
display: inline-block;
|
| 575 |
-
border: 1px solid #dce0e5;
|
| 576 |
-
border-radius: 6px;
|
| 577 |
-
padding: 9px 12px;
|
| 578 |
-
background: white;
|
| 579 |
-
color: #536675;
|
| 580 |
-
white-space: nowrap;
|
| 581 |
-
}
|
| 582 |
-
.bench-link.primary {
|
| 583 |
-
background: var(--accent);
|
| 584 |
-
color: #fff;
|
| 585 |
-
border-color: var(--accent);
|
| 586 |
-
}
|
| 587 |
-
.testbench-circuits {
|
| 588 |
-
display: grid;
|
| 589 |
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
| 590 |
-
gap: 18px;
|
| 591 |
-
margin: 24px 0;
|
| 592 |
-
}
|
| 593 |
-
.bench-card {
|
| 594 |
-
background: white;
|
| 595 |
-
border: 1px solid var(--line);
|
| 596 |
-
border-radius: 9px;
|
| 597 |
-
padding: 18px;
|
| 598 |
-
}
|
| 599 |
-
.bench-card img {
|
| 600 |
-
display: block;
|
| 601 |
-
width: 100%;
|
| 602 |
-
height: 155px;
|
| 603 |
-
object-fit: contain;
|
| 604 |
-
margin-bottom: 16px;
|
| 605 |
-
}
|
| 606 |
-
.bench-card h2 {
|
| 607 |
-
font:
|
| 608 |
-
700 16px Manrope,
|
| 609 |
-
Arial;
|
| 610 |
-
margin: 0 0 7px;
|
| 611 |
-
}
|
| 612 |
-
.bench-card p {
|
| 613 |
-
font-size: 11px;
|
| 614 |
-
color: #85909b;
|
| 615 |
-
line-height: 1.7;
|
| 616 |
-
min-height: 34px;
|
| 617 |
-
}
|
| 618 |
-
.bench-cases {
|
| 619 |
-
display: flex;
|
| 620 |
-
gap: 6px;
|
| 621 |
-
flex-wrap: wrap;
|
| 622 |
-
margin-top: 13px;
|
| 623 |
-
}
|
| 624 |
-
.bench-cases button {
|
| 625 |
-
font-size: 10px;
|
| 626 |
-
padding: 8px 10px;
|
| 627 |
-
}
|
| 628 |
-
.bench-cases button.active {
|
| 629 |
-
border-color: #e7ab95;
|
| 630 |
-
background: #fff0e9;
|
| 631 |
-
color: #b4492c;
|
| 632 |
-
}
|
| 633 |
-
.bench-detail {
|
| 634 |
-
border: 1px solid var(--line);
|
| 635 |
-
background: #fff;
|
| 636 |
-
border-radius: 9px;
|
| 637 |
-
overflow: hidden;
|
| 638 |
-
}
|
| 639 |
-
.bench-detail-heading {
|
| 640 |
-
padding: 22px 23px;
|
| 641 |
-
display: flex;
|
| 642 |
-
align-items: center;
|
| 643 |
-
justify-content: space-between;
|
| 644 |
-
gap: 15px;
|
| 645 |
-
}
|
| 646 |
-
.bench-detail-heading h2 {
|
| 647 |
-
font:
|
| 648 |
-
700 18px Manrope,
|
| 649 |
-
Arial;
|
| 650 |
-
margin: 8px 0 0;
|
| 651 |
-
}
|
| 652 |
-
.bench-summary {
|
| 653 |
-
display: grid;
|
| 654 |
-
grid-template-columns: repeat(5, 1fr);
|
| 655 |
-
border-top: 1px solid #edf0f3;
|
| 656 |
-
border-bottom: 1px solid #edf0f3;
|
| 657 |
-
padding: 8px 23px;
|
| 658 |
-
background: #fcfcfd;
|
| 659 |
-
gap: 4px 16px;
|
| 660 |
-
}
|
| 661 |
-
.bench-summary div {
|
| 662 |
-
padding: 10px 0;
|
| 663 |
-
}
|
| 664 |
-
.bench-summary span {
|
| 665 |
-
display: block;
|
| 666 |
-
font-size: 9px;
|
| 667 |
-
letter-spacing: 0.2px;
|
| 668 |
-
color: #929ca7;
|
| 669 |
-
margin-bottom: 7px;
|
| 670 |
-
}
|
| 671 |
-
.bench-summary strong {
|
| 672 |
-
font-size: 12px;
|
| 673 |
-
color: #41515f;
|
| 674 |
-
font-weight: 500;
|
| 675 |
-
}
|
| 676 |
-
.bench-content {
|
| 677 |
-
display: grid;
|
| 678 |
-
grid-template-columns: 270px minmax(0, 1fr);
|
| 679 |
-
}
|
| 680 |
-
.bench-content > aside {
|
| 681 |
-
padding: 20px 23px;
|
| 682 |
-
font-size: 11px;
|
| 683 |
-
color: #86919c;
|
| 684 |
-
line-height: 1.7;
|
| 685 |
-
border-right: 1px solid var(--line);
|
| 686 |
-
}
|
| 687 |
-
.bench-content h3 {
|
| 688 |
-
font-size: 11px;
|
| 689 |
-
color: #485b6b;
|
| 690 |
-
font-weight: 600;
|
| 691 |
-
margin: 0 0 10px;
|
| 692 |
-
}
|
| 693 |
-
.bench-content aside pre {
|
| 694 |
-
white-space: pre-wrap;
|
| 695 |
-
overflow-wrap: anywhere;
|
| 696 |
-
font-size: 10px;
|
| 697 |
-
line-height: 1.6;
|
| 698 |
-
background: #f4f5f7;
|
| 699 |
-
border-radius: 5px;
|
| 700 |
-
padding: 10px;
|
| 701 |
-
}
|
| 702 |
-
.bench-content details {
|
| 703 |
-
margin-top: 17px;
|
| 704 |
-
font-size: 10px;
|
| 705 |
-
}
|
| 706 |
-
.bench-content table {
|
| 707 |
-
font-size: 9px;
|
| 708 |
-
width: 100%;
|
| 709 |
-
margin: 10px 0;
|
| 710 |
-
text-align: left;
|
| 711 |
-
}
|
| 712 |
-
.bench-content th {
|
| 713 |
-
font-weight: 500;
|
| 714 |
-
color: #667c8b;
|
| 715 |
-
}
|
| 716 |
-
.bench-content td {
|
| 717 |
-
overflow-wrap: anywhere;
|
| 718 |
-
}
|
| 719 |
-
.bench-sha {
|
| 720 |
-
display: block;
|
| 721 |
-
overflow-wrap: anywhere;
|
| 722 |
-
font-size: 9px;
|
| 723 |
-
}
|
| 724 |
-
.bench-source-code {
|
| 725 |
-
min-width: 0;
|
| 726 |
-
background: #fafbfc;
|
| 727 |
-
}
|
| 728 |
-
.bench-source-code > div {
|
| 729 |
-
font:
|
| 730 |
-
10px ui-monospace,
|
| 731 |
-
monospace;
|
| 732 |
-
padding: 14px 20px;
|
| 733 |
-
border-bottom: 1px solid var(--line);
|
| 734 |
-
color: #a0a9b3;
|
| 735 |
-
background: #f4f6f8;
|
| 736 |
-
}
|
| 737 |
-
.bench-source-code pre {
|
| 738 |
-
margin: 0;
|
| 739 |
-
padding: 20px;
|
| 740 |
-
font:
|
| 741 |
-
11px/1.7 ui-monospace,
|
| 742 |
-
SFMono-Regular,
|
| 743 |
-
Consolas,
|
| 744 |
-
monospace;
|
| 745 |
-
overflow: auto;
|
| 746 |
-
max-height: 700px;
|
| 747 |
-
tab-size: 4;
|
| 748 |
-
color: #4e6172;
|
| 749 |
-
}
|
| 750 |
-
@media (max-width: 1000px) {
|
| 751 |
-
.bench-intro {
|
| 752 |
-
align-items: flex-start;
|
| 753 |
-
flex-direction: column;
|
| 754 |
-
}
|
| 755 |
-
.bench-content {
|
| 756 |
-
grid-template-columns: 220px minmax(0, 1fr);
|
| 757 |
-
}
|
| 758 |
-
.bench-card {
|
| 759 |
-
padding: 13px;
|
| 760 |
-
}
|
| 761 |
-
}
|
| 762 |
-
@media (max-width: 740px) {
|
| 763 |
-
.testbench-view {
|
| 764 |
-
padding: 22px 14px;
|
| 765 |
-
}
|
| 766 |
-
.testbench-circuits {
|
| 767 |
-
grid-template-columns: 1fr;
|
| 768 |
-
}
|
| 769 |
-
.bench-card {
|
| 770 |
-
display: grid;
|
| 771 |
-
grid-template-columns: 90px minmax(0, 1fr);
|
| 772 |
-
gap: 0 15px;
|
| 773 |
-
}
|
| 774 |
-
.bench-card img {
|
| 775 |
-
grid-row: 1/4;
|
| 776 |
-
height: 150px;
|
| 777 |
-
margin: 0;
|
| 778 |
-
}
|
| 779 |
-
.bench-card p {
|
| 780 |
-
margin: 2px 0;
|
| 781 |
-
min-height: 0;
|
| 782 |
-
}
|
| 783 |
-
.bench-card h2 {
|
| 784 |
-
font-size: 14px;
|
| 785 |
-
}
|
| 786 |
-
.bench-cases {
|
| 787 |
-
margin-top: 9px;
|
| 788 |
-
}
|
| 789 |
-
.bench-detail-heading {
|
| 790 |
-
align-items: flex-start;
|
| 791 |
-
flex-direction: column;
|
| 792 |
-
padding: 17px;
|
| 793 |
-
}
|
| 794 |
-
.bench-summary {
|
| 795 |
-
grid-template-columns: repeat(2, 1fr);
|
| 796 |
-
padding: 8px 17px;
|
| 797 |
-
}
|
| 798 |
-
.bench-content {
|
| 799 |
-
display: flex;
|
| 800 |
-
flex-direction: column;
|
| 801 |
-
}
|
| 802 |
-
.bench-content > aside {
|
| 803 |
-
border-right: 0;
|
| 804 |
-
border-bottom: 1px solid var(--line);
|
| 805 |
-
padding: 18px;
|
| 806 |
-
}
|
| 807 |
-
.bench-source-code pre {
|
| 808 |
-
font-size: 9px;
|
| 809 |
-
max-height: 500px;
|
| 810 |
-
}
|
| 811 |
-
.topbar nav button {
|
| 812 |
-
min-width: 0;
|
| 813 |
-
font-size: 11px;
|
| 814 |
-
padding-left: 10px;
|
| 815 |
-
padding-right: 10px;
|
| 816 |
-
}
|
| 817 |
-
}
|
| 818 |
.simulator-caption {
|
| 819 |
display: flex;
|
| 820 |
align-items: center;
|
|
@@ -884,7 +603,4 @@ footer a + a {
|
|
| 884 |
padding-right: 7px;
|
| 885 |
min-width: 0;
|
| 886 |
}
|
| 887 |
-
.bench-detail-heading .bench-actions {
|
| 888 |
-
gap: 5px;
|
| 889 |
-
}
|
| 890 |
}
|
|
|
|
| 534 |
height: 1000px;
|
| 535 |
}
|
| 536 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 537 |
.simulator-caption {
|
| 538 |
display: flex;
|
| 539 |
align-items: center;
|
|
|
|
| 603 |
padding-right: 7px;
|
| 604 |
min-width: 0;
|
| 605 |
}
|
|
|
|
|
|
|
|
|
|
| 606 |
}
|
static/pe.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import { createSimulator } from "./simulator.js";
|
| 2 |
-
import { createTestbenchLibrary } from "./testbenches.js";
|
| 3 |
const $ = (s) => document.querySelector(s),
|
| 4 |
$$ = (s) => [...document.querySelectorAll(s)];
|
| 5 |
const editor = $("#editor"),
|
|
@@ -22,9 +21,6 @@ function notify(message) {
|
|
| 22 |
$("#message").classList.toggle("visible", !!message);
|
| 23 |
}
|
| 24 |
const simulator = createSimulator(notify);
|
| 25 |
-
const testbenchLibrary = createTestbenchLibrary(notify, (caseId) =>
|
| 26 |
-
showView("simulator", caseId),
|
| 27 |
-
);
|
| 28 |
function saveLocal() {
|
| 29 |
if (!current) return;
|
| 30 |
try {
|
|
@@ -99,14 +95,12 @@ async function openStarter(s) {
|
|
| 99 |
notify(e.message);
|
| 100 |
}
|
| 101 |
}
|
| 102 |
-
function showView(view
|
| 103 |
const compare = view === "compare";
|
| 104 |
$("#design-view").hidden = view !== "design";
|
| 105 |
$("#compare-view").hidden = !compare;
|
| 106 |
-
$("#testbench-view").hidden = view !== "testbenches";
|
| 107 |
$("#simulator-view").hidden = view !== "simulator";
|
| 108 |
-
if (view === "simulator") void simulator.show(
|
| 109 |
-
if (view === "testbenches") void testbenchLibrary.show(active?.id);
|
| 110 |
$$("[data-view]").forEach((b) =>
|
| 111 |
b.classList.toggle("active", b.dataset.view === view),
|
| 112 |
);
|
|
@@ -286,5 +280,6 @@ const greet = () =>
|
|
| 286 |
editor.addEventListener("load", greet);
|
| 287 |
greet();
|
| 288 |
|
| 289 |
-
if (
|
| 290 |
-
|
|
|
|
|
|
| 1 |
import { createSimulator } from "./simulator.js";
|
|
|
|
| 2 |
const $ = (s) => document.querySelector(s),
|
| 3 |
$$ = (s) => [...document.querySelectorAll(s)];
|
| 4 |
const editor = $("#editor"),
|
|
|
|
| 21 |
$("#message").classList.toggle("visible", !!message);
|
| 22 |
}
|
| 23 |
const simulator = createSimulator(notify);
|
|
|
|
|
|
|
|
|
|
| 24 |
function saveLocal() {
|
| 25 |
if (!current) return;
|
| 26 |
try {
|
|
|
|
| 95 |
notify(e.message);
|
| 96 |
}
|
| 97 |
}
|
| 98 |
+
function showView(view) {
|
| 99 |
const compare = view === "compare";
|
| 100 |
$("#design-view").hidden = view !== "design";
|
| 101 |
$("#compare-view").hidden = !compare;
|
|
|
|
| 102 |
$("#simulator-view").hidden = view !== "simulator";
|
| 103 |
+
if (view === "simulator") void simulator.show();
|
|
|
|
| 104 |
$$("[data-view]").forEach((b) =>
|
| 105 |
b.classList.toggle("active", b.dataset.view === view),
|
| 106 |
);
|
|
|
|
| 280 |
editor.addEventListener("load", greet);
|
| 281 |
greet();
|
| 282 |
|
| 283 |
+
if (location.hash === "#testbenches")
|
| 284 |
+
history.replaceState(null, "", "#simulator");
|
| 285 |
+
if (location.hash === "#simulator") showView("simulator");
|
static/simulator.js
CHANGED
|
@@ -3,16 +3,7 @@ export function createSimulator(report) {
|
|
| 3 |
const frame = document.querySelector("#simulator");
|
| 4 |
const status = document.querySelector("#simulator-status");
|
| 5 |
let ready = false,
|
| 6 |
-
starting = null
|
| 7 |
-
pendingCase = null;
|
| 8 |
-
const deliver = () => {
|
| 9 |
-
if (!ready || !pendingCase) return;
|
| 10 |
-
frame.contentWindow.postMessage(
|
| 11 |
-
{ type: "pe:simulate-source", caseId: pendingCase, run: true },
|
| 12 |
-
location.origin,
|
| 13 |
-
);
|
| 14 |
-
pendingCase = null;
|
| 15 |
-
};
|
| 16 |
window.addEventListener("message", (event) => {
|
| 17 |
if (
|
| 18 |
event.origin !== location.origin ||
|
|
@@ -22,19 +13,10 @@ export function createSimulator(report) {
|
|
| 22 |
if (event.data?.type === "pe:simulator-ready") {
|
| 23 |
ready = true;
|
| 24 |
status.textContent = "";
|
| 25 |
-
deliver();
|
| 26 |
}
|
| 27 |
-
if (event.data?.type === "pe:simulator-busy")
|
| 28 |
-
report(
|
| 29 |
-
"A simulation is already running. Wait for it to finish before starting another case.",
|
| 30 |
-
);
|
| 31 |
});
|
| 32 |
-
async function show(
|
| 33 |
-
if (
|
| 34 |
-
if (ready) {
|
| 35 |
-
deliver();
|
| 36 |
-
return;
|
| 37 |
-
}
|
| 38 |
if (starting) return starting;
|
| 39 |
status.textContent = "Connecting to NGSpice…";
|
| 40 |
starting = (async () => {
|
|
|
|
| 3 |
const frame = document.querySelector("#simulator");
|
| 4 |
const status = document.querySelector("#simulator-status");
|
| 5 |
let ready = false,
|
| 6 |
+
starting = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
window.addEventListener("message", (event) => {
|
| 8 |
if (
|
| 9 |
event.origin !== location.origin ||
|
|
|
|
| 13 |
if (event.data?.type === "pe:simulator-ready") {
|
| 14 |
ready = true;
|
| 15 |
status.textContent = "";
|
|
|
|
| 16 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
});
|
| 18 |
+
async function show() {
|
| 19 |
+
if (ready) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
if (starting) return starting;
|
| 21 |
status.textContent = "Connecting to NGSpice…";
|
| 22 |
starting = (async () => {
|
static/testbenches.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
| 1 |
-
/** Source simulation cases remain independent of canvas edits and reference losses. */
|
| 2 |
-
export function createTestbenchLibrary(report, simulate) {
|
| 3 |
-
const $ = (selector) => document.querySelector(selector);
|
| 4 |
-
let catalog = null,
|
| 5 |
-
loading = null,
|
| 6 |
-
requestedCircuit = null,
|
| 7 |
-
selectedCase = null,
|
| 8 |
-
request = 0;
|
| 9 |
-
const fileUrl = (path) =>
|
| 10 |
-
new URL("./testbenches/" + path, location.href).href;
|
| 11 |
-
const textElement = (tag, text, className) => {
|
| 12 |
-
const node = document.createElement(tag);
|
| 13 |
-
node.textContent = text;
|
| 14 |
-
if (className) node.className = className;
|
| 15 |
-
return node;
|
| 16 |
-
};
|
| 17 |
-
async function selectCase(group, bench) {
|
| 18 |
-
const generation = ++request;
|
| 19 |
-
selectedCase = bench;
|
| 20 |
-
document.querySelector("#bench-simulate").onclick = () =>
|
| 21 |
-
simulate(bench.id);
|
| 22 |
-
document.querySelectorAll("[data-testbench-id]").forEach((button) => {
|
| 23 |
-
button.classList.toggle(
|
| 24 |
-
"active",
|
| 25 |
-
button.dataset.testbenchId === bench.id,
|
| 26 |
-
);
|
| 27 |
-
button.setAttribute(
|
| 28 |
-
"aria-pressed",
|
| 29 |
-
String(button.dataset.testbenchId === bench.id),
|
| 30 |
-
);
|
| 31 |
-
});
|
| 32 |
-
$("#bench-title").textContent = group.name + " · " + bench.title;
|
| 33 |
-
$("#bench-file-name").textContent = bench.id + ".cir";
|
| 34 |
-
$("#bench-download").href = fileUrl(bench.file);
|
| 35 |
-
$("#bench-download").download = bench.id + ".cir";
|
| 36 |
-
$("#bench-source").href = bench.source_url;
|
| 37 |
-
$("#bench-sha").textContent = bench.sha256;
|
| 38 |
-
$("#bench-run-command").textContent =
|
| 39 |
-
`python3 run_testbench.py ${bench.id}`;
|
| 40 |
-
$("#bench-summary").replaceChildren();
|
| 41 |
-
for (const [name, value] of [
|
| 42 |
-
["Input", bench.parameters.VIN + " V"],
|
| 43 |
-
["Output target", bench.parameters.VOUT_TARGET + " V"],
|
| 44 |
-
["Current target", bench.parameters.IOUT_NOM + " A"],
|
| 45 |
-
["Switching", group.frequency],
|
| 46 |
-
["Duty parameter", bench.parameters.DUTY],
|
| 47 |
-
["Run duration", bench.duration],
|
| 48 |
-
["Phase DCR", bench.dcr],
|
| 49 |
-
["Coupling k", bench.parameters.KCOUP],
|
| 50 |
-
["Flying C", bench.parameters.CFLY + "F"],
|
| 51 |
-
["Phase L", bench.parameters.LOUT + "H"],
|
| 52 |
-
]) {
|
| 53 |
-
const item = document.createElement("div");
|
| 54 |
-
item.append(textElement("span", name), textElement("strong", value));
|
| 55 |
-
$("#bench-summary").append(item);
|
| 56 |
-
}
|
| 57 |
-
$("#bench-gating").textContent = group.gating;
|
| 58 |
-
$("#bench-parameters").replaceChildren();
|
| 59 |
-
for (const [name, value] of Object.entries(bench.parameters)) {
|
| 60 |
-
const row = document.createElement("tr");
|
| 61 |
-
row.append(textElement("th", name), textElement("td", value));
|
| 62 |
-
$("#bench-parameters").append(row);
|
| 63 |
-
}
|
| 64 |
-
$("#bench-copy").disabled = true;
|
| 65 |
-
$("#bench-code").textContent = "Loading original source…";
|
| 66 |
-
$("#bench-download").hidden = true;
|
| 67 |
-
try {
|
| 68 |
-
const response = await fetch(fileUrl(bench.file));
|
| 69 |
-
if (!response.ok) throw Error("Could not load the original testbench");
|
| 70 |
-
const bytes = await response.arrayBuffer();
|
| 71 |
-
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
| 72 |
-
const hash = [...new Uint8Array(digest)]
|
| 73 |
-
.map((value) => value.toString(16).padStart(2, "0"))
|
| 74 |
-
.join("");
|
| 75 |
-
if (hash !== bench.sha256)
|
| 76 |
-
throw Error(
|
| 77 |
-
"Testbench source checksum differs. Reload before downloading.",
|
| 78 |
-
);
|
| 79 |
-
if (generation !== request) return;
|
| 80 |
-
$("#bench-code").textContent = new TextDecoder().decode(bytes);
|
| 81 |
-
$("#bench-download").hidden = false;
|
| 82 |
-
$("#bench-copy").disabled = false;
|
| 83 |
-
} catch (error) {
|
| 84 |
-
if (generation !== request) return;
|
| 85 |
-
$("#bench-code").textContent = "Source is unavailable.";
|
| 86 |
-
$("#bench-copy").disabled = true;
|
| 87 |
-
report(error.message);
|
| 88 |
-
}
|
| 89 |
-
}
|
| 90 |
-
function drawLibrary() {
|
| 91 |
-
$("#testbench-circuits").replaceChildren();
|
| 92 |
-
for (const group of catalog.circuits) {
|
| 93 |
-
const card = document.createElement("article");
|
| 94 |
-
card.className = "bench-card";
|
| 95 |
-
const image = document.createElement("img");
|
| 96 |
-
image.src = fileUrl(group.image);
|
| 97 |
-
image.alt = group.name + " topology reference";
|
| 98 |
-
const controls = document.createElement("div");
|
| 99 |
-
controls.className = "bench-cases";
|
| 100 |
-
for (const bench of group.cases) {
|
| 101 |
-
const button = textElement("button", bench.title);
|
| 102 |
-
button.dataset.testbenchId = bench.id;
|
| 103 |
-
button.onclick = () => selectCase(group, bench);
|
| 104 |
-
controls.append(button);
|
| 105 |
-
}
|
| 106 |
-
card.append(
|
| 107 |
-
image,
|
| 108 |
-
textElement("h2", group.name),
|
| 109 |
-
textElement(
|
| 110 |
-
"p",
|
| 111 |
-
`${group.switches} switches · ${group.frequency} · ${group.gating}`,
|
| 112 |
-
),
|
| 113 |
-
controls,
|
| 114 |
-
);
|
| 115 |
-
$("#testbench-circuits").append(card);
|
| 116 |
-
}
|
| 117 |
-
$("#bench-revision").textContent = catalog.revision.slice(0, 12);
|
| 118 |
-
|
| 119 |
-
$("#bench-copy").onclick = async () => {
|
| 120 |
-
if (!selectedCase) return;
|
| 121 |
-
try {
|
| 122 |
-
await navigator.clipboard.writeText($("#bench-code").textContent);
|
| 123 |
-
report("Original testbench copied.");
|
| 124 |
-
} catch {
|
| 125 |
-
report("Clipboard access unavailable. Use Download .cir.");
|
| 126 |
-
}
|
| 127 |
-
};
|
| 128 |
-
}
|
| 129 |
-
async function show(circuit = null) {
|
| 130 |
-
requestedCircuit = circuit;
|
| 131 |
-
if (!catalog) {
|
| 132 |
-
if (!loading)
|
| 133 |
-
loading = (async () => {
|
| 134 |
-
const response = await fetch(fileUrl("index.json"));
|
| 135 |
-
if (!response.ok) throw Error("XFLY testbench library unavailable");
|
| 136 |
-
catalog = await response.json();
|
| 137 |
-
drawLibrary();
|
| 138 |
-
})();
|
| 139 |
-
try {
|
| 140 |
-
await loading;
|
| 141 |
-
} catch (error) {
|
| 142 |
-
loading = null;
|
| 143 |
-
report(error.message);
|
| 144 |
-
return;
|
| 145 |
-
}
|
| 146 |
-
}
|
| 147 |
-
const group =
|
| 148 |
-
catalog.circuits.find((group) => group.id === requestedCircuit) ??
|
| 149 |
-
catalog.circuits[0];
|
| 150 |
-
await selectCase(group, group.cases[0]);
|
| 151 |
-
}
|
| 152 |
-
return { show };
|
| 153 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|