openfpga/src/utils/lut_utils.cpp
/********************************************************************
 * This function aims to adapt the truth table to a mapped physical LUT 
 * subject to a pin rotation map
 * The modification is applied to line by line
 *   - For unused inputs : insert dont care
 *   - For used inputs : find the bit in the truth table rows and move it by the given mapping
 *
 * The rotated pin map is the reference to adapt the truth table.
 * Each element of the map represents the input index in the original truth table
 * The sequence of the rotate pin map is the final sequence of how
 * each line of the original truth table should be shuffled
 * Example: 
 *                     output_value(we do not modify)
 *                               |
 *                               v
 *   Truth table line:       00111
 *   rotated_pin_map:        2310
 *   Adapt truth table line: 11001     
 *
 * An illustrative example: 
 *          
 *          Original Truth Table       Post VPR Truth Table
 *
 *               +-------+                  +-------+
 *      net0 --->|       |          net1--->|       |
 *      net1 --->|  LUT  |          net0--->|  LUT  |
 *           ... |       |              ... |       |
 *               +-------+                  +-------+
 *
 *         Truth table line             Truth table line
 *     .names net0 net1 out          .names net1 net0 out
 *     01 1                          10 1
 *
 *******************************************************************/
This function aims to adapt the truth table to a mapped physical LUT
subject to a pin rotation map
The modification is applied to line by line
- For unused inputs : insert dont care
- For used inputs : find the bit in the truth table rows and move it by the given mapping

The rotated pin map is the reference to adapt the truth table.
Each element of the map represents the input index in the original truth table
The sequence of the rotate pin map is the final sequence of how
each line of the original truth table should be shuffled
Example:
output_value(we do not modify)
|
v
Truth table line:       00111
rotated_pin_map:        2310
Adapt truth table line: 11001

An illustrative example.

Original Truth Table       Post VPR Truth Table



Truth table line             Truth table line
.names net0 net1 out          .names net1 net0 out
01 1                          10 1
This function aims to adapt the truth table to a mapped physical LUT subject to a pin rotation map The modification is applied to line by line - For unused inputs : insert dont care - For used inputs : find the bit in the truth table rows and move it by the given mapping The rotated pin map is the reference to adapt the truth table . Each element of the map represents the input index in the original truth table The sequence of the rotate pin map is the final sequence of how each line of the original truth table should be shuffled Example : output_value ( we do not modify ) | v Truth table line : 00111 rotated_pin_map : 2310 Adapt truth table line : 11001 An illustrative example . Original Truth Table Post VPR Truth Table Truth table line Truth table line . names net0 net1 out . names net1 net0 out 01 1 10 1
AtomNetlist::TruthTable lut_truth_table_adaption(const AtomNetlist::TruthTable& orig_tt, 
                                                 const std::vector<int>& rotated_pin_map) {
  AtomNetlist::TruthTable tt;
  for (auto row : orig_tt) {
    VTR_ASSERT(row.size() - 1 <= rotated_pin_map.size());
    std::vector<vtr::LogicValue> tt_line;
    for (size_t i = 0; i < rotated_pin_map.size(); ++i) {
      if (-1 == rotated_pin_map[i]) {
        tt_line.push_back(vtr::LogicValue::DONT_CARE);
      } else { 
        VTR_ASSERT((size_t)rotated_pin_map[i] < row.size() - 1);
        tt_line.push_back(row[rotated_pin_map[i]]);
      }
    } 
    tt_line.push_back(row.back());
    tt.push_back(tt_line);
  }
  return tt;
}
AtomNetlist :: TruthTable lut_truth_table_adaption ( const AtomNetlist :: TruthTable & orig_tt , const std :: vector < int > & rotated_pin_map ) { AtomNetlist :: TruthTable tt ; for ( auto row : orig_tt ) { VTR_ASSERT ( row . size ( ) - 1 <= rotated_pin_map . size ( ) ) ; std :: vector < vtr :: LogicValue > tt_line ; for ( size_t i = 0 ; i < rotated_pin_map . size ( ) ; ++ i ) { if ( -1 == rotated_pin_map [ i ] ) { tt_line . push_back ( vtr :: LogicValue :: DONT_CARE ) ; } else { VTR_ASSERT ( ( size_t ) rotated_pin_map [ i ] < row . size ( ) - 1 ) ; tt_line . push_back ( row [ rotated_pin_map [ i ] ] ) ; } } tt_line . push_back ( row . back ( ) ) ; tt . push_back ( tt_line ) ; } return tt ; }
This function aims to adapt the truth table to a mapped physical LUT
 subject to a pin rotation map
 The modification is applied to line by line
   - For unused inputs : insert dont care
   - For used inputs : find the bit in the truth table rows and move it by the given mapping
This function aims to adapt the truth table to a mapped physical LUT subject to a pin rotation map The modification is applied to line by line - For unused inputs : insert dont care - For used inputs : find the bit in the truth table rows and move it by the given mapping
/* We do not care about the last digit, which is the output value */ /* Ensure we never access the last digit, i.e., the output value! */ /* Do not miss the last digit in the final result */