openfpga/src/fabric/build_top_module_memory.cpp
/********************************************************************
 * This function adds the SB, CBX, CBY and Grid of a tile
 * to the memory modules and memory instances 
 * This function is designed for organizing memory modules in top-level
 * module
 *******************************************************************/
This function adds the SB, CBX, CBY and Grid of a tile
to the memory modules and memory instances
This function is designed for organizing memory modules in top-level
module
This function adds the SB CBX CBY and Grid of a tile to the memory modules and memory instances This function is designed for organizing memory modules in top - level module
static 
void organize_top_module_tile_memory_modules(ModuleManager& module_manager, 
                                             const ModuleId& top_module,
                                             const CircuitLibrary& circuit_lib,
                                             const e_config_protocol_type& sram_orgz_type,
                                             const CircuitModelId& sram_model,
                                             const DeviceGrid& grids,
                                             const vtr::Matrix<size_t>& grid_instance_ids,
                                             const DeviceRRGSB& device_rr_gsb,
                                             const vtr::Matrix<size_t>& sb_instance_ids,
                                             const std::map<t_rr_type, vtr::Matrix<size_t>>& cb_instance_ids,
                                             const bool& compact_routing_hierarchy,
                                             const vtr::Point<size_t>& tile_coord,
                                             const e_side& tile_border_side) {
  vtr::Point<size_t> gsb_coord_range = device_rr_gsb.get_gsb_range();
  vtr::Point<size_t> gsb_coord(tile_coord.x(), tile_coord.y() - 1);
  if ( (gsb_coord.x() < gsb_coord_range.x())
    && (gsb_coord.y() < gsb_coord_range.y()) ) { 
    const RRGSB& rr_gsb = device_rr_gsb.get_gsb(gsb_coord.x(), gsb_coord.y());
    vtr::Point<size_t> sb_coord(rr_gsb.get_sb_x(), rr_gsb.get_sb_y());
    if (true == compact_routing_hierarchy) {
      const RRGSB& unique_mirror = device_rr_gsb.get_sb_unique_module(sb_coord);
      sb_coord.set_x(unique_mirror.get_sb_x()); 
      sb_coord.set_y(unique_mirror.get_sb_y()); 
    } 
    std::string sb_module_name = generate_switch_block_module_name(sb_coord);
    ModuleId sb_module = module_manager.find_module(sb_module_name);
    VTR_ASSERT(true == module_manager.valid_module_id(sb_module));
    if ( true == rr_gsb.is_sb_exist()) {
      if (0 < find_module_num_config_bits(module_manager, sb_module,
                                          circuit_lib, sram_model, 
                                          sram_orgz_type)) {
        module_manager.add_configurable_child(top_module, sb_module, sb_instance_ids[rr_gsb.get_sb_x()][rr_gsb.get_sb_y()]);
      }
    }
    organize_top_module_tile_cb_modules(module_manager, top_module, circuit_lib,
                                        sram_orgz_type, sram_model,
                                        cb_instance_ids.at(CHANX),
                                        device_rr_gsb, rr_gsb, CHANX,
                                        compact_routing_hierarchy);
    organize_top_module_tile_cb_modules(module_manager, top_module, circuit_lib,
                                        sram_orgz_type, sram_model,
                                        cb_instance_ids.at(CHANY),
                                        device_rr_gsb, rr_gsb, CHANY,
                                        compact_routing_hierarchy);
  }
  t_physical_tile_type_ptr grid_type = grids[tile_coord.x()][tile_coord.y()].type;
  if (true == is_empty_type(grid_type)) {
    return;
  }
  if ( (0 < grids[tile_coord.x()][tile_coord.y()].width_offset) 
    || (0 < grids[tile_coord.x()][tile_coord.y()].height_offset) ) {
    return;
  }
  std::string grid_module_name_prefix(GRID_MODULE_NAME_PREFIX);
  std::string grid_module_name = generate_grid_block_module_name(grid_module_name_prefix, std::string(grid_type->name), is_io_type(grid_type), tile_border_side);
  ModuleId grid_module = module_manager.find_module(grid_module_name);
  VTR_ASSERT(true == module_manager.valid_module_id(grid_module));
  if (0 < find_module_num_config_bits(module_manager, grid_module,
                                      circuit_lib, sram_model, 
                                      sram_orgz_type)) {
    module_manager.add_configurable_child(top_module, grid_module, grid_instance_ids[tile_coord.x()][tile_coord.y()]);
  }
}
static void organize_top_module_tile_memory_modules ( ModuleManager & module_manager , const ModuleId & top_module , const CircuitLibrary & circuit_lib , const e_config_protocol_type & sram_orgz_type , const CircuitModelId & sram_model , const DeviceGrid & grids , const vtr :: Matrix < size_t > & grid_instance_ids , const DeviceRRGSB & device_rr_gsb , const vtr :: Matrix < size_t > & sb_instance_ids , const std :: map < t_rr_type , vtr :: Matrix < size_t > > & cb_instance_ids , const bool & compact_routing_hierarchy , const vtr :: Point < size_t > & tile_coord , const e_side & tile_border_side ) { vtr :: Point < size_t > gsb_coord_range = device_rr_gsb . get_gsb_range ( ) ; vtr :: Point < size_t > gsb_coord ( tile_coord . x ( ) , tile_coord . y ( ) - 1 ) ; if ( ( gsb_coord . x ( ) < gsb_coord_range . x ( ) ) && ( gsb_coord . y ( ) < gsb_coord_range . y ( ) ) ) { const RRGSB & rr_gsb = device_rr_gsb . get_gsb ( gsb_coord . x ( ) , gsb_coord . y ( ) ) ; vtr :: Point < size_t > sb_coord ( rr_gsb . get_sb_x ( ) , rr_gsb . get_sb_y ( ) ) ; if ( true == compact_routing_hierarchy ) { const RRGSB & unique_mirror = device_rr_gsb . get_sb_unique_module ( sb_coord ) ; sb_coord . set_x ( unique_mirror . get_sb_x ( ) ) ; sb_coord . set_y ( unique_mirror . get_sb_y ( ) ) ; } std :: string sb_module_name = generate_switch_block_module_name ( sb_coord ) ; ModuleId sb_module = module_manager . find_module ( sb_module_name ) ; VTR_ASSERT ( true == module_manager . valid_module_id ( sb_module ) ) ; if ( true == rr_gsb . is_sb_exist ( ) ) { if ( 0 < find_module_num_config_bits ( module_manager , sb_module , circuit_lib , sram_model , sram_orgz_type ) ) { module_manager . add_configurable_child ( top_module , sb_module , sb_instance_ids [ rr_gsb . get_sb_x ( ) ] [ rr_gsb . get_sb_y ( ) ] ) ; } } organize_top_module_tile_cb_modules ( module_manager , top_module , circuit_lib , sram_orgz_type , sram_model , cb_instance_ids . at ( CHANX ) , device_rr_gsb , rr_gsb , CHANX , compact_routing_hierarchy ) ; organize_top_module_tile_cb_modules ( module_manager , top_module , circuit_lib , sram_orgz_type , sram_model , cb_instance_ids . at ( CHANY ) , device_rr_gsb , rr_gsb , CHANY , compact_routing_hierarchy ) ; } t_physical_tile_type_ptr grid_type = grids [ tile_coord . x ( ) ] [ tile_coord . y ( ) ] . type ; if ( true == is_empty_type ( grid_type ) ) { return ; } if ( ( 0 < grids [ tile_coord . x ( ) ] [ tile_coord . y ( ) ] . width_offset ) || ( 0 < grids [ tile_coord . x ( ) ] [ tile_coord . y ( ) ] . height_offset ) ) { return ; } std :: string grid_module_name_prefix ( GRID_MODULE_NAME_PREFIX ) ; std :: string grid_module_name = generate_grid_block_module_name ( grid_module_name_prefix , std :: string ( grid_type -> name ) , is_io_type ( grid_type ) , tile_border_side ) ; ModuleId grid_module = module_manager . find_module ( grid_module_name ) ; VTR_ASSERT ( true == module_manager . valid_module_id ( grid_module ) ) ; if ( 0 < find_module_num_config_bits ( module_manager , grid_module , circuit_lib , sram_model , sram_orgz_type ) ) { module_manager . add_configurable_child ( top_module , grid_module , grid_instance_ids [ tile_coord . x ( ) ] [ tile_coord . y ( ) ] ) ; } }
This function adds the SB, CBX, CBY and Grid of a tile
 to the memory modules and memory instances
 This function is designed for organizing memory modules in top-level
 module
This function adds the SB CBX CBY and Grid of a tile to the memory modules and memory instances This function is designed for organizing memory modules in top - level module
/* We do NOT consider SB and CBs if the gsb is not in the range! */ /* Find Switch Block: unique module id and instance id!
     * Note that switch block does always exist in a GSB
     */ /* If we use compact routing hierarchy, we should instanciate the unique module of SB */ /* Identify if this sub module includes configuration bits, 
     * we will update the memory module and instance list
     */ /* If the CB does not exist, we can skip addition */ /* Try to find and add CBX and CBY */ /* Find the module name for this type of grid */ /* Skip EMPTY Grid */ /* Skip width > 1 or height > 1 Grid, which should already been processed when offset=0 */ /* Identify if this sub module includes configuration bits, 
   * we will update the memory module and instance list
   */