Menu

#51 Verbose error log or stacktrace

v1.0 (example)
open
nobody
None
5
2020-09-27
2020-09-25
kjslkfjsd
No

I am still quite new to ngspice and am having trouble finding any sort of verbose error logs. For example I have this simple circuit:

.include "SQP/SQP.lib"
R1 in QB 100
R2 QC GND 5k
R3 QB GND 16
V1 in GND Pulse(0 20 0 10)
XQ1 QC QB in SQP90P06-07L
.tran 100m 10 0 
.end

With the SQP.lib file being:

EESchema-LIBRARY Version 2.4
#encoding utf-8
#
# SQP90P06-07L
#
********************************
* Copyright:                   *
* Vishay Intertechnology, Inc. *
********************************
*Apr 27, 2015
*ECN S15-0949, Rev. A
*File Name: SQP90P06-07L_PS.txt and SQP90P06-07L_PS.lib
*This document is intended as a SPICE modeling guideline and does not
*constitute a commercial product datasheet. Designers should refer to the
*appropriate datasheet of the same number for guaranteed specification
*limits.
.SUBCKT SQP90P06-07L D G S  
M1 3 GX S S PMOS W= 19911044u L= 0.3u 
M2 S GX S D NMOS W= 19911044u L= 0.42u 
R1 D 3 5.040e-03 TC=5.458e-03,7.805e-06
CGS GX S 6.574e-09 
CGD GX D 1.885e-10 
RG G GY 1m 
RTCV 100 S 1e6 TC=3.411e-04,-2.704e-06
ETCV GY GX 100 200 1 
ITCV S 100 1u 
VTCV 200 S 1 
DBD D S DBD 19911044u 
************************************************** 
.MODEL PMOS PMOS ( LEVEL = 3 TOX = 5e-8 
+ RS = 0 KP = NSUB NSUB = 4.565e+16 
+ KAPPA = 1.001e-02 NFS = 3.30e+11 
+ LD = 0 IS = 0 TPG = -1    )
**************************************************  
.MODEL NMOS NMOS ( LEVEL = 3 TOX = 5e-8 
+NSUB = 1.290e+16 IS = 0 TPG = -1    )
************************************************** 
.MODEL DBD D ( 
+FC = 0.1 TT = 2.389e-08 T_measured = 25 BV = 61
+RS = 3.848e-02 N = 1.084e+00 IS = 1.408e-12 
+EG = 1.498e+00 XTI = -8.875e+00 TRS1 = 2.706e-03
+CJO = 9.387e-11 VJ = 3.212e+00 M = 9.990e-01 ) 
.ENDS 
*************************
DEF SQP90P06-07L Q 0 20 Y N 1 F N
F0 "Q" 195 75 50 H V L CNN
F1 "SQP90P06-07L" 195 0 50 H V L CNN
F2 "Package_TO_SOT_SMD:TO-252-2" 195 -75 50 H I L CIN
F3 "" 0 0 50 H I C CNN
$FPLIST
 TO?252*
$ENDFPLIST
DRAW
C 65 0 110 0 1 10 N
C 100 -70 10 0 1 0 F
C 100 70 10 0 1 0 F
P 2 0 1 0 10 0 -100 0 N
P 2 0 1 10 10 75 10 -75 N
P 2 0 1 10 30 -50 30 -90 N
P 2 0 1 10 30 20 30 -20 N
P 2 0 1 10 30 90 30 50 N
P 2 0 1 0 100 100 100 70 N
P 3 0 1 0 100 -100 100 0 30 0 N
P 4 0 1 0 30 70 130 70 130 -70 30 -70 N
P 4 0 1 0 90 0 50 15 50 -15 90 0 F
P 4 0 1 0 110 -20 115 -15 145 -15 150 -10 N
P 4 0 1 0 130 -15 115 10 145 10 130 -15 N
X G 1 -200 0 100 R 50 50 1 1 I
X D 2 100 200 100 D 50 50 1 1 P
X S 3 100 -200 100 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
#End Library

When running ngspice robot_copy.cir I get the following error:

Error: unknown subckt: x g 1 -200 0 100 r 50 50 1 1 i

Now as this is a fairly simple circuit and only a single external library, I can track this down fairly easily (line 68 of the library file), but how do you debug more complicated projects with multiple libraries accross different directories (external and internal to your project), or if you had multiple identical lines. How would you figure out in which file and on which line the error was thrown so that you can go investigate it?

I see no stack trace or verbose logging options on the man page or in the ngspice -h. I tried looking at the -o and -r outputs, but there doesn't appear to be anything more verbose than what is sent to stdout.

