Tcl SpiceGenTcl package (v0.60)

::SpiceGenTclTop, Main, Index

CommandsTop, Main, Index

forgetCommon [::SpiceGenTcl]Top, Main, Index

Forgets all ::SpiceGenTcl::Common commands from caller namespace

forgetCommon
proc ::SpiceGenTcl::forgetCommon {} {

    # Forgets all ::SpiceGenTcl::Common commands from caller namespace
    uplevel 1 {foreach nameSpc [namespace children ::SpiceGenTcl::Common] {
        namespace forget ${nameSpc}::*
    }}
}

forgetNgspice [::SpiceGenTcl]Top, Main, Index

Forgets all ::SpiceGenTcl::Ngspice commands from caller namespace

forgetNgspice
proc ::SpiceGenTcl::forgetNgspice {} {

    # Forgets all ::SpiceGenTcl::Ngspice commands from caller namespace
    uplevel 1 {foreach nameSpc [namespace children ::SpiceGenTcl::Ngspice] {
        namespace forget ${nameSpc}::*
    }}
}

forgetXyce [::SpiceGenTcl]Top, Main, Index

Forgets all ::SpiceGenTcl::Xyce commands from caller namespace

forgetXyce
proc ::SpiceGenTcl::forgetXyce {} {

    # Forgets all ::SpiceGenTcl::Xyce commands from caller namespace
    uplevel 1 {foreach nameSpc [namespace children ::SpiceGenTcl::Xyce] {
        namespace forget ${nameSpc}::*
    }}
}

importCommon [::SpiceGenTcl]Top, Main, Index

Imports all ::SpiceGenTcl::Common commands to caller namespace

importCommon
proc ::SpiceGenTcl::importCommon {} {

    # Imports all ::SpiceGenTcl::Common commands to caller namespace
    uplevel 1 {foreach nameSpc [namespace children ::SpiceGenTcl::Common] {
        namespace import ${nameSpc}::*
    }}
}

importNgspice [::SpiceGenTcl]Top, Main, Index

Imports all ::SpiceGenTcl::Ngspice commands to caller namespace

importNgspice
proc ::SpiceGenTcl::importNgspice {} {

    # Imports all ::SpiceGenTcl::Ngspice commands to caller namespace
    uplevel 1 {foreach nameSpc [namespace children ::SpiceGenTcl::Ngspice] {
        namespace import ${nameSpc}::*
    }}
}

importXyce [::SpiceGenTcl]Top, Main, Index

Imports all ::SpiceGenTcl::Xyce commands to caller namespace

importXyce
proc ::SpiceGenTcl::importXyce {} {

    # Imports all ::SpiceGenTcl::Xyce commands to caller namespace
    uplevel 1 {foreach nameSpc [namespace children ::SpiceGenTcl::Xyce] {
        namespace import ${nameSpc}::*
    }}
}

ClassesTop, Main, Index

Analysis [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
addParamAdds new Parameter object to the list Params.
configureConfigure properties.
deleteParamDeletes existing Parameter object from list Params.
duplListCheckSee DuplChecker.duplListCheck
genSPICEStringCreates analysis for SPICE netlist.
getParamsGets the dictionary that contains parameter name as keys and parameter values as the values.
setParamValueSets (or change) value of particular parameters.
Properties

Readable: -name, -type

Writable: -name, -type

Superclasses

SPICEElement

Mixins

DuplChecker

Subclasses

::SpiceGenTcl::Ngspice::Analyses::Dc, ::SpiceGenTcl::Ngspice::Analyses::Ac, ::SpiceGenTcl::Ngspice::Analyses::Sp, ::SpiceGenTcl::Ngspice::Analyses::SensAc, ::SpiceGenTcl::Ngspice::Analyses::SensDc, ::SpiceGenTcl::Ngspice::Analyses::Tran, ::SpiceGenTcl::Ngspice::Analyses::Op, ::SpiceGenTcl::Xyce::Analyses::Dc, ::SpiceGenTcl::Xyce::Analyses::Ac, ::SpiceGenTcl::Xyce::Analyses::Sens, ::SpiceGenTcl::Xyce::Analyses::Tran, ::SpiceGenTcl::Xyce::Analyses::Op

constructor [::SpiceGenTcl::Analysis]Analysis, Top, Main, Index

Creates object of class Analysis.

OBJECT constructor type params ?-name value?
Parameters
typeType of analysis, for example, tran, ac, dc, etc.
paramsList of instance parameters in form {{name value} {name -sw} {name Value -eq} {name Value -posnocheck} ...}
-nameName of the string that could be used to retrieve element from ::SpiceGenTcl::Netlist object and its descendants, optional.
Description

Class models analysis statement.

method constructor {type params args} {

    # Creates object of class `Analysis`.
    #  type - type of analysis, for example, tran, ac, dc, etc
    #  params - list of instance parameters in form
    #   `{{name value} {name -sw} {name Value -eq} {name Value -posnocheck} ...}`
    #  -name - name of the string that could be used to retrieve element from [::SpiceGenTcl::Netlist] object
    #    and its descendants, optional
    # Class models analysis statement.
    # Synopsis: type params ?-name value?
    my variable name
    set arguments [argparse {
        -name=
    }]
    if {[info exists name]} {
        my configure -name $name
    } else {
        my configure -name [self object]
    }
    my configure -type $type
    # create Analysis objects
    foreach param $params {
        if {[@ $param 2]=={}} {
            my addParam [@ $param 0] [@ $param 1]
        } elseif {[@ $param 1]=="-sw"} {
            my addParam [@ $param 0] -sw
        } else {
            my addParam {*}$param
        }
    }
}

addParam [::SpiceGenTcl::Analysis]Analysis, Top, Main, Index

Adds new Parameter object to the list Params.

OBJECT addParam paramName value ?-name value? ?-eq|-poseq|-posnocheck|-pos|-nocheck?
Parameters
paramNameName of parameter.
valueValue of parameter.
-eqParameter is of class ::SpiceGenTcl::ParameterEquation, optional, forbids other switches.
-nocheckParameter is of class ::SpiceGenTcl::ParameterNoCheck, optional, forbids other switches.
-posParameter is of class ::SpiceGenTcl::ParameterPositional, optional, forbids other switches.
-poseqParameter is of class ::SpiceGenTcl::ParameterPositionalEquation, optional, forbids other switches.
-posnocheckParameter is of class ::SpiceGenTcl::ParameterPositionalNoCheck, optional, forbids other switches.
method addParam {paramName value args} {

    # Adds new Parameter object to the list `Params`.
    #  paramName - name of parameter
    #  value - value of parameter
    #  -eq - parameter is of class [::SpiceGenTcl::ParameterEquation], optional, forbids other switches
    #  -poseq - parameter is of class [::SpiceGenTcl::ParameterPositionalEquation], optional, forbids other
    #    switches
    #  -posnocheck - parameter is of class [::SpiceGenTcl::ParameterPositionalNoCheck], optional, forbids other
    #    switches
    #  -pos - parameter is of class [::SpiceGenTcl::ParameterPositional], optional, forbids other switches
    #  -nocheck - parameter is of class [::SpiceGenTcl::ParameterNoCheck], optional, forbids other switches
    # Synopsis: paramName value ?-name value? ?-eq|-poseq|-posnocheck|-pos|-nocheck?
    set arguments [argparse {
        {-eq -forbid {poseq posnocheck pos nocheck}}
        {-poseq -forbid {eq posnocheck pos nocheck}}
        {-posnocheck -forbid {eq poseq pos nocheck}}
        {-pos -forbid {eq poseq posnocheck nocheck}}
        {-nocheck -forbid {eq poseq posnocheck pos}}
    }]
    set paramName [string tolower $paramName]
    if {[info exists Params]} {
        set paramList [dict keys $Params]
    }
    lappend paramList $paramName
    if {[my duplListCheck $paramList]} {
        return -code error "Parameters list '$paramList' has already contains parameter with name '$paramName'"
    }
    if {$value=="-sw"} {
        dict append Params $paramName [::SpiceGenTcl::ParameterSwitch new $paramName]
    } elseif {[info exists eq]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterEquation new $paramName $value]
    } elseif {[info exists poseq]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterPositionalEquation new $paramName $value]
    } elseif {[info exists posnocheck]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterPositionalNoCheck new $paramName $value]
    } elseif {[info exists pos]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterPositional new $paramName $value]
    } elseif {[info exists nocheck]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterNoCheck new $paramName $value]
    } else {
        dict append Params $paramName [::SpiceGenTcl::Parameter new $paramName $value]
    }
    return
}

deleteParam [::SpiceGenTcl::Analysis]Analysis, Top, Main, Index

Deletes existing Parameter object from list Params.

OBJECT deleteParam paramName
Parameters
paramNameName of parameter that will be deleted.
method deleteParam {paramName} {

    # Deletes existing `Parameter` object from list `Params`.
    #  paramName - name of parameter that will be deleted
    set paramName [string tolower $paramName]
    set error [catch {dget $Params $paramName}]
    if {$error>0} {
        return -code error "Parameter with name '$paramName' was not found in device's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
    } else {
        set Params [dict remove $Params $paramName]
    }
    return
}

genSPICEString [::SpiceGenTcl::Analysis]Analysis, Top, Main, Index

Creates analysis for SPICE netlist.

OBJECT genSPICEString
Return value

string '.$type $Params'

method genSPICEString {} {

    # Creates analysis for SPICE netlist.
    # Returns: string '.$type $Params'
    if {[info exists Params]} {
        dict for {paramName param} $Params {
            lappend params [$param genSPICEString]
        }
        return ".[my configure -type] [join $params]"
    } else {
        return ".[my configure -type]"
    }
}

getParams [::SpiceGenTcl::Analysis]Analysis, Top, Main, Index

Gets the dictionary that contains parameter name as keys and parameter values as the values.

OBJECT getParams
Return value

parameters dictionary

method getParams {} {

    # Gets the dictionary that contains parameter name as keys and
    #  parameter values as the values.
    # Returns: parameters dictionary
    set tempDict [dcreate]
    dict for {paramName param} $Params {
        dict append tempDict $paramName [$param configure -value]
    }
    return $tempDict
}

setParamValue [::SpiceGenTcl::Analysis]Analysis, Top, Main, Index

Sets (or change) value of particular parameters.

