Main Content

Model Linear Circuit Response from SPICE Netlist

The Linear Circuit Wizard block parses a SPICE netlist to model the response of a desired linear circuit such as a custom filter design or a circuit with parasitics. The block supports a limited number of SPICE netlist constructs, specifically conforming to Berkeley SPICE syntax [1] or the HSPICE syntax [2]. Edit your SPICE netlist so that the desired circuit is described at the top level of the netlist by supported netlist constructs. The block ignores any statements that use unsupported netlist syntaxes.

The SPICE netlist can contain passive devices, independent sources, controlled sources, and subcircuits.

If present, independent sources are interpreted as input ports by the Linear Circuit Wizard block. The name of the input port is the designator for the circuit element, the port type matches the source type, and the nodes are the nodes to which the source is connected. For each such input port, the stimulus is the Simulink® signal connected to the port, not the description provided by the SPICE netlist.

The output ports are defined by .PRINT or .PLOT statements conforming to the HSPICE syntax. Because the SPICE statements do not supply port names for probed voltages, the Linear Circuit Wizard block supplies default names for voltage output ports. Current output ports are named after the independent voltage source used to sense the current. The netlist must contain all of the circuit nodes and circuit elements required to support the output ports.

The Linear Circuit Wizard block does not support mathematical functions.

Supported SPICE Syntax

Statements can be continued onto multiple lines by starting each continuation line with a plus sign ("+"). For example, these two statements are equivalent.

E1 2 0 LAPLACE 3 4 6.3e7/6.3e4 1
E1 2 0 LAPLACE 3 4
+ 6.3e7/6.3e4 1

Three forms of comment are supported.

  • Block comment. The comment block starts with the line #com and ends with the line #endcom. For example:

    #com
    When you’re lying awake with a dismal headache
    and repose is taboo’d by anxiety,
    I conceive you may use any language you choose
    to indulge in without impropriety.
    #endcom
    

  • Line comment. The comment is a line that starts with an asterisk ("*"). For example:

    * Gilbert, Iolanthe, act 2, “Love, unrequited, robs me of my rest”, line 5
  • End of line comment. The comment follows a pipe symbol ("|") and is ignored. For example:

    .end | That’s all, folks.

The node labeled “0” is defined as the common return node for the circuit.

ComponentSyntaxComment
Passive Devices
Resistor

R<name> <+ node> <- node> <value>

Create a resistor with a specific value.
Capacitor

C<name> <+ node> <- node> <value>

Create a capacitor of a specific value.
Inductor

L<name> <+ node> <- node> <value>

Create an inductor of a specific value.

Mutual inductance

K<name> <inductor name> <inductor name> <value>

Create a mutual inductance coupling between two inductors.

For each inductor, current flow in the positive direction is from the first node to the second node in the statement that creates the inductor.

The circuit element value is the mutual inductance factor k, where 0 < k < 1.

Independent Sources
Independent voltage sourceV<name> <+ node> <- node> Create an input voltage port in the Simulink block.
Independent current sourceI<name> <+ node> <- node> Create an input current port in the Simulink block.
Controlled sources
Voltage controlled voltage source

E<name> <+ node> <- node> <+ control node> <- control node> <gain>

E<name> <+ node> <- node> LAPLACE <+ control node> <- control node> <k0, k1, …km>/<d0,d1,…dn>

Create a voltage controlled voltage source.

The gain can be a constant value or a rational transfer function.

See LAPLACE Keyword for the transfer function definition.

Current controlled current source

F<name> <+ node> <- node> <voltage source name> <gain>

F<name> <+ node> <- node> LAPLACE <voltage source name> <k0, k1, …km>/<d0,d1,…dn>

Create a current controlled current source.

The gain can be a constant value or a rational transfer function.

The current through the controlling voltage source determines the output current. The controlling source must be an independent voltage source, although it does not need to have a zero DC value.

See LAPLACE Keyword for the transfer function definition.

Voltage controlled current source

G<name> <+ node> <- node> <+ control node> <- control node> <gain>

G<name> <+ node> <- node> LAPLACE <+ control node> <- control node> <k0, k1, …km>/<d0,d1,…dn>

Create a voltage controlled current source.

The gain can be a constant value or a rational transfer function.

The current through the controlling voltage source determines the output current. The controlling source must be an independent voltage source, although it does not need to have a zero DC value.

See LAPLACE Keyword for the transfer function definition.

Current controlled voltage source
  • H<name> <+ node> <- node> <voltage source name> <gain>

  • H<name> <+ node> <- node> LAPLACE <voltage source name> + <k0, k1, …km>/<d0,d1,…dn>

Create a current controlled voltage source.

The gain can be a constant value or a rational transfer function.

See LAPLACE Keyword for the transfer function definition.

Subcircuit
SubcircuitX<name> <external node names> <subcircuit name> <parameter list>Create an instance of a subcircuit. The number of external nodes must equal the number of nodes in the subcircuit definition. Entries in the parameter list take the form <name> = <value>.
Commands
.PARAM.param <param name> = <expression>Definable parameter
.SUBCKT.subckt <subname> <external node names> <parameter list> Begin the definition of a subcircuit. The number of external nodes is arbitrary. Entries in the parameter list take the form <name> = <value>. Subcircuit definitions can be nested.
.ENDS

.ends

.ends <subname>

Directive to end a subcircuit definition.
.END.endDirective to end the netlist. Optional command.
.INC.inc[lude] <file name>Directive to include contents of an external netlist
.PRINT.print V(<one or two nodes>) | I(<voltage source name>)Directive to define output ports. Multiple voltage and current outputs can be defined in a single statement.
.PLOT.plot V(<one or two nodes>) | I(<voltage source name>)Directive to define output ports. Multiple voltage and current outputs can be defined in a single statement.

LAPLACE Keyword

The LAPLACE keyword defines a Laplace domain transfer function for a controlled voltage or current source. The transfer function is defined by a series of transfer function numerator coefficients, from constant term to highest power of s, followed by a forward slash (‘/’), followed by a series of denominator coefficients from constant term to highest power of s.

References

[1] "SPICE Circuit Components." http://bwrcs.eecs.berkeley.edu/Classes/IcBook/SPICE/UserGuide/elements_fr.html.

[2] "HSPICE® User Guide: Simulation and Analysis." https://cseweb.ucsd.edu/classes/wi10/cse241a/assign/hspice_sa.pdf.

See Also

Related Examples

More About