How to identify packages being imported into a module

From Verific Design Automation FAQ
Jump to: navigation, search

Q: How do I identify packages being imported into a module?

Code example:

 MapIter mi ;
 VeriModule *mod ;
 FOREACH_VERILOG_MODULE(mi, mod) {
   if (!mod || !mod->IsRootModule()) continue ;
   Array *mod_items = mod->GetModuleItems() ;
   unsigned i ;
   VeriModuleItem *item ;
   FOREACH_ARRAY_ITEM(mod_items, i, item) {
       if (!item || !item->IsImportDecl()) continue ;
       // Here item is an import declaration
       // item->GetPrettyPrintedString() will give you the string representation
       // item->Linefile() will return the linefile of the import declaration
       // Please check VeriImportDecl class in VeriModuleItem.h file for more details
   }
 }