libopenfpga/libarchopenfpga/src/check_circuit_library.cpp
/************************************************************************
 * Circuit models have unique names, return the number of errors 
 *  If not found, we give an error
 ***********************************************************************/
Circuit models have unique names, return the number of errors
If not found, we give an error
Circuit models have unique names return the number of errors If not found we give an error
static 
size_t check_circuit_library_unique_prefix(const CircuitLibrary& circuit_lib) {
  size_t num_err = 0;
  for (size_t i = 0; i < circuit_lib.num_models(); ++i) {
    if (i == circuit_lib.num_models() - 1) {
      continue;
    }
    const std::string& i_prefix = circuit_lib.model_prefix(CircuitModelId(i));
    for (size_t j = i + 1; j < circuit_lib.num_models(); ++j) {
      const std::string& j_prefix = circuit_lib.model_prefix(CircuitModelId(j));
      if (0 != i_prefix.compare(j_prefix)) {
        continue;
      }
      VTR_LOG_ERROR("Circuit model(name=%s) and (name=%s) share the same prefix, which is invalid!\n",
                    circuit_lib.model_name(CircuitModelId(i)).c_str(),
                    circuit_lib.model_name(CircuitModelId(j)).c_str(),
                    i_prefix.c_str());
      num_err++;
    }
  }
  return num_err;
}
static size_t check_circuit_library_unique_prefix ( const CircuitLibrary & circuit_lib ) { size_t num_err = 0 ; for ( size_t i = 0 ; i < circuit_lib . num_models ( ) ; ++ i ) { if ( i == circuit_lib . num_models ( ) - 1 ) { continue ; } const std :: string & i_prefix = circuit_lib . model_prefix ( CircuitModelId ( i ) ) ; for ( size_t j = i + 1 ; j < circuit_lib . num_models ( ) ; ++ j ) { const std :: string & j_prefix = circuit_lib . model_prefix ( CircuitModelId ( j ) ) ; if ( 0 != i_prefix . compare ( j_prefix ) ) { continue ; } VTR_LOG_ERROR ( " \n " , circuit_lib . model_name ( CircuitModelId ( i ) ) . c_str ( ) , circuit_lib . model_name ( CircuitModelId ( j ) ) . c_str ( ) , i_prefix . c_str ( ) ) ; num_err ++ ; } } return num_err ; }
Circuit models have unique names, return the number of errors
  If not found, we give an error
Circuit models have unique names return the number of errors If not found we give an error
/* Skip for the last element, because the inner loop will access it */ /* Get the name of reference */ /* Compare the name of candidate */ /* Compare the name and skip for different prefix */ /* Incremental the counter for errors */