Closed tk-ka closed 11 months ago
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;
}
Many THX for the report, the PR and the reproducer!
When creating multiple
tlm_target
instances inside onesc_module
, allsocket
member variables will have the same name in the object hierarchy, leading to the warning:It would be an easy fix to extend the existing constructor with a _socketname argument: https://github.com/Minres/SystemC-Components/blob/7d8a0173b219d684c80ba268086b31027d4a7402/src/components/scc/tlm_target.h#L53 By adding a default value for "socket", the code will remain compatible to existing usages.