openfpga/src/utils/mux_utils.cpp
/**************************************************
 * Find the number of inputs for majority of branches 
 * in a multi-level multiplexer implementation
 *************************************************/
Find the number of inputs for majority of branches
in a multi-level multiplexer implementation
Find the number of inputs for majority of branches in a multi - level multiplexer implementation
size_t find_multilevel_mux_branch_num_inputs(const size_t& mux_size,
                                             const size_t& mux_level) {
  if (2 == mux_size) {
    return mux_size; 
  }
  if (1 == mux_level) {
    return mux_size;
  }  
  if (2 == mux_level) {
    size_t num_input_per_unit = (size_t)sqrt(mux_size);
    while ( num_input_per_unit * num_input_per_unit < mux_size) {
      num_input_per_unit++;
    }
    return num_input_per_unit;
  }
  VTR_ASSERT_SAFE(2 < mux_level);
  size_t num_input_per_unit = 2;
  while (pow((double)num_input_per_unit, (double)mux_level) < mux_size) {
    num_input_per_unit++;
  }
  if (!valid_mux_implementation_num_inputs(num_input_per_unit)) {
    VTR_LOG_ERROR("Number of inputs of each basis should be at least 2!\n");
    exit(1); 
  }
  return num_input_per_unit;
}
size_t find_multilevel_mux_branch_num_inputs ( const size_t & mux_size , const size_t & mux_level ) { if ( 2 == mux_size ) { return mux_size ; } if ( 1 == mux_level ) { return mux_size ; } if ( 2 == mux_level ) { size_t num_input_per_unit = ( size_t ) sqrt ( mux_size ) ; while ( num_input_per_unit * num_input_per_unit < mux_size ) { num_input_per_unit ++ ; } return num_input_per_unit ; } VTR_ASSERT_SAFE ( 2 < mux_level ) ; size_t num_input_per_unit = 2 ; while ( pow ( ( double ) num_input_per_unit , ( double ) mux_level ) < mux_size ) { num_input_per_unit ++ ; } if ( ! valid_mux_implementation_num_inputs ( num_input_per_unit ) ) { VTR_LOG_ERROR ( " \n " ) ; exit ( 1 ) ; } return num_input_per_unit ; }
Find the number of inputs for majority of branches
 in a multi-level multiplexer implementation
Find the number of inputs for majority of branches in a multi - level multiplexer implementation
/* Special Case: mux_size = 2 */