next up previous contents index
Next: Creating Loadable Modules from Up: The WRspice User Interface Previous: Scripts and Batch Mode   Contents   Index


Loadable Device Modules

It is possible to load device models into WRspice at run time, through use of ``loadable device modules''. These are dynamically loaded libraries containing the device model description in a form which can be read into a running WRspice process. This capability opens up some interesting possibilities for future versions of WRspice in how new device models are distributed. It also gives the user, at least in principle, the ability to generate and use custom device models in WRspice. Support for this important new feature is available in all releases.

Loadable device modules are most often created by translating and compiling Verilog-A compact model descriptions, though it is also possible to write C/C++ code directly.

Loadable device modules are specific to a particular release number of WRspice, and to the operating system. Since the interface may change, user-created loadable modules need to be rebuilt for new releases of WRspice. This may be relaxed in future releases, when the interface stabilizes.

Loadable device modules can be loaded into WRspice in two ways.

  1. On startup, WRspice will look for loadable modules in the directories listed in the modpath variable, or, if that variable is not set, in the devices directory under the startup directory (i.e., /usr/local/xictools/wrspice/startup/devices if installed in the default location). Modules found will be loaded automatically by default.

    If either of the -m or -mnone command line options is given, or if the nomodload variable is set in the .wrspiceinit file, the automatic device loading will not be done.

  2. The devload command can be used to load a module from the command prompt or from a script. The syntax is
    devload [path_to_loadable_module]

    The argument can also be a directory containing loadable modules, all of which would be loaded by the command.

    The ``devload all'' command will load all known modules, as when WRspice starts.

    If no argument is given, a list of the presently loaded modules is printed.

Once a module is loaded, it can't presently be unloaded. The file can be re-loaded, however, so if a module is modified and rebuilt, it can be loaded again to update the running WRspice.

There are two ways to reference a loaded device model.

  1. By traditional SPICE model level and name.
    There are traditional model names in SPICE, which often provide differentiation of device polarity. These are names like ``npn'' and ``pnp'' for a BJT device, and ``nmos'' and ``pmos'' for MOSFETs. Other devices will use the key character as the model name. The SPICE input file will include lines like
    .model mynpn npn level=100 ...
    .model nch nmos level=101 ...
    .model sxx s level=2 ...
    Every device model must have a unique level value (an integer) for its type. If a module is loaded that has a conflicting level, a warning is issued. If the conflict is with a built-in model, the built-in model will always have precedence, and the loaded model will not be accessible.

  2. By model name.
    Every loadable module has a given model name. Further, device models of dual-polarity devices have a parameter that sets the device polarity. This is defined in the model code, but most models have standardized on a parameter named ``type'' which is set to 1 for n-type and -1 for p-type.

    The model can be referenced by name, for example

    .model mynpn hicum2 type=1 level=8 ...
    .model nch bsim6 type=1 level=80 ...
    If the device has a level value different from 1, a matching level parameter must be defined in the .model line. WRspice does not check for a unique name, as the level parameter should enforce uniqueness.

The devkit directory in the WRspice installation location (/usr/local/xictools/wrspice is the default) will provide the tools needed to build loadable device modules.



Subsections
next up previous contents index
Next: Creating Loadable Modules from Up: The WRspice User Interface Previous: Scripts and Batch Mode   Contents   Index
Stephen R. Whiteley 2022-09-18