Related

Support Requests: #51

Discussion

  • kjslkfjsd

    kjslkfjsd - 2020-09-25

    I should add another example. I just rearranged the library file above into two seperate files one for the spice model and one for the kicad symbol definition. Now I get the following error:

    Error on line 2 :
    #encoding utf-8
    unknown device type - error
    Error on line 3 :
    #
    unknown device type - error
    Error on line 4 :
    # sqp90p06-07l
    unknown device type - error
    Error on line 5 :
    #
    unknown device type - error
    Error on line 37 :
    #
    unknown device type - error
    Error on line 38 :

    As the NET list .cir file only has 9 lines, I know the line numbers 37 and 38 must be from the library file, but again, if I were to have multiple library files, how would I know which file to look for line 37 and 38?

     
    • marcel hendrix

      marcel hendrix - 2020-09-25

      On 2020-09-25 11:01, kjslkfjsd wrote:

      I should add another example. I just rearranged the library file above
      into two seperate files one for the spice model and one for the kicad
      symbol definition. Now I get the following error:

      Error on line 2 :
      #encoding utf-8
      unknown device type - error
      Error on line 3 :
      #
      unknown device type - error
      Error on line 4 :
      # sqp90p06-07l
      unknown device type - error
      Error on line 5 :
      #
      unknown device type - error
      Error on line 37 :
      #
      unknown device type - error
      Error on line 38 :

      As the NET list .cir file only has 9 lines, I know the line numbers 37
      and 38 must be from the library file, but again, if I were to have
      multiple library files, how would I know which file to look for line
      37 and 38?

      Did you try typing the interactive LISTING ( various options )
      command? (This won't work when the netlist refuses to load,
      which sometimes happens.)

      -marcel

       
  • marcel hendrix

    marcel hendrix - 2020-09-25

    On 2020-09-25 09:52, kjslkfjsd wrote:


    [support-requests:#51] Verbose error log or stacktrace

    Status: open
    Group: v1.0 (example)
    Created: Fri Sep 25, 2020 07:52 AM UTC by kjslkfjsd
    Last Updated: Fri Sep 25, 2020 07:52 AM UTC
    Owner: nobody

    I am still quite new to ngspice and am having trouble finding any sort
    of verbose error logs. For example I have this simple circuit:

    .include "SQP/SQP.lib" R1 in QB 100 R2 QC GND 5k R3 QB GND 16 V1 in GND Pulse(0 20 0 10) XQ1 QC QB in SQP90P06-07L .tran 100m 10 0 .end

    With the SQP.lib file being:

    ```
    EESchema-LIBRARY Version 2.4

    encoding utf-8

    SQP90P06-07L


    • Copyright: *
    • Vishay Intertechnology, Inc. *

    Apr 27, 2015
    ECN S15-0949, Rev. A
    File Name: SQP90P06-07L_PS.txt and SQP90P06-07L_PS.lib
    This document is intended as a SPICE modeling guideline and does not
    constitute a commercial product datasheet. Designers should refer to
    the
    appropriate datasheet of the same number for guaranteed specification
    *limits.
    .SUBCKT SQP90P06-07L D G S
    M1 3 GX S S PMOS W= 19911044u L= 0.3u
    M2 S GX S D NMOS W= 19911044u L= 0.42u
    R1 D 3 5.040e-03 TC=5.458e-03,7.805e-06
    CGS GX S 6.574e-09
    CGD GX D 1.885e-10
    RG G GY 1m
    RTCV 100 S 1e6 TC=3.411e-04,-2.704e-06
    ETCV GY GX 100 200 1
    ITCV S 100 1u
    VTCV 200 S 1
    DBD D S DBD 19911044u


    .MODEL PMOS PMOS ( LEVEL = 3 TOX = 5e-8
    + RS = 0 KP = NSUB NSUB = 4.565e+16
    + KAPPA = 1.001e-02 NFS = 3.30e+11
    + LD = 0 IS = 0 TPG = -1 )


    .MODEL NMOS NMOS ( LEVEL = 3 TOX = 5e-8
    +NSUB = 1.290e+16 IS = 0 TPG = -1 )


    .MODEL DBD D (
    +FC = 0.1 TT = 2.389e-08 T_measured = 25 BV = 61
    +RS = 3.848e-02 N = 1.084e+00 IS = 1.408e-12
    +EG = 1.498e+00 XTI = -8.875e+00 TRS1 = 2.706e-03
    +CJO = 9.387e-11 VJ = 3.212e+00 M = 9.990e-01 )
    .ENDS


    DEF SQP90P06-07L Q 0 20 Y N 1 F N
    F0 "Q" 195 75 50 H V L CNN
    F1 "SQP90P06-07L" 195 0 50 H V L CNN
    F2 "Package_TO_SOT_SMD:TO-252-2" 195 -75 50 H I L CIN
    F3 "" 0 0 50 H I C CNN
    $FPLIST
    TO?252*
    $ENDFPLIST
    DRAW
    C 65 0 110 0 1 10 N
    C 100 -70 10 0 1 0 F
    C 100 70 10 0 1 0 F
    P 2 0 1 0 10 0 -100 0 N
    P 2 0 1 10 10 75 10 -75 N
    P 2 0 1 10 30 -50 30 -90 N
    P 2 0 1 10 30 20 30 -20 N
    P 2 0 1 10 30 90 30 50 N
    P 2 0 1 0 100 100 100 70 N
    P 3 0 1 0 100 -100 100 0 30 0 N
    P 4 0 1 0 30 70 130 70 130 -70 30 -70 N
    P 4 0 1 0 90 0 50 15 50 -15 90 0 F
    P 4 0 1 0 110 -20 115 -15 145 -15 150 -10 N
    P 4 0 1 0 130 -15 115 10 145 10 130 -15 N
    X G 1 -200 0 100 R 50 50 1 1 I
    X D 2 100 200 100 D 50 50 1 1 P
    X S 3 100 -200 100 U 50 50 1 1 P
    ENDDRAW
    ENDDEF

    End Library

    ```

    When running ngspice robot_copy.cir I get the following error:

    Error: unknown subckt: x g 1 -200 0 100 r 50 50 1 1 i

    Now as this is a fairly simple circuit and only a single external
    library, I can track this down fairly easily (line 68 of the library
    file), but how do you debug more complicated projects with multiple
    libraries accross different directories (external and internal to your
    project), or if you had multiple identical lines. How would you figure
    out in which file and on which line the error was thrown so that you
    can go investigate it?

    I see no stack trace or verbose logging options on the man page or in
    the ngspice -h. I tried looking at the -o and -r outputs, but
    there doesn't appear to be anything more verbose than what is sent to
    stdout.

    One can compile a debug version of ngspice and run that within Visual
    Studio. It leaves nothing to be desired for me, but YMMV.

    -marcel

     

    Related

    Support Requests: #51

  • kjslkfjsd

    kjslkfjsd - 2020-09-25

    Thanks for the help marcel. Are you refering to this? This is another thing I've found contributes to the rather steep learning curve of this, is that a lot of commands or keywords are very common words or single letters making finding them in the manual, or elsewhere quite difficult. If you have any tips for searching for such things as well, other than reading through the manual word for word and memorizing all of them, I'm happy to hear them! :)

     
    • marcel hendrix

      marcel hendrix - 2020-09-25

      On 2020-09-25 12:52, kjslkfjsd wrote:

      Thanks for the help marcel. Are you refering to
      this?
      This is another thing I've found contributes to the rather steep
      learning curve of this, is that a lot of commands or keywords are very
      common words or single letters making finding them in the manual, or
      elsewhere quite difficult. If you have any tips for searching for such
      things as well, other than reading through the manual word for word
      and memorizing all of them, I'm happy to hear them! :)

      Memorizing is not necessary, but try to execute all the
      commands at least once. It might help to use the console
      version of NGSPICE for a while.

      Some commands obey certain options and environment variables
      that are not always well documented. I only know this from
      reading through all of the Q&A in the discussion groups,
      and of course from reading the sources.

      Reading the sources will tell NOTHING on how SPICE
      works. For that I recommend 'Circuit Simulation with
      SPICE OPUS - Theory and Practice' by Tadek Tuma and Arpad
      Burmen, ISBN 978-0-8176-4866-4. OPUS is almost NGSPICE
      but its control section commands are beautifully well
      organized and have all kinds of natural extensions.
      Unfortunately OPUS is closed source (last time I looked).
      One will learn nothing about XSPICE internals, but AFAIK
      there is no book or paper that gives these details.

      When you start delving into NUTMEG commands the fun
      really starts. Their awkwardness is still perplexing
      10 years after I first encountered them.

      -marcel

       
      • kjslkfjsd

        kjslkfjsd - 2020-09-25

        Memorizing is not necessary, but try to execute all the
        commands at least once. It might help to use the console
        version of NGSPICE for a while.

        Hmm... I'm pretty sure I won't remember anything starting with an x means an instance of a subcircuit a month after not using this but I hear what you're trying to say. I'm sure for those who use this regularly, the shorthand makes for very speedy development, but for those like me who only need it a few times a year, the learning curve and relearning curve appear steep.

        Yes, I've been using the console version as much as I can for this purpose. I guess I've been spoiled by the various IDEs out there for all the other languages I use where you can just hover over anything and it shows you the relevant documentation.

        I still appreciate all the existing documentation that is here though!

        So do you run a debug version all the time through VS or are there release tools available to help further investigate the sometimes ambiguous error messages?

         
        • Holger Vogt

          Holger Vogt - 2020-09-25

          You may provide a

          set ngdebug
          

          in .spiceinit.
          This will output three intermediate files debug-out.txt debug-out2.txt debug-out3.txt.

          debug-out.txt is the internal intermediate netlist after reading all input files (*.cir, .lib, .inc) and assembling them into a common netlist. Details of what has been done to the input data are found in the source code comments in inpcom.c, lines 553 - 588

          debug-out2.txt is the internal netlist after subcircuit expansion. All subcircuits are flattened and expanded into the intermediate netlist (including all subcircuit parameter handling).

          debug-out3.txt is the final internal netlist that will be entered into the simulator. .if commands, statistical functions are evaluated, temperature has been set and some more.

          It will require some experience, but then getting to know the internal status may help identifying input bugs.

          Sometimes even preparing the firs debug file debug-out.txt fails due to some input error. Unfortunately shortly after reading the input file data the information of its origin (file name ...) is lossed. So the resulting error message may be somewhat cryptic.

          I will consider adding the source information to the internal netlist, which may then be used in the error message. This is however not just a simple add-on.

           
  • kjslkfjsd

    kjslkfjsd - 2020-09-25

    One can compile a debug version of ngspice and run that within Visual
    Studio. It leaves nothing to be desired for me, but YMMV.

    I'll look into that next week. I didn't consider that.

     
  • Holger Vogt

    Holger Vogt - 2020-09-25

    I have to make a general comment here:

    You are using a lib file that is not ngspice compatible.

    If it is an Eeschema file (as the internal title suggests), then please use Eeschema with its internal ngspice.

    If you are a casual user, you might not deviate from the prescribed procedures. If you do so, it may be your task to learn more about ngspice.

    Eeschema btw has a tool to export a ngspice netlist which is directly readable by ngspice.

     
  • Holger Vogt

    Holger Vogt - 2020-09-25

    I am beginning to understand what is going on here. Unfortunately this is somewhat out of our (ngspice) control.

    VISHAY has created a nice lib file which includes ngspice stuff and KiCad/Eeschema stuff as well in a single file. When you use Eeschema and add the simulation lib by entering the subcircuit, Eeschema will read from .subckt to .ends in the lib file and discard the rest.

    When one generates the netlist by the Eeschema command, Eeschema adds the lib file by an .include command because the developers have acted on the assumption that all stuff inside the lib file is ngspice compatible (contains only subcircuit descriptions). The VISHAY approach runs against this assumption, it is new, compact, but incompatible to plain ngspice. ngspice wants the .include file command to be universally applicable, i.e. allow reading in complete netlists or other (compatible) stuff, not just subcircuits.

    Using this VISHAY lib file outside of Eeschema for now will require ngspice know-how. A simple way would be to put the .subcircuit ... .ends into a separate file for inclusion (no other lines outside of it).

     
    • kjslkfjsd

      kjslkfjsd - 2020-09-27

      Thanks Holger. Yes, I realized the Eeschema incompatibilities after starting this thread. I'm still getting familiar with both tools, and the same file extension (.lib) was throwing me off for quite some time. I'm always reading more of the ngspice manual that you seem to have helped write, so thanks for your efforts!

      VISHAY has created a nice lib file which includes ngspice stuff and KiCad/Eeschema stuff as well in a single file.

      No no, I made this hybrid file based on a misunderstanding of the Eeschema docs. It is essentially the Vishay spice file (with a few changes) and the generated symbol from Eeschema which I copied from an existing part of the same package size. I'm at fault for the errors, and have since managed to resolve them by separating the two into different lib files. This issue was just and example. I was more interested in general how to better debug these situations because the error messages I was seeing were not informative enough to understand the root cause of the error. Your suggestion to set ngdebug is likely what I was looking for. I'll try that out this week.

      Your explanation helped me understand the meaning of many error messages already. I'm not in front of the same machine atm, but there was often mention of an original file and a new or internal file. These compounded netlist files seem give light to the meaning of this.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.