I have a query. I want to write my model equations and want to include them in NGSPICE like we have already inbuilt BSIM models. What i have been able to find out that there are code models to define new models. But what I can understand from that in code models we can only define functionality and can't write model equations.
Is it possible anyway to write our equations and include them in NGSPCE circuit simulations.
> Is it possible anyway to write our equations and include
> them in NGSPCE circuit simulations.
Code models allow anything you'd want to do computationally, even including calling other programs or dlls from within the inner SPICE solvers. What you can *not* do, is change the SPICE syntax in order to call these models.
Maybe I don't understand the question. Please give a very small example of what want to do or of what you think is presently impossible.
there are several ways to add models to ngspice. Let's take a memristor as an example. It is a 2-terminal device (a resistor) whose resistance value depends on the current it has seen, or the charge moved through it.
The most tedious way, but probably the most efficient way concerning simulation speed is to intergrate it like a BSIM model. People have done that, adding a memristor model to spice3 ( see http://www.memristorproject.com/). Some information on device model integration is available at http://www.eecs.berkeley.edu/Pubs/TechRpts/1989/ERL-89-45.pdf. Examples are there in the ngspice sources (http://ngspice.git.sourceforge.net/git/gitweb.cgi?p=ngspice/ngspice;a=tree;f=src/spicelib/devices;hb=HEAD). You will have to generate several files, and add code to the model interface.
The next possibility is using XSPICE. An input file for an XSPICE code model is available at http://ngspice.git.sourceforge.net/git/gitweb.cgi?p=ngspice/ngspice;a=tree;f=examples/memristor;hb=HEAD as memristor_x.sp. The code model itself is found at http://ngspice.git.sourceforge.net/git/gitweb.cgi?p=ngspice/ngspice;a=tree;f=src/xspice/icm/xtradev/memristor;hb=HEAD. You will see the c code in cfunc.mod. Please have a look at the ngspice manual, chapt. 27, how to implement a new code model.
Finally, if your model is not too complex, you may use behavioral sources (B-source, E, G) or behavioral devices (C, L, R) to add model like functionality. You will find a memristor modelled by a B source in a subcircuit as memristor.sp in the above mentioned example directory.
thanks marcel and Holger
Ok let me explain it a bit more detailed way.
Spice simulators use models developed by BSIM. Lets consider Id expression in linear mode.
Id=k(Vgs-Vth)Vds. So whenever we simulate a circuit in linear mode, this expression is used to calculate the expression.
Similarly I want to include model equations for my work, so that they can be used like standard BSIM expression.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.