Jump to content


  • Posts

  • Joined

  • Last visited

shoji's Achievements


Member (1/2)



  1. I get odd behavior when I link 2 independent DLLs that both require systemc to my program. In the first DLL are a bunch of Utility code that is used in my project along with a default sc_main (Call this Utils) In the second are user specific systemc code (call this User) Both are compiled linking to libsystemc.so In the program file which is the top frame work I link both User and Utils. First observation: Order matters. If User is imported before Utils then sc_main is not found. This makes sense since sc_main lives in Utils all wire/binding done in the User code are not properly registered (this assumes Utils is imported prior to User) Generally the User code gets errors such as terminating with uncaught exception of type sc_core::sc_report: Error: (E118) find event failed: port is not bound: port 'player_instance_name.ClockIn' (sc_in) In file: ../../../src/sysc/communication/sc_event_finder.cpp:51 Aborted Obviously the port selected for failure is which ever port is listed first (in this example a clock). Second observation adding a sc_main to User code eliminates the error but import order still matters import must have User code first and Utils code second All of this implies that each library must have its own sc_main and that only the last imported file will have all of its behavior honored (ie. binding registrations). I have not tried wiring/binding in Utils and wiring/binding in User to see if there are further issues. Likely I'm being naive in my implementation but is there a way around this behavior since it will be brittle to my end users? It seems there must be some internal assumptions about sc_main and port registration/wiring.
  2. By the way thank you for thinking about this problem. I changed line 170 in src/sysc/kernel/sc_cmnhdr.h to set the define as you list above. compared to the build of the systemc DLL without the change there are a lot of warnings that this particular compiler directive is ignored. If that is the only changes you were suggesting then it made no difference. I still see that systemc does not see the port binding.
  3. exporting all my classes of course goes against why you might use the -fvisibility=hidden flag so I'm not sure what the intention would be to use it once you export the world. Here is my example source code. I tried it with/without the counter class having visibility set to default. It fails either way. Compile these with -fvisibility=hidden and the code fails to elaborate. Remove the flag and you get the output: SystemC 2.3.2-Accellera --- Apr 28 2019 15:26:09 Copyright (c) 1996-2017 by all Contributors, ALL RIGHTS RESERVED reset active:count 0 reset active:count 0 reset active:count 0 enable active:count 1 enable active:count 2 enable active:count 3 enable active:count 4 // --------------------- sc_main.cc ----------------------------------------------- #include "counter.h" int __attribute__ ((visibility ("default"))) //<--- comment /uncomment line if desired sc_main(int argc, char* argv[]) { sc_signal<bool> reset, enable; sc_signal<sc_uint<4>> count; sc_time step(5.0, SC_NS); sc_clock clk("clock", sc_time(5.0, SC_NS)); counter counter("counter"); counter.clock(clk); counter.reset(reset); counter.enable(enable); counter.countOut(count); reset = true; enable = false; sc_start(step); sc_start(step); reset = false; enable = true; sc_start(step); sc_start(step); sc_start(step); sc_start(step); return 0; } // ------------------------------------ counter.h ------------------------------------------------------------------ #pragma once #include "systemc.h" class __attribute__ ((visibility ("default"))) //<--- comment /uncomment line if desired counter: public sc_module { public: sc_in_clk clock; sc_in<bool> reset; sc_in<bool> enable; sc_out<sc_uint<4>> countOut; SC_HAS_PROCESS(counter); counter(const sc_core::sc_module_name& name); void inc(); private: sc_uint<4> count; }; // -------------------------------------------- counter.cc ---------------------------------------------------------------------- #include <iostream> #include "counter.h" counter::counter(const sc_core::sc_module_name& name): sc_module(name), count(0) { SC_METHOD(inc); sensitive << reset; sensitive << clock.pos(); } void counter::inc() { if (reset.read() == 1) { count = 0; countOut.write(count); std::cout << "reset active:count " << count << std::endl; } else if (enable.read() == 1) { count += 1; countOut.write(count); std::cout << "enable active:count " << count << std::endl; } }
  4. I've compiled my C++14 systemc 2.3.2 library and when I compile my model code with --visibility=hidden the code will not properly elaborate. The only apparent requirement is that sc_main have default visibility, for example: int __attribute__ ((visibility ("default"))) sc_main(int argc, char* argv[]) { ... your code here ... } You can use any simple module (eg simple counter sc_module) to show that by not using the -fvisibility=hidden flag the code works fine. when compiled with that flag I get the following error: terminating with uncaught exception of type sc_core::sc_report: Error: (E118) find event failed: port is not bound: port 'counter.port_0' (sc_in) In file: ../../../src/sysc/communication/sc_event_finder.cpp:51 Aborted My version of g++ is as follows: g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. If you need additional information please let me know.
  • Create New...