sumit_tuwien Posted April 14, 2021 Report Share Posted April 14, 2021 Hello All, I have a module, which have a public member function which when called will write some values in a signal declared within the module. I can write into the signal from within the module. But if I try to access member function from outside the module instance, I get a crash. When I am trying to debug it, I find the following message: Program received signal SIGSEGV, Segmentation fault. t0x00000000080869c6 in sc_core::sc_signal_t<double, (sc_core::sc_writer_policy)0>::write (this=0xe8, value_=@0x7ffffea1ff00: 1) at /blah/systemc-2.3.3/include/sysc/communication/sc_signal.h:292 292 bool value_changed = !( m_new_val == value_ ); I am using gcc-9.3.0. Any help will be appreciated. Regards, Sumit Quote Link to comment Share on other sites More sharing options...
Eyck Posted April 14, 2021 Report Share Posted April 14, 2021 To me it looks like if the signal is not being properly constructed. But without additional code it is not possible to give more advise.... Quote Link to comment Share on other sites More sharing options...
sumit_tuwien Posted April 14, 2021 Author Report Share Posted April 14, 2021 19 minutes ago, Eyck said: To me it looks like if the signal is not being properly constructed. But without additional code it is not possible to give more advise.... Possibly not. It even cannot write a simple double public member variable. Quote Link to comment Share on other sites More sharing options...
David Black Posted April 14, 2021 Report Share Posted April 14, 2021 If you want real help, you need to show us the source code. At a minimum, we would need to see the signal declarationwithin its context, and the location of it's constructor and write method. If using a custom datatype, we need to know that definition. Also, what compiler switches are used (e.g., -Wall -Wextra -std=?)? What compilation warnings are emitted? What version of SystemC? Quote Link to comment Share on other sites More sharing options...
sumit_tuwien Posted April 14, 2021 Author Report Share Posted April 14, 2021 Hi @David Black, Following is the reduced version of the class: # ifndef BLAH_H_ # define BLAH_H_ class Blah final : sc_core::sc_module { private : double ThisOneWillAlsoNotLetWrite { 0.0 } ; public : sc_core::sc_signal < double > IWillNotLetYouWrite { "IWillNotLetYouWrite" } ; SC_HAS_PROCESS (Blah) ; explicit Blah(const sc_core::sc_module_name& ModuleName_) : sc_core::sc_module { ModuleName_ } {} ~Blah() final = default ; Blah& operator=(const Blah& other) = delete ; Blah(const Blah& other) = delete ; Blah operator=(Blah&& other) = delete ; Blah(Blah&& other) = delete ; void LetsWrite() { IWillNotLetYouWrite.write(1.0); } void ThisOneFailsToo() { ThisOneWillAlsoNotLetWrite = 1.0 ; } }; # endif ~ # Yes, -Wall -Wextra was turned ON. --std=c++14. # SystemC version : 2.3.3 # Compiler gcc-9.3.0 Regards, Sumit Quote Link to comment Share on other sites More sharing options...
Bas Arts Posted April 16, 2021 Report Share Posted April 16, 2021 Hi Sumit, I cannot test with gcc 9.3.0, but with SystemC 2.3.3 and gcc 9.1.0 using c++14 the following code doesn't give any problems: int sc_main(int argc, char* argv[]) { Blah myblah {"myblah"}; myblah.LetsWrite(); myblah.ThisOneFailsToo(); return 0; } Quote Link to comment Share on other sites More sharing options...
sumit_tuwien Posted April 17, 2021 Author Report Share Posted April 17, 2021 Thanks @Bas Arts , Thanks for checking. Seems either the compiler or the system has some issues. Regards, Sumit Quote Link to comment Share on other sites More sharing options...
David Black Posted April 26, 2021 Report Share Posted April 26, 2021 With some corrections, it works on EDA playground <https://edaplayground.com/x/q3Ei>. Note: You do really don't need those deleted copy-constructors, etc. Rule of zero works. Also SC_HAS_PROCESS works best inside the thread. Also works on under Ubuntu with GCC 10.0. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.