openfpga/src/utils/lut_utils.cpp
/********************************************************************
 * Generate the bitstream for a single-output LUT with a given truth table
 * As truth tables may come from different logic blocks, truth tables could be in on and off sets
 * We first build a base SRAM bits, where different parts are set to tbe on/off sets 
 * Then, we can decode SRAM bits as regular process 
 *******************************************************************/
Generate the bitstream for a single-output LUT with a given truth table
As truth tables may come from different logic blocks, truth tables could be in on and off sets
We first build a base SRAM bits, where different parts are set to tbe on/off sets
Then, we can decode SRAM bits as regular process
Generate the bitstream for a single - output LUT with a given truth table As truth tables may come from different logic blocks truth tables could be in on and off sets We first build a base SRAM bits where different parts are set to tbe on / off sets Then we can decode SRAM bits as regular process
static 
std::vector<bool> build_single_output_lut_bitstream(const AtomNetlist::TruthTable& truth_table,
                                                    const MuxGraph& lut_mux_graph,
                                                    const size_t& default_sram_bit_value) {
  size_t lut_size = lut_mux_graph.num_memory_bits();
  size_t bitstream_size = lut_mux_graph.num_inputs();
  std::vector<bool> lut_bitstream(bitstream_size, false);
  AtomNetlist::TruthTable completed_truth_table;
  bool on_set = false;
  bool off_set = false;
  if (0 == truth_table.size()) {
    switch (default_sram_bit_value) {
    case 0:
      on_set = true;
      off_set = false;
      break;
    case 1:
      on_set = false;
      off_set = true;
      break;
    default:
      VTR_LOGF_ERROR(__FILE__, __LINE__,
                     "Invalid default_signal_init_value '%lu'!\n",
                     default_sram_bit_value);
      exit(1);
    }
  } else {
    on_set = lut_truth_table_use_on_set(truth_table);
    off_set = !on_set;
  }
  for (const std::vector<vtr::LogicValue>& tt_line : truth_table) {
    completed_truth_table.push_back(complete_truth_table_line(lut_size, tt_line));
  }
  if (true == off_set) {
    lut_bitstream.clear(); 
    lut_bitstream.resize(bitstream_size, true);
  }
  for (const std::vector<vtr::LogicValue>& tt_line : completed_truth_table) {
    rec_build_lut_bitstream_per_line(lut_bitstream, lut_size, tt_line, 0);
  }
  return lut_bitstream;
}
static std :: vector < bool > build_single_output_lut_bitstream ( const AtomNetlist :: TruthTable & truth_table , const MuxGraph & lut_mux_graph , const size_t & default_sram_bit_value ) { size_t lut_size = lut_mux_graph . num_memory_bits ( ) ; size_t bitstream_size = lut_mux_graph . num_inputs ( ) ; std :: vector < bool > lut_bitstream ( bitstream_size , false ) ; AtomNetlist :: TruthTable completed_truth_table ; bool on_set = false ; bool off_set = false ; if ( 0 == truth_table . size ( ) ) { switch ( default_sram_bit_value ) { case 0 : on_set = true ; off_set = false ; break ; case 1 : on_set = false ; off_set = true ; break ; default : VTR_LOGF_ERROR ( __FILE__ , __LINE__ , " \n " , default_sram_bit_value ) ; exit ( 1 ) ; } } else { on_set = lut_truth_table_use_on_set ( truth_table ) ; off_set = ! on_set ; } for ( const std :: vector < vtr :: LogicValue > & tt_line : truth_table ) { completed_truth_table . push_back ( complete_truth_table_line ( lut_size , tt_line ) ) ; } if ( true == off_set ) { lut_bitstream . clear ( ) ; lut_bitstream . resize ( bitstream_size , true ) ; } for ( const std :: vector < vtr :: LogicValue > & tt_line : completed_truth_table ) { rec_build_lut_bitstream_per_line ( lut_bitstream , lut_size , tt_line , 0 ) ; } return lut_bitstream ; }
Generate the bitstream for a single-output LUT with a given truth table
 As truth tables may come from different logic blocks, truth tables could be in on and off sets
 We first build a base SRAM bits, where different parts are set to tbe on/off sets
 Then, we can decode SRAM bits as regular process
Generate the bitstream for a single - output LUT with a given truth table As truth tables may come from different logic blocks truth tables could be in on and off sets We first build a base SRAM bits where different parts are set to tbe on / off sets Then we can decode SRAM bits as regular process
/* if No truth_table, do default*/ /* Read in truth table lines, decode one by one */ /* Complete the truth table line by line*/ /* Initial all the bits in the bitstream */ /* By default, the lut_bitstream is initialize for on_set
     * For off set, it should be flipped
     */ /* Update the truth table, sram_bits */