Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tlm_target: Allow assigning custom name to socket #46

Closed
tk-ka opened this issue Jul 24, 2023 · 2 comments
Closed

tlm_target: Allow assigning custom name to socket #46

tk-ka opened this issue Jul 24, 2023 · 2 comments
Assignees

Comments

@tk-ka
Copy link
Contributor

tk-ka commented Jul 24, 2023

When creating multiple tlm_target instances inside one sc_module, all socket member variables will have the same name in the object hierarchy, leading to the warning:

Warning: (W505) object already exists: <some_path>.socket. Latter declaration will be renamed to <some_path>.socket_0
In file: kernel/sc_object_manager.cpp:153

It would be an easy fix to extend the existing constructor with a socket_name argument:

tlm_target(sc_core::sc_time& clock);

By adding a default value for "socket", the code will remain compatible to existing usages.

@tk-ka
Copy link
Contributor Author

tk-ka commented Jul 24, 2023

I attached a reproducer.
With pull request #47, use line 13 instead of Line 12 to see the improved behavior (no more warning).

#include "scc/tlm_target.h"
#include <tlm>
#include <tlm_utils/simple_initiator_socket.h>

class TestTarget : sc_core::sc_module {
public:
    scc::tlm_target<32> target1;
    scc::tlm_target<32> target2;
    sc_core::sc_time tlm_target_clk;

    TestTarget(sc_core::sc_module_name name, sc_core::sc_time clk = sc_core::sc_time(0, sc_core::SC_NS))
        : sc_core::sc_module(name), target1(tlm_target_clk), target2(tlm_target_clk), tlm_target_clk(clk) {}
        //: sc_core::sc_module(name), target1(tlm_target_clk, "target1"), target2(tlm_target_clk, "target2"), tlm_target_clk(clk) {}
};

class TestInitiator : sc_core::sc_module {
public:
    tlm_utils::simple_initiator_socket<TestInitiator, 32> isocket1{"isocket1"};
    tlm_utils::simple_initiator_socket<TestInitiator, 32> isocket2{"isocket2"};

    TestInitiator(sc_core::sc_module_name name) : sc_core::sc_module(name) {}
};

int sc_main(int argc, char *argv[]) {
    TestTarget targetmodule("target_module");
    TestInitiator initiatormodule("initiator_module");
    initiatormodule.isocket1.bind(targetmodule.target1.socket);
    initiatormodule.isocket2.bind(targetmodule.target2.socket);
    sc_core::sc_start();
    return 0;
}

@eyck
Copy link
Contributor

eyck commented Jul 24, 2023

Many THX for the report, the PR and the reproducer!

@eyck eyck closed this as completed Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants