I'm working on a project consisting out of a VHDL/Verilog part and several C++ classes around it, communication using VPI. I compile using NCVerilog and run using NCSim (08.20-s201).
I've two problems here:
1) Typically I have to run for a long time, 10s of millions of cycles. Every now and then a 'ncsim internal error' in a VPI method occurs with zero useful information. Since my code does the same over and over, I don't understand why it would crash all of the sudden. Are there ways to get more information out of NCSim regarding such crashes? Or is it 'normal' that NCSim crashes every now and then? The stack trace often names 'vpi_scan' or 'vpi_iterate'.
2) Is it possible to get VPI performance profiling information out of ncsim? Just attaching perf does not produce so much useful information. In a very old post I found that adding '+ncprofile' should produce performance results, but that does not seem to work (any more?). What would be the preferred way to do this in a modern ncsim?
Thanks a lot,
If the crash is intermittent and points to anything VPI-related, I would predict that there is a memory corruption issue at play. Without wishing to seem rude, my experience is that 99.9% of the time that would be in user-defined C/C++ code rather than the simulator!
I assume you built your C/C++ using the debug options like -g? Failing to do that would prevent a meaningful stack trace. You could try using the -dumpstack option when you run ncsim, this will force static linking which tends to give better stack traces.
The Incisive version you're using is archaic and no longer supported, I would strongly recommend moving to a more recent version of Incisive such as 15.10. There are many advantages to upgrading, including the "irun" command which can replace the old nverilog/ncsim commands and simplifies the flow significantly.
In some of the very old releases there was a limitation in 64-bit mode that prevents the stack trace from being dumped, this was fixed a long time ago and should not be an issue in any of the current supported versions (14.10, 14.20, 15.10).
Again, in these more recent versions we have better code profiling with the iprof tool, this was not available back in 8.2! Even so, this is meant for profiling HDL code not C/C++ code; you should really investigate using a 3rd-party profiler like Oracle Sun Studio (free of charge) or Google perftools for profiling C/C++ code.
thanks for your quick reply. Your hint towards memory corruption made me found a missing free() on an vpi iterator. It seems to work stable now (so far).
I wasn't aware we're using such an old version of ncsim, I've to look into that.