pub enum GateBinding {
Block {
ctrl: String,
v_gs_th: f64,
},
}Expand description
How one ideal switch’s gate state is resolved, every step: always from a named block’s
current output, on while it’s >= 0.5. No non-block-driven variant exists — even a
permanently-off gate is an explicit Const(0.0) wired through a domain=voltage
BlockKind::Sig2Phys,
the same as every other gate — and no bare carrier-comparator variant exists either: that
comparison now lives entirely inside gate-driving BlockKinds themselves
(BlockKind::Pwm/BlockKind::PhaseShiftPwm, or a hand-built chain of ordinary blocks),
so GateBinding has exactly one job — reading a number and thresholding it — regardless of
what produced that number: a modulator’s own main/complement output, a
BlockKind::Hysteresis block (no carrier at all, event-driven bang-bang switching), or any
other block a caller composes.
Variants§
Block
§Gate Binding
Purpose: how an ideal switch’s gate state is resolved from a named block, every step. Library: Electrical Interface
§Description
This is not a kind= block itself — it’s the gate=/ctrl= field pair on a
kind=ideal_switch device line. GateBinding has exactly one variant and exactly one
job: reading a named block’s current output and thresholding it at >= v_gs_th. No
non-block-driven variant exists — even a permanently-off gate is an explicit Const(0.0)
wired through a domain=voltage BlockKind::Sig2Phys, the same as every other gate.
The named block (ctrl=) must itself be a domain=voltage BlockKind::Sig2Phys — an
ideal switch’s gate is itself a voltage ($V_{GS}$, compared against this binding’s
own v_gs_th), not a distinct
discrete-actuation signal domain (and never domain=current, even though Sig2Phys
itself allows that domain for I-source targets).
This comment used to say the gate was compared against v_th, which was false:
v_th on a kind=ideal_switch line is the body diode’s forward threshold and the
gate path never read it. The comparison was a hard-coded 0.5. That is the double
meaning v_gs_th and the body_ prefix exist to remove.
§Parameters
gate=block— the only accepted value; every gate is block-driven.ctrl=<name>— the name of a declareddomain=voltageBlockKind::Sig2Physblock.
§Errors
gate=missing entirely on akind=ideal_switchline — rejected at parse time:missing field 'gate' (gate=block ctrl=<name> -- every gate is block-driven, see this file's own module doc comment).gate=present but notblock— rejected at parse time:unknown gate spec '<value>' (only gate=block ctrl=<name> exists -- every gate is block-driven).ctrl=naming a block that isn’t adomain=voltageBlockKind::Sig2Phys(including adomain=currentone) — rejected atdae-runtime’s validation stage (not netlist parse time):DaeError::GateTargetNotSig2Voltage.
§Netlist form
NAME kind=ideal_switch r_on=<f64> body_g_breakdown=<f64> body_v_breakdown=<f64> \
body_g_off=<f64> \
body_v_f=<f64> body_g_on=<f64> gate=block ctrl=<name> [v_gs_th=<f64>]§Example
An ideal switch permanently held on via a Const(1) wired through Sig2Phys — the
plain D1 in out idealswitchmodel line gives the electrical connectivity (drain, source;
the model name is unused for a kind=ideal_switch-overridden device), the same-named
kind=ideal_switch line supplies the physics and gate. Verified end to end: V(out)
settles to 5 * 1000 / (1000 + 0.1) ≈ 4.9995 (a fully-on 0.1 Ω ideal switch in series
with a 1 kΩ load):
ONVAL kind=const value=1
ONGATE kind=sig2phys domain=voltage in=ONVAL
V1 in 0 5
D1 in out idealswitchmodel
D1 kind=ideal_switch r_on=0.1 body_g_breakdown=0 body_v_breakdown=-100 body_g_off=0 \
body_v_f=0.5 body_g_on=5 \
gate=block ctrl=ONGATE
R1 out 0 1kOn while the named block’s current output is at or above v_gs_th.
Fields
v_gs_th: f64The gate threshold, datasheet $V_{GS(th)}$. Defaults to 0.5.
This field closes a trap rather than adding a knob. Before it, the comparison was a
hard-coded 0.5 and the language had nowhere to put a real gate threshold – so
anyone modelling a device with a 5 V gate reached for the nearest-looking name,
v_th, which was the body diode’s forward threshold. The deck stayed valid, the run
completed, and the converter’s freewheeling path silently acquired a 5 V diode drop.
With v_gs_th honoured here the obvious thing to write is also the correct thing, and
no body-diode field is a candidate. The 0.5 default leaves every deck written before
this field existed behaving identically.
Implementations§
Source§impl GateBinding
impl GateBinding
Sourcepub fn source_blocks(&self) -> [Option<&str>; 2]
pub fn source_blocks(&self) -> [Option<&str>; 2]
The block this binding reads from.
Sourcepub fn resolve(&self, outputs: &BTreeMap<String, SignalValue>) -> SwitchState
pub fn resolve(&self, outputs: &BTreeMap<String, SignalValue>) -> SwitchState
§Panics
If the named block’s own current value is a SignalValue::Vector — unreachable in
practice, since the only legal GateBinding target is a domain=voltage
BlockKind::Sig2Phys converter (enforced before any step runs), and Sig2Phys itself
rejects a Vector input at evaluation time — there is no way for a validly-targeted gate
to ever see one here. Also panics if name isn’t in outputs at all, exactly as before
this variant existed (equally unreachable, for the same “checked before any step runs”
reason).
Trait Implementations§
Source§impl Clone for GateBinding
impl Clone for GateBinding
Source§fn clone(&self) -> GateBinding
fn clone(&self) -> GateBinding
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more