openfpga/src/repack/build_physical_truth_table.cpp
/***************************************************************************************
 * Create pin rotation map for a LUT
 ***************************************************************************************/
Create pin rotation map for a LUT
Create pin rotation map for a LUT
static 
std::vector<int> generate_lut_rotated_input_pin_map(const std::vector<AtomNetId>& input_nets,
                                                    const AtomContext& atom_ctx,
                                                    const AtomBlockId& atom_blk,
                                                    const VprDeviceAnnotation& device_annotation,
                                                    const CircuitLibrary& circuit_lib,
                                                    const t_pb_graph_node* pb_graph_node) { 
  std::vector<int> rotated_pin_map(input_nets.size(), -1);
  for (int iport = 0; iport < pb_graph_node->num_input_ports; ++iport) {
    for (int ipin = 0; ipin < pb_graph_node->num_input_pins[iport]; ++ipin) {
      CircuitPortId circuit_port = device_annotation.pb_circuit_port(pb_graph_node->input_pins[iport][ipin].port);
      if (true == circuit_lib.port_is_harden_lut_port(circuit_port)) {
        continue;
      }
      t_port* lut_pb_type_in_port = pb_graph_node->input_pins[iport][ipin].port; 
      if (0 != pb_graph_node->pb_type->num_modes) {
        VTR_ASSERT(2 == pb_graph_node->pb_type->num_modes);
        VTR_ASSERT(1 == pb_graph_node->pb_type->modes[VPR_PB_TYPE_LUT_MODE].num_pb_type_children);
        lut_pb_type_in_port = &(pb_graph_node->pb_type->modes[VPR_PB_TYPE_LUT_MODE].pb_type_children[0].ports[iport]);
        VTR_ASSERT(std::string(lut_pb_type_in_port->name) == std::string(pb_graph_node->input_pins[iport][ipin].port->name));
        VTR_ASSERT(lut_pb_type_in_port->num_pins == pb_graph_node->input_pins[iport][ipin].port->num_pins);
      }
      AtomPortId atom_port = atom_ctx.nlist.find_atom_port(atom_blk, lut_pb_type_in_port->model_port);
      if (!atom_port) { 
        continue;
      }
      for (AtomPinId atom_pin : atom_ctx.nlist.port_pins(atom_port)) {
        AtomNetId atom_pin_net = atom_ctx.nlist.pin_net(atom_pin);
        if (atom_pin_net == input_nets[ipin]) {
          rotated_pin_map[ipin] = atom_ctx.nlist.pin_port_bit(atom_pin);
          break;
        }
      }
    }
  }
  return rotated_pin_map;
}
static std :: vector < int > generate_lut_rotated_input_pin_map ( const std :: vector < AtomNetId > & input_nets , const AtomContext & atom_ctx , const AtomBlockId & atom_blk , const VprDeviceAnnotation & device_annotation , const CircuitLibrary & circuit_lib , const t_pb_graph_node * pb_graph_node ) { std :: vector < int > rotated_pin_map ( input_nets . size ( ) , -1 ) ; for ( int iport = 0 ; iport < pb_graph_node -> num_input_ports ; ++ iport ) { for ( int ipin = 0 ; ipin < pb_graph_node -> num_input_pins [ iport ] ; ++ ipin ) { CircuitPortId circuit_port = device_annotation . pb_circuit_port ( pb_graph_node -> input_pins [ iport ] [ ipin ] . port ) ; if ( true == circuit_lib . port_is_harden_lut_port ( circuit_port ) ) { continue ; } t_port * lut_pb_type_in_port = pb_graph_node -> input_pins [ iport ] [ ipin ] . port ; if ( 0 != pb_graph_node -> pb_type -> num_modes ) { VTR_ASSERT ( 2 == pb_graph_node -> pb_type -> num_modes ) ; VTR_ASSERT ( 1 == pb_graph_node -> pb_type -> modes [ VPR_PB_TYPE_LUT_MODE ] . num_pb_type_children ) ; lut_pb_type_in_port = & ( pb_graph_node -> pb_type -> modes [ VPR_PB_TYPE_LUT_MODE ] . pb_type_children [ 0 ] . ports [ iport ] ) ; VTR_ASSERT ( std :: string ( lut_pb_type_in_port -> name ) == std :: string ( pb_graph_node -> input_pins [ iport ] [ ipin ] . port -> name ) ) ; VTR_ASSERT ( lut_pb_type_in_port -> num_pins == pb_graph_node -> input_pins [ iport ] [ ipin ] . port -> num_pins ) ; } AtomPortId atom_port = atom_ctx . nlist . find_atom_port ( atom_blk , lut_pb_type_in_port -> model_port ) ; if ( ! atom_port ) { continue ; } for ( AtomPinId atom_pin : atom_ctx . nlist . port_pins ( atom_port ) ) { AtomNetId atom_pin_net = atom_ctx . nlist . pin_net ( atom_pin ) ; if ( atom_pin_net == input_nets [ ipin ] ) { rotated_pin_map [ ipin ] = atom_ctx . nlist . pin_port_bit ( atom_pin ) ; break ; } } } } return rotated_pin_map ; }
Create pin rotation map for a LUT
Create pin rotation map for a LUT
/* Find the pin rotation status and record it ,
   * Note that some LUT inputs may not be used, we set them to be open by default
   */ /* Skip the input pin that do not drive by LUT MUXes */ /* The lut pb_graph_node may not be the primitive node 
       * because VPR adds two default modes to its LUT pb_type
       * If so, we will use the LUT mode of the pb_graph node
       */ /* Port exists (some LUTs may have no input and hence no port in the atom netlist) */