verificationcontractor / sc_enhance

Syntactic sugar for SystemC facilitated by modern C++ features
MIT License
5 stars 0 forks source link

Incorporate sc_enhance into systemc library #2

Open ghost opened 2 years ago

ghost commented 2 years ago

Hi @verificationcontractor, I recently start to explore on using sc-enhance.hpp and tried to incorporate it into systemc library header (by including sc_enhance.hpp in systemc).

I encounter 'symbol redefinition' issue when we compile the updated systemc library in a multi cpp files' project. To me it suggests that there are some codes that requires compilation in the header files.

Here is an example of the error when we tried to compile the UVM-SC.

uvmsc/.libs/libuvm-systemc.a(uvm_component_name.o):(.bss+0x120): multiple definition of `sc_mp::sc_method_port_db::in_method_ports[abi:cxx11]' uvmsc/.libs/libuvm-systemc.a(uvm_component.o):(.bss+0x140): first defined here

I would like to know is there actually a solution to it?

Thanks, Raymond

verificationcontractor commented 2 years ago

Hi Raymond,

Apologies for the late reply! I haven't tried to incorporate sc_enhance into SystemC yet, it was on my todo list.

One thing to lookout for is that the header sc_thread_process.h from sc_enhance is a modified version of the header with the same name from the SystemC source code. So including it into systemc via sc_enhance.hpp is not a good idea as it could cause re-declarations.

First thing you should do is diff sc_thread_process.h from sc_enhance and systemc and then copy those changes into the systemc library. After that you can try including the other two headers from sc_enhance: sc_enhance.hpp and sc_method_ports.hpp.

If sc_method_ports.hpp are causing problems you can exclude them with the SCE_EXCLUDE_MP define.

Also, make sure to include sc_enhance.hpp after sc_dynamic_processes.h otherwise the SC_FORK macro might not work.

Hope this helps.

Best Regards, Stefan