Erros simulating netlist with subckt

2013-05-19
2013-06-12
  • analog_match
    analog_match
    2013-05-19

    I am trying to run a simple simulation using a call to a subckt. My netlist is below:

    X1 Drn Gate gnd gnd nmos1 n=3 m=2 l=2u fw=3u
    R1 Drn Drn1 1.0
    .subckt nmos1 D G S B n=1 m=1 l=2u fw=2u
    .param W={fw*n}
    .param L={l}
    .param m={m}
    M1 D G S B NM m L W
    .MODEL NM NMOS VTO=1.0
    .ends nmos1
    

    But when I run a sim in ngspice I get the following message:

    ngspice 191 -> source test_nmos2.spi

    Circuit: *** spice deck for cell test_nmos{sch} from library testgpdk

    Error on line 0 : m.x1.m1 drn gate 0 0 x1.nm x1.m l    9.000000000e-06
    Unable to find definition of model x1.nm - default assumed

    unknown parameter (x1.m)

    1.Why is ngspice concatenating the subckt name x1 in front of the subckt call?
    2.From the error message, the

    .param W={n*fw}
    

    seems to have evaluated correctly to 9u. This is even more puzzling. Why is one parameter evaluating correctly but model name is not being resolved?

    Just for comparison I have another netlist that has a subckt call that works. It is as follows:

    xyres_yres3@0 vin vout yres
    +W=5u
    +L=5u
    xyres_yres3@1 vout gnd yres
    +W=5u
    +L=10u
    .subckt yres PLUS MINUS W=3u L=3u
    .param sheetrho=100.0
    .param rval={sheetrho*L/W}
    r0 PLUS MINUS rval TC1=0.002
    .ends yres
    

    The major difference between the two is that the second one that works does not have a .model statement. Could defining a .model somehow be causing the issue?

    Is there a problem with my syntax or is this a bug ?

     
  • Holger Vogt
    Holger Vogt
    2013-05-19

    There is a bug in your input file.

    If you look at the manual, chapt. 11.1, you see the syntax for a MOSFET:
    MXXXXXXX nd ng ns nb mname <m=val > < l =val > <w=val >
    + <ad=val > <as=val > <pd=val > <ps=val > <nrd=val >
    + <nrs=val > <of f > < i c =vds , vgs , vbs> <temp=t >

    Your MOSFET line has to read
    M1 D G S B NM m=m L=L W=W

    Holger

     
  • analog_match
    analog_match
    2013-05-20

    Thank you Holger. Your suggestion solved my issue. Your help is much appreciated.