openfpga/src/annotation/check_pb_graph_annotation.cpp
/********************************************************************
 * This function will recursively walk through all the pb_graph nodes
 * starting from a top node.
 * It aims to check 
 * - if each primitive pb_graph node has been binded to a physical 
 *   pb_graph_node
 * - if each pin of the primitive pb_graph node has been binded to 
 *   a physical graph_pin
 *******************************************************************/
This function will recursively walk through all the pb_graph nodes
starting from a top node.
It aims to check
- if each primitive pb_graph node has been binded to a physical
pb_graph_node
- if each pin of the primitive pb_graph node has been binded to
a physical graph_pin
This function will recursively walk through all the pb_graph nodes starting from a top node . It aims to check - if each primitive pb_graph node has been binded to a physical pb_graph_node - if each pin of the primitive pb_graph node has been binded to a physical graph_pin
static 
void rec_check_vpr_physical_pb_graph_node_annotation(t_pb_graph_node* pb_graph_node, 
                                                     const VprDeviceAnnotation& vpr_device_annotation,
                                                     size_t& num_err) {
  if (false == is_primitive_pb_type(pb_graph_node->pb_type)) {
    for (int imode = 0; imode < pb_graph_node->pb_type->num_modes; ++imode) {
      for (int ipb = 0; ipb < pb_graph_node->pb_type->modes[imode].num_pb_type_children; ++ipb) {
        for (int jpb = 0; jpb < pb_graph_node->pb_type->modes[imode].pb_type_children[ipb].num_pb; ++jpb) {
          rec_check_vpr_physical_pb_graph_node_annotation(&(pb_graph_node->child_pb_graph_nodes[imode][ipb][jpb]), 
                                                          vpr_device_annotation, num_err);
        }
      }
    }
    return;
  }
  t_pb_graph_node* physical_pb_graph_node = vpr_device_annotation.physical_pb_graph_node(pb_graph_node);
  if (nullptr == physical_pb_graph_node) { 
    VTR_LOG_ERROR("Found a pb_graph_node '%s' missing physical pb_graph_node binding!\n",
                  pb_graph_node->pb_type->name);
    num_err++;
    return; 
  } 
  for (int iport = 0; iport < physical_pb_graph_node->num_input_ports; ++iport) {
    for (int ipin = 0; ipin < physical_pb_graph_node->num_input_pins[iport]; ++ipin) {
      if (false == check_physical_pb_graph_pin(&(physical_pb_graph_node->input_pins[iport][ipin]),
                                               vpr_device_annotation)) {
        num_err++;
      }
    } 
  }
  for (int iport = 0; iport < physical_pb_graph_node->num_output_ports; ++iport) {
    for (int ipin = 0; ipin < physical_pb_graph_node->num_output_pins[iport]; ++ipin) {
      if (false == check_physical_pb_graph_pin(&(physical_pb_graph_node->output_pins[iport][ipin]),
                                               vpr_device_annotation)) {
        num_err++;
      }
    } 
  }
  for (int iport = 0; iport < physical_pb_graph_node->num_clock_ports; ++iport) {
    for (int ipin = 0; ipin < physical_pb_graph_node->num_clock_pins[iport]; ++ipin) {
      if (false == check_physical_pb_graph_pin(&(physical_pb_graph_node->clock_pins[iport][ipin]),
                                               vpr_device_annotation)) {
        num_err++;
      }
    } 
  }
}
static void rec_check_vpr_physical_pb_graph_node_annotation ( t_pb_graph_node * pb_graph_node , const VprDeviceAnnotation & vpr_device_annotation , size_t & num_err ) { if ( false == is_primitive_pb_type ( pb_graph_node -> pb_type ) ) { for ( int imode = 0 ; imode < pb_graph_node -> pb_type -> num_modes ; ++ imode ) { for ( int ipb = 0 ; ipb < pb_graph_node -> pb_type -> modes [ imode ] . num_pb_type_children ; ++ ipb ) { for ( int jpb = 0 ; jpb < pb_graph_node -> pb_type -> modes [ imode ] . pb_type_children [ ipb ] . num_pb ; ++ jpb ) { rec_check_vpr_physical_pb_graph_node_annotation ( & ( pb_graph_node -> child_pb_graph_nodes [ imode ] [ ipb ] [ jpb ] ) , vpr_device_annotation , num_err ) ; } } } return ; } t_pb_graph_node * physical_pb_graph_node = vpr_device_annotation . physical_pb_graph_node ( pb_graph_node ) ; if ( nullptr == physical_pb_graph_node ) { VTR_LOG_ERROR ( " \n " , pb_graph_node -> pb_type -> name ) ; num_err ++ ; return ; } for ( int iport = 0 ; iport < physical_pb_graph_node -> num_input_ports ; ++ iport ) { for ( int ipin = 0 ; ipin < physical_pb_graph_node -> num_input_pins [ iport ] ; ++ ipin ) { if ( false == check_physical_pb_graph_pin ( & ( physical_pb_graph_node -> input_pins [ iport ] [ ipin ] ) , vpr_device_annotation ) ) { num_err ++ ; } } } for ( int iport = 0 ; iport < physical_pb_graph_node -> num_output_ports ; ++ iport ) { for ( int ipin = 0 ; ipin < physical_pb_graph_node -> num_output_pins [ iport ] ; ++ ipin ) { if ( false == check_physical_pb_graph_pin ( & ( physical_pb_graph_node -> output_pins [ iport ] [ ipin ] ) , vpr_device_annotation ) ) { num_err ++ ; } } } for ( int iport = 0 ; iport < physical_pb_graph_node -> num_clock_ports ; ++ iport ) { for ( int ipin = 0 ; ipin < physical_pb_graph_node -> num_clock_pins [ iport ] ; ++ ipin ) { if ( false == check_physical_pb_graph_pin ( & ( physical_pb_graph_node -> clock_pins [ iport ] [ ipin ] ) , vpr_device_annotation ) ) { num_err ++ ; } } } }
This function will recursively walk through all the pb_graph nodes
 starting from a top node.
This function will recursively walk through all the pb_graph nodes starting from a top node .
/* Go recursive first until we touch the primitive node */ /* Each child may exist multiple times in the hierarchy*/ /* Ensure that the pb_graph_node has been mapped to a physical node */ /* Invalid pointer already, further check is not applicable */ /* Reach here, we should have a valid pointer to the physical pb_graph_node,
   * Check the physical pb_graph_pin for each pin 
   */