Reputation: 4789
I am new in systemc. There is one confusion that I am having.
I am creating a sc_module(hello_world)
. The sc_ctor(hello_world)
has nothing between the curly braces and I just have a simple void say_hello()
function inside the module which prints "hello world."
In the sc_main
, I did this:
hello_world hello;
hello.say_hello();
However, I am getting an error that error C2228: left of '.say_hello' must have class/struct/union.
I tried this and it worked:
in sc_main
, I did this:
hello_world hello("hi ");
hello.say_hello();
Why it is showing error in the first place? I didn't use one argument constructor.
So, instead of hello_world hello("hi ")
shouldn't it be hello_world hello
? I was just trying to compare with C++ class.
Upvotes: 2
Views: 2511
Reputation: 53
The macro SC_CTOR
has created a hello(const sc_module_name name&)
constructor for you. Therefor the compiler will not generate a default constructor for you to call and the object hello cannot be created.
Upvotes: 1
Reputation: 622
Every SystemC module, whether defined with macro SC_MODULE
or inherits sc_module
, needs to have a module name. Constructors of SystemC modules must have one parameter of class sc_module_name
.
In SystemC standard (IEEE Std 1666-2011)
Every class derived (directly or indirectly) from class
sc_module
shall have at least one constructor. Every such constructor shall have one and only one parameter of classsc_module_name
but may have further parameters of classes other thansc_module_name
. That parameter is not required to be the first parameter of the constructor.
If you are using macro SC_CTOR
, it is actually a constructor with one sc_module_name
parameter!
in sc_module.h:
#define SC_CTOR(user_module_name) \
typedef user_module_name SC_CURRENT_USER_MODULE; \
user_module_name( ::sc_core::sc_module_name )
Upvotes: 2
Reputation: 1
It is possible that you defined your constructor as private. As a result compiler cannot name it from main.cpp.
Upvotes: 0
Reputation: 126
I can´t see nothing wrong.
In fact, it seems to me, that you have the same code like this example -> http://www.asic-world.com/systemc/first1.html
I hope you could check your with this one.
Upvotes: 1