Makefile for --sc --exe with --vpi fails to build
While I think this is something I can work around, it would be nice if it "just worked".
I took the SystemC example given in the documentation and just changed the verilator command line to:
verilator -Wall --sc --vpi --exe our.v sc_main.cpp
cd obj_dir && make -f Vour.mk
and I get a linker failure as follows:
verilated_vpi.o: In function `vpi_get_time': verilated_vpi.cpp:(.text+0x11e4): undefined reference to `sc_time_stamp()' verilated_vpi.o: In function `vpi_register_cb': verilated_vpi.cpp:(.text+0x7ea3): undefined reference to `sc_time_stamp()' collect2: ld returned 1 exit status
The reason for the undefined reference is because verilated_vpi.cpp in this case really needs
before the #include "verilated.h" so that the VL_TIME_[IQD]() macros used within it are defined by verilated.h to refer to the SystemC sc_time_stamp() that returns a class instead of the default for non-systemC that returns a double.
This could easily be fixed by adding to $VERILATOR_ROOT/include/verilated.mk a definition of:
ifeq ($(VM_SC),1) VK_CPPFLAGS_WALL += -DVM_SC=$(VM_SC) endif
and then adding before line 29 of $VERILATOR_ROOT/include/verilated_vpi.cpp :
#ifdef VM_SC #include "systemc.h" #endif
Also available in: Atom