Products & Services Solutions Academia Support User Community Company

Learn more about SimElectronics   

netlist2sl - Convert SPICE netlist to library of Simulink blocks

Syntax

modelname = netlist2sl(filename, newname)
modelname = netlist2sl(filename, options)

Description

modelname = netlist2sl(filename, newname) maps the circuit elements listed in the SPICE netlist file filename to a Simulink library or model newname that contains one or more blocks.

netlist2sl can import either subcircuit information or model card information into a block:

SimElectronics only reads in device data. It ignores analysis statements such as .TRAN.

modelname = netlist2sl(filename, options) uses the information in the structure options to map the circuit elements in filename to a Simulink library. The structure has the following fields:

The netlist file must define one or more SPICE subcircuits or model cards. To import a netlist that is not a subcircuit into the Simulink environment, add a subcircuit wrapper before using the netlist2sl function. Example 2 shows this procedure.

The output library has one block that represents the top-level subcircuit, and a block for each subcircuit that this subcircuit references. The block names match the subcircuit names, except that slashes (/) are replaced by underscores (_).

If the library already exists in the specified directory, netlist2sl adds new blocks to it. If a subcircuit name conflicts with an existing block name in the library or model, netlist2sl prompts you to either overwrite the existing block or rename the new block.

The model name, subcircuit name, instance name, and node name are all case insensitive.

When you create a library, you can drag and drop the blocks into any Simulink model. If you make any change to the library, Simulink applies the change to all instances of the affected block or blocks.

Examples

Example 1

Suppose you have a netlist file, SimpleDiode.cir as follows:

.SUBCKT SimpleDiode 1 2
R1  1 3  100
D1  3 2  DMOD1
.model DMOD1 D(Is=1e-13 Rs=0.1)
.ENDS SimpleDiode

To import this netlist and create a library called mylib that contains a block called SimpleDiode, type the following at the MATLAB prompt:

netlist2sl(‘SimpleDiode.cir', ‘mylib')

Example 2

Suppose you have a netlist that is not a subcircuit. To use the netlist2sl function, add a subcircuit wrapper to the netlist. Consider the following netlist file:

R1  1 3  100
D1  3 2  DMOD1
.model DMOD1 D(Is=1e-13 Rs=0.1)

If you want to probe nodes 1 and 2 in Simulink, add the subcircuit wrapper as follows:

.SUBCKT mydiode 1 2
R1  1 3  100
D1  3 2  DMOD1
.model DMOD1 D(Is=1e-13 Rs=0.1)
.ENDS mydiode

Then, apply the netlist2sl function to the modified netlist, as described in the preceding example.

Example 3

See the Creating a Library Block from a Netlist demo.

See Also

Importing SPICE Models Into a SimElectronics Library

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS