Opened 3 weeks ago

Closed 3 weeks ago

#71124 closed defect (fixed)

ngspice @43: Lacking xspice support

Reported by: hughsonm (Max Hughson) Owned by: markemer (Mark Anderson)
Priority: Normal Milestone:
Component: ports Version: 2.10.2
Keywords: Cc: bpdegnan (Brian Degnan), markemer (Mark Anderson)
Port: ngspice

Description

Problem

I upgraded from ngspice-36 to ngspice-43 recently, by updating my macports. After upgrading, I started getting errors in my circuits due to the use of s_xfer, which is a model from xspice.

Steps to Reproduce

I've attached a circuit file that tries to use s_xfer. With ngspice-36, it succeeds. With ngspice-43, it fails.

Run these commands to reproduce the issue:

port info ngspice
# Check the version of ngspice. If less than 43, then sudo port selfupdate

sudo port install ngspice
# Run the example circuit from this ticket

ngspice -b example.cir 

At the time of writing, ngspice-36 is unavailable on macports. I have ngspice-36 on my computer, so I will show the different results I get from the 2 ngspice versions. Here is the text, copy-pasted from my terminal:

Maxs-MacBook-Pro:ng-versions max$ sudo port activate ngspice@36
--->  Computing dependencies for ngspice
--->  Deactivating ngspice @43_0+lib+manual
--->  Cleaning ngspice
--->  Activating ngspice @36_0+lib+manual
--->  Cleaning ngspice
Maxs-MacBook-Pro:ng-versions max$ ngspice -b ./example.cir 

No compatibility mode selected!


Circuit: *spara analysis

Reducing trtol to 1 for xspice 'A' devices
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

Warning: vpulse1: no DC value, transient time 0 value used

Initial Transient Solution
--------------------------

Node                                   Voltage
----                                   -------
in                                           0
xsubckt.int_a1_a1_0                          0
out                                          0
e.xsubckt.es_1_1_n1#branch                   0
vpulse1#branch                               0
a.xsubckt.ags_2_2_n1#branch_1_0               0


No. of Data Rows : 201
ERROR: (internal)  This operation is not defined for display type PrinterOnly.
Can't open viewport for graphics.
ERROR: (internal)  This operation is not defined for display type PrinterOnly.
Can't open viewport for graphics.
ASCII raw file "rc.raw"
Note: No ".plot", ".print", or ".fourier" lines; no simulations run
Maxs-MacBook-Pro:ng-versions max$ sudo port activate ngspice@43
--->  Computing dependencies for ngspice
--->  Deactivating ngspice @36_0+lib+manual
--->  Cleaning ngspice
--->  Activating ngspice @43_0+lib+manual
--->  Cleaning ngspice
Maxs-MacBook-Pro:ng-versions max$ ngspice -b ./example.cir 
Warning: can't find the initialization file spinit.

Note: No compatibility mode selected!


Circuit: *spara analysis

Error on line 3 or its substitute:
  a.xsubckt.ags_2_2_n1 in xsubckt.int_a1_a1_0 xsubckt:filter_ags_2_2_n1
 MIF-ERROR - unable to find definition of model xsubckt:filter_ags_2_2_n1
    Simulation interrupted due to error!

Note: No ".plot", ".print", or ".fourier" lines; no simulations run
Maxs-MacBook-Pro:ng-versions max$ 

My Investigation

  1. Activating the ngspice-36 port and deactivating the ngspice-43 port fixes the issue, but is not a long-term solution.
  2. I deactivated all my versions of ngspice from macports. Then, I pulled the code with git and followed the build instructions in INSTALL for macos/Clang.
    • If I configure with --enable-xspice=no, then the xspice models are inaccessible.
    • If I configure with --enable-xspice, then the xspice models are accessible.

I suspect that the macports build instructions are disabling xspice, though I do not know how they would be disabled. The portfile sets the correct configuration flags, as far as I can tell.

Attachments (1)

example.cir (443 bytes) - added by hughsonm (Max Hughson) 3 weeks ago.
Example file for demonstrating lack of xspice support

Download all attachments as: .zip

Change History (17)

Changed 3 weeks ago by hughsonm (Max Hughson)

Attachment: example.cir added

Example file for demonstrating lack of xspice support

comment:1 Changed 3 weeks ago by markemer (Mark Anderson)

The portfile is indeed correct, I'll have to check a build as to why the below isn't being respected for some reason.

    configure.args      --enable-cider \
                        --enable-xspice \

comment:2 Changed 3 weeks ago by markemer (Mark Anderson)

I've also been meaning to dive in to get openmp working now that we have compilers on every platform to handle them.

comment:3 Changed 3 weeks ago by markemer (Mark Anderson)

How did you compile the one that worked? Also, what macOS and Xcode version are you running as well as architecture?

Last edited 3 weeks ago by markemer (Mark Anderson) (previous) (diff)

comment:4 Changed 3 weeks ago by markemer (Mark Anderson)

Owner: changed from bpdegnan to markemer

comment:5 Changed 3 weeks ago by hughsonm (Max Hughson)

  • How did you compile the one that worked?
    • I pulled the code from ngspice's sourceforge here and followed the instructions in the INSTALL file, specifically section 10.3. If I follow the instructions, then I get a ngspice binary that can use xspice. If I change the configure step to ./configure --enable-cider --enable-xspice=no --enable-openmp --enable-pss --with-readline=yes --enable-debug=no, then I get a ngspice binary that cannot use xspice.
  • Also, what macOS and Xcode version are you running as well as architecture?
    • macos 14.6.1 (23G93)
    • xcode: I don't have Xcode installed (I think). How can I check? My AppleClang is Apple clang version 15.0.0 (clang-1500.3.9.4)
    • architecture: Intel x86 cpu

