Jump to content
Andreas

unexpected Error: (E100)

Recommended Posts

Hi,

 

I am reciving

Error: (E100) port specified outside of module: port 'port_0' (sc_port_base)
In file: ../../../../src/sysc/communication/sc_port.cpp:231

When I try to bild my systemc simulation. I have written a small example, that reproduce the error on my machine:

main.cpp

#include "systemc.h"
#include "exampleModule.cpp"

int sc_main (int argc, char* argv[])
{

    ExampleModule example("example");
}

exampleModule.cpp

#include "systemc.h"

struct ExampleModule : ::sc_core::sc_module{
public:
    sc_fifo_in<int> out;

    void readData(){

    }

    SC_HAS_PROCESS(ExampleModule);
    ExampleModule( const char* name ): sc_module( sc_module_name(name) )
    {
        cout << "name:" << this->name() << endl;
        SC_THREAD(readData);
    }

};

It looks like the error is in

ExampleModule( const char* name ): sc_module( sc_module_name(name) )

While debuggin this part I get an unexpected jump to sc_port.

 

When I'm changing the code to

ExampleModule( const char* name ): sc_module( name )

everything is fine. But this is deprecated.

 

Has anyone a suggestion what im doing wrong?

 

Regards
 

Share this post


Link to post
Share on other sites

Hi,

 

the following line

ExampleModule( const char* name ): sc_module( sc_module_name(name) );

seems to instantiate more than on sc_module_name object.

SystemC uses the creation ond destruction of sc_module_name to setup the module hierarchy and becomes confused here.

 

It works without the explicit sc_module_name constructor.

ExampleModule( const char* name ): sc_module( name );

Greetings

Ralph

Share this post


Link to post
Share on other sites

Well good to know it is not my fault :).

 

I know it works with:

ExampleModule( const char* name ): sc_module( name );

So I have to work with this. But I don't like it, because it's deprecated.

 

Thank you

 

Regards

Share this post


Link to post
Share on other sites

Well good to know it is not my fault :).

 

Strictly speaking, it is your fault. Quoting 1666-2011, section 5.2.3 (sc_module, constraints on usage), emphasis mine:

 

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 class sc_module_name but may have further parameters of classes other than sc_module_name.

 

So the last variant posted by Ralph is the correct definition.

 

/Philipp

Share this post


Link to post
Share on other sites

Hey

 

I would prefer to use this way, but it seems not as easy for me.

 

I try to generate Python bindings folowing this (http://forums.accellera.org/topic/1458-python-bindings-for-systemc/) paper (at the end of the topic). I am not finished now. But Swig could only pass char* as parameter. So my preffered way to create an object is using a call to:

ExampleModule( const char* name )

Regards

Share this post


Link to post
Share on other sites
I try to generate Python bindings folowing this (http://forums.accellera.org/topic/1458-python-bindings-for-systemc/) paper (at the end of the topic). I am not finished now. But Swig could only pass char* as parameter. So my preffered way to create an object is using a call to:

ExampleModule( const char* name )

 

As said before, you have to have an sc_module_name parameter in the (leaf) constructor of your module class hierarchy.  Using the deprecated constructor will likely mess up your object hierarchy during elaboration.

 

You can directly call such a constructor with a const char* argument, as you can implicitly construct an sc_module_name from a const char*. Maybe this is all you need.  Otherwise, you can create a wrapper (or a derived class), with no own sc_object/sc_module members and construct the real SystemC module from within C++.

 

hth,

Philipp

Share this post


Link to post
Share on other sites

Finally I had implemented the workaround you mentioned. something like:

struct ExampleModulePython :ExampleModule
{
    ExampleModulePython(const char* name):ExampleModule(name){}
};

But now I have a different problem. As long as I used

ExampleModule( const char* name )

I was able to create the Ports in Python. Now I get the same Error.
I guess that after the Module is registered using SC_HAS_PROCESS and SC_THREAD It is not possible to add any prots? I am rigth that there are no checks for this if you are using the deprecated way?

 

Regards

Share this post


Link to post
Share on other sites

I was able to create the Ports in Python. Now I get the same Error.

I guess that after the Module is registered using SC_HAS_PROCESS and SC_THREAD It is not possible to add any prots? I am rigth that there are no checks for this if you are using the deprecated way?

Quoting my earlier reply (emphasis added): "Otherwise, you can create a wrapper (or a derived class), with no own sc_object/sc_module members and construct the real SystemC module from within C++."

 

The module/object hierarchy creation is closely related to the sc_module_name stack.  Once the sc_module_name instance is destroyed (after the completion of your ExampleModule (base class) constructor), the "current module" is removed from this stack.  Therefore, the ports you create afterwards can not be assigned to the correct module.

 

Again, a workaround may be to create the ports via Python from within before_end_of_elaboration callback, where the module hierarchy is correctly restored without having a proper sc_module_name stack.

 

The deprecated constructor comes from very old versions of SystemC (before the introduction of sc_module_name) and requires you to manually call the (similarly non-standard) function end_module after the creation of all sc_object members at the end of the constructor.  Otherwise, your hierarchy will be messed up in case of multiple (nested) modules. I would not recommend this approach.

 

Greetings from Oldenburg,

Philipp

Edited by Philipp A. Hartmann

Share this post


Link to post
Share on other sites

 

Otherwise, you can create a wrapper (or a derived class), with no own sc_object/sc_module members and construct the real SystemC module from within C++.

 

I am a little bit confused now. Isn't this what I had done with

struct ExampleModulePython :ExampleModule
{
   ExampleModulePython(const char* name):ExampleModule(name){}
};

 

Again, a workaround may be to create the ports via Python from within before_end_of_elaboration callback, where the module hierarchy is correctly restored without having a proper sc_module_name stack.

 

I will try this approach.

 

Thanks

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

×