openfpga/src/tile_direct/build_tile_direct.cpp
/********************************************************************
 * Find the coordinate of the destination clb/heterogeneous block
 * considering intra column/row direct connections in core grids
 *******************************************************************/
Find the coordinate of the destination clb/heterogeneous block
considering intra column/row direct connections in core grids
Find the coordinate of the destination clb / heterogeneous block considering intra column / row direct connections in core grids
static 
vtr::Point<size_t> find_inter_direct_destination_coordinate(const DeviceGrid& grids,
                                                            const vtr::Point<size_t>& src_coord,
                                                            const std::string des_tile_type_name,
                                                            const ArchDirect& arch_direct,
                                                            const ArchDirectId& arch_direct_id) {
  vtr::Point<size_t> des_coord(grids.width(), grids.height());
  std::vector<size_t> first_search_space;
  std::vector<size_t> second_search_space;
  if (INTER_COLUMN == arch_direct.type(arch_direct_id)) {
    if (POSITIVE_DIR == arch_direct.x_dir(arch_direct_id)) {
      for (size_t ix = src_coord.x() + 1; ix < grids.width() - 1; ++ix) {
        first_search_space.push_back(ix);
      }
    } else { 
      VTR_ASSERT(NEGATIVE_DIR == arch_direct.x_dir(arch_direct_id));
      for (size_t ix = src_coord.x() - 1; ix >= 1; --ix) {
        first_search_space.push_back(ix);
      }
    }
    for (size_t iy = 1 ; iy < grids.height() - 1; ++iy) {
      second_search_space.push_back(iy);
    }
    if (POSITIVE_DIR == arch_direct.y_dir(arch_direct_id)) {
      std::reverse(second_search_space.begin(), second_search_space.end());
    }
  }
  if (INTER_ROW == arch_direct.type(arch_direct_id)) {
    if (POSITIVE_DIR == arch_direct.y_dir(arch_direct_id)) {
      for (size_t iy = src_coord.y() + 1; iy < grids.height() - 1; ++iy) {
        first_search_space.push_back(iy);
      }
    } else { 
      VTR_ASSERT(NEGATIVE_DIR == arch_direct.y_dir(arch_direct_id));
      for (size_t iy = src_coord.y() - 1; iy >= 1; --iy) {
        first_search_space.push_back(iy);
      }
    }
    for (size_t ix = 1 ; ix < grids.width() - 1; ++ix) {
      second_search_space.push_back(ix);
    }
    if (POSITIVE_DIR == arch_direct.x_dir(arch_direct_id)) {
      std::reverse(second_search_space.begin(), second_search_space.end());
    }
  }
  for (size_t ix : first_search_space) {
    std::vector<vtr::Point<size_t>> next_col_row_coords;
    for (size_t iy : second_search_space) {
      if (INTER_COLUMN == arch_direct.type(arch_direct_id)) {
        next_col_row_coords.push_back(vtr::Point<size_t>(ix, iy));
      } else {
        VTR_ASSERT(INTER_ROW == arch_direct.type(arch_direct_id));
        next_col_row_coords.push_back(vtr::Point<size_t>(iy, ix));
      }
    }
    vtr::Point<size_t> des_coord_cand = find_grid_coordinate_given_type(grids, next_col_row_coords, des_tile_type_name); 
    if (true == is_grid_coordinate_exist_in_device(grids, des_coord_cand)) {
      return des_coord_cand;
    }
  }
  return des_coord;
}
static vtr :: Point < size_t > find_inter_direct_destination_coordinate ( const DeviceGrid & grids , const vtr :: Point < size_t > & src_coord , const std :: string des_tile_type_name , const ArchDirect & arch_direct , const ArchDirectId & arch_direct_id ) { vtr :: Point < size_t > des_coord ( grids . width ( ) , grids . height ( ) ) ; std :: vector < size_t > first_search_space ; std :: vector < size_t > second_search_space ; if ( INTER_COLUMN == arch_direct . type ( arch_direct_id ) ) { if ( POSITIVE_DIR == arch_direct . x_dir ( arch_direct_id ) ) { for ( size_t ix = src_coord . x ( ) + 1 ; ix < grids . width ( ) - 1 ; ++ ix ) { first_search_space . push_back ( ix ) ; } } else { VTR_ASSERT ( NEGATIVE_DIR == arch_direct . x_dir ( arch_direct_id ) ) ; for ( size_t ix = src_coord . x ( ) - 1 ; ix >= 1 ; -- ix ) { first_search_space . push_back ( ix ) ; } } for ( size_t iy = 1 ; iy < grids . height ( ) - 1 ; ++ iy ) { second_search_space . push_back ( iy ) ; } if ( POSITIVE_DIR == arch_direct . y_dir ( arch_direct_id ) ) { std :: reverse ( second_search_space . begin ( ) , second_search_space . end ( ) ) ; } } if ( INTER_ROW == arch_direct . type ( arch_direct_id ) ) { if ( POSITIVE_DIR == arch_direct . y_dir ( arch_direct_id ) ) { for ( size_t iy = src_coord . y ( ) + 1 ; iy < grids . height ( ) - 1 ; ++ iy ) { first_search_space . push_back ( iy ) ; } } else { VTR_ASSERT ( NEGATIVE_DIR == arch_direct . y_dir ( arch_direct_id ) ) ; for ( size_t iy = src_coord . y ( ) - 1 ; iy >= 1 ; -- iy ) { first_search_space . push_back ( iy ) ; } } for ( size_t ix = 1 ; ix < grids . width ( ) - 1 ; ++ ix ) { second_search_space . push_back ( ix ) ; } if ( POSITIVE_DIR == arch_direct . x_dir ( arch_direct_id ) ) { std :: reverse ( second_search_space . begin ( ) , second_search_space . end ( ) ) ; } } for ( size_t ix : first_search_space ) { std :: vector < vtr :: Point < size_t > > next_col_row_coords ; for ( size_t iy : second_search_space ) { if ( INTER_COLUMN == arch_direct . type ( arch_direct_id ) ) { next_col_row_coords . push_back ( vtr :: Point < size_t > ( ix , iy ) ) ; } else { VTR_ASSERT ( INTER_ROW == arch_direct . type ( arch_direct_id ) ) ; next_col_row_coords . push_back ( vtr :: Point < size_t > ( iy , ix ) ) ; } } vtr :: Point < size_t > des_coord_cand = find_grid_coordinate_given_type ( grids , next_col_row_coords , des_tile_type_name ) ; if ( true == is_grid_coordinate_exist_in_device ( grids , des_coord_cand ) ) { return des_coord_cand ; } } return des_coord ; }
Find the coordinate of the destination clb/heterogeneous block
 considering intra column/row direct connections in core grids
