Hadrian2002 Posted June 25, 2014 Report Posted June 25, 2014 Hello, I have a question regarding the reflection possibilities of SystemC in combination with TLM-Sockets. For logging I want to know the name of a simple-initiator-socket, which is bound to a given simple-target-socket. The Idea is, to log something like " 'CPU_1_initiator_socket' starts request to 'Bus_Port_4_target_socket' ", but this message needs to be created at the submodule, which only knows the target-socket. I know, since the sockets are sc_objects, they will get a unique name, but is also saved the binding relation to the socket? Quote
Hadrian2002 Posted July 18, 2014 Author Report Posted July 18, 2014 As far as my researches shows, only the Interfaces to the sockets are bound and they not include references to the bounded object. Of course this is the intended behavior. Regarding an interface (derived from sc_interface) should not derive from sc_object, so also no chance to do bad casting stuff. I tried this with simple_target_socket.get_base_port()->get_interface(0) and so on. Seems to be that I need an additional TLM-Extension carrying the name of Initiator. I think I could also implement a target-socket, which saves the name, when the socket is bound, but then I forbid to bound against exports and so on ... Really annoying is, that with a Debugger I could extract the, but there is no API for that. Any other suggestions ? Quote
Philipp A Hartmann Posted July 20, 2014 Report Posted July 20, 2014 You can use a dynamic cast to access the channel object bound to the port/socket: sc_object * obj = dynamic_cast<sc_object*>(socket.get_interface()); std::cout << obj->name() << std::endl; Greetings from Oldenburg,Philipp Quote
Hadrian2002 Posted July 21, 2014 Author Report Posted July 21, 2014 I tried exactly this, but as the IEEE Standard §5.14.3 says, it should not be derived from sc_object. For the convenience sockets simple_*_socket, this is also the case. I think I need to modify the binding operation to save the name of the binded Object. Quote
Philipp A Hartmann Posted July 21, 2014 Report Posted July 21, 2014 I tried exactly this, but as the IEEE Standard §5.14.3 says, it should not be derived from sc_object. Yes, sc_interface itself is not derived from sc_object. But the channel that is bound to the port/socket is frequently derived from sc_object. I didn't look up the details in the standard, but to me it may be a reasonable assumption that the bound object is indeed a proper part of the SystemC object hierarchy. For the convenience sockets simple_*_socket, this is also the case. I think I need to modify the binding operation to save the name of the binded Object. Indeed, the current implementation of the simple sockets use internal classes not derived from sc_object to provide the interface implementations. To me, this is at least an inconvenience for use cases like yours. I'll take this to the LWG/TLMWG for discussion. You may still be able to "lookup" the correct socket by traversing the object hierarchy (5.16.7) looking for candidate sockets and comparing the original result of 'get_interface()' with the interfaces of the candidates. Or derive your own socket and override the bind() function to store the name. Make sure to call the base-class bind() to actually perform the binding. /Philipp Quote
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.