Jump to content
Flori_He

Example from the SystemC Verification Standard Specification doesn't work

Recommended Posts

Hello everyone,
I tried to use code from the SystemC Verification Standard
Specification. It can be found on page 46 and reads:

 

class my_module : public sc_module {
public:
        scv_smart_ptr<int> fsm_state;
        SC_CTOR(my_module) {
                fsm_state->register_cb(fsm_state_callback);
        }

       void fsm_state_callback(scv_extensions_if& data, scv_extensions_if::callback_reason r) {
               if ( r == scv_extensions_if::VALUE_CHANGE) {
                       cout << "The FSM state has been changed to : " << data << endl;
                       // write_to_the_database(data);
               }
       }
};

Compiling this with the respective haeders and libraries, I get the error.
my_mod.cpp: In constructor ‘my_module::my_module(sc_core::sc_module_name)’:
my_mod.cpp:11:42: error: no matching function for call to ‘scv_extensions<int>::register_cb(<unresolved overloaded function type>)’
 fsm_state->register_cb(fsm_state_callback);
                                          ^

I already searched for a solution and found that there seems to be a problem with:

pointer-to-member-function vs pointer-to-function are different and incompatible

This seems to be the case here as the definition of the function in the API reads:

virtual callback_h register_cb(
void (*f)(scv_extensions_if&, callback_reason)
) = 0;


In the above example I try to register a pointer-to-member-function to a pointer-to-function which leads to the error (as I understand it).
So is there any known solution to the problem?

Regards,
Florian

 

Share this post


Link to post
Share on other sites

Hi Florian,

 

you understood the problem correct, it seems the example wasn't tested ("can be performed using code similar to..."). However, a quick solution would be to move the fsm_state_callback function out of the class and thus make it a C-function.

Share this post


Link to post
Share on other sites

Hello Stephan,
yes I tried this out, but when moving this function out of the class or keeping it in the class and making it a static member,  I cannot work on any member variables (of objects) of the class.

Regards Florian

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×