Find the coordinate of the destination clb / heterogeneous block considering intra column / row direct connections in core grids
/* Cross column connection from Bottom to Top on Right 
   * The next column may NOT have the grid type we want!
   * Think about heterogeneous architecture!  
   * Our search space will start from the next column 
   * and ends at the RIGHT side of fabric 
   */ /* Our first search space will be in x-direction:
      *
      *      x      ...      nx 
      *   +-----+
      *   |Grid |  ----->
      *   +-----+
      */ /* Our first search space will be in x-direction:
      *
      *    1   ...      x    
      *              +-----+
      *     < -------|Grid | 
      *              +-----+
      */ /* Our second search space will be in y-direction:
     *
     *  +------+  
     *  | Grid | ny
     *  +------+
     *     ^     .
     *     |     .
     *     |     .
     *  +------+
     *  | Grid | 1
     *  +------+
     */ /* For negative direction, our second search space will be in y-direction:
     *
     *  +------+  
     *  | Grid | ny
     *  +------+
     *     |     .
     *     |     .
     *     v     .
     *  +------+
     *  | Grid | 1
     *  +------+
     */ /* Cross row connection from Bottom to Top on Right 
   * The next column may NOT have the grid type we want!
   * Think about heterogeneous architecture!  
   * Our search space will start from the next column 
   * and ends at the RIGHT side of fabric 
   */ /* Our first search space will be in y-direction:
      *
      *  +------+  
      *  | Grid | ny
      *  +------+
      *     ^     .
      *     |     .
      *     |     .
      *  +------+
      *  | Grid | y
      *  +------+
      */ /* For negative y-direction,
       * Our first search space will be in y-direction:
       *
       *  +------+  
       *  | Grid | ny
       *  +------+
       *     |     .
       *     |     .
       *     v     .
       *  +------+
       *  | Grid | y
       *  +------+
       */ /* Our second search space will be in x-direction:
     *
     *     1      ...     nx
     *  +------+       +------+
     *  | Grid |<------| Grid |
     *  +------+       +------+
     */ /* For negative direction,
     * our second search space will be in x-direction:
     *
     *     1      ...     nx
     *  +------+       +------+
     *  | Grid |------>| Grid |
     *  +------+       +------+
     */ /* For cross-row connection, our search space is flipped */ /* For a valid coordinate, we can return */