Difference between revisions of "How to get all Verilog files being analyzed"

From Verific Design Automation FAQ
Jump to: navigation, search
(Created page with "'''Q: I'm using -v, -y, .... After Verific is done with the analysis, how do I get a list of all the files being analyzed?''' Use this code: Array analyzed_files ; // Array...")
 
m
Line 3: Line 3:
 
Use this code:
 
Use this code:
  
  Array analyzed_files ; // Array to store file-names
+
  Array *GetAllAbsFileNames() {
unsigned file_id = 1 ; // File-id starts from 1
+
  Array *files = new Array() ;
char *file_name = 0 ;
+
  unsigned file_id = 1 ;
while ((file_name = LineFile::GetFileNameFromId(file_id++))) {
+
  const char *file_name ;
          analyzed_files.InsertLast(file_name) ;
+
  while ((file_name=LineFile::GetAbsFileNameFromId(file_id++))!=0) {
 +
    // Instead of LineFile::GetAbsFileNameFromId(), the API LineFile::GetFileNameFromId()
 +
    // can also be used if relative file name is required.
 +
    // This is a file we processed:
 +
    files->Insert(file_name) ;
 +
  }
 +
  // Now analyzed_files array should contain names of all the files analyzed
 +
  if (!file->Size()) { delete files ; files = 0 ; }
 +
  return files ;
 
  }
 
  }
// Now analyzed_files array should contain all the files analyzed
 
  
 
How this works:
 
How this works:
Line 17: Line 24:
 
# LineFile::GetFileNameFromId() returns 0 for non-existing id.
 
# LineFile::GetFileNameFromId() returns 0 for non-existing id.
 
# The code keeps calling the API with increnemted file_id until getting a 0.
 
# The code keeps calling the API with increnemted file_id until getting a 0.
 
You may want to use LineFile::GetAbsFileNameFromId() API instead of LineFile::GetFileNameFromId() if you need absolute filenames (with full path).
 

Revision as of 14:11, 25 July 2016

Q: I'm using -v, -y, .... After Verific is done with the analysis, how do I get a list of all the files being analyzed?

Use this code:

Array *GetAllAbsFileNames() {
  Array *files = new Array() ;
  unsigned file_id = 1 ;
  const char *file_name ;
  while ((file_name=LineFile::GetAbsFileNameFromId(file_id++))!=0) {
    // Instead of LineFile::GetAbsFileNameFromId(), the API LineFile::GetFileNameFromId()
    // can also be used if relative file name is required.
    // This is a file we processed:
    files->Insert(file_name) ;
  }
  // Now analyzed_files array should contain names of all the files analyzed
  if (!file->Size()) { delete files ; files = 0 ; }
  return files ;
}

How this works:

  1. Verific keeps file_name vs. file_id mapping.
  2. File_id starts from 1 and increases by 1.
  3. LineFile::GetFileNameFromId() returns 0 for non-existing id.
  4. The code keeps calling the API with increnemted file_id until getting a 0.