| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimElectronics |
| Contents | Index |
| Learn more about SimElectronics |
modelname = netlist2sl(filename, newname)
modelname = netlist2sl(filename, options)
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.
filename is the full name of the netlist file; it can also include the path name.
newname is the optional Simulink library or model name.
netlist2sl can import either subcircuit information or model card information into a block:
When you import subcircuit data from a SPICE netlist, SimElectronics creates a block that represents the netlist.
The block dialog box for each imported block contains the following information:
Subcircuit name
Netlist file name
Time the netlist2sl function created the block
You can look at a snapshot of the netlist the function used to create the block by clicking Help in the block dialog box.
When you import model card data from a SPICE netlist, SimElectronics uses the data to populate the parameter values of the corresponding SPICE-compatible SimElectronics 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:
LibName — A string that specifies the name of the Simulink library (or model) where netlist2sl puts the blocks.
ModelOnly — A boolean value. True tells netlist2sl to generate a library that contains only blocks representing the model cards that appear in the SPICE file. False (the default value) tells netlist2sl to generate a library that contains all circuit information that appears in the SPICE file.
BlockDiagramType — A string that indicates whether netlist2sl will generate a library or a model. Specifying 'library' causes the function to generate a library; specifying 'model' causes the function to generate a model without a library. 'library' and 'model' are the only two possible values. The default is 'library'.
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.
Note You cannot make changes directly to library blocks that you create with the netlist2sl function. To update the blocks, change the netlist and then run the netlist2sl function again. |
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')
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.
See the Creating a Library Block from a Netlist demo.
Importing SPICE Models Into a SimElectronics Library
![]() | Functions — Alphabetical List |

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 |