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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×