Updated with corrections.

This commit is contained in:
pnenzi 2006-02-01 18:26:44 +00:00
parent 5990ff03cc
commit 5d12d0b523
1 changed files with 440 additions and 432 deletions

View File

@ -1,432 +1,440 @@
*************************************************************************** ***************************************************************************
* DISCLAIMER * * DISCLAIMER *
* * * *
* The admst code generators, part of adms and this document are released * * The admst code generators, part of adms and this document are released *
* under LGPL license terms. * * under LGPL license terms. *
* * * *
* Copyright (C) 2006 Freescale Inc. * * Copyright (C) 2006 Freescale Inc. *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public * * modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either * * License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. * * version 2.1 of the License, or (at your option) any later version. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. * * Lesser General Public License for more details. *
* * * *
* You should have received a copy of the GNU Lesser General Public * * You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software * * License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA * * 02110-1301 USA *
*************************************************************************** ***************************************************************************
INTRODUCTION INTRODUCTION
In this document we will provide a guideline on how to auto-generate the In this document we will provide a guideline on how to auto-generate the
ready-to compile C code for the ngspice API of a compact device model ready-to compile C code for the ngspice API of a compact device model
defined in the Verilog-AMS language. defined in the Verilog-AMS language.
Version: Condition:
This guideline has been tested on Windows-XP under cygwin using: To compile Verilog-AMS compact models into ngspice-ready C models with
$ admsXml -v admsXml a copy of the latest adms distribution is needed. You get it from
[usage] <release name="admsXml" version="2.1.2" date="Jan 27 2006" time="16:50:42"/> the adms Download page http://mot-adms.sourceforge.net as a source code
[info] elapsed time: 0 package. (Also use of cvs version is possible, but needs some more effort.)
[info] admst iterations: 0 (0 freed)
Version:
Goal: This guideline has been tested on Windows-XP under cygwin using:
In this guideline we will add device model hicum0 to ngspice $ admsXml -v
using the Verilog-AMS source code available at: [usage] <release name="admsXml" version="2.1.2" date="Jan 27 2006" time="16:50:42"/>
http://www.iee.et.tu-dresden.de/~schroter/Hicum_PD/Hicumna/hicumL0V1p11.va [info] elapsed time: 0
[info] admst iterations: 0 (0 freed)
LIMITATIONS: the adms ngspice interface supports a limited set
of Verilog-AMS language constructs. See the home page of adms Goal:
(http://mot-adms.sourceforge.net/) for more info. In this guideline we will add device model hicum0 to ngspice
Feel free to contribute to the adms ngspice interface so that more using the Verilog-AMS source code available at:
constructs can be supported. http://www.iee.et.tu-dresden.de/~schroter/Hicum_PD/Hicumna/hicumL0V1p11.va
Limitations:
01- ngspice Files The adms ngspice interface supports a limited set of Verilog-AMS language
constructs. See the home page of adms (http://mot-adms.sourceforge.net/)
Ngspice does not (yet) have support for loading models at run time, every for more info.
model must be included at compile time. Then, adding a new model into Feel free to contribute to the adms ngspice interface so that more
ngspice is a process that cannot be completely automated. Some files need constructs can be supported.
to be edited by hand.
01.01 What ngspice need to know of a new model ? 01- ngspice Files
First you have to assign your new model a "device type". As you probably Ngspice does not (yet) have support for loading models at run time, every
know, ngspice recognizes the type of a device by the first letter in model must be included at compile time. Then, adding a new model into
device's name in the netlists ("r" for resistors, "q" for BJT, "m" for ngspice is a process that cannot be completely automated. Some files need
mosfets and so on). Then the first thing you have to find is the correct to be edited by hand.
type for your new device (let's call this device_type).
01.01 What ngspice need to know of a new model ?
Since there can be more than one model for each device type, another
parameter you have to set is the device_level, which must be unique First you have to assign your new model a "device type". As you probably
for each device type. know, ngspice recognizes the type of a device by the first letter in
device's name in the netlists ("r" for resistors, "q" for BJT, "m" for
Once you have found the (device_type, device_level) couple you have mosfets and so on). Then the first thing you have to find is the correct
identified the files you have to edit: type for your new device (let's call this device_type).
<ngspice-data-tree>/src/Makefile.am Since there can be more than one model for each device type, another
Here you have to add the entry in DYNAMIC_DEVICELIBS for your new library parameter you have to set is the device_level, which must be unique
for each device type.
<ngspice-data-tree>/src/spicelib/parser/inp2<device_type>.c
Substitute <device_type> with the letter corresponding to the Once you have found the (device_type, device_level) couple you have
type of you new model. Here you have to add the interface code for your identified the files you have to edit:
new device. In the case of hicum (a BJT model and thus a "q" device type)
you have to edit inp2q.c <ngspice-data-tree>/src/Makefile.am
Here you have to add the entry in DYNAMIC_DEVICELIBS for your new library
<ngspice-data-tree>/src/spicelib/parser/inpdomod.c
Here you have to add a switch for the level of your new device. <ngspice-data-tree>/src/spicelib/parser/inp2<device_type>.c
Substitute <device_type> with the letter corresponding to the
<ngspice-data-tree>/src/spicelib/devices/dev.c type of you new model. Here you have to add the interface code for your
<ngspice-data-tree>/src/spicelib/devices/Makefile.am new device. In the case of hicum (a BJT model and thus a "q" device type)
<ngspice-data-tree>/configure.in you have to edit inp2q.c
Follow the structure of the files and add information on your new
model. In dev.c you have to adjust some macro. <ngspice-data-tree>/src/spicelib/parser/inpdomod.c
Here you have to add a switch for the level of your new device.
See existing examples to make the modifications for your own implementation.
<ngspice-data-tree> is the path to the ngspice source installation. <ngspice-data-tree>/src/spicelib/devices/dev.c
For instance <ngspice-data-tree> can be /tools/ng-spice-rework-17 <ngspice-data-tree>/src/spicelib/devices/Makefile.am
<ngspice-data-tree>/configure.in
Please see appendix 01 about spice3-flavoured flags. Follow the structure of the files and add information on your new
model. In dev.c you have to adjust some macro.
02- adms Files
See existing examples to make the modifications for your own implementation.
List of files that adms needs to create the ready-to-compile C code: <ngspice-data-tree> is the path to the ngspice source installation.
<ngspice-data-tree>/src/spicelib/devices/adms/admst/ngspice*.xml For instance <ngspice-data-tree> can be /tools/ng-spice-rework-17
adms creates the ready-to-compile C code from a set of admst code
generators. admst is a subset of the XML language which has been created Please see appendix 01 about spice3-flavoured flags.
specifically for the purpose of C code generation. The syntax of admst is
very close to the XSLT language (it includes some extensions.) 02- adms Files
03- Create the data file structure List of files that adms needs to create the ready-to-compile C code:
<ngspice-data-tree>/src/spicelib/devices/adms/admst/ngspice*.xml
Create the following directories if they do not already exist: adms creates the ready-to-compile C code from a set of admst code
-a <ngspice-data-tree>/src/spicelib/devices/adms/hicum0 generators. admst is a subset of the XML language which has been created
-b <ngspice-data-tree>/src/spicelib/devices/adms/hicum0/admsva specifically for the purpose of C code generation. The syntax of admst is
very close to the XSLT language (it includes some extensions.)
There is no convention on the way to choice the last directory name in -a.
However in -b 'admsva' is mandatory. 03- Create the data file structure
04- Save the Verilog-AMS source code Create the following directories if they do not already exist:
-a <ngspice-data-tree>/src/spicelib/devices/adms/hicum0
Save the source code of hicum0 from -b <ngspice-data-tree>/src/spicelib/devices/adms/hicum0/admsva
http://www.iee.et.tu-dresden.de/~schroter/Hicum_PD/Hicumna/hicumL0V1p11.va
to: There is no convention on the way to choice the last directory name in -a.
<ngspice-data-tree>/src/spicelib/devices/adms/hicum0/admsva/hic0_full.va However in -b 'admsva' is mandatory.
NOTE: the name of the Verilog-AMS file that contains the 'module' declaration 04- Save the Verilog-AMS source code
should match the name of the module in the file.
For instance in file hic0_full.va you will find the following declaration: Save the source code of hicum0 from
... http://www.iee.et.tu-dresden.de/~schroter/Hicum_PD/Hicumna/hicumL0V1p11.va
module hic0_full (c,b,e,s); to:
... <ngspice-data-tree>/src/spicelib/devices/adms/hicum0/admsva/hic0_full.va
05- Create file 'Makefile.am' NOTE: the name of the Verilog-AMS file that contains the 'module' declaration
should match the name of the module in the file.
In directory ..../hicum0 run the following command in order to create file 'Makefile.am': For instance in file hic0_full.va you will find the following declaration:
$ admsXml admsva/hic0_full.va -e ../admst/ngspiceMakefile.am.xml ...
[info] admsXml-2.1.2 Jan 27 2006 16:50:59 module hic0_full (c,b,e,s);
[warning] [admsva\hic0_full.va:30]: standard vams file created (not found in -I path) ... 'constants.h' ...
[warning] [admsva\hic0_full.va:31]: standard vams file created (not found in -I path) ... 'discipline.h'
[info] Makefile.am: file created 05- Create file 'Makefile.am'
[info] elapsed time: 1.0624
[info] admst iterations: 185425 (185425 freed) In directory ..../hicum0 run the following command in order to create file 'Makefile.am':
After this step file 'Makefile.am' is created: $ admsXml admsva/hic0_full.va -Iadmsva -e ../admst/ngspiceMakefile.am.xml
$ head Makefile.am [info] admsXml-2.1.2 Jan 27 2006 16:50:59
## [warning] [admsva\hic0_full.va:30]: standard vams file created (not found in -I path) ... 'constants.h'
## Interface: [warning] [admsva\hic0_full.va:31]: standard vams file created (not found in -I path) ... 'discipline.h'
## created by: admsXml-2.1.2 - Monday, 01/30/06 [info] Makefile.am: file created
## Process this file with automake to produce Makefile.in [info] elapsed time: 1.0624
ADMSXMLINTERFACE:=../admst [info] admst iterations: 185425 (185425 freed)
adms: After this step file 'Makefile.am' is created:
admsXml.exe -Iadmsva admsva/hic0_full.va \ $ head Makefile.am
##
06- Update/Create the auto-tools files (configure, Makefile.in, Makefile) ## Interface:
## created by: admsXml-2.1.2 - Monday, 01/30/06
06.01 Manual changes ## Process this file with automake to produce Makefile.in
In directory <ngspice-data-tree> edit file configure.ac, add new device 'hicum0' ADMSXMLINTERFACE:=../admst
(use the name of the directory - not the name of the module): adms:
$ grep hicum0 configure.in admsXml.exe -Iadmsva admsva/hic0_full.va \
src/spicelib/devices/adms/hicum0/Makefile \
In directory <ngspice-data-tree>/src/spicelib/devices edit file Makefile.am, add new device 'hicum0': 06- Update/Create the auto-tools files (configure, Makefile.in, Makefile)
$ grep hicum0 Makefile.am
adms/hicum0 \ 06.01 Manual changes
adms/hicum0 \ In directory <ngspice-data-tree> edit file configure.ac, add new device 'hicum0'
(use the name of the directory - not the name of the module):
06.02 Makefile.in $ grep hicum0 configure.in
In directory <ngspice-data-tree> run the shell command 'automake': src/spicelib/devices/adms/hicum0/Makefile \
File 'Makefile.in' is created in directory <ngspice-data-tree>/src/spicelib/devices/hicum0. In directory <ngspice-data-tree>/src/spicelib/devices edit file Makefile.am, add new device 'hicum0':
In directory <ngspice-data-tree>/src/spicelib/devices/hicum0 you should have: $ grep hicum0 Makefile.am
$ ls adms/hicum0 \
Makefile.am Makefile.in admsva constants.h discipline.h adms/hicum0 \
06.03 Update file 'configure' 06.02 Makefile.in
In directory <ngspice-data-tree> run the shell command 'autoconf': In directory <ngspice-data-tree> run the shell command 'automake':
File 'configure' is updated. File 'Makefile.in' is created in directory <ngspice-data-tree>/src/spicelib/devices/hicum0.
Edit the file to make sure that "adms/hicum0/Makefile" is present in the file. In directory <ngspice-data-tree>/src/spicelib/devices/hicum0 you should have:
$ ls
06.04 Makefile Makefile.am Makefile.in admsva constants.h discipline.h
In directory <ngspice-data-tree> run shell command 'configure':
$ configure 06.03 Update file 'configure'
... In directory <ngspice-data-tree> run the shell command 'autoconf':
config.status: creating src/spicelib/devices/adms/hicum0/Makefile File 'configure' is updated.
... Edit the file to make sure that "adms/hicum0/Makefile" is present in the file.
File 'Makefile' is created in directory <ngspice-data-tree>/src/spicelib/devices/hicum0.
In directory <ngspice-data-tree>/src/spicelib/devices/hicum0 you should have: 06.04 Makefile
$ ls In directory <ngspice-data-tree> run shell command 'configure':
Makefile Makefile.am Makefile.in admsva constants.h discipline.h $ configure
...
07- Create the ready-to-compile auto-generated C code of device hicum0 config.status: creating src/spicelib/devices/adms/hicum0/Makefile
...
In directory ..../hicum0 run the following command in order to create the auto-generated C code: File 'Makefile' is created in directory <ngspice-data-tree>/src/spicelib/devices/hicum0.
$ make adms In directory <ngspice-data-tree>/src/spicelib/devices/hicum0 you should have:
admsXml.exe -Iadmsva admsva/hic0_full.va \ $ ls
-e ../admst/ngspiceVersion.xml \ Makefile Makefile.am Makefile.in admsva constants.h discipline.h
-e ../admst/ngspiceMakefile.am.xml \
-e ../admst/ngspiceMODULEitf.h.xml \ 07- Create the ready-to-compile auto-generated C code of device hicum0
-e ../admst/ngspiceMODULEinit.c.xml \
-e ../admst/ngspiceMODULEinit.h.xml \ In directory ..../hicum0 run the following command in order to create the auto-generated C code:
-e ../admst/ngspiceMODULEext.h.xml \ $ make adms
-e ../admst/ngspiceMODULEdefs.h.xml \ admsXml.exe -Iadmsva admsva/hic0_full.va \
-e ../admst/ngspiceMODULEask.c.xml \ -e ../admst/ngspiceVersion.xml \
-e ../admst/ngspiceMODULEmask.c.xml \ -e ../admst/ngspiceMakefile.am.xml \
-e ../admst/ngspiceMODULEpar.c.xml \ -e ../admst/ngspiceMODULEitf.h.xml \
-e ../admst/ngspiceMODULEmpar.c.xml \ -e ../admst/ngspiceMODULEinit.c.xml \
-e ../admst/ngspiceMODULEload.c.xml \ -e ../admst/ngspiceMODULEinit.h.xml \
-e ../admst/ngspiceMODULEacld.c.xml \ -e ../admst/ngspiceMODULEext.h.xml \
-e ../admst/ngspiceMODULEtemp.c.xml \ -e ../admst/ngspiceMODULEdefs.h.xml \
-e ../admst/ngspiceMODULEsetup.c.xml \ -e ../admst/ngspiceMODULEask.c.xml \
-e ../admst/ngspiceMODULEguesstopology.c.xml \ -e ../admst/ngspiceMODULEmask.c.xml \
-e ../admst/ngspiceMODULE.c.xml -e ../admst/ngspiceMODULEpar.c.xml \
[info] admsXml-2.1.2 Jan 27 2006 16:50:59 -e ../admst/ngspiceMODULEmpar.c.xml \
[info] Makefile.am: file created -e ../admst/ngspiceMODULEload.c.xml \
[info] hic0_fullitf.h: file created -e ../admst/ngspiceMODULEacld.c.xml \
[info] hic0_fullinit.c: file created -e ../admst/ngspiceMODULEtemp.c.xml \
[info] hic0_fullinit.h: file created -e ../admst/ngspiceMODULEsetup.c.xml \
[info] hic0_fullext.h: file created -e ../admst/ngspiceMODULEguesstopology.c.xml \
[info] hic0_fulldefs.h: file created -e ../admst/ngspiceMODULE.c.xml
[info] hic0_fullask.c: file created [info] admsXml-2.1.2 Jan 27 2006 16:50:59
[info] hic0_fullmask.c: file created [info] Makefile.am: file created
[info] hic0_fullpar.c: file created [info] hic0_fullitf.h: file created
[info] hic0_fullmpar.c: file created [info] hic0_fullinit.c: file created
[info] noise contribution not implemented - ignored! [info] hic0_fullinit.h: file created
[info] noise contribution not implemented - ignored! [info] hic0_fullext.h: file created
[info] noise contribution not implemented - ignored! [info] hic0_fulldefs.h: file created
[info] noise contribution not implemented - ignored! [info] hic0_fullask.c: file created
[info] noise contribution not implemented - ignored! [info] hic0_fullmask.c: file created
[info] noise contribution not implemented - ignored! [info] hic0_fullpar.c: file created
[info] hic0_fullload.c: file created [info] hic0_fullmpar.c: file created
[info] hic0_fullacld.c: file created [info] noise contribution not implemented - ignored!
[info] hic0_fulltemp.c: file created [info] noise contribution not implemented - ignored!
[info] hic0_fullsetup.c: file created [info] noise contribution not implemented - ignored!
[info] hic0_fullguesstopology.c: file created [info] noise contribution not implemented - ignored!
[info] hic0_full.c: file created [info] noise contribution not implemented - ignored!
[info] elapsed time: 5.43757 [info] noise contribution not implemented - ignored!
[info] admst iterations: 1099640 (1099640 freed) [info] hic0_fullload.c: file created
perl -p -i -e 's/IOP\("(\w+)"/IOP("\L\1"/' hic0_full.c [info] hic0_fullacld.c: file created
[info] hic0_fulltemp.c: file created
In directory <ngspice-data-tree>/src/spicelib/devices/hicum0 you should have: [info] hic0_fullsetup.c: file created
$ ls [info] hic0_fullguesstopology.c: file created
Makefile constants.h hic0_fullacld.c hic0_fullguesstopology.c hic0_fullload.c hic0_fullsetup.c [info] hic0_full.c: file created
Makefile.am discipline.h hic0_fullask.c hic0_fullinit.c hic0_fullmask.c hic0_fulltemp.c [info] elapsed time: 5.43757
Makefile.in hic0_full.c hic0_fulldefs.h hic0_fullinit.h hic0_fullmpar.c [info] admst iterations: 1099640 (1099640 freed)
admsva hic0_fullext.h hic0_fullitf.h hic0_fullpar.c perl -p -i -e 's/IOP\("(\w+)"/IOP("\L\1"/' hic0_full.c
08- Compile the ready-to-compile auto-generated C code In directory <ngspice-data-tree>/src/spicelib/devices/hicum0 you should have:
$ ls
In directory ..../hicum0 run the following command in order to create the object files*.o and libhic0_full.a: Makefile constants.h hic0_fullacld.c hic0_fullguesstopology.c hic0_fullload.c hic0_fullsetup.c
$ make CFLAGS="-g" Makefile.am discipline.h hic0_fullask.c hic0_fullinit.c hic0_fullmask.c hic0_fulltemp.c
if gcc -DHAVE_CONFIG_H -I. -I. -I../../../../.. -I../../../../../src/include -g -MT hic0_full.o Makefile.in hic0_full.c hic0_fulldefs.h hic0_fullinit.h hic0_fullmpar.c
-MD -MP -MF ".ds/hic0_full.Tpo" -c -o hic0_full.o hic0_full.c; \ admsva hic0_fullext.h hic0_fullitf.h hic0_fullpar.c
then mv -f ".deps/hic0_full.Tpo" ".deps/hic0_full.Po"; else rm -f ".deps/hic0_full.Tpo"; exit 1; fi
... 08- Compile the ready-to-compile auto-generated C code
ar cru libhic0_full.a hic0_full.o hic0_fullacld.o hic0_fullask.o hic0_fullguesstopology.o hic0_fullinit.o
hic0_fullload.o hic0_fullmask.o hic0_fullmpar.o hic0_fullpar.o hic0_fullsetup.o hic0_fulltemp.o In directory ..../hicum0 run the following command in order to create the object files*.o and libhic0_full.a:
ranlib libhic0_full.a $ make CFLAGS="-g"
if gcc -DHAVE_CONFIG_H -I. -I. -I../../../../.. -I../../../../../src/include -g -MT hic0_full.o
WARNING: at the compilation step some messages about '#warning conflict' will be printed. -MD -MP -MF ".ds/hic0_full.Tpo" -c -o hic0_full.o hic0_full.c; \
They mean that some ngspice reserved keywords have been used in the Verilog-AMS. then mv -f ".deps/hic0_full.Tpo" ".deps/hic0_full.Po"; else rm -f ".deps/hic0_full.Tpo"; exit 1; fi
Just ignore them in the case of hicum0. ...
ar cru libhic0_full.a hic0_full.o hic0_fullacld.o hic0_fullask.o hic0_fullguesstopology.o hic0_fullinit.o
In directory <ngspice-data-tree>/src/spicelib/devices/hicum0 you should have: hic0_fullload.o hic0_fullmask.o hic0_fullmpar.o hic0_fullpar.o hic0_fullsetup.o hic0_fulltemp.o
$ ls ranlib libhic0_full.a
Makefile hic0_full.c hic0_fullask.o hic0_fullinit.h hic0_fullmask.o hic0_fullsetup.o
Makefile.am hic0_fulldefs.h hic0_fullinit.o hic0_fullmpar.c hic0_fulltemp.c WARNING: at the compilation step some messages about '#warning conflict' will be printed.
Makefile.in hic0_full.o hic0_fullext.h hic0_fullitf.h hic0_fullmpar.o hic0_fulltemp.o They mean that some ngspice reserved keywords have been used in the Verilog-AMS.
admsva hic0_fullacld.c hic0_fullguesstopology.c hic0_fullload.c hic0_fullpar.c libhic0_full.a Just ignore them in the case of hicum0.
constants.h hic0_fullacld.o hic0_fullguesstopology.o hic0_fullload.o hic0_fullpar.o
discipline.h hic0_fullask.c hic0_fullinit.c hic0_fullmask.c hic0_fullsetup.c In directory <ngspice-data-tree>/src/spicelib/devices/hicum0 you should have:
$ ls
NOTE: CFLAGS is redefined to "-g" is order to speed up the compilation process. Makefile hic0_full.c hic0_fullask.o hic0_fullinit.h hic0_fullmask.o hic0_fullsetup.o
It is better NOT to redefine CFLAGS for official releases. Makefile.am hic0_fulldefs.h hic0_fullinit.o hic0_fullmpar.c hic0_fulltemp.c
(the compilation will take a lot longer to complete) Makefile.in hic0_full.o hic0_fullext.h hic0_fullitf.h hic0_fullmpar.o hic0_fulltemp.o
admsva hic0_fullacld.c hic0_fullguesstopology.c hic0_fullload.c hic0_fullpar.c libhic0_full.a
constants.h hic0_fullacld.o hic0_fullguesstopology.o hic0_fullload.o hic0_fullpar.o
09- Update manually the ngspice parser files discipline.h hic0_fullask.c hic0_fullinit.c hic0_fullmask.c hic0_fullsetup.c
Modify the following files:
<ngspice-data-tree>/src/spicelib/parser/inp2q.c ----> depends on the type of the device, here 'q' device NOTE: CFLAGS is redefined to "-g" is order to speed up the compilation process.
<ngspice-data-tree>/src/spicelib/parser/inpdomod.c It is better NOT to redefine CFLAGS for official releases.
<ngspice-data-tree>/src/spicelib/devices/dev.c (the compilation will take a lot longer to complete)
...
10- Update executable 'ngspice'
09- Update manually the ngspice parser files
10-01 Update ngspice Modify the following files:
In directory <ngspice-data-tree> run shell command 'make': <ngspice-data-tree>/src/spicelib/parser/inp2q.c ----> depends on the type of the device, here 'q' device
$ make <ngspice-data-tree>/src/spicelib/parser/inpdomod.c
File 'src/ngspice.exe' is updated and contains the new device 'hicum0'. <ngspice-data-tree>/src/spicelib/devices/dev.c
...
10-02 Install ngspice 10- Update executable 'ngspice'
In directory <ngspice-data-tree> run shell command 'make':
$ make install 10-01 Update ngspice
ngspice executables are installed in /usr/local/bin. In directory <ngspice-data-tree> run shell command 'make':
$ make
11- Test the Implementation of hicum0 into ngspice File 'src/ngspice.exe' is updated and contains the new device 'hicum0'.
11-01 Create a simple ngspice netlist
Create file 'hicum0.sp'. Its contents is given below: 10-02 Install ngspice
$ cat hicum0.sp In directory <ngspice-data-tree> run shell command 'make':
.title Netlist $ make install
.option ngspice executables are installed in /usr/local/bin.
+ temp=25.0
+ reltol=1e-5 11- Test the Implementation of hicum0 into ngspice
+ abstol=1e-15 11-01 Create a simple ngspice netlist
.model mybjtmodel npn Create file 'hicum0.sp'. Its contents is given below:
+ npn=1 $ cat hicum0.sp
+ level=5 .title Netlist
qN1 .option
+ c b 0 0 + temp=25.0
+ mybjtmodel + reltol=1e-5
rcc cc c 100.0 + abstol=1e-15
rbb bb b 1k .model mybjtmodel npn
vcc + npn=1
+ cc 0 + level=5
+ 1.0 qN1
vbb + c b 0 0
+ bb 0 + mybjtmodel
+ 0.0 rcc cc c 100.0
+ ac=0.0 rbb bb b 1k
.dc vbb 0.0 1.0 0.02 vcc
.print + cc 0
+ dc + 1.0
+ v(c) vbb
+ i(vbb) + bb 0
+ i(vcc) + 0.0
.end + ac=0.0
.dc vbb 0.0 1.0 0.02
11-02 run 'ngspice': .print
$ ngspice -b hicum0.sp + dc
Circuit: .title Netlist + v(c)
Doing analysis at TEMP = 298.150000 and TNOM = 300.150000 + i(vbb)
No. of Data Rows : 51 + i(vcc)
.title Netlist .end
DC transfer characteristic Mon Jan 30 10:22:01 2006
-------------------------------------------------------------------------------- 11-02 run 'ngspice':
Index v-sweep v(c) vbb#branch vcc#branch $ ngspice -b hicum0.sp
-------------------------------------------------------------------------------- Circuit: .title Netlist
0 0.000000e+00 1.000000e+00 0.000000e+00 -7.105421e-17 Doing analysis at TEMP = 298.150000 and TNOM = 300.150000
1 2.000000e-02 1.000000e+00 -5.593842e-19 -1.265654e-16 No. of Data Rows : 51
2 4.000000e-02 1.000000e+00 -2.076336e-18 -2.775558e-16 .title Netlist
3 6.000000e-02 1.000000e+00 -5.366258e-18 -6.061817e-16 DC transfer characteristic Mon Jan 30 10:22:01 2006
4 8.000000e-02 1.000000e+00 -1.254873e-17 -1.320055e-15 --------------------------------------------------------------------------------
5 1.000000e-01 1.000000e+00 -2.812744e-17 -2.874367e-15 Index v-sweep v(c) vbb#branch vcc#branch
6 1.200000e-01 1.000000e+00 -7.629085e-17 -7.666090e-15 --------------------------------------------------------------------------------
7 1.400000e-01 1.000000e+00 -1.669761e-16 -1.669553e-14 0 0.000000e+00 1.000000e+00 0.000000e+00 -7.105421e-17
8 1.600000e-01 1.000000e+00 -3.645759e-16 -3.636425e-14 1 2.000000e-02 1.000000e+00 -5.593842e-19 -1.265654e-16
9 1.800000e-01 1.000000e+00 -7.948513e-16 -7.920553e-14 2 4.000000e-02 1.000000e+00 -2.076336e-18 -2.775558e-16
10 2.000000e-01 1.000000e+00 -1.732082e-15 -1.725142e-13 3 6.000000e-02 1.000000e+00 -5.366258e-18 -6.061817e-16
11 2.200000e-01 1.000000e+00 -3.773484e-15 -3.757461e-13 4 8.000000e-02 1.000000e+00 -1.254873e-17 -1.320055e-15
12 2.400000e-01 1.000000e+00 -8.219658e-15 -8.183998e-13 5 1.000000e-01 1.000000e+00 -2.812744e-17 -2.874367e-15
13 2.600000e-01 1.000000e+00 -1.790375e-14 -1.782522e-12 6 1.200000e-01 1.000000e+00 -7.629085e-17 -7.666090e-15
14 2.800000e-01 1.000000e+00 -3.899630e-14 -3.882434e-12 7 1.400000e-01 1.000000e+00 -1.669761e-16 -1.669553e-14
15 3.000000e-01 1.000000e+00 -8.493698e-14 -8.456170e-12 8 1.600000e-01 1.000000e+00 -3.645759e-16 -3.636425e-14
16 3.200000e-01 1.000000e+00 -1.849987e-13 -1.841804e-11 9 1.800000e-01 1.000000e+00 -7.948513e-16 -7.920553e-14
17 3.400000e-01 1.000000e+00 -4.029389e-13 -4.011557e-11 10 2.000000e-01 1.000000e+00 -1.732082e-15 -1.725142e-13
18 3.600000e-01 1.000000e+00 -8.776254e-13 -8.737407e-11 11 2.200000e-01 1.000000e+00 -3.773484e-15 -3.757461e-13
19 3.800000e-01 1.000000e+00 -1.911521e-12 -1.903059e-10 12 2.400000e-01 1.000000e+00 -8.219658e-15 -8.183998e-13
20 4.000000e-01 1.000000e+00 -4.163405e-12 -4.144973e-10 13 2.600000e-01 1.000000e+00 -1.790375e-14 -1.782522e-12
21 4.200000e-01 9.999999e-01 -9.068141e-12 -9.027994e-10 14 2.800000e-01 1.000000e+00 -3.899630e-14 -3.882434e-12
22 4.400000e-01 9.999998e-01 -1.975094e-11 -1.966349e-09 15 3.000000e-01 1.000000e+00 -8.493698e-14 -8.456170e-12
23 4.600000e-01 9.999996e-01 -4.301867e-11 -4.282821e-09 16 3.200000e-01 1.000000e+00 -1.849987e-13 -1.841804e-11
24 4.800000e-01 9.999991e-01 -9.369701e-11 -9.328218e-09 17 3.400000e-01 1.000000e+00 -4.029389e-13 -4.011557e-11
25 5.000000e-01 9.999980e-01 -2.040767e-10 -2.031732e-08 18 3.600000e-01 1.000000e+00 -8.776254e-13 -8.737407e-11
26 5.200000e-01 9.999956e-01 -4.444870e-10 -4.425191e-08 19 3.800000e-01 1.000000e+00 -1.911521e-12 -1.903059e-10
27 5.400000e-01 9.999904e-01 -9.680991e-10 -9.638130e-08 20 4.000000e-01 1.000000e+00 -4.163405e-12 -4.144973e-10
28 5.600000e-01 9.999790e-01 -2.108483e-09 -2.099148e-07 21 4.200000e-01 9.999999e-01 -9.068141e-12 -9.027994e-10
29 5.800000e-01 9.999543e-01 -4.591957e-09 -4.571626e-07 22 4.400000e-01 9.999998e-01 -1.975094e-11 -1.966349e-09
30 6.000000e-01 9.999004e-01 -9.999448e-09 -9.955176e-07 23 4.600000e-01 9.999996e-01 -4.301867e-11 -4.282821e-09
31 6.200000e-01 9.997833e-01 -2.176941e-08 -2.167303e-06 24 4.800000e-01 9.999991e-01 -9.369701e-11 -9.328218e-09
32 6.400000e-01 9.995284e-01 -4.736784e-08 -4.715812e-06 25 5.000000e-01 9.999980e-01 -2.040767e-10 -2.031732e-08
33 6.600000e-01 9.989751e-01 -1.029470e-07 -1.024912e-05 26 5.200000e-01 9.999956e-01 -4.444870e-10 -4.425191e-08
34 6.800000e-01 9.977781e-01 -2.231776e-07 -2.221894e-05 27 5.400000e-01 9.999904e-01 -9.680991e-10 -9.638130e-08
35 7.000000e-01 9.952090e-01 -4.812339e-07 -4.791028e-05 28 5.600000e-01 9.999790e-01 -2.108483e-09 -2.099148e-07
36 7.200000e-01 9.897838e-01 -1.026165e-06 -1.021618e-04 29 5.800000e-01 9.999543e-01 -4.591957e-09 -4.571626e-07
37 7.400000e-01 9.786930e-01 -2.140206e-06 -2.130697e-04 30 6.000000e-01 9.999004e-01 -9.999448e-09 -9.955176e-07
38 7.600000e-01 9.573154e-01 -4.287705e-06 -4.268455e-04 31 6.200000e-01 9.997833e-01 -2.176941e-08 -2.167303e-06
39 7.800000e-01 9.197474e-01 -8.062749e-06 -8.025264e-04 32 6.400000e-01 9.995284e-01 -4.736784e-08 -4.715812e-06
40 8.000000e-01 8.611162e-01 -1.395965e-05 -1.388838e-03 33 6.600000e-01 9.989751e-01 -1.029470e-07 -1.024912e-05
41 8.200000e-01 7.801099e-01 -2.212604e-05 -2.198901e-03 34 6.800000e-01 9.977781e-01 -2.231776e-07 -2.221894e-05
42 8.400000e-01 6.791392e-01 -3.235919e-05 -3.208608e-03 35 7.000000e-01 9.952090e-01 -4.812339e-07 -4.791028e-05
43 8.600000e-01 5.627227e-01 -4.429334e-05 -4.372773e-03 36 7.200000e-01 9.897838e-01 -1.026165e-06 -1.021618e-04
44 8.800000e-01 4.367031e-01 -5.756142e-05 -5.632969e-03 37 7.400000e-01 9.786930e-01 -2.140206e-06 -2.130697e-04
45 9.000000e-01 3.111929e-01 -7.186079e-05 -6.888071e-03 38 7.600000e-01 9.573154e-01 -4.287705e-06 -4.268455e-04
46 9.200000e-01 2.120521e-01 -8.696058e-05 -7.879479e-03 39 7.800000e-01 9.197474e-01 -8.062749e-06 -8.025264e-04
47 9.400000e-01 1.637984e-01 -1.026891e-04 -8.362016e-03 40 8.000000e-01 8.611162e-01 -1.395965e-05 -1.388838e-03
48 9.600000e-01 1.443326e-01 -1.189191e-04 -8.556674e-03 41 8.200000e-01 7.801099e-01 -2.212604e-05 -2.198901e-03
49 9.800000e-01 1.353683e-01 -1.355550e-04 -8.646317e-03 42 8.400000e-01 6.791392e-01 -3.235919e-05 -3.208608e-03
50 1.000000e+00 1.312181e-01 -1.525242e-04 -8.687819e-03 43 8.600000e-01 5.627227e-01 -4.429334e-05 -4.372773e-03
Total elapsed time: 0.625 seconds. 44 8.800000e-01 4.367031e-01 -5.756142e-05 -5.632969e-03
Current dynamic memory usage = 1.515520 MB, 45 9.000000e-01 3.111929e-01 -7.186079e-05 -6.888071e-03
Dynamic memory limit = 1241.702400 MB. 46 9.200000e-01 2.120521e-01 -8.696058e-05 -7.879479e-03
47 9.400000e-01 1.637984e-01 -1.026891e-04 -8.362016e-03
12- How to update ngspice when the Verilog-AMS source code changes 48 9.600000e-01 1.443326e-01 -1.189191e-04 -8.556674e-03
49 9.800000e-01 1.353683e-01 -1.355550e-04 -8.646317e-03
If you modify the Verilog-AMS source code of 'hicum0' 50 1.000000e+00 1.312181e-01 -1.525242e-04 -8.687819e-03
just complete the following steps in order to update Total elapsed time: 0.625 seconds.
'ngspice': Current dynamic memory usage = 1.515520 MB,
Dynamic memory limit = 1241.702400 MB.
12-01 Update the auto-generated C code
In directory ..../hicum0 run: 12- How to update ngspice when the Verilog-AMS source code changes
- make clean
- make adms If you modify the Verilog-AMS source code of 'hicum0'
- make just complete the following steps in order to update
12-02 Update 'ngspice' and re-install 'ngspice':
In directory <ngspice-data-tree> run:
- make 12-01 Update the auto-generated C code
- make install In directory ..../hicum0 run:
- make clean
Appendix 01: Comments on spice3-flavoured flags like npn, pnp, nmos, pmos and so on - make adms
- make
In the adms-based implementation of hicum0 the value of the device type flag (either npn or pnp) 12-02 Update 'ngspice' and re-install
in the model card is just ignored. In directory <ngspice-data-tree> run:
The selection of the type of the device is actually done using model parameters. - make
In the Verilog-AMS code of hicum0 there are two special model parameters called 'npn' and 'pnp' - make install
which decide what the type of the device will be (either a npn bipolar model or pnp bipolar model).
The Verilog-AMS piece of code that triggers the decision is as follows: Appendix 01: Comments on spice3-flavoured flags like npn, pnp, nmos, pmos and so on
if (`PGIVEN(npn))
HICUMtype = `NPN; In the adms-based implementation of hicum0 the value of the device type flag (either npn or pnp)
else if (`PGIVEN(pnp)) in the model card is just ignored.
HICUMtype = `PNP; The selection of the type of the device is actually done using model parameters.
else In the Verilog-AMS code of hicum0 there are two special model parameters called 'npn' and 'pnp'
HICUMtype = `NPN; which decide what the type of the device will be (either a npn bipolar model or pnp bipolar model).
end The Verilog-AMS piece of code that triggers the decision is as follows:
`PGIVEN(npn) is a macro that returns 1 is model parameter 'npn' occurs in the .model card if (`PGIVEN(npn))
of the ngspice netlist. Otherwise it returns 0. HICUMtype = `NPN;
For instance: else if (`PGIVEN(pnp))
1- the following model card will select a NPN type device: HICUMtype = `PNP;
.model mybjtmodel npn else
+ npn=1 HICUMtype = `NPN;
+ level=5 end
2- the following model card will select a PNP type device: `PGIVEN(npn) is a macro that returns 1 is model parameter 'npn' occurs in the .model card
.model mybjtmodel npn of the ngspice netlist. Otherwise it returns 0.
+ pnp=1 For instance:
+ level=5 1- the following model card will select a NPN type device:
.model mybjtmodel npn
In both cases flag 'npn' is just ignored. + npn=1
In section 'Update manually the ngspice parser files' it is recommended + level=5
to use flag 'adms' instead. 2- the following model card will select a PNP type device:
This limitation results from the LRM of VerilogAMS that does not support flags. .model mybjtmodel npn
+ pnp=1
+ level=5
In both cases flag 'npn' is just ignored.
In section 'Update manually the ngspice parser files' it is recommended
to use flag 'adms' instead.
This limitation results from the LRM of VerilogAMS that does not support flags.