method constructor {args} {
# Creates object of class `CSwitch` that describes current controlled switch device.# name - name of the device without first-letter designator W# np - name of node connected to positive pin# nm - name of node connected to negative pin# -icntrl value - source of control current# -model value - model name# -on/-off - initial state of switch# ```# WYYYYYYY N+ N- VNAM MODEL <ON> <OFF># ```# Example of class initialization:# ```# CSwitch new 1 net1 0 -icntrl v1 -model sw1 -on# ```# Synopsis: name np nm -icntrl value -model value ?-on|-off?set arguments [argparse -inline -pfirst -help {Creates object of class `CSwitch` that describes current controlled switch device} {
{-icntrl= -required -help {Source of control current}}
{-model= -required -help {Model name}}
{-on -forbid {off} -help {Initial on state of switch}}
{-off -forbid {on} -help {Initial off state of switch}}
{name -help {Name of the device without first-letter designator W}}
{np -help {Name of node connected to positive pin}}
{nm -help {Name of node connected to negative pin}}
}]
lappend params [list -posnocheck icntrl [dget $arguments icntrl]]
lappend params [list -posnocheck model [dget $arguments model] -posnocheck]
if {[dexist $arguments on]} {
lappend params {-sw on}
} elseif {[dexist $arguments off]} {
lappend params {-sw off}
}
next w[dget $arguments name] [my FormPinNodeList $arguments {np nm}] $params
}
method constructor {args} {
# Creates object of class `SubcircuitInstance` that describes subcircuit instance.# name - name of the device without first-letter designator X# pins - list of pins `{{pinName nodeName} {pinName nodeName} ...}`# subName - name of subcircuit definition# params - list of parameters `{{?-eq? paramName paramValue} {?-eq? paramName paramValue}}`# ```# XYYYYYYY N1 <N2 N3 ...> SUBNAM# ```# Example of class initialization:# ```# SubcircuitInstance new 1 {{plus net1} {minus net2}} rcnet {{r 1} {-eq c cpar}}# ```##nagelfar implicitvarcmd {argparse *Creates object of class 'SubcircuitInstance'*} name pins subName params
argparse -pfirst -help {Creates object of class 'SubcircuitInstance' that describes subcircuit instance} {
{name -help {Name of the device without first-letter designator}}
{pins -help {List of pins {{pinName nodeName} {pinName nodeName} ...}}}
{subName -help {Name of subcircuit definition}}
{params -help {List of parameters {{?-eq? paramName paramValue} {?-eq? paramName paramValue}}}}
}
set params [linsert $params 0 [list -posnocheck model $subName]]
next x$name $pins $params
}
method constructor {subcktObj name nodes args} {
# Creates object of class `SubcircuitInstanceAuto` that describes subcircuit instance with already created# subcircuit definition object.# subcktObj - object of subcircuit that defines it's pins, subName and parameters# nodes - list of nodes connected to pins in the same order as pins in subcircuit definition `{nodeName1# nodeName2 ...}`# args - parameters as argument in form : `-paramName {?-eq? paramValue} -paramName {?-eq? paramValue}`# ```# XYYYYYYY N1 <N2 N3 ...> SUBNAM# ```# Example of class initialization:# ```# SubcircuitInstanceAuto new $subcktObj 1 {net1 net2} -r 1 -c {-eq cpar}# ```# Synopsis: subcktObj name nodes ?-paramName {?-eq? paramValue} ...?# check that inputs object class is Subcircuitif {![info object class $subcktObj "::SpiceGenTcl::Subcircuit"]} {
set objClass [info object class $subcktObj]
error "Wrong object class '$objClass' is passed as subcktObj, should be '::SpiceGenTcl::Subcircuit'"
}
set subName [$subcktObj configure -name]
set pinsNames [dict keys [$subcktObj actOnPin -get -all]]
# check if number of pins in subcircuit definition matchs the number of supplied nodesif {[llength $pinsNames]!=[llength $nodes]} {
return -code error "Wrong number of nodes '[llength $nodes]' in definition, should be '[llength $pinsNames]'"
}
set pinsList [lmap pinName $pinsNames node $nodes {join [list $pinName $node]}]
if {[$subcktObj actOnParam -get -all] ne {}} {
set paramDefList [lmap paramName [dict keys [$subcktObj actOnParam -get -all]] {subst -${paramName}=}]
}
if {[info exists paramDefList]} {
# create definition for argparse module for passing parameters as optional argumentsset arguments [argparse -inline "
[join $paramDefList \n]
"]
# create list of parameters and values from which were supplied by argsdict for {paramName value} $arguments {
if {[@ $value 0] eq {-eq}} {
lappend params [list -eq $paramName [@ $value 1]]
} else {
lappend params [list $paramName $value]
}
}
} else {
set params {}
}
set params [linsert $params 0 [list -posnocheck model $subName]]
next x$name $pinsList $params
}
method constructor {args} {
# Creates object of class `VSwitch` that describes voltage controlled switch device.# name - name of the device without first-letter designator S# np - name of node connected to positive pin# nm - name of node connected to negative pin# ncp - name of node connected to positive controlling pin# ncm - name of node connected to negative controlling pin# -model value - model name# -on/-off - initial state of switch# ```# SXXXXXXX N+ N- NC+ NC- MODEL <ON> <OFF># ```# Example of class initialization:# ```# VSwitch new 1 net1 0 netc 0 -model sw1 -on# ```# Synopsis: name np nm ncp ncm -model value ?-on|-off?set arguments [argparse -inline -pfirst -help {Creates object of class `VSwitch` that describes voltage controlled switch device} {
{-model= -required -help {Model name}}
{-on -forbid {off} -help {Initial on state of switch}}
{-off -forbid {on} -help {Initial off state of switch}}
{name -help {Name of the device without first-letter designator}}
{np -help {Name of node connected to positive pin}}
{nm -help {Name of node connected to negative pin}}
{ncp -help {Name of node connected to positive controlling pin}}
{ncm -help {Name of node connected to negative controlling pin}}
}]
lappend params [list -posnocheck model [dget $arguments model]]
if {[dexist $arguments on]} {
lappend params {-sw on}
} elseif {[dexist $arguments off]} {
lappend params {-sw off}
}
next s[dget $arguments name] [my FormPinNodeList $arguments {np nm ncp ncm}] $params
}