In reply to Luca Iovinella:
Most simulators will generate the correct header file for DPI calls. You can use this header file in your C code to ensure compatibility.
The correct C prototype is:
int my_dpi(const char arg, const char* ret);
Since the second argument is a pointer to a pointer, you need to de-reference it when it’s being assigned:
int my_dpi(const char *arg, const char **ret) {
printf(“DPI Received arg: %s\n”, arg);
*ret = “HELLO”;
return TRUE;
}
You need to ensure that anything returned back to the simulator has a suitable lifetime and isn’t destroyed on the C side as this may result in invalid data being returned.