OBJECT setParamValue ?args?
Parameters
argsList with even number of elements with parameter name and value, {paramName0 paramValue0 # paramName1 paramValue1 ...}
method setParamValue {args} {

    # Sets (or change) value of particular parameters.
    #  args - list with even number of elements with parameter name and value, {paramName0 paramValue0 #    paramName1 paramValue1 ...}
    if {[llength $args]%2!=0} {
        return -code error "Number of arguments to method '[dict get [info frame 0] method]' must be even"
    }
    for {set i 0} {$i<[llength $args]} {incr i 2} {
        set paramName [string tolower [@ $args [= {$i}]]]
        set paramValue [@ $args [= {$i+1}]]
        if {[catch {dget $Params $paramName}]} {
            return -code error "Parameter with name '$paramName' was not found in element's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
        } else {
            set param [dget $Params $paramName]
        }
        $param configure -value $paramValue
    }
    return
}

Axis [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
appendDataPointsSee Dataset.appendDataPoints
configureConfigure properties.
getDataPointsSee Dataset.getDataPoints
getStrSee Dataset.getStr
setDataPointsSee Dataset.setDataPoints
Properties

Readable: -Len, -NumType, -Type, -name

Writable: -Len, -NumType, -Type, -name

Superclasses

Dataset

constructor [::SpiceGenTcl::Axis]Axis, Top, Main, Index

initialize axis

Axis create OBJNAME name type len ?numType?
Axis new name type len ?numType?
Parameters
nameName of the axis.
typeType of axis.
lenTotal number of points.
numTypeNumerical type of axis. Optional, default real.
method constructor {name type len {numType real}} {

    # initialize axis
    #  name - name of the axis
    #  type - type of axis
    #  len - total number of points
    #  numType - numerical type of axis
    next $name $type $len $numType
}

BinaryReader [::SpiceGenTcl]Top, Main, Index

Method summary
configureConfigure properties.
readComplexReads two 8 byte numbers from file.
readFloat32Reads 4 bytes number from file.
readFloat64Reads 8 bytes number from file .
skip4bytesMoves pointer of position in file forward in 4 bytes.
skip8bytesMoves pointer of position in file forward in 8 bytes.
skip16bytesMoves pointer of position in file forward in 16 bytes.
Subclasses

RawFile

readComplex [::SpiceGenTcl::BinaryReader]BinaryReader, Top, Main, Index

Reads two 8 byte numbers from file.

OBJECT readComplex file
Parameters
fileFile handler.
Return value

list of two values.

method readComplex {file} {

    # Reads two 8 byte numbers from file.
    #  file - file handler
    # Returns: list of two values.
    set s [read $file 16]
    binary scan $s "dd" re im
    return [list $re $im]
}

readFloat32 [::SpiceGenTcl::BinaryReader]BinaryReader, Top, Main, Index

Reads 4 bytes number from file.

OBJECT readFloat32 file
Parameters
fileFile handler.
Return value

value of number.

method readFloat32 {file} {

    # Reads 4 bytes number from file.
    #  file - file handler
    # Returns: value of number.
    set s [read $file 4]
    binary scan $s "f" num
    return $num
}

readFloat64 [::SpiceGenTcl::BinaryReader]BinaryReader, Top, Main, Index

Reads 8 bytes number from file .

OBJECT readFloat64 file
Parameters
fileFile handler.
Return value

value of number.

method readFloat64 {file} {

    # Reads 8 bytes number from file .
    #  file - file handler
    # Returns: value of number.
    set s [read $file 8]
    binary scan $s "d" num
    return $num
}

skip4bytes [::SpiceGenTcl::BinaryReader]BinaryReader, Top, Main, Index

Moves pointer of position in file forward in 4 bytes.

OBJECT skip4bytes file
Parameters
fileFile handler.
method skip4bytes {file} {

    # Moves pointer of position in file forward in 4 bytes.
    #  file - file handler
    read $file 4
    return
}

skip8bytes [::SpiceGenTcl::BinaryReader]BinaryReader, Top, Main, Index

Moves pointer of position in file forward in 8 bytes.

OBJECT skip8bytes file
Parameters
fileFile handler.
method skip8bytes {file} {

    # Moves pointer of position in file forward in 8 bytes.
    #  file - file handler
    read $file 8
    return
}

skip16bytes [::SpiceGenTcl::BinaryReader]BinaryReader, Top, Main, Index

Moves pointer of position in file forward in 16 bytes.

OBJECT skip16bytes file
Parameters
fileFile handler.
method skip16bytes {file} {

    # Moves pointer of position in file forward in 16 bytes.
    #  file - file handler
    read $file 16
    return
}

Circuit [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
addAdds elements object to Elements dictionary.
configureConfigure properties.
delDeletes element from the circuit by its name.
detachSimulatorRemoves Simulator object reference from Circuit.
duplListCheckSee DuplChecker.duplListCheck
genSPICEStringCreates circuit string for SPICE netlist.
getAllElemNamesSee Netlist.getAllElemNames
getDataCsvReturns string with csv formatting containing all data.
getDataDictMethod to get dictionary with raw data vectors.
getElementGets particular element object reference by its name.
runAndReadInvokes 'runAndRead', 'configure -log' and 'configure -data' methods from attached simulator.
Properties

Readable: -data, -log, -name, -simulator

Writable: -data, -log, -name, -simulator

Superclasses

Netlist

constructor [::SpiceGenTcl::Circuit]Circuit, Top, Main, Index

Creates object of class CircuitNetlist.

Circuit create OBJNAME name
Circuit new name
Parameters
nameName of the tol-level circuit.
Description

Class implements a top level netlist which is run in SPICE. We should add ::SpiceGenTcl::Simulator object reference to make it able to run simulation.

method constructor {name} {

    # Creates object of class `CircuitNetlist`.
    #  name - name of the tol-level circuit
    # Class implements a top level netlist which is run in SPICE. We should add [::SpiceGenTcl::Simulator]
    # object reference to make it able to run simulation.
    next $name
}

add [::SpiceGenTcl::Circuit]Circuit, Top, Main, Index

Adds elements object to Elements dictionary.

OBJECT add element
Parameters
elementElement object reference.
method add {element} {

    # Adds elements object to Elements dictionary.
    #  element - element object reference
    my variable Elements
    set elemName [string tolower [$element configure -name]]
    if {([info object class $element {::SpiceGenTcl::Analysis}]) && ([info exists ContainAnalysis])} {
        return -code error "Netlist '[my configure -name]' already contains Analysis element"
    } elseif {[info object class $element {::SpiceGenTcl::Analysis}]} {
        set ContainAnalysis ""
    }
    if {[info exists Elements]} {
        set elemList [my getAllElemNames]
    }
    lappend elemList $elemName
    if {[my duplListCheck $elemList]} {
        return -code error "Netlist '[my configure -name]' already contains element with name $elemName"
    }
    dict append Elements [$element configure -name] $element
    return
}

del [::SpiceGenTcl::Circuit]Circuit, Top, Main, Index

Deletes element from the circuit by its name.

OBJECT del elemName
Parameters
elemNameName of element to delete.
method del {elemName} {

    # Deletes element from the circuit by its name.
    #  elemName - name of element to delete
    my variable Elements
    set elemName [string tolower $elemName]
    set error [catch {dget $Elements $elemName}]
    if {$error>0} {
        return -code error "Element with name '$elemName' was not found in device's '[my configure -name]' list of elements"
    } else {
        set Elements [dict remove $Elements $elemName]
        if {[info object class [dget $Elements $elemName] {::SpiceGenTcl::Analysis}]} {
            unset ContainAnalysis
        }
    }
    return
}

detachSimulator [::SpiceGenTcl::Circuit]Circuit, Top, Main, Index

Removes Simulator object reference from Circuit.

OBJECT detachSimulator
method detachSimulator {} {

    # Removes `Simulator` object reference from `Circuit`.
    unset simulator
    return
}

genSPICEString [::SpiceGenTcl::Circuit]Circuit, Top, Main, Index

Creates circuit string for SPICE netlist.

OBJECT genSPICEString
Return value

'circuit string'

method genSPICEString {} {

    # Creates circuit string for SPICE netlist.
    # Returns: 'circuit string'
    my variable Elements
    lappend totalStr [my configure -name]
    dict for {elemName element} $Elements {
        lappend totalStr [$element genSPICEString]
    }
    return [join $totalStr \n]
}

getDataCsv [::SpiceGenTcl::Circuit]Circuit, Top, Main, Index

Returns string with csv formatting containing all data

OBJECT getDataCsv ?-all? ?-traces list? ?-sep value?
Parameters
-allSelect all traces.
-sepSeparator of columns, default is comma.
-tracesSelect names of traces to return.
Return value

Returns string with csv formatting containing all data

method getDataCsv {args} {

    # Returns string with csv formatting containing all data
    #  -all - select all traces
    #  -traces - select names of traces to return
    #  -sep - separator of columns, default is comma
    # Synopsis: ?-all? ?-traces list? ?-sep value?
    return [[my configure -data] getTracesCsv {*}$args]
}

getDataDict [::SpiceGenTcl::Circuit]Circuit, Top, Main, Index

Method to get dictionary with raw data vectors.

OBJECT getDataDict
Return value

dict with vectors data, keys - names of vectors

method getDataDict {} {

    # Method to get dictionary with raw data vectors.
    # Returns: dict with vectors data, keys - names of vectors
    return [[my configure -data] getTracesData]
}

getElement [::SpiceGenTcl::Circuit]Circuit, Top, Main, Index

Gets particular element object reference by its name.

OBJECT getElement elemName
Parameters
elemNameName of element.
method getElement {elemName} {

    # Gets particular element object reference by its name.
    #  elemName - name of element
    my variable Elements
    set elemName [string tolower $elemName]
    set error [catch {dget $Elements $elemName}]
    if {$error>0} {
        return -code error "Element with name '$elemName' was not found in netlist's '[my configure -name]' list of elements"
    } else {
        set foundElem [dget $Elements $elemName]
    }
    return $foundElem
}

runAndRead [::SpiceGenTcl::Circuit]Circuit, Top, Main, Index

Invokes 'runAndRead', 'configure -log' and 'configure -data' methods from attached simulator.

OBJECT runAndRead ?-nodelete?
Parameters
-nodeleteFlag to forbid simulation file deletion.
method runAndRead {args} {

    # Invokes 'runAndRead', 'configure -log' and 'configure -data' methods from attached simulator.
    #  -nodelete - flag to forbid simulation file deletion
    # Synopsis: ?-nodelete?
    set arguments [argparse {
        -nodelete
    }]
    if {[info exists simulator]==0} {
        return -code error "Simulator is not attached to '[my configure -name]' circuit"
    }
    if {[info exists nodelete]} {
        $simulator runAndRead [my genSPICEString] -nodelete
    } else {
        $simulator runAndRead [my genSPICEString]
    }
    my configure -log [$simulator configure -log] -data [$simulator configure -data]
}

Comment [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringCreates comment string for SPICE netlist.
Properties

Readable: -name, -value

Writable: -name, -value

Superclasses

RawString

constructor [::SpiceGenTcl::Comment]Comment, Top, Main, Index

Creates object of class Comment.

OBJECT constructor value ?-name value?
Parameters
valueValue of the comment.
-nameName of the string that could be used to retrieve element from ::SpiceGenTcl::Netlist object and its descendants, optional.
Description

Class represent comment string, it can be a multiline comment.

method constructor {value args} {

    # Creates object of class `Comment`.
    #  value - value of the comment
    #  -name - name of the string that could be used to retrieve element from [::SpiceGenTcl::Netlist] object
    #    and its descendants, optional
    # Class represent comment string, it can be a multiline comment.
    # Synopsis: value ?-name value?
    argparse {
        -name=
    }
    if {[info exists name]} {
        my configure -name $name
    } else {
        my configure -name [self object]
    }
    my configure -value $value
}

genSPICEString [::SpiceGenTcl::Comment]Comment, Top, Main, Index

Creates comment string for SPICE netlist.

OBJECT genSPICEString
Return value

string '$value'

method genSPICEString {} {

    # Creates comment string for SPICE netlist.
    # Returns: string '$value'
    set splitted [split [my configure -value] "\n"]
    set prepared [join [lmap line $splitted {set result "*$line"}] \n]
    return $prepared
}

Dataset [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
appendDataPointsMethod to set the data points.
configureConfigure properties.
getDataPointsNot documented.
getStrNot documented.
setDataPointsMethod to set the data points.
Properties

Readable: -Len, -NumType, -Type, -name

Writable: -Len, -NumType, -Type, -name

Subclasses

Axis, Trace, EmptyTrace

constructor [::SpiceGenTcl::Dataset]Dataset, Top, Main, Index

initialize dataset

Dataset create OBJNAME name type len ?numType?
Dataset new name type len ?numType?
Parameters
nameName of the dataset.
typeType of dataset.
lenTotal number of points.
numTypeNumerical type of dataset. Optional, default real.
method constructor {name type len {numType real}} {

    # initialize dataset
    #  name - name of the dataset
    #  type - type of dataset
    #  len - total number of points
    #  numType - numerical type of dataset
    my configure -name $name -Type $type -Len $len -NumType $numType
}

appendDataPoints [::SpiceGenTcl::Dataset]Dataset, Top, Main, Index

method to set the data points

OBJECT appendDataPoints dataPoint
Parameters
dataPointNot documented.
method appendDataPoints {dataPoint} {

    # method to set the data points
    lappend DataPoints $dataPoint
    return
}

getDataPoints [::SpiceGenTcl::Dataset]Dataset, Top, Main, Index

OBJECT getDataPoints
method getDataPoints {} {

    if {[info exists DataPoints]} {
        return $DataPoints
    } else {
        return -code error "Dataset with name '[my configure -name]' doesn't contain non-zero points"
    }
    return
}

getStr [::SpiceGenTcl::Dataset]Dataset, Top, Main, Index

OBJECT getStr
method getStr {} {

    return "Name: '[my configure -name]', Type: '[my configure -Type]', Length: '[my configure -Len]', Numerical type: '[my configure -NumType]'"
}

setDataPoints [::SpiceGenTcl::Dataset]Dataset, Top, Main, Index

method to set the data points

OBJECT setDataPoints dataPoints
Parameters
dataPointsNot documented.
method setDataPoints {dataPoints} {

    # method to set the data points
    set DataPoints $dataPoints
    return
}

Device [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
addParamAdds new parameter to device, and throws error on dublicated names.
checkFloatingPinsCheck if some pin device doesn't have connected nodes and return list of them.
configureConfigure properties.
deleteParamDeletes existing Parameter object from list Params.
duplListCheckSee DuplChecker.duplListCheck
genSPICEStringCreates device string for SPICE netlist.
getParamsGets the dictionary that contains parameter name as keys and parameter values as the values.
getPinsGets the dictionary that contains pin name as keys and connected node name as the values.
setParamValueSets (or change) value of particular parameters.
setPinNodeNameSets node name of particular pin, so, in other words, connect particular pin to particular node.
Properties

Readable: -name

Writable: -name

Superclasses

SPICEElement

Mixins

DuplChecker

Subclasses

::SpiceGenTcl::Common::BasicDevices::Resistor, ::SpiceGenTcl::Common::BasicDevices::Capacitor, ::SpiceGenTcl::Common::BasicDevices::Inductor, ::SpiceGenTcl::Common::BasicDevices::SubcircuitInstance, ::SpiceGenTcl::Common::BasicDevices::VSwitch, ::SpiceGenTcl::Common::BasicDevices::CSwitch, ::SpiceGenTcl::Common::BasicDevices::SubcircuitInstanceAuto, ::SpiceGenTcl::Common::Sources::dc, ::SpiceGenTcl::Common::Sources::ac, ::SpiceGenTcl::Common::Sources::pulse, ::SpiceGenTcl::Common::Sources::sin, ::SpiceGenTcl::Common::Sources::exp, ::SpiceGenTcl::Common::Sources::pwl, ::SpiceGenTcl::Common::Sources::sffm, ::SpiceGenTcl::Common::Sources::Vccs, ::SpiceGenTcl::Common::Sources::Vcvs, ::SpiceGenTcl::Common::Sources::Cccs, ::SpiceGenTcl::Common::Sources::Ccvs, ::SpiceGenTcl::Ngspice::BasicDevices::Resistor, ::SpiceGenTcl::Ngspice::BasicDevices::Capacitor, ::SpiceGenTcl::Ngspice::BasicDevices::Inductor, ::SpiceGenTcl::Ngspice::BasicDevices::SubcircuitInstance, ::SpiceGenTcl::Ngspice::BasicDevices::SubcircuitInstanceAuto, ::SpiceGenTcl::Ngspice::Sources::pulse, ::SpiceGenTcl::Ngspice::Sources::sffm, ::SpiceGenTcl::Ngspice::Sources::am, ::SpiceGenTcl::Ngspice::Sources::Vport, ::SpiceGenTcl::Ngspice::Sources::BehaviouralSource, ::SpiceGenTcl::Ngspice::SemiconductorDevices::Diode, ::SpiceGenTcl::Ngspice::SemiconductorDevices::Bjt, ::SpiceGenTcl::Ngspice::SemiconductorDevices::Jfet, ::SpiceGenTcl::Ngspice::SemiconductorDevices::Mesfet, ::SpiceGenTcl::Ngspice::SemiconductorDevices::Mosfet, ::SpiceGenTcl::Xyce::BasicDevices::Resistor, ::SpiceGenTcl::Xyce::BasicDevices::Capacitor, ::SpiceGenTcl::Xyce::BasicDevices::Inductor, ::SpiceGenTcl::Xyce::BasicDevices::GenSwitch, ::SpiceGenTcl::Xyce::BasicDevices::SubcircuitInstance, ::SpiceGenTcl::Xyce::BasicDevices::SubcircuitInstanceAuto, ::SpiceGenTcl::Xyce::Sources::BehaviouralSource, ::SpiceGenTcl::Xyce::SemiconductorDevices::Diode, ::SpiceGenTcl::Xyce::SemiconductorDevices::Bjt, ::SpiceGenTcl::Xyce::SemiconductorDevices::Jfet, ::SpiceGenTcl::Xyce::SemiconductorDevices::Mesfet, ::SpiceGenTcl::Xyce::SemiconductorDevices::Mosfet

constructor [::SpiceGenTcl::Device]Device, Top, Main, Index

Creates object of class Device.

Device create OBJNAME name pins params
Device new name pins params
Parameters
nameName of the device.
pinsList of pins in the order they appear in SPICE device's definition together with connected node in form: {{Name0 NodeName} {Name1 NodeName} {Name2 NodeName} ...} Nodes string values could be empty.
paramsList of instance parameters in form {{Name Value ?-pos|eq|poseq?} {Name Value ?-pos|eq|poseq?} {Name Value ?-pos|eq|poseq?} ...} Parameter list can be empty if device doesn't have instance parameters.
Description

Class models general device in SPICE, number of which must be assembled (connected) to get the circuit to simulate. This class provides basic machinery for creating any device that can be connected to net in circuit. It can be instantiated to create device that contains:

This class accept definition that contains elements listed above, and generates classes: Pin, Parameter, PositionalParameter with compositional relationship (has a).

Each parameter definition could be modified by optional flags:

method constructor {name pins params} {

    # Creates object of class `Device`.
    #  name - name of the device
    #  pins - list of pins in the order they appear in SPICE device's definition together
    #   with connected node in form: `{{Name0 NodeName} {Name1 NodeName} {Name2 NodeName} ...}`
    #   Nodes string values could be empty.
    #  params - list of instance parameters in form `{{Name Value ?-pos|eq|poseq?} {Name Value ?-pos|eq|poseq?}
    #   {Name Value ?-pos|eq|poseq?} ...}` Parameter list can be empty if device doesn't have instance
    #   parameters.
    # Class models general device in SPICE, number of which
    # must be assembled (connected) to get the circuit to simulate. This class provides basic machinery
    # for creating any device that can be connected to net in circuit. It can be instantiated to create
    # device that contains:
    #  - reference name, like R1, L1, M1, etc;
    #  - list of pins in the order of appearence of device's definition, for example, 'drain gate source' for
    #     MOS transistor;
    #  - list of parameters, that could be positional (+equation), keyword (+equation) parameters, like
    #     `R1 nm np 100 tc1=1 tc2={tc0*tc12}`, where 100 - positional parameter, tc1 - keyword parameters and
    #     tc2 - keyword parameter with equation
    # This class accept definition that contains elements listed above, and generates classes: Pin, Parameter,
    # PositionalParameter with compositional relationship (has a).

    my configure -name $name
    # create Pins objects
    foreach pin $pins {
        my AddPin [@ $pin 0] [@ $pin 1]
    }
    #ruff
    # Each parameter definition could be modified by
    #  optional flags:
    #  - pos - parameter has strict position and only '$Value' is displayed in netlist
    #  - eq - parameter may contain equation in terms of functions and other parsmeters,
    #    printed as '$name={$equation}'
    #  - poseq - combination of both flags, print only '{$equation}'
    if {$params!=""} {
        foreach param $params {
            if {[@ $param 2]=={}} {
                my addParam [@ $param 0] [@ $param 1]
            } elseif {[@ $param 1]=="-sw"} {
                my addParam [@ $param 0] -sw
            } else {
                my addParam {*}$param
            }
        }
    } else {
        set Params ""
    }
}

addParam [::SpiceGenTcl::Device]Device, Top, Main, Index

Adds new parameter to device, and throws error on dublicated names.

OBJECT addParam paramName value ?-name value? ?-eq|-poseq|-posnocheck|-pos|-nocheck?
Parameters
paramNameName of parameter.
valueValue of parameter.
-eqParameter is of class ::SpiceGenTcl::ParameterEquation, optional, forbids other switches.
-nocheckParameter is of class ::SpiceGenTcl::ParameterNoCheck, optional, forbids other switches.
-posParameter is of class ::SpiceGenTcl::ParameterPositional, optional, forbids other switches.
-poseqParameter is of class ::SpiceGenTcl::ParameterPositionalEquation, optional, forbids other switches.
-posnocheckParameter is of class ::SpiceGenTcl::ParameterPositionalNoCheck, optional, forbids other switches.
method addParam {paramName value args} {

    # Adds new parameter to device, and throws error on dublicated names.
    #  paramName - name of parameter
    #  value - value of parameter
    #  -eq - parameter is of class [::SpiceGenTcl::ParameterEquation], optional, forbids other switches
    #  -poseq - parameter is of class [::SpiceGenTcl::ParameterPositionalEquation], optional, forbids other
    #    switches
    #  -posnocheck - parameter is of class [::SpiceGenTcl::ParameterPositionalNoCheck], optional, forbids other
    #    switches
    #  -pos - parameter is of class [::SpiceGenTcl::ParameterPositional], optional, forbids other switches
    #  -nocheck - parameter is of class [::SpiceGenTcl::ParameterNoCheck], optional, forbids other switches
    # Synopsis: paramName value ?-name value? ?-eq|-poseq|-posnocheck|-pos|-nocheck?
    argparse {
        {-pos -forbid {eq poseq posnocheck nocheck}}
        {-eq -forbid {pos poseq posnocheck nocheck}}
        {-poseq -forbid {pos eq posnocheck nocheck}}
        {-posnocheck -forbid {pos eq poseq nocheck}}
        {-nocheck -forbid {pos eq poseq posnocheck}}
    }
    # method adds new Parameter object to the list Params
    set paramName [string tolower $paramName]
    if {[info exists Params]} {
        set paramList [dict keys $Params]
    }
    lappend paramList $paramName
    if {[my duplListCheck $paramList]} {
        return -code error "Parameters list '$paramList' has already contains parameter with name '$paramName'"
    }
    # select parameter object according to parameter qualificator
    if {$value=="-sw"} {
        dict append Params $paramName [::SpiceGenTcl::ParameterSwitch new $paramName]
    } elseif {[info exists pos]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterPositional new $paramName $value]
    } elseif {[info exists eq]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterEquation new $paramName $value]
    } elseif {[info exists poseq]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterPositionalEquation new $paramName $value]
    } elseif {[info exists posnocheck]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterPositionalNoCheck new $paramName $value]
    } elseif {[info exists nocheck]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterNoCheck new $paramName $value]
    } else {
        dict append Params $paramName [::SpiceGenTcl::Parameter new $paramName $value]
    }
    return
}

checkFloatingPins [::SpiceGenTcl::Device]Device, Top, Main, Index

Check if some pin device doesn't have connected nodes and return list of them.

OBJECT checkFloatingPins
Return value

list of floating pins

method checkFloatingPins {} {

    # Check if some pin device doesn't have connected nodes and return list of them.
    # Returns: list of floating pins
    set floatingPins {}
    dict for {pinName pin} $Pins {
        if {[$pin checkFloating]=="true"} {
            lappend floatingPins [$pin configure -name]
        }
    }
    return $floatingPins
}

deleteParam [::SpiceGenTcl::Device]Device, Top, Main, Index

Deletes existing Parameter object from list Params.

OBJECT deleteParam paramName
Parameters
paramNameName of parameter that will be deleted.
method deleteParam {paramName} {

    # Deletes existing `Parameter` object from list `Params`.
    #  paramName - name of parameter that will be deleted
    set paramName [string tolower $paramName]
    set error [catch {dget $Params $paramName}]
    if {$error>0} {
        return -code error "Parameter with name '$paramName' was not found in device's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
    } else {
        set Params [dict remove $Params $paramName]
    }
    return
}

genSPICEString [::SpiceGenTcl::Device]Device, Top, Main, Index

Creates device string for SPICE netlist.

OBJECT genSPICEString
Return value

string '$Name $Nodes $Params'

method genSPICEString {} {

    # Creates device string for SPICE netlist.
    # Returns: string '$Name $Nodes $Params'
    dict for {pinName pin} $Pins {
        set error [catch {$pin genSPICEString} errStr]
        if {$error!=1} {
            lappend nodes [$pin genSPICEString]
        } else {
            return -code error "Device '[my configure -name]' can't be netlisted because '$pinName' pin is floating"
        }
    }
    if {($Params=="") || ([info exists Params]==0)} {
        lappend params ""
        return "[my configure -name] [join $nodes]"
    } else {
        dict for {paramName param} $Params {
            lappend params [$param genSPICEString]
        }
        return "[my configure -name] [join $nodes] [join $params]"
    }
}

getParams [::SpiceGenTcl::Device]Device, Top, Main, Index

Gets the dictionary that contains parameter name as keys and parameter values as the values.

OBJECT getParams
Return value

parameters dictionary

method getParams {} {

    # Gets the dictionary that contains parameter name as keys and
    #  parameter values as the values.
    # Returns: parameters dictionary
    set tempDict [dcreate]
    dict for {paramName param} $Params {
        dict append tempDict $paramName [$param configure -value]
    }
    return $tempDict
}

getPins [::SpiceGenTcl::Device]Device, Top, Main, Index

Gets the dictionary that contains pin name as keys and connected node name as the values.

OBJECT getPins
Return value

parameters dictionary

method getPins {} {

    # Gets the dictionary that contains pin name as keys and
    #  connected node name as the values.
    # Returns: parameters dictionary
    set tempDict [dcreate]
    dict for {pinName pin} $Pins {
        dict append tempDict $pinName [$pin configure -nodename]
    }
    return $tempDict
}

setParamValue [::SpiceGenTcl::Device]Device, Top, Main, Index

Sets (or change) value of particular parameters.

OBJECT setParamValue ?args?
Parameters
argsList with even number of elements with parameter name and value, {paramName0 paramValue0 # paramName1 paramValue1 ...}
method setParamValue {args} {

    # Sets (or change) value of particular parameters.
    #  args - list with even number of elements with parameter name and value, {paramName0 paramValue0 #    paramName1 paramValue1 ...}
    if {[llength $args]%2!=0} {
        return -code error "Number of arguments to method '[dict get [info frame 0] method]' must be even"
    }
    for {set i 0} {$i<[llength $args]} {incr i 2} {
        set paramName [string tolower [@ $args [= {$i}]]]
        set paramValue [@ $args [= {$i+1}]]
        if {[catch {dget $Params $paramName}]} {
            return -code error "Parameter with name '$paramName' was not found in element's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
        } else {
            set param [dget $Params $paramName]
        }
        $param configure -value $paramValue
    }
    return
}

setPinNodeName [::SpiceGenTcl::Device]Device, Top, Main, Index

Sets node name of particular pin, so, in other words, connect particular pin to particular node.

OBJECT setPinNodeName pinName nodeName
Parameters
pinNameName of the pin.
nodeNameName of the node that we want connect to pin.
method setPinNodeName {pinName nodeName} {

    # Sets node name of particular pin, so,
    #  in other words, connect particular pin to particular node.
    #  pinName - name of the pin
    #  nodeName - name of the node that we want connect to pin
    set error [catch {dget $Pins $pinName}]
    if {$error>0} {
        return -code error "Pin with name '$pinName' was not found in device's '[my configure -name]' list of pins '[dict keys [my getPins]]'"
    } else {
        set pin [dget $Pins $pinName]
    }
    $pin configure -nodename $nodeName
    return
}

DuplChecker [::SpiceGenTcl]Top, Main, Index

Method summary
configureConfigure properties.
duplListCheckChecks if list contains duplicates.
Subclasses

Device, Model, Options, ParamStatement, Netlist, Analysis

duplListCheck [::SpiceGenTcl::DuplChecker]DuplChecker, Top, Main, Index

Checks if list contains duplicates.

OBJECT duplListCheck list
Parameters
listList to check.
Return value

0 if there are no duplicates and 1 if there are.

method duplListCheck {list} {

    # Checks if list contains duplicates.
    #  list - list to check
    # Returns: 0 if there are no duplicates and 1 if there are.
    set flag 0
    set new {}
    foreach item $list {
        if {[lsearch $new $item] < 0} {
            lappend new $item
        } else {
            set flag 1
            break
        }
    }
    return $flag
}

EmptyTrace [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
appendDataPointsSee Dataset.appendDataPoints
configureConfigure properties.
getDataPointsNot documented.
getStrSee Dataset.getStr
setDataPointsSee Dataset.setDataPoints
Properties

Readable: -Len, -NumType, -Type, -name

Writable: -Len, -NumType, -Type, -name

Superclasses

Dataset

constructor [::SpiceGenTcl::EmptyTrace]EmptyTrace, Top, Main, Index

initialize dummy trace

EmptyTrace create OBJNAME name type len ?numType?
EmptyTrace new name type len ?numType?
Parameters
nameName of the dummy trace.
typeType of dummy trace.
lenTotal number of points.
numTypeNumerical type of dummy trace. Optional, default real.
axisName of axis that is linked to dummy trace.
method constructor {name type len {numType real}} {

    # initialize dummy trace
    #  name - name of the dummy trace
    #  type - type of dummy trace
    #  len - total number of points
    #  axis - name of axis that is linked to dummy trace
    #  numType - numerical type of dummy trace
    next $name $type $len $numType
}

getDataPoints [::SpiceGenTcl::EmptyTrace]EmptyTrace, Top, Main, Index

OBJECT getDataPoints
method getDataPoints {} {

    if {[info exists DataPoints]} {
        return ""
    }
    return
}

Include [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringCreates include string for SPICE netlist.
Properties

Readable: -name, -value

Writable: -name, -value

Superclasses

RawString

constructor [::SpiceGenTcl::Include]Include, Top, Main, Index

Creates object of class Include.

OBJECT constructor value ?-name value?
Parameters
valueValue of the include path.
-nameName of the string that could be used to retrieve element from ::SpiceGenTcl::Netlist object and its descendants, optional.
Description

This class represent .include statement.

method constructor {value args} {

    # Creates object of class `Include`.
    #  value - value of the include path
    #  -name - name of the string that could be used to retrieve element from [::SpiceGenTcl::Netlist] object
    #    and its descendants, optional
    # This class represent .include statement.
    # Synopsis: value ?-name value?
    argparse {
        -name=
    }
    if {[info exists name]} {
        my configure -name $name
    } else {
        my configure -name [self object]
    }
    my configure -value $value
}

genSPICEString [::SpiceGenTcl::Include]Include, Top, Main, Index

Creates include string for SPICE netlist.

OBJECT genSPICEString
Return value

'.include $value'

method genSPICEString {} {

    # Creates include string for SPICE netlist.
    # Returns: '.include $value'
    return ".include [my configure -value]"
}

KeyArgsBuilder [::SpiceGenTcl]Top, Main, Index

Method summary
argsPreprocessCalls argparse and constructs list for passing to Device constructor.
buildArgStrBuilds argument list for argparse.
Subclasses

::SpiceGenTcl::Common::BasicDevices::Inductor, ::SpiceGenTcl::Common::Sources::Vsin, ::SpiceGenTcl::Ngspice::Sources::sffm, ::SpiceGenTcl::Ngspice::Sources::Vsffm, ::SpiceGenTcl::Ngspice::Sources::BehaviouralSource, ::SpiceGenTcl::Ngspice::BasicDevices::RModel, ::SpiceGenTcl::Ngspice::BasicDevices::CModel, ::SpiceGenTcl::Ngspice::BasicDevices::LModel, ::SpiceGenTcl::Ngspice::BasicDevices::VSwitchModel, ::SpiceGenTcl::Ngspice::BasicDevices::CSwitchModel, ::SpiceGenTcl::Ngspice::SemiconductorDevices::DiodeModel, ::SpiceGenTcl::Ngspice::SemiconductorDevices::BjtGPModel, ::SpiceGenTcl::Ngspice::SemiconductorDevices::Jfet1Model, ::SpiceGenTcl::Ngspice::SemiconductorDevices::Jfet2Model, ::SpiceGenTcl::Ngspice::SemiconductorDevices::Mesfet1Model, ::SpiceGenTcl::Xyce::BasicDevices::Resistor, ::SpiceGenTcl::Xyce::BasicDevices::Capacitor, ::SpiceGenTcl::Xyce::BasicDevices::Inductor, ::SpiceGenTcl::Xyce::Sources::BehaviouralSource, ::SpiceGenTcl::Xyce::BasicDevices::RModel, ::SpiceGenTcl::Xyce::BasicDevices::CModel, ::SpiceGenTcl::Xyce::BasicDevices::LModel, ::SpiceGenTcl::Xyce::BasicDevices::VSwitchModel, ::SpiceGenTcl::Xyce::BasicDevices::CSwitchModel, ::SpiceGenTcl::Xyce::SemiconductorDevices::DiodeModel, ::SpiceGenTcl::Xyce::SemiconductorDevices::BjtGPModel, ::SpiceGenTcl::Xyce::SemiconductorDevices::Jfet1Model, ::SpiceGenTcl::Xyce::SemiconductorDevices::Jfet2Model, ::SpiceGenTcl::Xyce::SemiconductorDevices::Mesfet1Model

argsPreprocess [::SpiceGenTcl::KeyArgsBuilder]KeyArgsBuilder, Top, Main, Index

Calls argparse and constructs list for passing to Device constructor.

OBJECT argsPreprocess paramsNames ?args?
Parameters
paramsNamesList of parameter names, define alias for parameter name by using two element list {paramName aliasName}
argsArgument list with key names and it's values.
Return value

string in form *-paramName= \n {-paramName= -alias aliasName} \n ...*

method argsPreprocess {paramsNames args} {

    # Calls argparse and constructs list for passing to Device constructor.
    #  paramsNames - list of parameter names, define alias for parameter name by
    #  using two element list {paramName aliasName}
    #  args - argument list with key names and it's values
    # Returns: string in form *-paramName= \n {-paramName= -alias aliasName} \n ...*
    set paramDefList [my buildArgStr $paramsNames]
    set arguments [argparse -inline "
        $paramDefList
    "]
    set params ""
    dict for {paramName value} $arguments {
        lappend params "$paramName $value"
    }
    return $params
}

buildArgStr [::SpiceGenTcl::KeyArgsBuilder]KeyArgsBuilder, Top, Main, Index

Builds argument list for argparse.

OBJECT buildArgStr paramsNames
Parameters
paramsNamesList of parameter names, define alias for parameter name by using two element list {paramName aliasName}
Return value

string in form *-paramName= \n {-paramName= -alias aliasName} \n ...*

method buildArgStr {paramsNames} {

    # Builds argument list for argparse.
    #  paramsNames - list of parameter names, define alias for parameter name by
    #  using two element list {paramName aliasName}
    # Returns: string in form *-paramName= \n {-paramName= -alias aliasName} \n ...*
    foreach paramName $paramsNames {
        if {[llength $paramName]>1} {
            lappend paramDefList "\{-[@ $paramName 0]= -alias [@ $paramName 1]\}"
        } else {
            lappend paramDefList "-${paramName}="
        }
    }
    set paramDefStr [join $paramDefList \n]
    return $paramDefStr
}

Library [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringCreates library string for SPICE netlist.
Properties

Readable: -libvalue, -name, -value

Writable: -libvalue, -name, -value

Superclasses

RawString

constructor [::SpiceGenTcl::Library]Library, Top, Main, Index

Creates object of class Library.

OBJECT constructor value libValue ?-name value?
Parameters
valueValue of the include file.
libValueValue of selected library.
-nameName of the string that could be used to retrieve element from ::SpiceGenTcl::Netlist object and its descendants, optional.
Description

Class represent .lib statement.

method constructor {value libValue args} {

    # Creates object of class `Library`.
    #  value - value of the include file
    #  libValue - value of selected library
    #  -name - name of the string that could be used to retrieve element from [::SpiceGenTcl::Netlist] object
    #    and its descendants, optional
    # Class represent .lib statement.
    # Synopsis: value libValue ?-name value?
    argparse {
        -name=
    }
    if {[info exists name]} {
        my configure -name $name
    } else {
        my configure -name [self object]
    }
    my configure -value $value -libvalue $libValue
}

genSPICEString [::SpiceGenTcl::Library]Library, Top, Main, Index

Creates library string for SPICE netlist.

OBJECT genSPICEString
Return value

'.lib $value $libvalue'

method genSPICEString {} {

    # Creates library string for SPICE netlist.
    # Returns: '.lib $value $libvalue'
    return ".lib [my configure -value] [my configure -libvalue]"
}

Model [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
addParamAdds new parameter to device, and throws error on dublicated names.
configureConfigure properties.
deleteParamDeletes existing Parameter object from list Params.
duplListCheckSee DuplChecker.duplListCheck
genSPICEStringCreates model string for SPICE netlist.
getParamsGets the dictionary that contains parameter name as keys and parameter values as the values.
setParamValueSets (or change) value of particular parameters.
Properties

Readable: -name, -type

Writable: -name, -type

Superclasses

SPICEElement

Mixins

DuplChecker

Subclasses

::SpiceGenTcl::Ngspice::BasicDevices::RModel, ::SpiceGenTcl::Ngspice::BasicDevices::CModel, ::SpiceGenTcl::Ngspice::BasicDevices::LModel, ::SpiceGenTcl::Ngspice::BasicDevices::VSwitchModel, ::SpiceGenTcl::Ngspice::BasicDevices::CSwitchModel, ::SpiceGenTcl::Ngspice::SemiconductorDevices::DiodeModel, ::SpiceGenTcl::Ngspice::SemiconductorDevices::BjtGPModel, ::SpiceGenTcl::Ngspice::SemiconductorDevices::Jfet1Model, ::SpiceGenTcl::Ngspice::SemiconductorDevices::Jfet2Model, ::SpiceGenTcl::Ngspice::SemiconductorDevices::Mesfet1Model, ::SpiceGenTcl::Xyce::BasicDevices::RModel, ::SpiceGenTcl::Xyce::BasicDevices::CModel, ::SpiceGenTcl::Xyce::BasicDevices::LModel, ::SpiceGenTcl::Xyce::BasicDevices::VSwitchModel, ::SpiceGenTcl::Xyce::BasicDevices::CSwitchModel, ::SpiceGenTcl::Xyce::SemiconductorDevices::DiodeModel, ::SpiceGenTcl::Xyce::SemiconductorDevices::BjtGPModel, ::SpiceGenTcl::Xyce::SemiconductorDevices::Jfet1Model, ::SpiceGenTcl::Xyce::SemiconductorDevices::Jfet2Model, ::SpiceGenTcl::Xyce::SemiconductorDevices::Mesfet1Model

constructor [::SpiceGenTcl::Model]Model, Top, Main, Index

Creates object of class Model.

Model create OBJNAME name type params
Model new name type params
Parameters
nameName of the model.
typeType of model, for example, diode, npn, etc.
paramsNot documented.
instParamsList of instance parameters in form {{name value ?-pos|eq|poseq?} {name value ?-pos|eq|poseq?} {name value ?-pos|eq|poseq?} ...}
Description

Class represents model card in SPICE netlist.

method constructor {name type params} {

    # Creates object of class `Model`.
    #  name - name of the model
    #  type - type of model, for example, diode, npn, etc
    #  instParams - list of instance parameters in form `{{name value ?-pos|eq|poseq?}
    #   {name value ?-pos|eq|poseq?} {name value ?-pos|eq|poseq?} ...}`
    # Class represents model card in SPICE netlist.
    my configure -name $name -type $type
    # create Params objects
    if {$params!=""} {
        foreach param $params {
            if {[@ $param 2]=={}} {
                my addParam [@ $param 0] [@ $param 1]
            } elseif {[@ $param 2]=="-eq"} {
                my addParam [@ $param 0] [@ $param 1] -eq
            } else {
                error "Wrong parameter definition in model $name"
            }
        }
    } else {
        set Params ""
    }
}

addParam [::SpiceGenTcl::Model]Model, Top, Main, Index

Adds new parameter to device, and throws error on dublicated names.

OBJECT addParam paramName value ?-name value? ?-eq|-poseq|-posnocheck|-pos|-nocheck?
Parameters
paramNameName of parameter.
valueValue of parameter.
-eqParameter is of class ::SpiceGenTcl::ParameterEquation, optional, forbids other switches.
-nocheckParameter is of class ::SpiceGenTcl::ParameterNoCheck, optional, forbids other switches.
-posParameter is of class ::SpiceGenTcl::ParameterPositional, optional, forbids other switches.
-poseqParameter is of class ::SpiceGenTcl::ParameterPositionalEquation, optional, forbids other switches.
-posnocheckParameter is of class ::SpiceGenTcl::ParameterPositionalNoCheck, optional, forbids other switches.
method addParam {paramName value args} {

    # Adds new parameter to device, and throws error on dublicated names.
    #  paramName - name of parameter
    #  value - value of parameter
    #  -eq - parameter is of class [::SpiceGenTcl::ParameterEquation], optional, forbids other switches
    #  -poseq - parameter is of class [::SpiceGenTcl::ParameterPositionalEquation], optional, forbids other
    #    switches
    #  -posnocheck - parameter is of class [::SpiceGenTcl::ParameterPositionalNoCheck], optional, forbids other
    #    switches
    #  -pos - parameter is of class [::SpiceGenTcl::ParameterPositional], optional, forbids other switches
    #  -nocheck - parameter is of class [::SpiceGenTcl::ParameterNoCheck], optional, forbids other switches
    # Synopsis: paramName value ?-name value? ?-eq|-poseq|-posnocheck|-pos|-nocheck?
    argparse {
        {-pos -forbid {eq poseq posnocheck nocheck}}
        {-eq -forbid {pos poseq posnocheck nocheck}}
        {-poseq -forbid {pos eq posnocheck nocheck}}
        {-posnocheck -forbid {pos eq poseq nocheck}}
        {-nocheck -forbid {pos eq poseq posnocheck}}
    }
    # method adds new Parameter object to the list Params
    set paramName [string tolower $paramName]
    if {[info exists Params]} {
        set paramList [dict keys $Params]
    }
    lappend paramList $paramName
    if {[my duplListCheck $paramList]} {
        return -code error "Parameters list '$paramList' has already contains parameter with name '$paramName'"
    }
    # select parameter object according to parameter qualificator
    if {$value=="-sw"} {
        dict append Params $paramName [::SpiceGenTcl::ParameterSwitch new $paramName]
    } elseif {[info exists pos]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterPositional new $paramName $value]
    } elseif {[info exists eq]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterEquation new $paramName $value]
    } elseif {[info exists poseq]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterPositionalEquation new $paramName $value]
    } elseif {[info exists posnocheck]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterPositionalNoCheck new $paramName $value]
    } elseif {[info exists nocheck]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterNoCheck new $paramName $value]
    } else {
        dict append Params $paramName [::SpiceGenTcl::Parameter new $paramName $value]
    }
    return
}

deleteParam [::SpiceGenTcl::Model]Model, Top, Main, Index

Deletes existing Parameter object from list Params.

OBJECT deleteParam paramName
Parameters
paramNameName of parameter that will be deleted.
method deleteParam {paramName} {

    # Deletes existing `Parameter` object from list `Params`.
    #  paramName - name of parameter that will be deleted
    set paramName [string tolower $paramName]
    set error [catch {dget $Params $paramName}]
    if {$error>0} {
        return -code error "Parameter with name '$paramName' was not found in device's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
    } else {
        set Params [dict remove $Params $paramName]
    }
    return
}

genSPICEString [::SpiceGenTcl::Model]Model, Top, Main, Index

Creates model string for SPICE netlist.

OBJECT genSPICEString
Return value

string '.model $name $type $Params'

method genSPICEString {} {

    # Creates model string for SPICE netlist.
    # Returns: string '.model $name $type $Params'
    if {($Params=="") || ([info exists Params]==0)} {
        lappend params ""
        return ".model [my configure -name] [my configure -type]"
    } else {
        dict for {paramName param} $Params {
            lappend params [$param genSPICEString]
        }
        return ".model [my configure -name] [my configure -type]([join $params])"
    }
}

getParams [::SpiceGenTcl::Model]Model, Top, Main, Index

Gets the dictionary that contains parameter name as keys and parameter values as the values.

OBJECT getParams
Return value

parameters dictionary

method getParams {} {

    # Gets the dictionary that contains parameter name as keys and
    #  parameter values as the values.
    # Returns: parameters dictionary
    set tempDict [dcreate]
    dict for {paramName param} $Params {
        dict append tempDict $paramName [$param configure -value]
    }
    return $tempDict
}

setParamValue [::SpiceGenTcl::Model]Model, Top, Main, Index

Sets (or change) value of particular parameters.

OBJECT setParamValue ?args?
Parameters
argsList with even number of elements with parameter name and value, {paramName0 paramValue0 # paramName1 paramValue1 ...}
method setParamValue {args} {

    # Sets (or change) value of particular parameters.
    #  args - list with even number of elements with parameter name and value, {paramName0 paramValue0 #    paramName1 paramValue1 ...}
    if {[llength $args]%2!=0} {
        return -code error "Number of arguments to method '[dict get [info frame 0] method]' must be even"
    }
    for {set i 0} {$i<[llength $args]} {incr i 2} {
        set paramName [string tolower [@ $args [= {$i}]]]
        set paramValue [@ $args [= {$i+1}]]
        if {[catch {dget $Params $paramName}]} {
            return -code error "Parameter with name '$paramName' was not found in element's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
        } else {
            set param [dget $Params $paramName]
        }
        $param configure -value $paramValue
    }
    return
}

Netlist [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
addAdds elements object to Elements dictionary.
configureConfigure properties.
delDeletes element from the netlist by its name.
duplListCheckSee DuplChecker.duplListCheck
genSPICEStringCreates netlist string for SPICE netlist.
getAllElemNamesGets names of all elements in netlist.
getElementGets particular element object reference by its name.
Properties

Readable: -name

Writable: -name

Superclasses

SPICEElement

Mixins

DuplChecker

Subclasses

Circuit, Subcircuit

constructor [::SpiceGenTcl::Netlist]Netlist, Top, Main, Index

Creates object of class Netlist.

Netlist create OBJNAME name
Netlist new name
Parameters
nameName of the netlist.
Description

Class implements netlist as a collection of SPICE elements. Any element that has SPICEElement as a parent class can be added to Netlist, except Options and Analysis.

method constructor {name} {

    # Creates object of class `Netlist`.
    #  name - name of the netlist
    # Class implements netlist as a collection of SPICE elements. Any element that has SPICEElement
    # as a parent class can be added to Netlist, except Options and Analysis.
    my configure -name $name
}

add [::SpiceGenTcl::Netlist]Netlist, Top, Main, Index

Adds elements object to Elements dictionary.

OBJECT add element
Parameters
elementElement object reference.
method add {element} {

    # Adds elements object to Elements dictionary.
    #  element - element object reference
    set elementClass [info object class $element]
    if {$elementClass=={::SpiceGenTcl::Options}} {
        return -code error "Options element can't be included in general netlist, only top-level Circuit"
    } elseif {$elementClass=={::SpiceGenTcl::Analysis}} {
        return -code error "Analysis element can't be included in general netlist, only top-level Circuit"
    }
    set elemName [string tolower [$element configure -name]]
    if {[info exists Elements]} {
        set elemList [my getAllElemNames]
    }
    lappend elemList $elemName
    if {[my duplListCheck $elemList]} {
        return -code error "Netlist '[my configure -name]' already contains element with name $elemName"
    }
    dict append Elements [$element configure -name] $element
    return
}

del [::SpiceGenTcl::Netlist]Netlist, Top, Main, Index

Deletes element from the netlist by its name.

OBJECT del elemName
Parameters
elemNameName of element to delete.
method del {elemName} {

    # Deletes element from the netlist by its name.
    #  elemName - name of element to delete
    set elemName [string tolower $elemName]
    set error [catch {dget $Elements $elemName}]
    if {$error>0} {
        return -code error "Element with name '$elemName' was not found in netlist's '[my configure -name]' list of elements"
    } else {
        set Elements [dict remove $Elements $elemName]
    }
    return
}

genSPICEString [::SpiceGenTcl::Netlist]Netlist, Top, Main, Index

Creates netlist string for SPICE netlist.

OBJECT genSPICEString
Return value

'netlist string'

method genSPICEString {} {

    # Creates netlist string for SPICE netlist.
    # Returns: 'netlist string'
    dict for {elemName element} $Elements {
        lappend totalStr [$element genSPICEString]
    }
    return [join $totalStr \n]
}

getAllElemNames [::SpiceGenTcl::Netlist]Netlist, Top, Main, Index

Gets names of all elements in netlist.

OBJECT getAllElemNames
Return value

list of elements names

method getAllElemNames {} {

    # Gets names of all elements in netlist.
    # Returns: list of elements names
    dict for {elemName elem} $Elements {
        lappend names $elemName
    }
    return $names
}

getElement [::SpiceGenTcl::Netlist]Netlist, Top, Main, Index

Gets particular element object reference by its name.

OBJECT getElement elemName
Parameters
elemNameName of element.
method getElement {elemName} {

    # Gets particular element object reference by its name.
    #  elemName - name of element
    set elemName [string tolower $elemName]
    set error [catch {dget $Elements $elemName}]
    if {$error>0} {
        return -code error "Element with name '$elemName' was not found in netlist's '[my configure -name]' list of elements"
    } else {
        set foundElem [dget $Elements $elemName]
    }
    return $foundElem
}

Options [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
addParamCreates new parameter object and add it to the list Params.
configureConfigure properties.
deleteParamDeletes existing Parameter object from list Params.
duplListCheckSee DuplChecker.duplListCheck
genSPICEStringCreates options string for SPICE netlist.
getParamsGets the dictionary that contains parameter name as keys and parameter values as the values.
setParamValueSets (or change) value of particular parameters.
Properties

Readable: -name

Writable: -name

Superclasses

SPICEElement

Mixins

DuplChecker

constructor [::SpiceGenTcl::Options]Options, Top, Main, Index

Creates object of class Options.

OBJECT constructor params ?-name value?
Parameters
paramsList of instance parameters in form {{name value ?-sw?} {name value ?-sw?} {name value ?-sw?} ...}
-nameName of the string that could be used to retrieve element from ::SpiceGenTcl::Netlist object and its descendants, optional.
Description

This class represent .options statement.

method constructor {params args} {

    # Creates object of class `Options`.
    #  params - list of instance parameters in form `{{name value ?-sw?} {name value ?-sw?}
    #   {name value ?-sw?} ...}`
    #  -name - name of the string that could be used to retrieve element from [::SpiceGenTcl::Netlist] object
    #    and its descendants, optional
    # This class represent .options statement.
    # Synopsis: params ?-name value?
    argparse {
        -name=
    }
    if {[info exists name]} {
        my configure -name $name
    } else {
        my configure -name [self object]
    }
    foreach param $params {
        if {[@ $param 2]=={}} {
            if {[@ $param 1]=="-sw"} {
                my addParam [@ $param 0] -sw
            } else {
                my addParam [@ $param 0] [@ $param 1]
            }
        } else {
            return -code error "Wrong parameter definition in Options"
        }
    }
}

addParam [::SpiceGenTcl::Options]Options, Top, Main, Index

Creates new parameter object and add it to the list Params.

OBJECT addParam paramName value
Parameters
paramNameName of parameter.
valueValue of parameter, with optional qualificator -eq.
method addParam {paramName value} {

    # Creates new parameter object and add it to the list `Params`.
    #  paramName - name of parameter
    #  value - value of parameter, with optional qualificator -eq
    set paramName [string tolower $paramName]
    if {[info exists Params]} {
        set paramList [dict keys $Params]
    }
    lappend paramList $paramName
    if {[my duplListCheck $paramList]} {
        return -code error "Parameters list '$paramList' has already contains parameter with name '$paramName'"
    }
    if {$value=="-sw"} {
        dict append Params $paramName [::SpiceGenTcl::ParameterSwitch new $paramName]
    } else {
        dict append Params $paramName [::SpiceGenTcl::ParameterNoCheck new $paramName $value]
    }
    return
}

deleteParam [::SpiceGenTcl::Options]Options, Top, Main, Index

Deletes existing Parameter object from list Params.

OBJECT deleteParam paramName
Parameters
paramNameName of parameter that will be deleted.
method deleteParam {paramName} {

    # Deletes existing `Parameter` object from list `Params`.
    #  paramName - name of parameter that will be deleted
    set paramName [string tolower $paramName]
    set error [catch {dget $Params $paramName}]
    if {$error>0} {
        return -code error "Parameter with name '$paramName' was not found in device's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
    } else {
        set Params [dict remove $Params $paramName]
    }
    return
}

genSPICEString [::SpiceGenTcl::Options]Options, Top, Main, Index

Creates options string for SPICE netlist.

OBJECT genSPICEString
Return value

'.options $Params'

method genSPICEString {} {

    # Creates options string for SPICE netlist.
    # Returns: '.options $Params'
    dict for {paramName param} $Params {
        lappend params [$param genSPICEString]
    }
    return ".options [join $params]"
}

getParams [::SpiceGenTcl::Options]Options, Top, Main, Index

Gets the dictionary that contains parameter name as keys and parameter values as the values.

OBJECT getParams
Return value

parameters dictionary

method getParams {} {

    # Gets the dictionary that contains parameter name as keys and
    #  parameter values as the values.
    # Returns: parameters dictionary
    set tempDict [dcreate]
    dict for {paramName param} $Params {
        # check if parameter doesn't have value, it means that we return {} for switch parameter
        if {[catch {$param configure -value}]} {
            dict append tempDict $paramName ""
        } else {
            dict append tempDict $paramName [$param configure -value]
        }
    }
    return $tempDict
}

setParamValue [::SpiceGenTcl::Options]Options, Top, Main, Index

Sets (or change) value of particular parameters.

OBJECT setParamValue ?args?
Parameters
argsList with even number of elements with parameter name and value, {paramName0 paramValue0 # paramName1 paramValue1 ...}
method setParamValue {args} {

    # Sets (or change) value of particular parameters.
    #  args - list with even number of elements with parameter name and value, {paramName0 paramValue0 #    paramName1 paramValue1 ...}
    if {[llength $args]%2!=0} {
        return -code error "Number of arguments to method '[dict get [info frame 0] method]' must be even"
    }
    for {set i 0} {$i<[llength $args]} {incr i 2} {
        set paramName [string tolower [@ $args [= {$i}]]]
        set paramValue [@ $args [= {$i+1}]]
        if {[catch {dget $Params $paramName}]} {
            return -code error "Parameter with name '$paramName' was not found in element's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
        } else {
            set param [dget $Params $paramName]
        }
        $param configure -value $paramValue
    }
    return
}

Parameter [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringCreates string for SPICE netlist.
Properties

Readable: -name, -value

Writable: -name, -value

Superclasses

ParameterSwitch

Subclasses

ParameterNoCheck, ParameterPositional, ParameterDefault, ParameterEquation

constructor [::SpiceGenTcl::Parameter]Parameter, Top, Main, Index

Creates object of class Parameter with parameter name and value.

Parameter create OBJNAME name value
Parameter new name value
Parameters
nameName of the parameter.
valueValue of the parameter.
Description

Class models parameter that has a name and a value - the most common type of parameters in SPICE netlist. Its representation in netlist is 'name=value', and can be called "keyword parameter".

method constructor {name value} {

    # Creates object of class `Parameter` with parameter name and value.
    #  name - name of the parameter
    #  value - value of the parameter
    # Class models parameter that has a name and a value - the most
    # common type of parameters in SPICE netlist. Its representation in netlist is
    # 'name=value', and can be called "keyword parameter".
    my configure -name $name -value $value
}

genSPICEString [::SpiceGenTcl::Parameter]Parameter, Top, Main, Index

Creates string for SPICE netlist.

OBJECT genSPICEString
Return value

'$name=$value'

method genSPICEString {} {

    # Creates string for SPICE netlist.
    # Returns: '$name=$value'
    return "[my configure -name]=[my configure -value]"
}

ParameterDefault [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringSee Parameter.genSPICEString
resetValueResets value of the parameter to it's default value.
Properties

Readable: -defvalue, -name, -value

Writable: -defvalue, -name, -value

Superclasses

Parameter

constructor [::SpiceGenTcl::ParameterDefault]ParameterDefault, Top, Main, Index

Creates object of class ParameterDefault with parameter name, value and default value.

ParameterDefault create OBJNAME name value defValue
ParameterDefault new name value defValue
Parameters
nameName of the parameter.
valueValue of the parameter.
defValueDefault value of the parameter.
Description

Class models parameter that has a name and a value, but it differs from parent class in sense of having default value, so it has special ability to reset its value to default value by special method resetValue.

method constructor {name value defValue} {

    # Creates object of class `ParameterDefault` with parameter name, value and default value.
    #  name - name of the parameter
    #  value - value of the parameter
    #  defValue - default value of the parameter
    # Class models parameter that has a name and a value, but it differs from
    # parent class in sense of having default value, so it has special ability to reset its value to default
    # value by special method `resetValue`.
    my configure -defvalue $defValue
    next $name $value
}

resetValue [::SpiceGenTcl::ParameterDefault]ParameterDefault, Top, Main, Index

Resets value of the parameter to it's default value.

OBJECT resetValue
method resetValue {} {

    # Resets value of the parameter to it's default value.
    my configure -value [my configure -defvalue]
    return
}

ParameterEquation [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringCreates string for SPICE netlist.
Properties

Readable: -name, -value

Writable: -name, -value

Superclasses

Parameter

Subclasses

ParameterPositionalEquation

constructor [::SpiceGenTcl::ParameterEquation]ParameterEquation, Top, Main, Index

Creates object of class ParameterEquation with parameter name and value as an equation.

ParameterEquation create OBJNAME name value
ParameterEquation new name value
Parameters
nameName of the parameter.
valueValue of the parameter.
Description

Class models parameter that has representation as an equation. Example: R={R1+R2}

method constructor {name value} {

    # Creates object of class `ParameterEquation` with parameter name and value as an equation.
    #  name - name of the parameter
    #  value - value of the parameter
    # Class models parameter that has representation as an equation.
    # Example: R={R1+R2}
    next $name $value
}

genSPICEString [::SpiceGenTcl::ParameterEquation]ParameterEquation, Top, Main, Index

Creates string for SPICE netlist.

OBJECT genSPICEString
Return value

'$name={$value}'

method genSPICEString {} {

    # Creates string for SPICE netlist.
    # Returns: '$name={$value}'
    return "[my configure -name]=\{[my configure -value]\}"
}

ParameterNoCheck [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringSee Parameter.genSPICEString
Properties

Readable: -name, -value

Writable: -name, -value

Superclasses

Parameter

constructor [::SpiceGenTcl::ParameterNoCheck]ParameterNoCheck, Top, Main, Index

Creates object of class ParameterNoCheck with parameter name and value.

ParameterNoCheck create OBJNAME name value
ParameterNoCheck new name value
Parameters
nameName of the parameter.
valueValue of the parameter.
Description

Class models parameter the same as described by Parameter but without check for value form.

method constructor {name value} {

    # Creates object of class `ParameterNoCheck` with parameter name and value.
    #  name - name of the parameter
    #  value - value of the parameter
    # Class models parameter the same as described by `Parameter` but without check for value form.
    next $name $value
}

ParameterPositional [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringCreates string for SPICE netlist.
Properties

Readable: -name, -value

Writable: -name, -value

Superclasses

Parameter

Subclasses

ParameterPositionalNoCheck

constructor [::SpiceGenTcl::ParameterPositional]ParameterPositional, Top, Main, Index

Creates object of class ParameterPositional with parameter name and value.

ParameterPositional create OBJNAME name value
ParameterPositional new name value
Parameters
nameName of parameter.
valueValue of parameter.
Description

Class models parameter that has a name and a value, but it differs from parent class in the sense of netlist representation: this parameter represents only by the value in the netlist. It's meaning for holding element is taken from it's position in the element's definition, for example, R1 np nm 100 tc1=1 tc2=0 - resistor with positional parameter R=100, you can't put it after parameters tc1 and tc2, it must be placed right after the pins definition.

method constructor {name value} {

    # Creates object of class `ParameterPositional` with parameter name and value.
    #  name - name of parameter
    #  value - value of parameter
    # Class models parameter that has a name and a value, but it differs from
    # parent class in the sense of netlist representation: this parameter represents only
    # by the value in the netlist. It's meaning for holding element is taken from
    # it's position in the element's definition, for example, R1 np nm 100 tc1=1 tc2=0 - resistor
    # with positional parameter R=100, you can't put it after parameters tc1 and tc2, it must be placed
    # right after the pins definition.
    next $name $value
}

genSPICEString [::SpiceGenTcl::ParameterPositional]ParameterPositional, Top, Main, Index

Creates string for SPICE netlist.

OBJECT genSPICEString
Return value

'$Value'

method genSPICEString {} {

    # Creates string for SPICE netlist.
    # Returns: '$Value'
    return "[my configure -value]"
}

ParameterPositionalEquation [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringCreates string for SPICE netlist.
Properties

Readable: -name, -value

Writable: -name, -value

Superclasses

ParameterEquation

constructor [::SpiceGenTcl::ParameterPositionalEquation]ParameterPositionalEquation, Top, Main, Index

Creates object of class ParameterPositionalEquation with parameter name and value as an equation in positional form.

ParameterPositionalEquation create OBJNAME name value
ParameterPositionalEquation new name value
Parameters
nameName of the parameter.
valueValue of the parameter.
Description

Class models parameter that has representation as an equation, but in form of positional parameter. Example: {R1+R2}

method constructor {name value} {

    # Creates object of class `ParameterPositionalEquation` with parameter name and value as an equation in
    # positional form.
    #  name - name of the parameter
    #  value - value of the parameter
    # Class models parameter that has representation as an equation, but in form of
    # positional parameter. Example: {R1+R2}
    next $name $value
}

genSPICEString [::SpiceGenTcl::ParameterPositionalEquation]ParameterPositionalEquation, Top, Main, Index

Creates string for SPICE netlist.

OBJECT genSPICEString
Return value

'{$paramValue}'

method genSPICEString {} {

    # Creates string for SPICE netlist.
    # Returns: '{$paramValue}'
    return "\{[my configure -value]\}"
}

ParameterPositionalNoCheck [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringCreates string for SPICE netlist. Results: '$value'
Properties

Readable: -name, -value

Writable: -name, -value

Superclasses

ParameterPositional

constructor [::SpiceGenTcl::ParameterPositionalNoCheck]ParameterPositionalNoCheck, Top, Main, Index

Creates object of class ParameterPositionalNoCheck.

ParameterPositionalNoCheck create OBJNAME name value
ParameterPositionalNoCheck new name value
Parameters
nameName of parameter.
valueValue of parameter.
Description

Class models parameter the same as described by ParameterPositional but without check for value form.

method constructor {name value} {

    # Creates object of class `ParameterPositionalNoCheck`.
    #  name - name of parameter
    #  value - value of parameter
    # Class models parameter the same as described by `ParameterPositional` but without check for value form.
    next $name $value
}

genSPICEString [::SpiceGenTcl::ParameterPositionalNoCheck]ParameterPositionalNoCheck, Top, Main, Index

Creates string for SPICE netlist. Results: '$value'

OBJECT genSPICEString
method genSPICEString {} {

    # Creates string for SPICE netlist.
    # Results: '$value'
    return "[my configure -value]"
}

ParameterSwitch [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringCreates string for SPICE netlist.
Properties

Readable: -name

Writable: -name

Superclasses

SPICEElement

Subclasses

Parameter

constructor [::SpiceGenTcl::ParameterSwitch]ParameterSwitch, Top, Main, Index

Creates object of class ParameterSwitch with parameter name.

ParameterSwitch create OBJNAME name
ParameterSwitch new name
Parameters
nameName of the parameter.
Description

Class models base parameter acting like a switch - its presence gives us information that something it controls is on. This parameter doesn't have a value, and it is the most basic class in Parameter class family.

method constructor {name} {

    # Creates object of class `ParameterSwitch` with parameter name.
    #  name - name of the parameter
    # Class models base parameter acting like a switch -
    # its presence gives us information that something it controls is on.
    # This parameter doesn't have a value, and it is the most basic class
    # in Parameter class family.
    my configure -name $name
}

genSPICEString [::SpiceGenTcl::ParameterSwitch]ParameterSwitch, Top, Main, Index

Creates string for SPICE netlist.

OBJECT genSPICEString
Return value

string '$name'

method genSPICEString {} {

    # Creates string for SPICE netlist.
    # Returns: string '$name'
    return "[my configure -name]"
}

ParamStatement [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
addParamAdds new Parameter object to the list Params.
configureConfigure properties.
deleteParamDeletes existing Parameter object from list Params.
duplListCheckSee DuplChecker.duplListCheck
genSPICEStringCreates parameter statement string for SPICE netlist.
getParamsGets the dictionary that contains parameter name as keys and parameter values as the values.
setParamValueSets (or change) value of particular parameters.
Properties

Readable: -name

Writable: -name

Superclasses

SPICEElement

Mixins

DuplChecker

constructor [::SpiceGenTcl::ParamStatement]ParamStatement, Top, Main, Index

Creates object of class ParamStatement.

OBJECT constructor params ?-name value?
Parameters
paramsList of instance parameters in form {{name value} {name value} {name equation -eq} ...}
-nameName of the library that could be used to retrieve element from ::SpiceGenTcl::Netlist object and its descendants, optional.
Description

Class represent .param statement.

method constructor {params args} {

    # Creates object of class `ParamStatement`.
    #  params - list of instance parameters in form `{{name value} {name value} {name equation -eq} ...}`
    #  -name - name of the library that could be used to retrieve element from [::SpiceGenTcl::Netlist] object
    #    and its descendants, optional
    # Class represent .param statement.
    # Synopsis: params ?-name value?
    argparse {
        -name=
    }
    if {[info exists name]} {
        my configure -name $name
    } else {
        my configure -name [self object]
    }
    foreach param $params {
        if {[@ $param 2]=={}} {
            my addParam [@ $param 0] [@ $param 1]
        } elseif {[@ $param 2]=="-eq"} {
            my addParam [@ $param 0] [@ $param 1] -eq
        } else {
            error "Wrong parameter definition in ParamStatement"
        }
    }
}

addParam [::SpiceGenTcl::ParamStatement]ParamStatement, Top, Main, Index

Adds new Parameter object to the list Params.

OBJECT addParam paramName value ?-eq?
Parameters
paramNameName of parameter.
valueValue of parameter.
-eqOptional parameter qualificator.
method addParam {paramName value args} {

    # Adds new Parameter object to the list Params.
    #  paramName - name of parameter
    #  value - value of parameter
    #  -eq - optional parameter qualificator
    # Synopsis: paramName value ?-eq?
    argparse {
        -eq
    }
    set paramName [string tolower $paramName]
    if {[info exists Params]} {
        set paramList [dict keys $Params]
    }
    lappend paramList $paramName
    if {[my duplListCheck $paramList]} {
        return -code error "Parameters list '$paramList' has already contains parameter with name '$paramName'"
    }
    if {[info exists eq]} {
        dict append Params $paramName [::SpiceGenTcl::ParameterEquation new $paramName $value]
    } else {
        dict append Params $paramName [::SpiceGenTcl::Parameter new $paramName $value]
    }
    return
}

deleteParam [::SpiceGenTcl::ParamStatement]ParamStatement, Top, Main, Index

Deletes existing Parameter object from list Params.

OBJECT deleteParam paramName
Parameters
paramNameName of parameter that will be deleted.
method deleteParam {paramName} {

    # Deletes existing `Parameter` object from list `Params`.
    #  paramName - name of parameter that will be deleted
    set paramName [string tolower $paramName]
    set error [catch {dget $Params $paramName}]
    if {$error>0} {
        return -code error "Parameter with name '$paramName' was not found in device's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
    } else {
        set Params [dict remove $Params $paramName]
    }
    return
}

genSPICEString [::SpiceGenTcl::ParamStatement]ParamStatement, Top, Main, Index

Creates parameter statement string for SPICE netlist.

OBJECT genSPICEString
Return value

'.param $Params'

method genSPICEString {} {

    # Creates parameter statement string for SPICE netlist.
    # Returns: '.param $Params'
    dict for {paramName param} $Params {
        lappend params [$param genSPICEString]
    }
    return ".param [join $params]"
}

getParams [::SpiceGenTcl::ParamStatement]ParamStatement, Top, Main, Index

Gets the dictionary that contains parameter name as keys and parameter values as the values.

OBJECT getParams
Return value

parameters dictionary

method getParams {} {

    # Gets the dictionary that contains parameter name as keys and
    #  parameter values as the values.
    # Returns: parameters dictionary
    set tempDict [dcreate]
    dict for {paramName param} $Params {
        dict append tempDict $paramName [$param configure -value]
    }
    return $tempDict
}

setParamValue [::SpiceGenTcl::ParamStatement]ParamStatement, Top, Main, Index

Sets (or change) value of particular parameters.

OBJECT setParamValue ?args?
Parameters
argsList with even number of elements with parameter name and value, {paramName0 paramValue0 # paramName1 paramValue1 ...}
method setParamValue {args} {

    # Sets (or change) value of particular parameters.
    #  args - list with even number of elements with parameter name and value, {paramName0 paramValue0 #    paramName1 paramValue1 ...}
    if {[llength $args]%2!=0} {
        return -code error "Number of arguments to method '[dict get [info frame 0] method]' must be even"
    }
    for {set i 0} {$i<[llength $args]} {incr i 2} {
        set paramName [string tolower [@ $args [= {$i}]]]
        set paramValue [@ $args [= {$i+1}]]
        if {[catch {dget $Params $paramName}]} {
            return -code error "Parameter with name '$paramName' was not found in element's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
        } else {
            set param [dget $Params $paramName]
        }
        $param configure -value $paramValue
    }
    return
}

Pin [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
checkFloatingDetermines if pin is connected to the node.
configureConfigure properties.
genSPICEStringCreates string for SPICE netlist.
unsetNodeNameMakes pin floating by setting nodename with empty string.
Properties

Readable: -name, -nodename

Writable: -name, -nodename

Superclasses

SPICEElement

constructor [::SpiceGenTcl::Pin]Pin, Top, Main, Index

Creates object of class Pin with name and connected node

Pin create OBJNAME name nodeName
Pin new name nodeName
Parameters
nameName of the pin.
nodeNameName of the node that connected to pin.
Description

Class models electrical pin of device/subcircuit, it has name and name of the node connected to it. It has general interface method genSPICEString that returns name of the node connected to it, this method must be called only in method with the same name in other classes. We can check if pin is floating by checking the name of connected node in method checkFloating - if is contains empty string it is floating. Floating pin can't be netlisted, so it throws error when try to do so. Set pin name empty by special method unsetNodeName.

method constructor {name nodeName} {

    # Creates object of class `Pin` with name and connected node
    #  name - name of the pin
    #  nodeName - name of the node that connected to pin
    # Class models electrical pin of device/subcircuit,
    # it has name and name of the node connected to it.
    # It has general interface method `genSPICEString` that returns
    # name of the node connected to it, this method must be called only
    # in method with the same name in other classes. We can check if pin is
    # floating by checking the name of connected node in method `checkFloating` -
    # if is contains empty string it is floating.
    # Floating pin can't be netlisted, so it throws error when try to
    # do so. Set pin name empty by special method `unsetNodeName`.
    my configure -name $name -nodename $nodeName
}

checkFloating [::SpiceGenTcl::Pin]Pin, Top, Main, Index

Determines if pin is connected to the node.

OBJECT checkFloating
Return value

true if connected and false if not

method checkFloating {} {

    # Determines if pin is connected to the node.
    # Returns: `true` if connected and `false` if not
    if {[my configure -nodename]=={}} {
        set floating true
    } else {
        set floating false
    }
    return $floating
}

genSPICEString [::SpiceGenTcl::Pin]Pin, Top, Main, Index

Creates string for SPICE netlist.

OBJECT genSPICEString
Return value

string '$nodename'

method genSPICEString {} {

    # Creates string for SPICE netlist.
    # Returns: string '*$nodename*'
    if {[my checkFloating]=="true"} {
        return -code error "Pin '[my configure -name]' is not connected to the node so can't be netlisted"
    }
    return "[my configure -nodename]"
}

unsetNodeName [::SpiceGenTcl::Pin]Pin, Top, Main, Index

Makes pin floating by setting nodename with empty string.

OBJECT unsetNodeName
method unsetNodeName {} {

    # Makes pin floating by setting `nodename` with empty string.
    my configure -nodename {}
}

RawFile [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
getCurrentsNamesReturns list that contains names of all current variables.
getTraceReturns trace object reference by it's name.
getTracesCsvReturns string with csv formatting containing all data.
getTracesDataReturns dictionary that contains all data in value and name as a key.
getTracesStrReturns information about all Traces in raw file in form of string.
getVariablesNamesReturns list that contains names of all variables.
getVoltagesNamesReturns list that contains names of all voltage variables.
readComplexSee BinaryReader.readComplex
readFloat32See BinaryReader.readFloat32
readFloat64See BinaryReader.readFloat64
skip4bytesSee BinaryReader.skip4bytes
skip8bytesSee BinaryReader.skip8bytes
skip16bytesSee BinaryReader.skip16bytes
Properties

Readable: -Axis, -BlockSize, -NPoints, -NVariables, -Path, -RawParams, -Traces

Writable: -Axis, -BlockSize, -NPoints, -NVariables, -Path, -RawParams, -Traces

Mixins

BinaryReader

constructor [::SpiceGenTcl::RawFile]RawFile, Top, Main, Index

Creates RawFile object.

RawFile create OBJNAME path ?traces2read? ?simulator?
RawFile new path ?traces2read? ?simulator?
Parameters
pathPath to raw file including it's file name.
traces2readList of traces that will be readed, default value is *, that means reading all traces. Optional, default *.
simulatorSimulator that produced this raw file, default is ngspice. Optional, default ngspice.
method constructor {path {traces2read *} {simulator ngspice}} {

                # Creates RawFile object.
                #  path - path to raw file including it's file name
                #  traces2read - list of traces that will be readed, default value is \*,
                #   that means reading all traces
                #  simulator - simulator that produced this raw file, default is ngspice
                my configure -Path $path
                set fileSize [file size $path]
                set file [open $path r]
                fconfigure $file -translation binary

    ####  read header

                set ch [read $file 6]
                if {$ch=={Title:}} {
                    set encSize 1
                    set encode "utf-8"
                    set line "Title:"
                } elseif {$ch=={Tit}} {
                    set encSize 2
                    set encode "utf-16-le"
                    set line "Tit"
                } else {
                    error "Unknown encoding"
                }
                my configure -RawParams [dcreate Filename $path]
                set header ""
                set binaryStart 6
                while true {
                    set ch [read $file $encSize]
                    incr binaryStart $encSize
                    if {$ch=="\n"} {
                        if {$encode=="utf-8"} {
                            set line [string trimright $line "\r"]
                        }
                        lappend header $line
                        if {$line in {Binary: Values:}} {
                            set rawType $line
                            break
                        }
                        set line ""
                    } else {
                        append line $ch
                    }
                }

    ####  save header parameters

                foreach line $header {
                    set lineList [split $line ":"]
                    if {[@ $lineList 0]=="Variables"} {
                        break
                    }
                    dict append RawParams [@ $lineList 0] [string trim [@ $lineList 1]]
                }
                my configure -NPoints [dget [my configure -RawParams] "No. Points"] -NVariables [dget [my configure -RawParams] "No. Variables"]
                if {[dget [my configure -RawParams] "Plotname"] in {"Operating Point" "Transfet Function"}} {
                    set hasAxis 0
                } else {
                    set hasAxis 1
                }
                set flags [split [dget [my configure -RawParams] "Flags"]]
                if {("complex" in $flags) || ([dget [my configure -RawParams] "Plotname"]=="AC Analysis")} {
                    set numType complex
                } else {
                    if {("double" in $flags) || ($simulator=="ngspice")} {
                        set numType double
                    } else {
                        set numType real
                    }
                }

    ####  parse variables

                set i [lsearch $header "Variables:"]
                set ivar 0
                foreach line [lrange $header [+ $i 1] end-1] {
                    set lineList [split [string trim $line] \t]
                    lassign $lineList idx name varType
                    if {$ivar==0} {
                        if {$numType=="real"} {
                            set axisNumType double
                        } else {
                            set axisNumType $numType
                        }
                        my configure -Axis [::SpiceGenTcl::Axis new $name $varType $NPoints $axisNumType]
                        set trace $Axis
                    } elseif {($traces2read=="*") || ($name in $traces2read)} {
                        if {$hasAxis} {
                            set trace [::SpiceGenTcl::Trace new $name $varType $NPoints [[my configure -Axis] configure -name] $numType]
                        } else {
                            set trace [::SpiceGenTcl::Trace new $name $varType $NPoints {} $numType]
                        }
                    } else {
                        set trace [::SpiceGenTcl::EmptyTrace new $name $varType $NPoints $numType]
                    }
                    lappend Traces $trace
                    incr ivar
                }
                if {($traces2read=="") || ([llength $traces2read]==0)} {
                    close $file
                    return
                }

    ####  read data

                if {$rawType=="Binary:"} {
                    my configure -BlockSize [= {($fileSize - $binaryStart)/$NPoints}]
                    set scanFunctions ""
                    set calcBlockSize 0
                    foreach trace [my configure -Traces] {
                        if {[$trace configure -NumType]=="double"} {
                            incr calcBlockSize 8
                            if {[info object class $trace ::SpiceGenTcl::EmptyTrace]} {
                                set fun skip8bytes
                            } else {
                                set fun readFloat64
                            }
                        } elseif {[$trace configure -NumType]=="complex"} {
                            incr calcBlockSize 16
                            if {[info object class $trace ::SpiceGenTcl::EmptyTrace]} {
                                set fun skip16bytes
                            } else {
                                set fun readComplex
                            }
                        } elseif {[$trace configure -NumType]=="real"} {
                            incr calcBlockSize 4
                            if {[info object class $trace ::SpiceGenTcl::EmptyTrace]} {
                                set fun skip4bytes
                            } else {
                                set fun readFloat32
                            }
                        } else {
                            error "Invalid data type '[$trace configure -NumType]' for trace '[$trace configure -name]'"
                        }
                        lappend scanFunctions $fun
                    }
                    if {$calcBlockSize!=[my configure -BlockSize]} {
                        error "Error in calculating the block size. Expected '[my configure -BlockSize]' bytes, but found '$calcBlockSize' bytes"
                    }
                     for {set i 0} {$i<$NPoints} {incr i} {
                        for {set j 0} {$j<[llength [my configure -Traces]]} {incr j} {
                            set value [eval "my [@ $scanFunctions $j]" $file]
                            set trace [@ [my configure -Traces] $j]
                            if {[info object class $trace]!="::SpiceGenTcl::EmptyTrace"} {
                                $trace appendDataPoints $value
                            }
                        }
                    }
                } elseif {$rawType=="Values:"} {
                    for {set i 0} {$i<$NPoints} {incr i} {
                        set firstVar true
                        for {set j 0} {$j<[llength [my configure -Traces]]} {incr j} {
                            set line [gets $file]
                            if {$line==""} {
                                continue
                            }
                            set lineList [textutil::split::splitx $line]
                            if {$firstVar=="true"} {
                                set firstVar false
                                set sPoint [@ $lineList 0]
                                if {$i!=int($sPoint)} {
                                    error "Error reading file"
                                }
                                if {$numType=="complex"} {
                                    set value [split [@ $lineList 1] ","]
                                } else {
                                    set value [@ $lineList 1]
                                }
                            } else {
                                if {$numType=="complex"} {
                                    set value [split [@ $lineList 1] ","]
                                } else {
                                    set value [@ $lineList 1]
                                }
                            }
                            set trace [@ [my configure -Traces] $j]
                            $trace appendDataPoints $value
                        }
                    }
                }
                close $file
}

getCurrentsNames [::SpiceGenTcl::RawFile]RawFile, Top, Main, Index

Returns list that contains names of all current variables

OBJECT getCurrentsNames
Return value

Returns list that contains names of all current variables

method getCurrentsNames {} {

    # Returns list that contains names of all current variables
    foreach trace [my configure -Traces] {
        if {[$trace configure -Type]=="current"} {
            lappend currNames [$trace configure -name]
        }
    }
    return $currNames
}

getTrace [::SpiceGenTcl::RawFile]RawFile, Top, Main, Index

Returns trace object reference by it's name

OBJECT getTrace traceName
Parameters
traceNameNot documented.
Return value

Returns trace object reference by it's name

method getTrace {traceName} {

    # Returns trace object reference by it's name
    set traceFoundFlag false
    foreach trace [my configure -Traces] {
        if {[$trace configure -name]==$traceName} {
            set traceFound $trace
            set traceFoundFlag true
            break
        }
    }
    if {$traceFoundFlag==false} {
        return -code error "Trace with name '$traceName' was not found in raw file '[my configure -Path]' list of traces"
    }
    return $traceFound
}

getTracesCsv [::SpiceGenTcl::RawFile]RawFile, Top, Main, Index

Returns string with csv formatting containing all data

OBJECT getTracesCsv ?-all? ?-traces list? ?-sep value?
Parameters
-allSelect all traces, optional.
-sepSeparator of columns, default is comma, optional.
-tracesSelect names of traces to return, optional.
Return value

Returns string with csv formatting containing all data

method getTracesCsv {args} {

    # Returns string with csv formatting containing all data
    #  -all - select all traces, optional
    #  -traces - select names of traces to return, optional
    #  -sep - separator of columns, default is comma, optional
    # Synopsis: ?-all? ?-traces list? ?-sep value?
    set arguments [argparse -inline {
        {-all -forbid {traces}}
        {-traces -catchall -forbid {all}}
        {-sep= -default {,}}
    }]
    if {[dexist $arguments all]} {
        set tracesDict [my getTracesData]
        set tracesList [list [dict keys $tracesDict]]
        for {set i 0} {$i<[my configure -NPoints]} {incr i} {
            dict for {traceName traceValues} $tracesDict {
                lappend row [@ $traceValues $i]
            }
            lappend tracesList $row
            unset row
        }
    } elseif {[dget $arguments traces]!=""} {
        foreach traceName [dget $arguments traces] {
            set traceObj [my getTrace $traceName]
            dict append tracesDict [$traceObj configure -name] [$traceObj getDataPoints]
        }
        set tracesList [list [dict keys $tracesDict]]
        for {set i 0} {$i<[my configure -NPoints]} {incr i} {
            dict for {traceName traceValues} $tracesDict {
                lappend row [@ $traceValues $i]
            }
            lappend tracesList $row
            unset row
        }
    } else {
        return -code error "Arguments '-all' or '-traces traceName1 traceName2 ...' must be provided to 'getTracesCsv' method"
    }
    return [::csv::joinlist $tracesList [dget $arguments sep]]
}

getTracesData [::SpiceGenTcl::RawFile]RawFile, Top, Main, Index

Returns dictionary that contains all data in value and name as a key

OBJECT getTracesData
Return value

Returns dictionary that contains all data in value and name as a key

method getTracesData {} {

    # Returns dictionary that contains all data in value and name as a key
    set dict [dcreate]
    foreach trace [my configure -Traces] {
        dict append dict [$trace configure -name] [$trace getDataPoints]
    }
    return $dict
}

getTracesStr [::SpiceGenTcl::RawFile]RawFile, Top, Main, Index

Returns information about all Traces in raw file in form of string

OBJECT getTracesStr
Return value

Returns information about all Traces in raw file in form of string

method getTracesStr {} {

    # Returns information about all Traces in raw file in form of string
    foreach trace [my configure -Traces] {
        lappend tracesList "[$trace configure -name] [$trace configure -Type] [$trace configure -NumType]"
    }
    return $tracesList
}

getVariablesNames [::SpiceGenTcl::RawFile]RawFile, Top, Main, Index

Returns list that contains names of all variables

OBJECT getVariablesNames
Return value

Returns list that contains names of all variables

method getVariablesNames {} {

    # Returns list that contains names of all variables
    foreach trace [my configure -Traces] {
        lappend tracesNames [$trace configure -name]
    }
    return $tracesNames
}

getVoltagesNames [::SpiceGenTcl::RawFile]RawFile, Top, Main, Index

Returns list that contains names of all voltage variables

OBJECT getVoltagesNames
Return value

Returns list that contains names of all voltage variables

method getVoltagesNames {} {

    # Returns list that contains names of all voltage variables
    foreach trace [my configure -Traces] {
        if {[$trace configure -Type]=="voltage"} {
            lappend voltNames [$trace configure -name]
        }
    }
    return $voltNames
}

RawString [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringCreates raw string for SPICE netlist.
Properties

Readable: -name, -value

Writable: -name, -value

Superclasses

SPICEElement

Subclasses

Comment, Include, Library

constructor [::SpiceGenTcl::RawString]RawString, Top, Main, Index

Creates object of class RawString.

OBJECT constructor value ?-name value?
Parameters
valueValue of the raw string.
-nameName of the string that could be used to retrieve element from ::SpiceGenTcl::Netlist object and its descendants, optional.
Description

Class represent arbitary string. It can be used to pass any string directly into netlist, for example, it can add elements that doesn't have dedicated class.

method constructor {value args} {

    # Creates object of class `RawString`.
    #  value - value of the raw string
    #  -name - name of the string that could be used to retrieve element from [::SpiceGenTcl::Netlist] object
    #    and its descendants, optional
    # Class represent arbitary string.
    #  It can be used to pass any string directly into netlist,
    #  for example, it can add elements that doesn't have dedicated class.
    # Synopsis: value ?-name value?
    argparse {
        -name=
    }
    if {[info exists name]} {
        my configure -name $name
    } else {
        my configure -name [self object]
    }
    my configure -value $value
}

genSPICEString [::SpiceGenTcl::RawString]RawString, Top, Main, Index

Creates raw string for SPICE netlist.

OBJECT genSPICEString
Return value

string '$value'

method genSPICEString {} {

    # Creates raw string for SPICE netlist.
    # Returns: string '$value'
    return [my configure -value]
}

Simulator [::SpiceGenTcl]Top, Main, Index

Method summary
configureConfigure properties.
getLogReturns log file of completed simulations.
readDataReads raw data file of last simulation.
readLogReads log file of completed simulations.
runRuns simulation.
Properties

Readable: -Command, -data, -log, -name

Writable: -Command, -data, -log, -name

Subclasses

::SpiceGenTcl::Ngspice::Simulators::Batch, ::SpiceGenTcl::Xyce::Simulators::Batch

getLog [::SpiceGenTcl::Simulator]Simulator, Top, Main, Index

Returns log file of completed simulations.

OBJECT getLog
Return value

Returns log file of completed simulations.

method getLog {} {

    # Returns log file of completed simulations.
    error "Not implemented"
}

readData [::SpiceGenTcl::Simulator]Simulator, Top, Main, Index

Reads raw data file of last simulation.

OBJECT readData
method readData {} {

    # Reads raw data file of last simulation.
    error "Not implemented"
}

readLog [::SpiceGenTcl::Simulator]Simulator, Top, Main, Index

Reads log file of completed simulations.

OBJECT readLog
method readLog {} {

    # Reads log file of completed simulations.
    error "Not implemented"
}

run [::SpiceGenTcl::Simulator]Simulator, Top, Main, Index

Runs simulation.

OBJECT run
method run {} {

    # Runs simulation.
    error "Not implemented"
}

SPICEElement [::SpiceGenTcl]Top, Main, Index

Method summary
configureConfigure properties.
genSPICEStringDeclaration of method common for all SPICE elements that generates representation of element in SPICE netlist. Not implemented in abstraction class.
Subclasses

Pin, ParameterSwitch, Device, Model, RawString, Options, ParamStatement, Temp, Netlist, Analysis

genSPICEString [::SpiceGenTcl::SPICEElement]SPICEElement, Top, Main, Index

Declaration of method common for all SPICE elements that generates representation of element in SPICE netlist. Not implemented in abstraction class.

OBJECT genSPICEString
method genSPICEString {} {

    # Declaration of method common for all SPICE elements that generates
    #  representation of element in SPICE netlist. Not implemented in
    #  abstraction class.
    error "Not implemented"
}

Subcircuit [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
addAdd element object reference to Netlist, it extends add method to add check of element class because subcircuit can't contain particular elements inside, like ::SpiceGenTcl::Include, ::SpiceGenTcl::Library, ::SpiceGenTcl::Options and ::SpiceGenTcl::Analysis.
addParamAdds new parameter to subcircuit, and throws error on dublicated names.
configureConfigure properties.
delSee Netlist.del
deleteParamDeletes existing Parameter object from list Params.
duplListCheckSee DuplChecker.duplListCheck
genSPICEStringCreates subcircuit string for SPICE subcircuit.
getAllElemNamesSee Netlist.getAllElemNames
getElementSee Netlist.getElement
getParamsGets the dictionary that contains parameter name as keys and parameter values as the values.
getPinsGets the dictionary that contains pin name as keys and connected node name as the values.
setParamValueSets (or change) value of particular parameters.
Properties

Readable: -name

Writable: -name

Superclasses

Netlist

constructor [::SpiceGenTcl::Subcircuit]Subcircuit, Top, Main, Index

Creates object of class Subcircuit.

Subcircuit create OBJNAME name pins params
Subcircuit new name pins params
Parameters
nameName of the subcircuit.
pinsList of pins in the order they appear in SPICE subcircuits definition together in form: {pinName0 pinName1 pinName2 ...}
paramsList of input parameters in form {{name value} {name value} {name value} ...}
Description

This class implements subcircuit, it is subclass of netlist because it holds list of elements inside subcircuit, together with header and connection of elements inside.

method constructor {name pins params} {

    # Creates object of class `Subcircuit`.
    #  name - name of the subcircuit
    #  pins - list of pins in the order they appear in SPICE subcircuits definition together
    #   in form: `{pinName0 pinName1 pinName2 ...}`
    #  params - list of input parameters in form `{{name value} {name value} {name value} ...}`
    # This class implements subcircuit, it is subclass of netlist because it holds list of elements
    # inside subcircuit, together with header and connection of elements inside.

    # create Pins objects, nodes are set to empty line
    foreach pin $pins {
        my AddPin [@ $pin 0] {}
    }
    # create Params objects that are input parameters of subcircuit
    if {$params!=""} {
        foreach param $params {
            if {[llength $param]<=2} {
                my addParam [@ $param 0] [@ $param 1]
            } else {
                error "Wrong parameter '[@ $param 0]' definition in subcircuit $name"
            }
        }
    } else {
        set Params ""
    }
    next $name
}

add [::SpiceGenTcl::Subcircuit]Subcircuit, Top, Main, Index

Add element object reference to Netlist, it extends add method to add check of element class because subcircuit can't contain particular elements inside, like ::SpiceGenTcl::Include, ::SpiceGenTcl::Library, ::SpiceGenTcl::Options and ::SpiceGenTcl::Analysis.

OBJECT add element
Parameters
elementElement object reference.
method add {element} {

    # Add element object reference to `Netlist`, it extends add method to add check of element class because
    # subcircuit can't contain particular elements inside, like [::SpiceGenTcl::Include],
    # [::SpiceGenTcl::Library], [::SpiceGenTcl::Options] and [::SpiceGenTcl::Analysis].
    #  element - element object reference
    set elementClass [info object class $element]
    set elementClassSuperclass [info class superclasses $elementClass]
    if {$elementClass=={::SpiceGenTcl::Include}} {
        return -code error "Include element can't be included in subcircuit"
    } elseif {$elementClass=={::SpiceGenTcl::Library}} {
        return -code error "Library element can't be included in subcircuit"
    } elseif {$elementClass=={::SpiceGenTcl::Options}} {
        return -code error "Options element can't be included in subcircuit"
    } elseif {$elementClassSuperclass=={::SpiceGenTcl::Analysis}} {
        return -code error "Analysis element can't be included in subcircuit"
    }
    next $element
}

addParam [::SpiceGenTcl::Subcircuit]Subcircuit, Top, Main, Index

Adds new parameter to subcircuit, and throws error on dublicated names.

OBJECT addParam paramName value
Parameters
paramNameName of parameter.
valueValue of parameter.
method addParam {paramName value} {

    # Adds new parameter to subcircuit, and throws error
    #  on dublicated names.
    #  paramName - name of parameter
    #  value - value of parameter
    set paramName [string tolower $paramName]
    if {[info exists Params]} {
        set paramList [dict keys $Params]
    }
    lappend paramList $paramName
    if {[my duplListCheck $paramList]} {
        return -code error "Parameters list '$paramList' has already contains parameter with name '$paramName'"
    }
    dict append Params $paramName [::SpiceGenTcl::Parameter new $paramName $value]
    return
}

deleteParam [::SpiceGenTcl::Subcircuit]Subcircuit, Top, Main, Index

Deletes existing Parameter object from list Params.

OBJECT deleteParam paramName
Parameters
paramNameName of parameter that will be deleted.
method deleteParam {paramName} {

    # Deletes existing `Parameter` object from list `Params`.
    #  paramName - name of parameter that will be deleted
    set paramName [string tolower $paramName]
    set error [catch {dget $Params $paramName}]
    if {$error>0} {
        return -code error "Parameter with name '$paramName' was not found in device's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
    } else {
        set Params [dict remove $Params $paramName]
    }
    return
}

genSPICEString [::SpiceGenTcl::Subcircuit]Subcircuit, Top, Main, Index

Creates subcircuit string for SPICE subcircuit.

OBJECT genSPICEString
Return value

'.subckt $Pins $Params'

method genSPICEString {} {

    # Creates subcircuit string for SPICE subcircuit.
    # Returns: '.subckt $Pins $Params'
    set name [my configure -name]
    dict for {pinName pin} $Pins {
        lappend nodes [$pin configure -name]
    }
    if {$Params==""} {
        lappend params ""
        set header ".subckt $name [join $nodes]"
    } else {
        dict for {paramName param} $Params {
            lappend params [$param genSPICEString]
        }
        set header ".subckt $name [join $nodes] [join $params]"
    }
    # get netlist elements from netlist genSPICEString method
    set resStr [next]
    set end ".ends"
    return [join [list $header $resStr $end] \n]
}

getParams [::SpiceGenTcl::Subcircuit]Subcircuit, Top, Main, Index

Gets the dictionary that contains parameter name as keys and parameter values as the values.

OBJECT getParams
Return value

parameters dictionary

method getParams {} {

    # Gets the dictionary that contains parameter name as keys and
    #  parameter values as the values.
    # Returns: parameters dictionary
    set tempDict [dcreate]
    dict for {paramName param} $Params {
        dict append tempDict $paramName [$param configure -value]
    }
    return $tempDict
}

getPins [::SpiceGenTcl::Subcircuit]Subcircuit, Top, Main, Index

Gets the dictionary that contains pin name as keys and connected node name as the values.

OBJECT getPins
Return value

parameters dictionary

method getPins {} {

    # Gets the dictionary that contains pin name as keys and
    #  connected node name as the values.
    # Returns: parameters dictionary
    set tempDict [dcreate]
    dict for {pinName pin} $Pins {
        dict append tempDict $pinName [$pin configure -nodename]
    }
    return $tempDict
}

setParamValue [::SpiceGenTcl::Subcircuit]Subcircuit, Top, Main, Index

Sets (or change) value of particular parameters.

OBJECT setParamValue ?args?
Parameters
argsList with even number of elements with parameter name and value, {paramName0 paramValue0 # paramName1 paramValue1 ...}
method setParamValue {args} {

    # Sets (or change) value of particular parameters.
    #  args - list with even number of elements with parameter name and value, {paramName0 paramValue0 #    paramName1 paramValue1 ...}
    if {[llength $args]%2!=0} {
        return -code error "Number of arguments to method '[dict get [info frame 0] method]' must be even"
    }
    for {set i 0} {$i<[llength $args]} {incr i 2} {
        set paramName [string tolower [@ $args [= {$i}]]]
        set paramValue [@ $args [= {$i+1}]]
        if {[catch {dget $Params $paramName}]} {
            return -code error "Parameter with name '$paramName' was not found in element's '[my configure -name]' list of parameters '[dict keys [my getParams]]'"
        } else {
            set param [dget $Params $paramName]
        }
        $param configure -value $paramValue
    }
    return
}

Temp [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
configureConfigure properties.
genSPICEStringCreates .temp statement string for SPICE netlist.
Properties

Readable: -name, -value

Writable: -name, -value

Superclasses

SPICEElement

constructor [::SpiceGenTcl::Temp]Temp, Top, Main, Index

Creates object of class Temp.

OBJECT constructor value ?-eq?
Parameters
valueValue of the temperature.
-eqOptional parameter qualificator.
Description

This class represent .temp statement with temperature value.

method constructor {value args} {

    # Creates object of class `Temp`.
    #  value - value of the temperature
    #  -eq - optional parameter qualificator
    # This class represent .temp statement with temperature value.
    # Synopsis: value ?-eq?
    argparse {
        {-eq -boolean}
    }
    #set [my varname value] $value
    my configure -name temp
    if {$eq} {
        my AddParam temp $value -eq
    } else {
        my AddParam temp $value
    }
}

genSPICEString [::SpiceGenTcl::Temp]Temp, Top, Main, Index

Creates .temp statement string for SPICE netlist.

OBJECT genSPICEString
Return value

'.temp $value'

method genSPICEString {} {

    # Creates .temp statement string for SPICE netlist.
    # Returns: '.temp $value'
    return ".temp [$value genSPICEString]"
}

Trace [::SpiceGenTcl]Top, Main, Index

Method summary
constructorConstructor for the class.
appendDataPointsSee Dataset.appendDataPoints
configureConfigure properties.
getDataPointsSee Dataset.getDataPoints
getStrSee Dataset.getStr
setDataPointsSee Dataset.setDataPoints
Properties

Readable: -Axis, -Len, -NumType, -Type, -name

Writable: -Axis, -Len, -NumType, -Type, -name

Superclasses

Dataset

constructor [::SpiceGenTcl::Trace]Trace, Top, Main, Index

initialize trace

Trace create OBJNAME name type len axis ?numType?
Trace new name type len axis ?numType?
Parameters
nameName of the trace.
typeType of trace.
lenTotal number of points.
axisName of axis that is linked to trace.
numTypeNumerical type of trace. Optional, default real.
method constructor {name type len axis {numType real}} {

    # initialize trace
    #  name - name of the trace
    #  type - type of trace
    #  len - total number of points
    #  axis - name of axis that is linked to trace
    #  numType - numerical type of trace
    my configure -Axis $axis
    next $name $type $len $numType
}