openfpga/src/utils/circuit_library_utils.cpp
/********************************************************************
 * A generic function to find the number of shared configuration bits 
 * for circuit model
 * It will return 0 for CMOS circuits 
 * It will return the maximum shared configuration bits across ReRAM models
 *
 * Note: This function may give WRONG results when all the SRAM ports
 * are not properly linked to its circuit models!
 * So, it should be called after the SRAM linking is done!!!
 *
 * IMPORTANT: This function should NOT be used to find the number of shared configuration bits
 * for a multiplexer, because the multiplexer size is determined during 
 * the FPGA architecture generation (NOT during the XML parsing). 
 *******************************************************************/
A generic function to find the number of shared configuration bits
for circuit model
It will return 0 for CMOS circuits
It will return the maximum shared configuration bits across ReRAM models

This function may give WRONG results when all the SRAM ports
are not properly linked to its circuit models.
So, it should be called after the SRAM linking is done

This function should NOT be used to find the number of shared configuration bits
for a multiplexer, because the multiplexer size is determined during
the FPGA architecture generation (NOT during the XML parsing).
A generic function to find the number of shared configuration bits for circuit model It will return 0 for CMOS circuits It will return the maximum shared configuration bits across ReRAM models This function may give WRONG results when all the SRAM ports are not properly linked to its circuit models . So it should be called after the SRAM linking is done This function should NOT be used to find the number of shared configuration bits for a multiplexer because the multiplexer size is determined during the FPGA architecture generation ( NOT during the XML parsing ) .
size_t find_circuit_num_shared_config_bits(const CircuitLibrary& circuit_lib,
                                           const CircuitModelId& circuit_model,
                                           const e_config_protocol_type& sram_orgz_type) {
  size_t num_shared_config_bits = 0;
  std::vector<CircuitPortId> sram_ports = circuit_lib.model_ports_by_type(circuit_model, CIRCUIT_MODEL_PORT_SRAM);
  for (auto sram_port : sram_ports) {
    CircuitModelId sram_model = circuit_lib.port_tri_state_model(sram_port);
    VTR_ASSERT( true == circuit_lib.valid_model_id(sram_model) );
    switch (circuit_lib.design_tech_type(sram_model)) {
    case CIRCUIT_MODEL_DESIGN_CMOS: 
      break;
    case CIRCUIT_MODEL_DESIGN_RRAM: 
       num_shared_config_bits = std::max((int)num_shared_config_bits, (int)find_rram_circuit_num_shared_config_bits(circuit_lib, sram_model, sram_orgz_type));
       break;
    default:
      VTR_LOGF_ERROR(__FILE__, __LINE__,
                     "Invalid design technology for SRAM model!\n");
      exit(1);
    }
  } 
  return num_shared_config_bits;
}
size_t find_circuit_num_shared_config_bits ( const CircuitLibrary & circuit_lib , const CircuitModelId & circuit_model , const e_config_protocol_type & sram_orgz_type ) { size_t num_shared_config_bits = 0 ; std :: vector < CircuitPortId > sram_ports = circuit_lib . model_ports_by_type ( circuit_model , CIRCUIT_MODEL_PORT_SRAM ) ; for ( auto sram_port : sram_ports ) { CircuitModelId sram_model = circuit_lib . port_tri_state_model ( sram_port ) ; VTR_ASSERT ( true == circuit_lib . valid_model_id ( sram_model ) ) ; switch ( circuit_lib . design_tech_type ( sram_model ) ) { case CIRCUIT_MODEL_DESIGN_CMOS : break ; case CIRCUIT_MODEL_DESIGN_RRAM : num_shared_config_bits = std :: max ( ( int ) num_shared_config_bits , ( int ) find_rram_circuit_num_shared_config_bits ( circuit_lib , sram_model , sram_orgz_type ) ) ; break ; default : VTR_LOGF_ERROR ( __FILE__ , __LINE__ , " \n " ) ; exit ( 1 ) ; } } return num_shared_config_bits ; }
A generic function to find the number of shared configuration bits
 for circuit model
 It will return 0 for CMOS circuits
 It will return the maximum shared configuration bits across ReRAM models
A generic function to find the number of shared configuration bits for circuit model It will return 0 for CMOS circuits It will return the maximum shared configuration bits across ReRAM models
/* Depend on the design technolgy of SRAM model, the number of configuration bits will be different */ /* CMOS circuit do not need shared configuration bits */ /* RRAM circuit do need shared configuration bits, but it is subjected to the largest one among different SRAM models */