comment:6 Changed 3 weeks ago by markemer (Mark Anderson)

I wonder if it has to do with openmp. That makes no sense, but it's the only difference. Your circuit file doesn't work for me either, but I see it building the xspice stuff, and my own build didn't work either. However, I didn't enable open-mp.

Still makes zero sense, since openmp is for BSIM3 models.

To be clear this is the line you ran that works?

./configure --enable-cider --enable-xspice --enable-openmp --enable-pss --with-readline=yes --enable-debug=no

comment:7 Changed 3 weeks ago by markemer (Mark Anderson)

I can't get this circuit file to work with any ngspice-43, one I built myself, one with openmp, anything. Are we sure the problem isn't in ngspice or the file? For example, if all you have installed is Apple clang version 15.0.0 (clang-1500.3.9.4), there is no way it should have built. Mine failed while building with openmp failures.

comment:8 Changed 3 weeks ago by markemer (Mark Anderson)

My current theory is it has something to do with this:

Warning: can't find the initialization file spinit.

Note: No compatibility mode selected!

comment:9 Changed 3 weeks ago by hughsonm (Max Hughson)

That was my first suspicion too, but I believe those are both optional

comment:10 Changed 3 weeks ago by hughsonm (Max Hughson)

And the spinit file does exist, at /opt/local/share/ngspice/scripts/spinit. Mine looks like

* Standard ngspice init file
alias exit quit
alias acct rusage all
set x11lineararcs
*set rndseed=12
** ascii rawfile **
*set filetype=ascii
** frontend debug output **
*set ngdebug
** asking after quit **
*set askquit
** set the number of threads in openmp
** default (if compiled with --enable-openmp) is: 2
set num_threads=8

* comment out if central osdi management is set up
unset osdi_enabled

* Load the codemodels
if $?xspice_enabled

 codemodel ../lib/ngspice/spice2poly.cm
 codemodel ../lib/ngspice/analog.cm
 codemodel ../lib/ngspice/digital.cm
 codemodel ../lib/ngspice/xtradev.cm
 codemodel ../lib/ngspice/xtraevt.cm
 codemodel ../lib/ngspice/table.cm

end

* Load the OpenVAF/OSDI models
if $?osdi_enabled

 osdi ../lib/ngspice/asmhemt.osdi
 osdi ../lib/ngspice/bjt504t.osdi
 osdi ../lib/ngspice/BSIMBULK107.osdi
 osdi ../lib/ngspice/BSIMCMG.osdi
 osdi ../lib/ngspice/HICUMl0-2.0.osdi
 osdi ../lib/ngspice/psp103_nqs.osdi
 osdi ../lib/ngspice/r2_cmc.osdi
 osdi ../lib/ngspice/vbic_4T_et_cf.osdi
 
end

comment:11 Changed 3 weeks ago by markemer (Mark Anderson)

Yep, I added this .spiceinit in the directory I ran ngspice in makes it work. Why it's not picking our spinit up, or not running it, I'm not sure.

* Standard ngspice init file
alias exit quit
alias acct rusage all
** set the number of threads in openmp
** default (if compiled with --enable-openmp) is: 2
set num_threads=4

echo "runing this"

if $?sharedmode
  unset interactive
  unset moremode
else
  set interactive
  set x11lineararcs
end

strcmp __flag $program "ngspice"
if $__flag = 0

 codemodel /opt/local/lib/ngspice/spice2poly.cm
 codemodel /opt/local/lib/ngspice/analog.cm
 codemodel /opt/local/lib/ngspice/digital.cm
 codemodel /opt/local/lib/ngspice/xtradev.cm
 codemodel /opt/local/lib/ngspice/xtraevt.cm
 codemodel /opt/local/lib/ngspice/table.cm

end
unset __flag


comment:12 Changed 3 weeks ago by markemer (Mark Anderson)

So for some reason our default spinit isn't loading and so these aren't loaded, so boom, error.

 codemodel /opt/local/lib/ngspice/spice2poly.cm
 codemodel /opt/local/lib/ngspice/analog.cm
 codemodel /opt/local/lib/ngspice/digital.cm
 codemodel /opt/local/lib/ngspice/xtradev.cm
 codemodel /opt/local/lib/ngspice/xtraevt.cm
 codemodel /opt/local/lib/ngspice/table.cm

comment:13 Changed 3 weeks ago by hughsonm (Max Hughson)

Yep, I added this .spiceinit in the directory I ran ngspice in makes it work

Worked for me too!

Maybe it's caused by some naming confusion? spinit vs .spiceinit? Just speculating, I'm no expert.

comment:14 Changed 3 weeks ago by markemer (Mark Anderson)

Ok, it seems --enable-relpath in our build doing this. I need to look into why it doesn't load the default file when that's active. We may have needed it once upon a time, but don't anymore, or need to set something to pickup spinit

spinit is the main one, but you can override it locally, and usually have to for things like the Skywater 130 PDK which is why I may not have noticed it wasn't being picked up.

Version 0, edited 3 weeks ago by markemer (Mark Anderson) (next)

comment:15 Changed 3 weeks ago by markemer (Mark Anderson)

I think I have a fix in PR-26216 once it passes CI, I'll merge and that should deal with it

comment:16 Changed 3 weeks ago by markemer (Mark Anderson)

Resolution: fixed
Status: assignedclosed

In 169b19320f98b75e2ed674dad56a5b1094614500/macports-ports (master):

ngspice: fix inability to find spinit file (https://github.com/macports/macports-ports/pull/26216)

  • Delete --enable-relpath

Closes: #71124

Note: See TracTickets for help on using tickets.