Jump to content


  • Content Count

  • Joined

  • Last visited

  1. Tim_

    Accessing channel via port

    Hello, I am interested in getting the address of a channel during the binding. So, I have modified the bind function of the class class sc_port_b in this way to the see address: SC_VIRTUAL_ void bind( IF& interface_ ) { std::cout << "Address in bind: " << &interface_ << std::endl; base_type::bind( interface_ ); } And I use this sender/receiver example: #include "systemc.h" class Sender: public sc_module { public: sc_fifo_out<int> fifo_out; SC_HAS_PROCESS(Sender); Sender(sc_module_name mn): sc_module(mn) { SC_THREAD(main); } void main() { for(int i=0; i<50; i++) { std::cout << "writing " << i << std::endl; fifo_out.write(i); } } }; class Receiver: public sc_module { public: sc_fifo_in<int> fifo_in; SC_HAS_PROCESS(Receiver); Receiver(sc_module_name mn): sc_module(mn) { SC_THREAD(main); } void main() { while(true) { int value = fifo_in.read(); std::cout << "read " << value << std::endl; } } }; class Top: public sc_module { public: Sender sender_; Receiver receiver_; sc_fifo<int> fifo_; Top(sc_module_name mn): sc_module(mn), sender_("sender"), receiver_("receiver") { } void before_end_of_elaboration() { sender_.fifo_out.bind(fifo_); receiver_.fifo_in.bind(fifo_); } }; int sc_main(int argc, char **argv) { Top t("top"); std::cout << &t.fifo_ << std::endl; sc_start(); return 0; } My output (without the read/write messages) looks like this one: 0x7fff82b16d70 Address in bind: 0x7fff82b16d80 Address in bind: 0x7fff82b16d70 Can somebody help me out and explain to me why the address is different in the second binding? I appreciate any help Best regards, Tim
  2. Hello, the class sc_port offers the function get_interface(). Is there also an option to get the bound channel? Cheers! Tim