The CMI interface enables you to enter proprietary models into Star-Hspice. This section describes how to use CMI to add a new MOS model. Use CMI to simplify the integration process.
1. Create a directory environment and modify the configuration file.
2. Prepare and modify model routines.
3. Compile the shared library.
4. Set up the runtime shared library path.
To create the CMI directory environment:
1. Copy the CMI directory from the Star-Hspice release directory to a new location, as shown in the following example:
% cp -r $(installdir)/cmi /home/user1/userx/model
The new CMI directory /home/user1/userx/model/cmi is your working directory. Make sure that you have read and write access to your working directory.
2. Copy an existing model subdirectory to a new model directory and create a subdirectory for the new model under the working CMI directory. For example, if you have a MOSFET model whose LEVEL is 222, you can copy the subdirectory from the existing MOS model LEVEL 3, as follows:
3. Add the following line in the configuration file config :
mos222 222 "my own MOSFET model"
where mos222 is the model name
"my own MOSFET model" is the descriptive comment for the model. The model name and level must be unique in the configuration file. For more information, see the in-line comment in the configuration file.
In the new model subdirectory mos222 , rename mos3 in all filenames to mos222 , for example:
% mv CMImos3defs.h CMImos222defs.h
After renaming all the files, the new model subdirectory should contain the following group of files:
CMImos222GetIpar.c CMImos222SetIpar.c
CMImos222GetMpar.c CMImos222SetMpar.c
CMImos222eval.c CMImos222set.c
The purpose and detailed description of each routine can be found in Model Interface Routines. You must modify the functions as necessary. The majority of the work required to add a new model is for modification of these files.
Follow the steps above to modify the model routine files and the configuration file, then compile the model routines and the shared library with a single make operation. Prior to the make operation, manually set the environment variable HSPICE_CMI to the working CMI directory (see Creating the Directory Environment):
% setenv HSPICE_CMI /home/user1/userx/model/cmi
With HSPICE_CMI set correctly, invoke the compilation process by entering the following:
The new shared library called libCMImodel will be created in subdirectory lib/ with all the object files generated in subdirectory obj/ .
We recommend that you check the syntax of your C functions before launching the compilation process. Enter the following command:
to list any syntax errors in your model routines.
You can use any functional compiler by properly setting the environment variable
For SUNOS 5.4 platforms or later, the automatically generated compiler flag
There are no restrictions on the optimization flags you use for the CMI library. However, we recommend using the flag
If you use the gcc compiler, modify the makefile (
makefile.SUN
gcc -c -I../include -fPIC CMImain.c
gcc -r -o ./lib/libCMImodel obj/*.o
If you use the /usr/ucb/cc compiler, modify the makefile (
makefile.SUN
The /usr/ucb/cc compiler can not compile C source files until the "Language Optional Source Package" is installed. Verify that this source package is installed, then set the environment variable
The shared library is now ready for use. You must update the shared model search path defined by the environment variable hspice_lib_models so that the system dynamic loader can find the new CMI shared library for Star-Hspice. Enter the following:
setenv hspice_lib_models $HSPICE_CMI/lib
Sometimes you can successfully build the CMI dynamic library, but at run time Star-Hspice returns the following error message:
/home/ant/lib/models/libCMImodel and /home/ant/lib/models/libCMImodel.so
This problem is usually caused by undefined symbols at run time. The following is an example output of undefined symbols, using Sun workshop cc as a compiler on a SUNOS 5.5 machine (note that different compilers usually generate nm output in different formats)
[35] | 0| 0|NOTY |LOCL |0 |UNDEF |
[34] | 0| 0|NOTY |LOCL |0 |UNDEF |
[1779] | 0| 0|NOTY |GLOB |0 |UNDEF |.mul
[1853] | 0| 0|NOTY |GLOB |0 |UNDEF |__dtou
[1810] | 0| 0|NOTY |GLOB |0 |UNDEF |__iob
[1822] | 0| 0|NOTY |WEAK |0 |UNDEF |_ex_deregister
[1749] | 0| 0|NOTY |WEAK |0 |UNDEF |_ex_register
[1857] | 0| 0|NOTY |GLOB |0 |UNDEF |atan
[1878] | 0| 0|NOTY |GLOB |0 |UNDEF |cos
[1820] | 0| 0|NOTY |GLOB |0 |UNDEF |exp
[1777] | 0| 0|NOTY |GLOB |0 |UNDEF |fabs
[1872] | 0| 0|NOTY |GLOB |0 |UNDEF |fprintf
[1764] | 0| 0|NOTY |GLOB |0 |UNDEF |log
[1767] | 0| 0|NOTY |GLOB |0 |UNDEF |malloc
[1842] | 0| 0|NOTY |GLOB |0 |UNDEF |memset
[1772] | 0| 0|NOTY |GLOB |0 |UNDEF |pow
[1869] | 0| 0|NOTY |GLOB |0 |UNDEF |sin
[1790] | 0| 0|NOTY |GLOB |0 |UNDEF |sqrt
[1758] | 0| 0|NOTY |GLOB |0 |UNDEF |strcasecmp
[1848] | 0| 0|NOTY |GLOB |0 |UNDEF |strcpy
[1858] | 0| 0|NOTY |GLOB |0 |UNDEF |strlen
[1800] | 0| 0|NOTY |GLOB |0 |UNDEF |strncpy
The above undefined symbols can be satisfied at run time by libraries such as libc or libm. However, any unsatisfied symbols other than those shown in the example may cause the "Unable to load" problem.
Star-Hspice Manual - Release 2001.2 - June 2001