Jump to content

Recommended Posts

Posted

Hi

With the following code, I am getting the error "Error: (E513) an sc_module_name parameter for your constructor is required"

I am not able to understand why ?

Can anyone help please

#include <iostream>
#include <systemc.h>

using namespace std;

class Foo: public virtual sc_module
{
    public:
    Foo(sc_module_name val) { }
};

class Bar : public virtual sc_module
{
    public:
    Bar(sc_module_name name) : foo(name) { }
    Foo foo;
};

int sc_main(int argc, char* argv[]){
    Bar b("b");
    sc_start();
    return 0;
}

Thanks

Sumit

Posted

Hey try this alternative solution, its working for me



class Bar : public virtual sc_module
{
    Foo foo;
    public:
    Bar(sc_module_name a) : foo((const char*)(a)) {    }
 
};

I wonder why your solution is not working even though the base class  overloaded with sc_module_name parameter constructor

Posted

Hi Ralph

I tried as you suggested(see below). I still have the same issue.

#include <iostream>
#include <systemc.h>

using namespace std;

class Foo: public virtual sc_module
{
    public:
    Foo(sc_module_name name):sc_module(name) { }
};

class Bar : public virtual sc_module
{
    public:
    Foo foo;
    Bar(sc_module_name name) : foo(name) { }
};

int sc_main(int argc, char* argv[]){
    Bar b("b");
    sc_start();
    return 0;
}

Thanks

Sumit

Posted

Hi Sumit.

what you are doing here is a hierarchical module. foo is a member, i.e. a submodule of bar. They should not have the same name.

If you want bar to be derived from foo, then derive bar from foo instead of sc_module. Then, you instantiation will work.

If you want foo to be a submodule of bar, let the derivation as is but fix your initializer lists. You need to forward the name argument to the base class constructor in every class derived from sc_module, i.e. in bar as well. Furthermore, the submodule foo should not have the same name as its parent bar.

// constructor
Bar(sc_core::sc_module_name name)
: sc_module(name) // forward name to base class constructor
, foo("foo")	  // name submodule foo 'foo'
{ ...

Or use the SC_CTOR macro that handles this for you.

 

Greetings

Ralph

  • 4 weeks later...

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.

Guest
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...