katang Posted September 26, 2019 Report Share Posted September 26, 2019 I have some modules of the same class, and only part of the instances needs access to a certain bus, the others should not be linked to the bus. Of course I know during the setup phase, which ones should and which ones should not. The ones that should connect, I can connect, it works fine. At the same time, for the others, I would like to tell the ports they should not be connected. Is there some method to do so (i.e. I want to avoid 'complete binding failed', not more) . Or, shall I subclass a new module class for those modules, with the only difference that they have an extra port? Or, shall I give those modules a very low priority (they surely will not use the bus), and connect them formally to the bus? (maybe it causes unneeded wiring) I.e. Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted September 26, 2019 Report Share Posted September 26, 2019 Other option is to pass some flag to constructor struct my_module : sc_module { std::unique_ptr< bus_port > bus_slave; my_module(sc_module_name, bool has_slave_port) { if (has_slave_port) { bus_slave = std::make_unique<bus_port>("bus_slave"); } } For SystemC 2.4 there is a sc_optional<T> class proposal that will allow to create ports "on demand" at any time during elaboration. Quote Link to comment Share on other sites More sharing options...
katang Posted September 26, 2019 Author Report Share Posted September 26, 2019 Sorry, I forgot to mention: I have a master port, like this sc_port<scBus_blocking_if> bus_port; If I understand the point correctly, I shall use pointer, that (still within the constructor) I can change from the default null. Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted September 26, 2019 Report Share Posted September 26, 2019 I mean if you don't need to connect the port, then don't create the port. This is the idea. Quote Link to comment Share on other sites More sharing options...
katang Posted September 26, 2019 Author Report Share Posted September 26, 2019 You are absolutely right, thank you. From point of view of programming, it is OK. Till now, however, I never thought about ports that one create them with new 🙂 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.