Name of the device without first-letter designator C.
nm
Name of node connected to negative pin.
np
Name of node connected to positive pin.
Description
Capacitor type could be specified with additional switches: -beh if we want to model circuit's variable dependent capacitor, or -model modelName if we want to simulate capacitor with model card (semiconductor capacitor). Simple capacitor:
method constructor {args} {
# Creates object of class `CModel` that describes semiconductor capacitor model.# name - name of the model# args - keyword instance parameters# Example of class initialization:# ```# CModel new capmod -tc1 1 -tc2 2# ```# Synopsis: name ?-option value ...?next {*}[my ArgsPreprocess {cap cj cjsw defw narrow short tc1 tc2 tnom di thick} {name type} type {*}[linsert $args 1 c]]
}
method constructor {args} {
# Creates object of class `Coupling` that describes inductance coupling between inductors.# name - name of the device without first-letter designator L# -l1 value - first inductor name# -l2 value - second inductor name# -k value - coupling coefficient# ```# KXXXXXXX LYYYYYYY LZZZZZZZ value# ```# Example of class initialization as a simple inductor:# ```# Coupling new 1 -l1 la -l2 lb -k 0.5# ```# Synopsis: name -l1 value -l2 value -k value##nagelfar implicitvarcmd {argparse *Creates object of class `Coupling`*} name l1 l2 k
argparse -pfirst -help {Creates object of class `Coupling` that describes inductance coupling between inductors} {
{name -help {Name of the device without first-letter designator}}
{-l1= -required -help {First inductor name}}
{-l2= -required -help {Second inductor name}}
{-k= -required -help {Coupling coefficient}}
}
if {([llength $k]>1) && ([@ $k 0] eq {-eq})} {
##nagelfar ignore {Found constant "k"}set k [list -poseq k [@ $k 1]]
} else {
##nagelfar ignore {Found constant "k"}set k [list -pos k $k]
}
##nagelfar ignore {Found constant "l*"}next k$name {} [list [list -posnocheck l1 $l1] [list -posnocheck l2 $l2] $k]
}
method constructor {args} {
# Creates object of class `CSwitchModel` that describes current switch model.# name - name of the model# args - keyword instance parameters# Example of class initialization:# ```# CSwitchModel new cswmod -it 1 -ih 0.5 -ron 1 -roff 1e6# ```# Synopsis: name ?-option value ...?next {*}[my ArgsPreprocess {it ih ron roff} {name type} type {*}[linsert $args 1 csw]]
}
Name of the device without first-letter designator L.
nm
Name of node connected to negative pin.
np
Name of node connected to positive pin.
Description
Inductor type could be specified with additional switches: -beh if we want to model circuit's variable dependent inductor, or -model modelName if we want to simulate inductor with model card. Simple inductor:
method constructor {args} {
# Creates object of class `Inductor` that describes inductor.# name - name of the device without first-letter designator L# np - name of node connected to positive pin# nm - name of node connected to negative pin# -l value - inductance value or equation# -m value - multiplier value, optional# -scale value - scaling factor, optional# -temp value - device temperature, optional# -dtemp value - temperature offset, optional# -tc1 value - linear thermal coefficient, optional# -tc2 value - quadratic thermal coefficient, optional# -model value - model of the inductor, optional# -beh - selects behavioural type of inductor, optional# -ic value - initial current through inductor, optional# -nt value - number of turns, optional# Inductor type could be specified with additional switches: `-beh` if we want to model circuit's variable# dependent inductor, or `-model modelName` if we want to simulate inductor with model card.# Simple inductor:# ```# LYYYYYYY n+ n- <value> <m=val># + <scale=val> <temp=val> <dtemp=val> <tc1=val># + <tc2=val> <ic=init_condition># ```# Example of class initialization as a simple inductor:# ```# Inductor new 1 netp netm -l 1e-6 -tc1 1 -temp {-eq temp}# ```# Behavioral inductor:# ```# LYYYYYYY n+ n- L={expression} <tc1=val> <tc2=val># ```# Example of class initialization:# ```# Inductor new 1 netp netm -l "V(a)+V(b)+pow(V(c),2)" -beh -tc1 1# ```# Inductor with model card:# ```# LYYYYYYY n+ n- <value> <mname> <nt=val> <m=val># + <scale=val> <temp=val> <dtemp=val> <tc1=val># + <tc2=val> <ic=init_condition># ```# Example of class initialization:# ```# Inductor new 1 netp netm -l 1e-6 -model indm# ```# Synopsis: name np nm -l value ?-tc1 value? ?-tc2 value? ?-m value? ?-temp value|-dtemp value?# ?-scale value? ?-ic value?# Synopsis: name np nm -beh -l value ?-tc1 value? ?-tc2 value?# Synopsis: name np nm -model value ?-l value? ?-temp value|-dtemp value? ?-m value? ?scale value?# ?-ic value? ?-nt value? ?-tc1 value? ?-tc2 value?set arguments [argparse -inline -pfirst -help {Creates object of class 'Inductor' that describes inductor} {
{-l= -help {Inductance value or equation}}
{-beh -forbid {model} -require {l} -help {Selects behavioural type of inductor}}
{-model= -forbid {beh} -help {Model of the inductor}}
{-m= -forbid {beh} -help {Multiplier value}}
{-scale= -forbid {beh} -help {Scaling factor}}
{-temp= -forbid {beh dtemp} -help {Device temperature}}
{-dtemp= -forbid {beh temp} -help {Temperature offset}}
{-tc1= -help {Linear thermal coefficient}}
{-tc2= -help {Quadratic thermal coefficient}}
{-nt= -require {model} -help {Number of turns}}
{-ic= -forbid {beh} -help {Initial current through inductor}}
{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}}
}]
set params {}
if {[dexist $arguments l]} {
set lVal [dget $arguments l]
if {[dexist $arguments beh]} {
lappend params [list -eq l $lVal]
} elseif {([llength $lVal]>1) && ([@ $lVal 0] eq {-eq})} {
lappend params [list -poseq l [@ $lVal 1]]
} else {
lappend params [list -pos l $lVal]
}
} elseif {![dexist $arguments model]} {
return -code error {Inductor value must be specified with '-l value'}
}
if {[dexist $arguments model]} {
lappend params [list -posnocheck model [dget $arguments model]]
}
dict for {paramName value} $arguments {
if {$paramName ni {l beh model name np nm}} {
if {[@ $value 0] eq {-eq}} {
lappend params [list -eq $paramName [@ $value 1]]
} else {
lappend params [list $paramName $value]
}
}
}
next l[dget $arguments name] [my FormPinNodeList $arguments {np nm}] $params
}
method constructor {args} {
# Creates object of class `LModel` that describes inductor model.# name - name of the model# args - keyword instance parameters# Example of class initialization:# ```# LModel new indmod -tc1 1 -tc2 2# ```# Synopsis: name ?-option value ...?next {*}[my ArgsPreprocess {ind csect dia length tc1 tc2 tnom nt mu} {name type} type {*}[linsert $args 1 l]]
}
Name of the device without first-letter designator R.
nm
Name of node connected to negative pin.
np
Name of node connected to positive pin.
Description
Resistor type could be specified with additional switches: -beh if we want to model circuit's variable dependent resistor, or -model modelName if we want to simulate resistor with model card (semiconductor resistor). Simple resistor:
method constructor {args} {
# Creates object of class `RModel` that describes semiconductor resistor model.# name - name of the model# args - keyword instance parameters# Example of class initialization:# ```# RModel new resmod -tc1 1 -tc2 2# ```# Synopsis: name ?-option value ...?next {*}[my ArgsPreprocess {tc1 tc2 rsh defw narrow short tnom kf af wf lf ef r} {name type} type {*}[linsert $args 1 r]]
}
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]
return -code error "Wrong object class '$objClass' is passed as subcktObj, should be '::SpiceGenTcl::Subcircuit'"
}
# get name of subcircuitset subName [$subcktObj configure -name]
# get pins names of subcircuitset 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]'"
}
# create list of pins and connected nodesforeach pinName $pinsNames node $nodes {
lappend pinsList [list $pinName $node]
}
# get parameters names of subcircuitif {[$subcktObj actOnParam -get -all] ne {}} {
set paramsNames [dict keys [$subcktObj actOnParam -get -all]]
foreach paramName $paramsNames {
lappend paramDefList -${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 `VerilogA` that describes Verilog-A instance.# name - name of the device without first-letter designator N# pins - list of pins `{{pinName nodeName} {pinName nodeName} ...}`# modName - name of Verilog-A model# params - list of parameters `{{?-eq? paramName paramValue} {?-eq? paramName paramValue}}`# ```# NYYYYYYY N1 <N2 N3 ...> MODNAME# ```# Example of class initialization:# ```# VerilogA new 1 {{plus net1} {minus net2}} vmod {{r 1} {-eq c cpar}}# ```##nagelfar implicitvarcmd {argparse *Creates object of class 'VerilogA'*} name pins modName params
argparse -pfirst -help {Creates object of class 'VerilogA' that describes Verilog-A instance} {
{name -help {Name of the device without first-letter designator}}
{pins -help {List of pins {{pinName nodeName} {pinName nodeName} ...}}}
{modName -help {name of Verilog-A model}}
{params -help {List of parameters {{?-eq? paramName paramValue} {?-eq? paramName paramValue}}}}
}
set params [linsert $params 0 [list -posnocheck model $modName]]
next n$name $pins $params
}
method constructor {args} {
# Creates object of class `VSwitchModel` that describes voltage switch model.# name - name of the model# args - keyword instance parameters# Example of class initialization:# ```# VSwitchModel new swmod -vt 1 -vh 0.5 -ron 1 -roff 1e6# ```# Synopsis: name ?-option value ...?next {*}[my ArgsPreprocess {vt vh ron roff} {name type} type {*}[linsert $args 1 sw]]
}