SourceForge has been redesigned. Learn more.
Close

Shell command in ngspice

Fahim
2012-07-18
2013-06-12
  • Fahim

    Fahim - 2012-07-18

    Hi,

    I want to use shell command in ngspice  .cir file but it is giving me error. However when I try to use it on ngspice command interpreter it is working fine.

    What I am actually looking is to use the shell command interpreter in the .cir file to process on some other system and get back to ngspice again.

    Regards,
    Fahim Khan

     
  • Holger Vogt

    Holger Vogt - 2012-07-18

    Fahim,

    no analysis possible without an example file!

    Holger

     
  • Fahim

    Fahim - 2012-07-18

    Hi,

    Do you mean to say a .cir file?

    Can we write the unix command inside the .cir file?

    I want to accept the input file in ngspice from other system, say for example the file contain the 0 0,0 1,1 0  and 1 1 combination. And I want the port in ngspice to read this value from a file. Is there any command which can read value for port  from a file.

    Regards,
    Fahim Khan

     
  • Holger Vogt

    Holger Vogt - 2012-07-18

    "I want to use shell command in ngspice .cir file but it is giving me error."

    What error message?

    Example .cir file creating this error?

    For inputting data from files:
    XSPICE code models (reading the files upon start up)  filesource (for analog),  d_source (digital source). Please see chapter 12 of the manual for instructions.

    There is no command to read in data during simulation.

    What you might try and test:create your circuit using filesource for reading data.
    run command for starting a first simulation by 'run'
    change the filesource file by your external application (shell command?)
    issue the 'reset' command
    run the second simulation by another 'run'

    You have to figure out if the 'reset' command will reload the filesource (I do not know).

    Regards

    Holger

     
  • Fahim

    Fahim - 2012-07-18

    Hi Holger,

    I am using  shell ls -ltr >op3.txt before the .end statement in my .cir file but it is giving me below error.

    Circuit: code model test : new d_ucm_adder

    Error on line 46 : shell ls -ltr >op3.txt
    Unable to find definition of model  - default assumed

    Regards,
    Fahim Khan

     
  • Holger Vogt

    Holger Vogt - 2012-07-18

    Fahim,

    all commands as decribed in chapter 17 of the manual are interactive commands.

    They either may be invoke manually on the command line, or they have to be placed inside of a control section (.control <any commands> .endc).

    In the ngspice/examples directory, there are several examples how to make use of this control section, e.g. /Monte_Carlo/Opwien.sp.

    Holger

     
  • Fahim

    Fahim - 2012-07-18

    Hi Holger,

    thanks for your help.

    Now I am using the d_source model in my net listing. some thing like this

    *** analysis type ***
    .tran 1ps 4.5ns
    *

    a3  input_vector
    .model input_vector d_source(input_file =  op.txt)

    *** d_ucm_adder blocks***

    add1  20 adder1
    .model adder1 d_ucm_adder(rise_delay = 1.0e-12 fall_delay = 1.0e-12)
    .end

    However When I run it, it gives me below error.

    Circuit: code model test : new d_ucm_adder

    Original line no.: 7, new internal line no.: 7:
    Undefined number
    Original line no.: 7, new internal line no.: 7:
    Expression err: op.txt)
    Original line no.: 7, new internal line no.: 7:
    Cannot compute substitute
    Copies=11 Evals=11 Placeholders=1 Symbols=2 Errors=3
    Numparam expansion errors: Run Spice anyway? y/n ?

    Is there anything wrong with use of d_source model.

    Regards,
    Fahim Khan

     
  • Holger Vogt

    Holger Vogt - 2012-07-18

    Fahim,

    try
    .model input_vector d_source(input_file =  "op.txt")

    There is a bug in the manual.

    When I do this, then I get another error (out of memory). That reminds me of a bug no. 3456221 being reported last November. This should however concern only large input files.
    So please test and report.

    Holger

     
  • marcel hendrix

    marcel hendrix - 2012-07-18

    My (slightly modified) ngspice simply reports "Unknown model type d_ucm_adder - ignored."

    I can't find "d_ucm_adder" in the manual. Is this a recent addition?

    -marcel


    C:\Spice\mhx>spice testsource.cir
    c:/spice/share/ngspice/scripts/spinit found
    ******
    ** ngspice-124 : Circuit level simulation program
    ** The U. C. Berkeley CAD Group
    ** Copyright 1985-1994, Regents of the University of California.
    ** Please get your ngspice manual from http://ngspice.sourceforge.net/docs.htm
    ** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
    ** Creation Date: Tue Aug 16 02:54:20 WEDT 2011
    ******

    Circuit: *** analysis type ***

    Error on line 10 : add1  20 adder1
    MIF-ERROR - unable to find definition of model adder1
    Model issue on line 11 : .model adder1 d_ucm_adder(rise_delay=1.0e-12 fall_del
    Unknown model type d_ucm_adder - ignored
    ngspice 1 -> quit
    ngspice-124 done

     
  • Holger Vogt

    Holger Vogt - 2012-07-18

    Marcel,

    no, its something new Fahim is working on.

    To test, I have simply replaced it by d_nand.

    Interestngly, without any analog node, ngspice will fail to start after 'run'command
    with an obviously wrong error message 'out of memory'. So I added simply
    vnew 100 0 1
    then its o.k., when op.txt is placed where ngspice executable is found (using MS Windows).

    My op.txt is

    *
    0  0s 0s
    1n 1s 1s
    2n 1s 1s
    3n 0s 0s
    4n 0s 0s

    Holger

     
  • marcel hendrix

    marcel hendrix - 2012-07-19

    Hi Holger,

    Understood. The appended circuit allowed me to view all inputs and outputs (with the d_and).

    -marcel

    *** analysis type ***
    .tran 1ps 6.5ns

    r1 out1 0 1000
    r2 out2 0 1000
    r3 out3 0 1000

    A10    dac_buff
    A20    dac_buff
    A21   dac_buff

    a3  input_vector
    .model input_vector d_source(input_file="op.txt")

    *** d_ucm_adder blocks***

    add1  20 adder1

    * .model adder1 d_ucm_adder(rise_delay = 1.0e-12 fall_delay = 1.0e-12)
    .model adder1 d_and(rise_delay = 1.0e-12 fall_delay = 1.0e-12)
    .model adc_buff adc_bridge(in_low=0.1  in_high=0.9)
    .model dac_buff dac_bridge(out_low=0.1 out_high=0.9)

    .end

    The op.txt is

    *
    0    0s 0s
    1n   1s 0s
    2n   1s 1s
    3n   1s 1s
    4n   0s 1s
    5n   0s 0s
    6n   0s 0s

     
  • Fahim

    Fahim - 2012-07-19

    Hi Holger,

    Yes in my case also when I add analog  node along with proper syntax  then its working fine with the expected output.

    Thanks!!!

    Regards,
    Fahim Khan 

     

Log in to post a comment.