Hello,
I am trying to add the current version of the HisimHV-model to ngspice via osdi. Unfortunately when I try to start a simulation ngspice will exit reporting a segmentation violation. Any idea what I am doing wrong? OpenVaf generates a .lib file along with the .osdi file for this model. Do I have to include this .lib file somehow? Any help is appreciated.
OS is windows
Hi Sebastian, can you please give me a link to the Verilog-A File? Then we would be glad to have a look and fix the bug.
Edit: Found a link: https://www.hisim.hiroshima-u.ac.jp/cgi/HiSIM_HV/public_release.cgi
I will try to replicate the bug first.
Edit 1: I succesfully run attached netlist with Hisim 2.5 on Linux. Now will try with windows.
Had to remove the macro:
in file HSMHV_eval_rdrift.inc .
It is defined double in Hisim, which is against the Verilog-A standard. OpenVAF gives a warning, but it should be an error.
Last edit: Markus Müller 2023-02-10
Sebastian, I opened a new ticket on the Github of OpenVAF, I cannot even compile HISIMHV on
Windows, but on Linux it works. We will fix this.
https://github.com/pascalkuthe/OpenVAF/issues/38
Hi, thanks for your help. I also had to remove some double defined macros (depends on the version of HiSimHV). I admit that I used the older provided version of OpenVAF (to avoid installing Microsoft VS build tools). So after removing the macros I was able to compile with this version of OpenVAF. I thought it is an issue with ngspice.
There are multiple issues here:
multiple macro definitions are not a problem and allowed by the standard, OpenVAF just warns about them to avoid that happening by accident. The fact that oipenvaf does not finish compilation when there are warnings is a bug that was fixed with the 23.1.0 version
the crash you see when loading ngspice is related to the fact the 22.12.0 version used a custom c runtime shim to substitute to components usually provided by MSVC. This required me to implement a specific function in assembler to grow stack pages for very large functions (like the init function in hisim). The incorrect assembly implementation is causing the segmentation fault. The extra shim was removed in favor of linking with the official ucrt.lib from the MSVC build tools (there were also issues with embedding the lld linker directly which necessitate the removal anyways)
The issue Markus encountered was an unrelated bug with the new OpenVAF release on windows. You can download a prebuild version of the latest master build here: https://openva.fra1.digitaloceanspaces.com/openvaf_devel-x86_64-pc-windows-msvc.tar.gz . This version includes the appropriate fix for windows. A bugfix release will be published soon.
Last edit: Pascal Kuthe 2023-02-11
Confused: This binary builded 20:47 works well. The older one from 16:01 fails.
Thanks for attempting to resolve the issue. For me nothing seems to have changed with verson 23.2.0 (downloaded after 20:47). The issue with double defined macros preventing the build process still exists. After commenting out the macros I can build the .osdi on windows, but when attempting a simulation the segfault remains.
I also attempted to cross compile on linux, but a package seems to be missing and I could not find any info about it.
Sebastian,
the time 20:47 means the timestamp of the openvaf.exe.
Can you try the hisimhv model from my github rep: https://github.com/dwarning/VA-Models
Here the only one double defined macro is commented out. You speak about more double definitions. Which?
Dietmar, I just tried your model, and indeed, it works now. The official files of version 2.5 from Hiroshima University are working too, after commenting out the macro. Yesterday I just tried Version 2.4.2, because this is what my model cards ask for. Version 2.4.2 still does not work on windows (segfault in ngspice). Interestingly it works on linux.
OK, let me try.
EDIT: Same for me. linux OK.
EDIT: Can confirm the problem under win 10 with version 2.4.2. It is a exception in the osdi/ngspice interface function OSDIsetup in osdisetup.c, line 253. It seems not a model problem.
Last edit: Dietmar Warning 2023-02-12
I can now confirm on windows for Hisim 2.4.0:
- need to remove several duplicate definitions that give "warning" before I get osdi file (both windows and linux)
- Ngspice has a runtime error on Windows
With newer Hisim 2.5.0 these issue do not appear, so in the meantime you can use that.
We are on it.
Last edit: Markus Müller 2023-02-13
I now spend over an hour trying to build Ngspice on Windows with Visual Studio, but I cannot get it done. I do not understand how building on Windows can be so much more complicated than on Linux. I have to give up on the time beeing.
Maybe Pascal can have a look later this week.
Last edit: Markus Müller 2023-02-13
Can you be a bit more specific. Where is the problem? Which VS version you have?
For me on VS2022: I make a double click on the vngspice.sln file and the I choose "debug / 64bit" on top and the build ngspice from menu.
You will need VS2022. VS2019 does no longer do!
Holger, is F11 still working to step into function? I can't get it.
EDIT: I am just seeing "setup_instance" is not ngspice code - so I can't step into, sorry.
Last edit: Dietmar Warning 2023-02-13
Yes that likely happens in the shared lib from OpenVAF, so it is not easy to debug from here.
I was using VS2022, but the build fails. Will post details later. Thanks for your efforts.
What you also will need is a suitable install of flex/bison.
At the same directory level as ngspice you have to create a directory flex-bison. Then download flex and bison from https://sourceforge.net/projects/winflexbison/, and expand it into the above named directory. That's it.
Guys, I decided to switch to linux for now. I ran into an other issue today when I tried to copy the hisimhv 2.5 .osdi file from one PC to another (windows). On the new PC it crashed again with a segfault... Anyway a huge thanks for the effort you are putting into this project and for trying to help me.
Hi all, thanks for the advice with flex-bison, I had thought having the tools in the PATH would be enough. But now compiling works in Windows for me, very nice. We will fix this now that we can debug on Windows.
Sebastian, it is probably a good idea to switch to Linux for the time being. We will update date here once we have resolved the issue. With error reports like this you are helping us a lot to mature this relatively new tool, so please keep posting any issues you find.
I got the bug, it is in line 1965:
Now I do not yet understand why this causes the segfault, by removing it Hisim 2.4.0 works with Ngspice on windows.
Edit: I think the $write callback on Windows is bugged, will see further later.
Last edit: Markus Müller 2023-02-14