Jump to content
juliomelo

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.

Share this post


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

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

×