openfpga/src/fabric/fabric_hierarchy_writer.cpp
/***************************************************************************************
 * Write the hierarchy of modules to a plain text file
 * e.g.,
 *    <module_name>
 *      <child_module_name>
 *        ...
 * This file is mainly used by hierarchical P&R flow 
 *
 * Return 0 if successful
 * Return 1 if there are more serious bugs in the architecture 
 * Return 2 if fail when creating files
 ***************************************************************************************/
Write the hierarchy of modules to a plain text file
e.g.,



This file is mainly used by hierarchical P&R flow

Return 0 if successful
Return 1 if there are more serious bugs in the architecture
Return 2 if fail when creating files
Write the hierarchy of modules to a plain text file e . g . This file is mainly used by hierarchical P&R flow Return 0 if successful Return 1 if there are more serious bugs in the architecture Return 2 if fail when creating files
int write_fabric_hierarchy_to_text_file(const ModuleManager& module_manager,
                                        const std::string& fname,
                                        const size_t& hie_depth_to_stop,
                                        const bool& verbose) {
  std::string timer_message = std::string("Write fabric hierarchy to plain-text file '") + fname + std::string("'");
  std::string dir_path = format_dir_path(find_path_dir_name(fname));
  create_directory(dir_path);
  vtr::ScopedStartFinishTimer timer(timer_message);
  VTR_ASSERT(true != fname.empty());
  std::fstream fp;
  fp.open(fname, std::fstream::out | std::fstream::trunc);
  check_file_stream(fname.c_str(), fp);
  std::string top_module_name = generate_fpga_top_module_name();
  ModuleId top_module = module_manager.find_module(top_module_name);
  if (true != module_manager.valid_module_id(top_module)) {
    VTR_LOGV_ERROR(verbose,
                   "Unable to find the top-level module '%s'!\n",
                   top_module_name.c_str());
    return 1;
  }
  size_t hie_depth = 0;
  if (hie_depth_to_stop < hie_depth) {
    return 0;
  }
  fp << top_module_name << ":" << "\n";
  int err_code = rec_output_module_hierarchy_to_text_file(fp,
                                                          hie_depth_to_stop,
                                                          hie_depth + 1, 
                                                          module_manager,  
                                                          top_module,
                                                          verbose);
  fp.close();
  return err_code;
}
int write_fabric_hierarchy_to_text_file ( const ModuleManager & module_manager , const std :: string & fname , const size_t & hie_depth_to_stop , const bool & verbose ) { std :: string timer_message = std :: string ( " " ) + fname + std :: string ( " " ) ; std :: string dir_path = format_dir_path ( find_path_dir_name ( fname ) ) ; create_directory ( dir_path ) ; vtr :: ScopedStartFinishTimer timer ( timer_message ) ; VTR_ASSERT ( true != fname . empty ( ) ) ; std :: fstream fp ; fp . open ( fname , std :: fstream :: out | std :: fstream :: trunc ) ; check_file_stream ( fname . c_str ( ) , fp ) ; std :: string top_module_name = generate_fpga_top_module_name ( ) ; ModuleId top_module = module_manager . find_module ( top_module_name ) ; if ( true != module_manager . valid_module_id ( top_module ) ) { VTR_LOGV_ERROR ( verbose , " \n " , top_module_name . c_str ( ) ) ; return 1 ; } size_t hie_depth = 0 ; if ( hie_depth_to_stop < hie_depth ) { return 0 ; } fp << top_module_name << " " << " \n " ; int err_code = rec_output_module_hierarchy_to_text_file ( fp , hie_depth_to_stop , hie_depth + 1 , module_manager , top_module , verbose ) ; fp . close ( ) ; return err_code ; }
Write the hierarchy of modules to a plain text file
 e.g.,
    <module_name>
      <child_module_name>
        ...
Write the hierarchy of modules to a plain text file e . g . <module_name > <child_module_name > ...
/* Create directories */ /* Start time count */ /* Use default name if user does not provide one */ /* Create a file handler*/ /* Open a file */ /* Validate the file stream */ /* Find top-level module */ /* Record current depth of module: top module is the root with 0 depth */ /* Visit child module recursively and output the hierarchy */ /* Start with level 1 */ /* close a file */