Jump to content

Extract structural information from SystemC


Recommended Posts

Hi guys,

I'm a student, but experienced in c++, however not that much in SystemC. I'm trying to use SystemC to extract information about digital systems.

I mean, given a model in systemC, I'd like to know how the components are connected, through which signals. If possible I'd like to know information about signals as well (only the size of data is enough I think).

I have already found something in the internet that allows me to travel among the component's tree. Using the code below I can list every signal, entit, ports and other things for a given component, however I have no information about connectivity.

void get_child_port_ifs(std::vector<sc_object*> &children, std::vector<sc_interface*> &IfRefs) {
 for (std::vector<sc_object*>::iterator i = children.begin(); i !=
  children.end(); i++) {
   if ( std::string((*i)->kind())=="sc_module" ) {
  std::cout<<"found module "<<(*i)->name()<<std::endl;
  sc_module* mptr = dynamic_cast<sc_module*>(*i);
  std::vector<sc_object*> children = mptr->get_child_objects();
  get_child_port_ifs(children,IfRefs);
   }
   else if (std::string((*i)->kind())=="sc_in" || std::string((*i)->kind()) =="sc_out") {
  std::cout<<"found port "<<(*i)->name()<<std::endl;
  sc_port_base * optr = dynamic_cast<sc_port_base*>(*i);
  IfRefs.push_back(optr->get_interface());
   }
   else{
  if (std::string((*i)->kind()) == "sc_signal")
    std::cout<<"found signal  "<<(*i)->name()<<std::endl;
  else
    std::cout<<"found other child type "<<(*i)->kind()<<" name "<<(*i)->name()<<std::endl;
   }
 }
}

Thanks every one.

Link to post
Share on other sites

…, however I have no information about connectivity.

...
else if (std::string((*i)->kind())=="sc_in" || std::string((*i)->kind()) =="sc_out") {
  std::cout<<"found port "<<(*i)->name()<<std::endl;
  sc_port_base * optr = dynamic_cast<sc_port_base*>(*i);
  IfRefs.push_back(optr->get_interface());
}
...

There is information about the connectivity in the above snippet. You just need to store the relation between the ports you find (optr) and the connected channels (optr->get_interface()) in an appropriate data structure that fits your requirements.

HTH and Greetings from Oldenburg,

Philipp

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