Jump to content
Ramarao V

what are the major differences between sc_port and sc_export?

Recommended Posts

Port requires a pointer towards the object containing implementations of methods specified in the interface.

Export provides the very pointer that port needs.

Port goes from caller towards callee.

Export goes from callee towards caller.

Pseudo-graphically:

//  +----------------------------------------------------------------------------------+
//  |struct Top : sc_module {                                                          |
//  |                                                                                  |
//  | initiator.p1.bind( target.x1 );                                                  |
//  |                                                                                  |
//  | Initiator initiator{"orgin"};           Target target{"target"};                 |
//  | +------------------------------------+  +--------------------------------------+ |
//  | |struct Initiator : sc_module {      |  |struct Target : sc_module {           | |
//  | |                                    |  |                                      | |
//  | | sc_port<IF> p1{"p1"};              |  | sc_export<IF> x1{"x1"};              | |
//  | | caller.p0.bind( p1 );              |  | x1.bind( callee.x0 );                | |
//  | |                                    |  |                                      | |
//  | | Caller caller{"caller"};           |  |     Callee callee{"callee"};         | |
//  | | +----------------------------+     |  |     +------------------------------+ | |
//  | | |struct Caller : sc_module { |     |  |     |struct Callee : sc_module, IF | | |
//  | | |                            |     |  |     |                              | | |
//  | | | sc_port<IF> p0{"p0"};      |     |  |     | sc_export<IF> x0{"x0"};      | | |
//  | | | SC_THREAD(thread1);        |     |  |     | Data          m_data;        | | |
//  | | |                            |     |  |     | x0.bind(*this);              | | |
//  | | |                            |     |  |     |                              | | |
//  | | | .------------------.       |     |  |     |    .----------------------.  | | |
//  | | | | void thread1()   |       |     |  |     |    | void xfer( data& d ) |  | | |
//  | | | | {                |       |     |  |     |    | {                    |  | | |
//  | | | |   p0->xfer( v ); |    [p0]->[p1]->[x1]->[x0] |   // Save/load d     |  | | |
//  | | | | }                |       |     |  |     |    |   auto t = d;        |  | | |
//  | | | |                  |       |     |  |     |    |   d = m_data;        |  | | |
//  | | | |                  |       |     |  |     |    |   // Transform t     |  | | |
//  | | | |                  |       |     |  |     |    |   m_data = t;        |  | | |
//  | | | |                  |       |     |  |     |    | }                    |  | | |
//  | | | '------------------'       |     |  |     |    '----------------------'  | | |
//  | | |                            |     |  |     |                              | | |
//  | | |};                          |     |  |     |                              | | |
//  | | +----------------------------+     |  |     +------------------------------+ | |
//  | |                                    |  |                                      | |
//  | |};                                  |  |};                                    | |
//  | +------------------------------------+  +--------------------------------------+ |
//  |                                                                                  |
//  |};                                                                                |
//  +----------------------------------------------------------------------------------+

 

Share this post


Link to post
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...