Menu

#104 HSA compatibility mode bugs

open
nobody
None
5
7 days ago
2026-02-27
No

Using ngbehaviour=hsa in ngspice 45+ causes multiple errors:

  1. In netlist previously the following was an acceptable voltage source:
    v1 1 0 20
    v2 2 0 DC 20
    v3 2 0 DC=20
    Now when using "ngbehaviour=hsa" only "v3" works, this shouldn't be affected by hsa as per documentation the "a" indicates that this only applies for the PDK so this shouldn't affect circuit netlist.

  2. Sky PDK now doesn't work with ngbehaviour=hsa:

Although previously it worked with and without "ngbehaviour=hsa" the pdk recommends using "hsa" compatibility mode, and since error I experinced with dc voltage I figured that probably this was a bug in the new nggspice version.

Discussion

  • Holger Vogt

    Holger Vogt - 2026-02-27

    The command
    set ngbehaviour=hsa
    does not have any effect, as the correct command is
    set ngbehavior=hsa

     
  • Holger Vogt

    Holger Vogt - 2026-02-27

    Your example

    v1 1 0 20
    v2 2 0 DC 20
    v3 2 0 DC=20
    

    will lead to an error as you cannot put two voltage sources in parallel (see node 2).

     
  • Robert Turnbull

    Robert Turnbull - 2026-02-27

    The manual is a bit confusing in that both the US (behavioral) and UK (behavioural) spellings are used. Perhaps we should change the documentation to use "behavioral" everywhere to match the keyword.

     
  • yahia ghadiry

    yahia ghadiry - 2026-02-27

    @h_vogt
    The errors you pointed out are not what I meant, I must have mistyped

    Here is a better netlist:

    *bug demo
    
    .global 0
    .param dc_bias=15
    
    v1 1 0 dc_bias
    v2 2 0 DC dc_bias
    v3 3 0 DC=dc_bias
    

    Here is .spiceinit:

     set ngbehavior=hsa
    

    Here is ouptut without .spiceinit:

    Note: No compatibility mode selected!
    
    
    Circuit: *bug demo
    
    Error: incomplete or empty netlist
           or no ".plot", ".print", or ".fourier" lines in batch mode;
    no simulations run!
    

    Here is output with .spiceinit:

    Note: Compatibility modes selected: hs a
    
    
    Circuit: *bug demo
    
    Error on line 6 or its substitute:
      v1 1 0 dc_bias
      unknown parameter (dc_bias) 
        Simulation interrupted due to error!
    
    Error: incomplete or empty netlist
           or no ".plot", ".print", or ".fourier" lines in batch mode;
    no simulations run!
    

    Ignore the incomplete or empty netlist error, as the same bug occurs with complete netlist.

    The error only apears when using parameters

     
  • Holger Vogt

    Holger Vogt - 2026-02-27

    O.k., now I do understand.

    The ngspice manual (in chapter 2.11) suggest to putting parameters, which should be substituted, into braces {} or single quotes ' '.

    v1 1 0 {dc_bias}
    v2 2 0 DC {dc_bias}
    v3 3 0 DC={dc_bias}

    There is a function inp_quote_params() to add {} or ' ' to unquoted parameters.

    With my commit
    1aa3fa22f ("No quoting of potential params when comnpatmode is set to hs.", 2026-02-23)
    this has been excluded if compatmode hs is set, as it leads to errors in some PDK.

    I'll have to check what to do.

     
    • yahia ghadiry

      yahia ghadiry - 2026-02-27

      Okay great,
      but shouldn't this only affect PDKs and not actual circuit as the use of hsa, should only affect PDK, also check if this is the reason sky PDK doesn't work with hsa.

      and Generally using params with and without {}/'' causes unforseen bugs.

       
  • Holger Vogt

    Holger Vogt - 2026-02-27

    Please read again the chapter 12.14.1 Compatibility mode, as it is just the other way round.

    What are the "unforseen bugs"?

    All my tests with Skywater and IHP PDKs are o.k.

     
  • Holger Vogt

    Holger Vogt - 2026-02-27

    Please also have a look at chapter 4 of the manual. Nowhere it is stated that
    v3 2 0 DC=20
    is o.k.. If this is working, it is pure chance and may change without notice.

     
  • yahia ghadiry

    yahia ghadiry - 7 days ago

    @h_vogt
    I have done some debugging and found out the reason hsa didn't work for me with, sky.
    It turns out it doesn't have to do with the sky but the "bugginess" I was taking about.

    If I have a mosfet defined as ex:

    .param WIDTH=1 LENGTH=2 NF=3 MULT=4
    M0 v1 v2 v3 v4 nmos w=WIDTH l={LENGTH} nf='NF' m='{MULT}' as=' 5 * WIDTH' ad=' 6 * {WIDTH}'  
    

    The previouse example code will run with both hsa and no hsa in ngspice44, but in ngspice45+ this will only work without hsa enabled, as the following two will cause errors:

    m='{MULT}' 
    ad=' 6 * {WIDTH}'  
    

    as the output in termal signfies that the following substion takes place

    m={{MULT}} 
    ad={ 6 * {WIDTH}}  
    

    So this Causes an error.

    another error that apears is the following attached : ( I can only add 1 attachemnt and not add pictures for some reason):

    when I use SPICE_USERINIT_DIR with path where attachment has .spiceinit, and other files given by sky

    I get the outptut:

    Mutlitple definitoins of ........
    repeated for each device inside libary, this is unexpected behaviour, as it should only look for .spicinit and ignore rest of files.

     

Log in to post a comment.

MongoDB Logo MongoDB