11.1.10.9. Parser_jmgc¶
This module implements a partial SPICE netlist parser.
See the cir2py tool for an example of usage of the parser.
It would be difficult to implement a full parser for Ngspice since the syntax is mainly contextual.
SPICE is case insensitive.
-
class
PySpice.Spice.Parser_jmgc.CircuitStatement(title)[source]¶ Bases:
PySpice.Spice.Parser_jmgc.StatementThis class implements a circuit definition.
Spice syntax:
Title ...
-
property
models¶ Models of the circuit.
-
property
name¶ Name of the circuit.
-
property
params¶ Parameters of the circuit.
-
property
subcircuits¶ Subcircuits of the circuit.
-
property
title¶ Title of the circuit.
-
property
-
class
PySpice.Spice.Parser_jmgc.Element(line)[source]¶ Bases:
PySpice.Spice.Parser_jmgc.StatementThis class implements an element definition.
“{ expression }” are allowed in device line.
-
property
name¶ Name of the element
-
property
-
class
PySpice.Spice.Parser_jmgc.Include(line)[source]¶ Bases:
PySpice.Spice.Parser_jmgc.StatementThis class implements a include definition.
-
class
PySpice.Spice.Parser_jmgc.Line(line, line_range, end_of_line_comment)[source]¶ Bases:
objectThis class implements a line in the netlist.
-
property
comment¶
-
property
is_comment¶
-
read_words(start_location, number_of_words)[source]¶ Read a fixed number of words separated by space.
-
split_element(prefix)[source]¶ Split the line according to the following pattern:
keyword parameter1 parameter2 ... key1=value1 key2=value2 ...
Return the list of parameters and the dictionary.
-
property
-
class
PySpice.Spice.Parser_jmgc.Model(line)[source]¶ Bases:
PySpice.Spice.Parser_jmgc.StatementThis class implements a model definition.
Spice syntax:
.model mname type(pname1=pval1 pname2=pval2 ... )
-
property
name¶ Name of the model
-
property
-
class
PySpice.Spice.Parser_jmgc.Parameter(line)[source]¶ Bases:
PySpice.Spice.Parser_jmgc.StatementThis class implements a parameter definition.
Spice syntax:
.param name=expr
-
property
name¶ Name of the model
-
property
-
class
PySpice.Spice.Parser_jmgc.PrefixData(prefix, classes)[source]¶ Bases:
objectThis class represents a device prefix.
-
property
single¶
-
property
-
class
PySpice.Spice.Parser_jmgc.SpiceParser(path=None, source=None, end_of_line_comment=('$', '//', ';'))[source]¶ Bases:
objectThis class parse a Spice netlist file and build a syntax tree.
Public Attributes:
-
build_circuit(ground=0)[source]¶ Build a
Circuitinstance.Use the ground parameter to specify the node which must be translated to 0 (SPICE ground node).
-
property
circuit¶ Circuit statements.
-
property
models¶ Models of the sub-circuit.
-
property
subcircuits¶ Subcircuits of the sub-circuit.
-
-
class
PySpice.Spice.Parser_jmgc.Statement(line, statement=None)[source]¶ Bases:
objectThis base class implements a statement, in fact a line in a Spice netlist.
-
class
PySpice.Spice.Parser_jmgc.SubCircuitStatement(line)[source]¶ Bases:
PySpice.Spice.Parser_jmgc.StatementThis class implements a sub-circuit definition.
Spice syntax:
.SUBCKT name node1 ... param1=value1 ...
-
property
models¶ Models of the sub-circuit.
-
property
name¶ Name of the sub-circuit.
-
property
nodes¶ Nodes of the sub-circuit.
-
property
params¶ Params of the sub-circuit.
-
property
subcircuits¶ Subcircuits of the sub-circuit.
-
property
-
class
PySpice.Spice.Parser_jmgc.Title(line)[source]¶ Bases:
PySpice.Spice.Parser_jmgc.StatementThis class implements a title definition.