How to get systemc sc_module_name of the current current module

When I create the systemc module, I give it a string as the name of the module (:: sc_core :: sc_module_name).

How can I get the name of the module that is currently running in systemc?

+4
source share
2 answers

To get the name of the module that is currently running in systemc:

Use sc_get_current_process_b to get the current executable process (thread or SC method). Then use get_parent to get its parent, which will be the module. Then use basename or name to get its name:

 const char* name = sc_core::sc_get_current_process_b()->get_parent()->basename(); 

(error handling omitted for brevity)

+3
source

Do not use the inline macro for the constructor. Use the following, assuming the module name is "counter":

 counter(sc_module_name _name):sc_module(_name) { cout << "Creating object " << _name; } 

You can do various things with _name after including <string> . You can use string() , combine with the + operator, etc.

0
source

Source: https://habr.com/ru/post/1495508/


All Articles