openfpga/src/utils/circuit_library_utils.cpp
/********************************************************************
 * A generic function to find the number of configuration bits 
 * for circuit model
 * It will sum up the sizes of all the sram ports 
 * 
 * IMPORTANT: This function should NOT be used to find the number of 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 configuration bits
for circuit model
It will sum up the sizes of all the sram ports

This function should NOT be used to find the number of 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 configuration bits for circuit model It will sum up the sizes of all the sram ports This function should NOT be used to find the number of 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_config_bits(const e_config_protocol_type& config_protocol_type,
                                    const CircuitLibrary& circuit_lib,
                                    const CircuitModelId& circuit_model) {
  size_t num_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) {
    num_config_bits += circuit_lib.port_size(sram_port); 
  } 
  switch (config_protocol_type) {
  case CONFIG_MEM_STANDALONE: 
  case CONFIG_MEM_SCAN_CHAIN: 
  case CONFIG_MEM_MEMORY_BANK: {
    break;
  }
  case CONFIG_MEM_FRAME_BASED: {
    if (0 < num_config_bits) {
      num_config_bits = find_mux_local_decoder_addr_size(num_config_bits);
    }
    break;
  }
  default:
    VTR_LOGF_ERROR(__FILE__, __LINE__,
                   "Invalid type of SRAM organization !\n");
    exit(1);
  }
  return num_config_bits;
}
size_t find_circuit_num_config_bits ( const e_config_protocol_type & config_protocol_type , const CircuitLibrary & circuit_lib , const CircuitModelId & circuit_model ) { size_t num_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 ) { num_config_bits += circuit_lib . port_size ( sram_port ) ; } switch ( config_protocol_type ) { case CONFIG_MEM_STANDALONE : case CONFIG_MEM_SCAN_CHAIN : case CONFIG_MEM_MEMORY_BANK : { break ; } case CONFIG_MEM_FRAME_BASED : { if ( 0 < num_config_bits ) { num_config_bits = find_mux_local_decoder_addr_size ( num_config_bits ) ; } break ; } default : VTR_LOGF_ERROR ( __FILE__ , __LINE__ , " \n " ) ; exit ( 1 ) ; } return num_config_bits ; }
A generic function to find the number of configuration bits
 for circuit model
 It will sum up the sizes of all the sram ports
A generic function to find the number of configuration bits for circuit model It will sum up the sizes of all the sram ports
/* For frame-based configuration protocol
     * The number of configuration bits is the address size
     */