I am getting an error when I run it.
Can I know the reason?
In reply to Vinay Reddy:
When coding with C++, you need to provide a function prototype that is compatible with C:
example.cpp
#include "stdio.h"
#include "svdpi.h"
extern "C" int shift_c (const svBitVecVal *i, int n);
int shift_c (const svBitVecVal *i, int n)
{
if (n < 0)
return (*i >> (n *-1));
else if (n > 0)
return (*i << n);
else
return *i;
}
In reply to cgales:
BTW, note that some tools have automatic DPI header files that create generate prototype header files that you can include in your C/C++ file. This catches prototype mismatches at the the compile step instead of waiting until runtime. On EDAPlayground, if you add
-dpiheader dpi.h to the command line, and then
include “dpi.h” to the C file, that eliminates this error.