Jump to content

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 {
        scv_smart_ptr<int> fsm_state;
        SC_CTOR(my_module) {

       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>)’

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?



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

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...