Menu

Creating a code Model

2013-09-03
2013-09-11
  • Mutaz Yousef Melhem

    Actually I am trying to generate a code model for RC circuit to be called using ngspice and I am facing confusion between the code I downloaded from:

    http://ngspice.sourceforge.net/download.html

    and the manual

    Ngspice Users Manual

    Version 25

    where in section 27.2

    “ Creating Code Models”

    It is mentioned that :

    A. We need to create new directory for the new code model inside the new library file.

    But from the downloaded source file we found that libraries are .cm files not directories @ lib/ngspice folder inside the root folder downloaded from the above website.

    So what shall we do in order to make it work.

    B. I do not have any idea about the format of ifspec.ifs and cfunc.mod files, can you please assist with examples.

    If you can send me your phone number I will highly appreciate that .

     
  • Holger Vogt

    Holger Vogt - 2013-09-06

    ngspice codemodels use C language to describe device equations (source code files ifspec.ifs and cfunc.mod for each model). If you have coded the device description, you then need a compiler (like gcc) to create the code model library or libraries. These are shared libraries stored in *.cm files containing one or more codemodels.

    The files you have downloaded are not the source files (which are typically .c, .h), but the executables offered for MS Windows.

    The ngspice source code is contained in ngspice-25.tar.gz.

    Unfortunately it is not enough to just have ifspec.ifs and cfunc.mod and gcc to compile a library, you need a complete environment to do that. ngspice is creating a lot of codemodel in several libraries (see manual chapt. 12) during compilation. So why not use this existing environment to create your own, additional code models oinside existing libraries or even make your own libraries? This is what chapt. 27 of the ngspie25 manual is about.

    So what to do?

    Set up your compilation environment to create ngspice from its sources (ngspice-25.tar.gz for its latest release or the actual code from git). Manual chapter 31 on compilation notes tells you how to do that. Under MS Windows you will need the mingw/msys environment if you want to crreate your own code models, MS Visual Studio will not do.

    As soon as you can compile ngspice from its sources, you are ready to start to create and compile your own code models (as described in manual chapt. 27).

    If you look at the expanded source tree from ngspice-25.tar.gz, you will find the ifspec.ifs and cfunc.mod for all the the codemodels coming with ngspice (see ngspice\src\xspice\icm for the five libraries, if you go down to e.g. ngspice\src\xspice\icm\analog\sine, you will see the source files for the sine generator).

    Holger

     
  • Mutaz Yousef Melhem

    Dear Holger

    Thank you for your replay. I am trying to do the following tasks:

    1. To create a code model for RC circuit.

    Can you please advise for the format for RC circuit code model?

    1. To call a another program that will be use for optical sumilation from the code model.

    Can you please advise for the format for code model that calls the optical simulation tool?

    Best Regards

    Mutaz Y. Melhem

     
  • Holger Vogt

    Holger Vogt - 2013-09-11

    For an example you might have a look at the existing capacitor model:
    ngspice\src\xspice\icm\xtradev\capacitor

    For an interface using a codemodel between ngspice and another application yoi might look at the following literature:
    "Expression-level Parallelism for Distributed Spice Circuit Simulation" by Dylan Pfeiffer and Andreas Gerstlauer, 2011 15th IEEE/ACM Int. Symposium on Distributed and Real Time Applications. You may try to contact the authors at ECE, The University of Texas at Austin, USA and ask them, if they would be willing to share their XSpice TC/IP socket device with you, which they used for interprocess communication.

    Holger

     

Log in to post a comment.