Jump to content

benifits of sc_export over sc_port


amitk3553

Recommended Posts

Hello All,

 

 

WRF: P-158 Kulwer's book SystemC from Ground Up

 

Another reason for using sc_export is to provide multiple interfaces at the top level. Without sc_export, we are left to using the hierarchical channel, and that allows for only a single top-level set of interfaces.

 

What does multiple interfaces at the top level mean?

 

Does we can pass different interfaces to the same export at top level module object?

 

Please clarify.

 

Regards,

KS
Link to comment
Share on other sites

Hi Amit,

   I always think of ports and exports as having a number of features

 

1. strong type checking (you can't bind different types of port to each other)

2. The ability to make a remote function call without having to know where that function is implemented

3. the ability to do elaboration checks during binding

4. the option to create derived classes of sc_port/sc_export (specialized ports) with data members, extra features etc (e.g. sc_in /sc_fifo and so on).

5. hierarchical binding

 

Ports give you the ability to call a function in a far-away place by calling "up and out" of a module.

Exports let you make the interface of a channel available so you can call "down and in" to a module.

 

You can of course do without exports - they didn't exist in the original SystemC 2.1 code.

 

But in SystemC 2.1 if you wanted to access the implementation of an interface that was buried inside a hierarchy, you might have passed a pointer to the channel using a hierarchical path, which is not very maintainable. With exports you can hierarchically bind from down in the hierarchy up to where you want to access the channel without having to have use that difficult-to-maintain pointer.

 

The other handy use of exports is that if you have a channel that implements multiple interfaces, you can have multiple exports to explicitly make each interface visible to the outside world. As an example, the tlm_req_rsp_channel in TLM1 implemented a number of interfaces, which were made visible in different combinations with 6 different exports.

 

kind regards

Alan

Edited by apfitch
Link to comment
Share on other sites

Thanks Alan for your detailed response.

 

 

""""The other handy use of exports is that if you have a channel that implements multiple interfaces, you can have multiple exports to explicitly make each interface visible to the outside world. As an example, the tlm_req_rsp_channel in TLM1 implemented a number of interfaces, which were made visible in different combinations with 6 different exports."""

 

 

I had seen following structure of channel:

 

IF----CHANNEL------IF

 

where IF ---- Interface,

 

And in case of export this structure is inside the module.

 

So I want to know that How we could make this structure containing multiple interfaces in export?

 

And if this possible to have multiple interfaces in export then, is it possible to have multiple interfaces in port also?

 

 

 

Regards

cam 

Link to comment
Share on other sites

You have to parameterize the export by the interface. So if you have two interfaces, and you want them to be exported by a single export, you'd have to create a derived class. For instance

 

class tom_if : virtual public sc_interface {
public:
  virtual void tom() = 0;
};

class dick_if : virtual public sc_interface {
 public :
  virtual void dick() = 0;
};

class harry_if : virtual public sc_interface {
public:
  virtual void harry() = 0;
};

class mychan : public tom_if, public dick_if, public harry_if {
   void tom() { 
  // implementation of tom() 
  }
  
   void dick() { 
  // implementation of dic() 
  }

   void harry() { 
  // implementation of harry() 
  }

};


Now you can write exports such as

 

 

 class mod {
  public:
 sc_export<tom_if> e_tom;
 sc_export<harry_if> e_harry;

 mychan chan;

 SC_CTOR(mod)  {
   e_tom.bind(chan);
   e_harry.bind(chan);
 }

};
 

 

If you want a combined interface, then you could write

 

class tom_dick_if : virtual public tom_if, virtual public dick_if {
};

 

Then write

 

class mychan : virtual public tom_dick_if {
public:
// blah blah blah
};

Then you could declare an export

 

sc_export<tom_dick_if>

 

As I said before, it's worth looking at the code in systemc-2.3.0/src/tlm_core/tlm_1/tlm_req_rsp

 

regards

Alan

Link to comment
Share on other sites

Hi Amit,

  I didn't say "Concept of multiple interfaces in sc_export is a benefit of sc_export over sc_port".

 

I said "You have to parameterize the export by the interface. So if you have two interfaces, and you want them to be exported by a single export, you'd have to create a derived class."

 

You can do that with sc_port as well (i.e. use a single derived class interface that is derived from another set of interface classes) - see the code for sc_inout, for instance,

 

regards

Alan

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...