Skip to main content

GateBinding

Enum GateBinding 

Source
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 declared domain=voltage BlockKind::Sig2Phys block.
§Errors
  • gate= missing entirely on a kind=ideal_switch line — 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 not block — 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 a domain=voltage BlockKind::Sig2Phys (including a domain=current one) — rejected at dae-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 1k

On while the named block’s current output is at or above v_gs_th.

Fields

§ctrl: String

The named block whose output drives this gate.

§v_gs_th: f64

The 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

Source

pub fn source_blocks(&self) -> [Option<&str>; 2]

The block this binding reads from.

Source

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

Source§

fn clone(&self) -> GateBinding

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GateBinding

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for GateBinding

Source§

fn eq(&self, other: &GateBinding) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for GateBinding

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.