katang Posted May 26, 2017 Report Posted May 26, 2017 I am using the alternative style offered in book SCFTGU. In the .cpp file, I am using a normal contructor. The SC_HAS_PROCESS(MyObj); compiles OK, the SC_METHOD(MySub); ditto, but next to it sensitive << in; is refused with error message 'invalid static cast'. I guess that somehow the SC_CTOR() call is missing. What is the correct syntax? Quote
AmeyaVS Posted May 26, 2017 Report Posted May 26, 2017 Hello @katang, Can you provide the minimal code which reproduces this behaviour? Regards, Ameya Vikram Singh Quote
katang Posted June 4, 2017 Author Report Posted June 4, 2017 Here goes the code: #ifndef scMWE_h #define scMWE_h #include <systemc> #include <iostream> SC_MODULE(scMWE) { scMWE(sc_core::sc_module_name nm); void WritePseudo(int A ); sc_core::sc_fifo_in<int> in[4]; }; #endif #include "scMWE.h" SC_HAS_PROCESS(scMWE); scMWE::scMWE(sc_core::sc_module_name nm) : sc_core::sc_module(nm) { SC_METHOD(WritePseudo); // sensitive << in; } void scMWE:: WritePseudo(int A) { std::cout << "MWE:A" << A << std::endl; } Quote
Philipp A Hartmann Posted June 4, 2017 Report Posted June 4, 2017 Hi Katang, your process function takes a parameter (int A). This is not supported for SC_METHOD et.al. Hope that helps, Philipp Quote
Philipp A Hartmann Posted June 4, 2017 Report Posted June 4, 2017 Oh, and I just realized, that your in port is an sc_fifo_in<int>, which doesn't have a default event (IIRC). You probably want to use the data_written event finder instead: sensitive << in.data_written(); Hope that helps as well, Philipp Quote
Philipp A Hartmann Posted June 4, 2017 Report Posted June 4, 2017 Third point: You're using a C-style array of ports, which won't work either. You should use an sc_vector (to name your ports) and use a loop to add the sensitivity (if you want to be sensitive to all ports in the vector): // change member sc_core::sc_vector< sc_core::sc_fifo_in<int> > in; // constructor scMWE::scMWE(sc_core::sc_module_name nm) : sc_core::sc_module(nm) , in("in", 4) // initialize vector { SC_METHOD(WritePseudo); for( auto& in_x : in ) // or a plain loop over the elements, if you don't have C++11 sensitive << in_x.data_written(); } /Philipp Quote
katang Posted June 4, 2017 Author Report Posted June 4, 2017 Hm, I am starting to be proud of my ability to hide so many mistakes in a short MWE. :) What is the reason that the compiler claims "invalid static_cast" rather than wrong signature? (the rest of mistakes is just a consequence of the first unfixed one) Quote
Philipp A Hartmann Posted June 5, 2017 Report Posted June 5, 2017 20 hours ago, katang said: What is the reason that the compiler claims "invalid static_cast" rather than wrong signature? Hard to tell without details about what exact cast (i.e. between which types) is invalid. My guess would be the use of an array instead of the individual ports. /Philipp Quote
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.