katang Posted March 22, 2018 Report Share Posted March 22, 2018 For my subclassed constructor My::My(sc_core::sc_module_name nm, int ID) : sc_core::sc_module(((string(nm).append(1,ID<26 ?'A'+ID : 'A'+ID +6)).c_str())) I receive Warning: (W569) sc_module(const char*), sc_module(const std::string&) have been deprecated, use sc_module(const sc_module_name&) Why utilizing those two simple argument types are deprecated, and how can I legally do what I want? Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted March 22, 2018 Report Share Posted March 22, 2018 What do you want exactly? Can you use sc_vector<My> that automatically initializes names? Can you concatenate name and ID before module construction? SystemC elaboration relies on the fact that sc_module_name will be constructed before module. This way it can create correct hierarchical names for module fields. Modern way to declare module is like this: struct my_module : sc_module { my_module(sc_module_name) { } }; More compact way is to use SystemC macros: SC_MODULE(my_module) { SC_CTOR(my_module) { } }; Quote Link to comment Share on other sites More sharing options...
Eyck Posted March 22, 2018 Report Share Posted March 22, 2018 You may use a temporary object: My::My(sc_core::sc_module_name nm, int ID) : sc_core::sc_module(sc_core::sc_module_name((string(nm).append(1,ID<26 ?'A'+ID : 'A'+ID +6)).c_str())) But I would move the stuff into a free function: sc_core::sc_module_name concatenate(sc_core::sc_module_name nm, int ID){ std::string res(nm); res.append(1,ID<26 ? 'A'+ID : 'A'+ID+6); return res.c_str(); } My::My(sc_core::sc_module_name nm, int ID) : sc_core::sc_module(concatenate(nm, ID)) This makes the whole code easier to understand and more maintainable... Cheers Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted March 23, 2018 Report Share Posted March 23, 2018 4 hours ago, Eyck said: sc_core::sc_module_name concatenate(sc_core::sc_module_name nm, int ID) This makes the whole code easier to understand and more maintainable... No, this is not allowed by SystemC LRM "5.3.3 Constraints on usage": Quote Class sc_module_name shall only be used as the type of a parameter of a constructor of a class derived from class sc_module. Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted March 24, 2018 Report Share Posted March 24, 2018 On 23/03/2018 at 12:54 AM, Eyck said: My::My(sc_core::sc_module_name nm, int ID) : sc_core::sc_module(concatenate(nm, ID)) This usage of sc_module_name is wrong and will break the module hierarchy. The only thing you are allowed (but not even required) to do with the module name object inside your constructor is to forward it to the sc_module base class. As Roman said, you would have to prepare the name outside of the module instead (or use sc_vector). /Philipp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.