Jump to content

Accessing channel via port


Tim_

Recommended Posts

  • 1 month later...

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...