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.
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.
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.
.model mynpn npn level=100 ...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.
.model nch nmos level=101 ...
.model sxx s level=2 ...
The model can be referenced by name, for example
.model mynpn hicum2 type=1 level=8 ...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.
.model nch bsim6 type=1 level=80 ...
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.