mod comments

This commit is contained in:
Lin 2024-08-26 03:07:06 -07:00
parent 5153cee4dd
commit 67c7c2da66
3 changed files with 26 additions and 22 deletions

View File

@ -2,11 +2,9 @@
* Member functions for class DeviceRRGSB * Member functions for class DeviceRRGSB
***********************************************************************/ ***********************************************************************/
#include "device_rr_gsb.h"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include "device_rr_gsb.h"
#include "rr_gsb_utils.h" #include "rr_gsb_utils.h"
#include "vtr_assert.h" #include "vtr_assert.h"
#include "vtr_log.h" #include "vtr_log.h"
@ -582,20 +580,19 @@ size_t DeviceRRGSB::get_cb_unique_module_index(
void DeviceRRGSB::preload_unique_cbx_module( void DeviceRRGSB::preload_unique_cbx_module(
const vtr::Point<size_t> block_coordinate, const vtr::Point<size_t> block_coordinate,
const std::vector<vtr::Point<size_t>> instance_coords) { const std::vector<vtr::Point<size_t>> instance_coords) {
/* Add to list if this is a unique mirror*/ /*check whether the preloaded value exceeds the limit */
size_t limit_x = cbx_unique_module_id_.size(); size_t limit_x = cbx_unique_module_id_.size();
size_t limit_y = cbx_unique_module_id_[0].size(); size_t limit_y = cbx_unique_module_id_[0].size();
VTR_ASSERT(block_coordinate.x() < limit_x); VTR_ASSERT(block_coordinate.x() < limit_x);
VTR_ASSERT(block_coordinate.y() < limit_y); VTR_ASSERT(block_coordinate.y() < limit_y);
add_cb_unique_module(CHANX, block_coordinate); add_cb_unique_module(CHANX, block_coordinate);
/* Record the id of unique mirror */ /* preload the unique block */
set_cb_unique_module_id(CHANX, block_coordinate, set_cb_unique_module_id(CHANX, block_coordinate,
get_num_cb_unique_module(CHANX) - 1); get_num_cb_unique_module(CHANX) - 1);
/* Traverse the unique_mirror list and set up its module id */ /* preload the instances of the unique block. Instance will have the same id
* as the unique block */
for (auto instance_location : instance_coords) { for (auto instance_location : instance_coords) {
/* Record the id of unique mirror */
VTR_ASSERT(instance_location.x() < limit_x); VTR_ASSERT(instance_location.x() < limit_x);
VTR_ASSERT(instance_location.y() < limit_y); VTR_ASSERT(instance_location.y() < limit_y);
set_cb_unique_module_id( set_cb_unique_module_id(
@ -607,20 +604,20 @@ void DeviceRRGSB::preload_unique_cbx_module(
void DeviceRRGSB::preload_unique_cby_module( void DeviceRRGSB::preload_unique_cby_module(
const vtr::Point<size_t> block_coordinate, const vtr::Point<size_t> block_coordinate,
const std::vector<vtr::Point<size_t>> instance_coords) { const std::vector<vtr::Point<size_t>> instance_coords) {
/* Add to list if this is a unique mirror*/ /*check whether the preloaded value exceeds the limit */
size_t limit_x = cby_unique_module_id_.size(); size_t limit_x = cby_unique_module_id_.size();
size_t limit_y = cby_unique_module_id_[0].size(); size_t limit_y = cby_unique_module_id_[0].size();
VTR_ASSERT(block_coordinate.x() < limit_x); VTR_ASSERT(block_coordinate.x() < limit_x);
VTR_ASSERT(block_coordinate.y() < limit_y); VTR_ASSERT(block_coordinate.y() < limit_y);
add_cb_unique_module(CHANY, block_coordinate); add_cb_unique_module(CHANY, block_coordinate);
/* Record the id of unique mirror */ /* preload the unique block */
set_cb_unique_module_id(CHANY, block_coordinate, set_cb_unique_module_id(CHANY, block_coordinate,
get_num_cb_unique_module(CHANY) - 1); get_num_cb_unique_module(CHANY) - 1);
/* Traverse the unique_mirror list and set up its module id */ /* preload the instances of the unique block. Instance will have the same id
* as the unique block */
for (auto instance_location : instance_coords) { for (auto instance_location : instance_coords) {
/* Record the id of unique mirror */
VTR_ASSERT(instance_location.x() < limit_x); VTR_ASSERT(instance_location.x() < limit_x);
VTR_ASSERT(instance_location.y() < limit_y); VTR_ASSERT(instance_location.y() < limit_y);
set_cb_unique_module_id( set_cb_unique_module_id(
@ -632,7 +629,7 @@ void DeviceRRGSB::preload_unique_cby_module(
void DeviceRRGSB::preload_unique_sb_module( void DeviceRRGSB::preload_unique_sb_module(
const vtr::Point<size_t> block_coordinate, const vtr::Point<size_t> block_coordinate,
const std::vector<vtr::Point<size_t>> instance_coords) { const std::vector<vtr::Point<size_t>> instance_coords) {
/*input block coordinate should be within gsb coord range*/ /*check whether the preloaded value exceeds the limit */
VTR_ASSERT(block_coordinate.x() < sb_unique_module_id_.size()); VTR_ASSERT(block_coordinate.x() < sb_unique_module_id_.size());
VTR_ASSERT(block_coordinate.y() < sb_unique_module_id_[0].size()); VTR_ASSERT(block_coordinate.y() < sb_unique_module_id_[0].size());
sb_unique_module_.push_back(block_coordinate); sb_unique_module_.push_back(block_coordinate);
@ -650,6 +647,11 @@ void DeviceRRGSB::preload_unique_sb_module(
} }
} }
/*The following four functions will allow us to get
The map between (id,mirror instance coord), (id, unique block coord)
As the unique block and its mirror instances share the same id, we can get the
map between (unique block coord, mirror instance coord)
*/
void DeviceRRGSB::get_id_unique_sb_block_map( void DeviceRRGSB::get_id_unique_sb_block_map(
std::map<int, vtr::Point<size_t>>& id_unique_block_map) const { std::map<int, vtr::Point<size_t>>& id_unique_block_map) const {
for (size_t id = 0; id < get_num_sb_unique_module(); ++id) { for (size_t id = 0; id < get_num_sb_unique_module(); ++id) {

View File

@ -494,7 +494,7 @@ int read_unique_blocks_template(T& openfpga_ctx, const Command& cmd,
std::string file_name = cmd_context.option_value(cmd, opt_file); std::string file_name = cmd_context.option_value(cmd, opt_file);
std::string file_type = cmd_context.option_value(cmd, opt_type); std::string file_type = cmd_context.option_value(cmd, opt_type);
/* Write hierarchy to a file */ /* read unique blocks from a file */
if (file_type == "xml") { if (file_type == "xml") {
return read_xml_unique_blocks(openfpga_ctx, file_name.c_str(), return read_xml_unique_blocks(openfpga_ctx, file_name.c_str(),
file_type.c_str(), file_type.c_str(),
@ -521,7 +521,7 @@ int write_unique_blocks_template(T& openfpga_ctx, const Command& cmd,
std::string file_name = cmd_context.option_value(cmd, opt_file); std::string file_name = cmd_context.option_value(cmd, opt_file);
std::string file_type = cmd_context.option_value(cmd, opt_type); std::string file_type = cmd_context.option_value(cmd, opt_type);
/* Write hierarchy to a file */ /* Write unique blocks to a file */
return write_xml_unique_blocks(openfpga_ctx, file_name.c_str(), return write_xml_unique_blocks(openfpga_ctx, file_name.c_str(),
file_type.c_str(), file_type.c_str(),
cmd_context.option_enable(cmd, opt_verbose)); cmd_context.option_enable(cmd, opt_verbose));

View File

@ -2,9 +2,11 @@
#define READ_WRITE_XML_UNIQUE_BLOCKS_H #define READ_WRITE_XML_UNIQUE_BLOCKS_H
/******************************************************************** /********************************************************************
* This file includes the top-level function of this library * This file includes the top-level functions of this library
* which reads an XML of unique routing blocks to the associated * which includes:
* data structures device_rr_gsb * -- reads an XML file of unique blocks to the associated
* data structures: device_rr_gsb
* -- write device__rr_gsb's info about unique blocks to a xml file
*******************************************************************/ *******************************************************************/
#include <string> #include <string>
@ -32,7 +34,7 @@
/******************************************************************** /********************************************************************
* Parse XML codes of a <instance> to an object of device_rr_gsb * Parse XML codes of a <instance> to an object of device_rr_gsb
* instance is the mirror module of unique module. * instance is the mirror of unique module.
*******************************************************************/ *******************************************************************/
vtr::Point<size_t> read_xml_unique_instance_info( vtr::Point<size_t> read_xml_unique_instance_info(
pugi::xml_node& xml_instance_info, const pugiutil::loc_data& loc_data) { pugi::xml_node& xml_instance_info, const pugiutil::loc_data& loc_data) {
@ -157,7 +159,7 @@ int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name,
/* get device_rr_gsb data type and initialize it*/ /* get device_rr_gsb data type and initialize it*/
openfpga::DeviceRRGSB& device_rr_gsb = openfpga_ctx.mutable_device_rr_gsb(); openfpga::DeviceRRGSB& device_rr_gsb = openfpga_ctx.mutable_device_rr_gsb();
/* clear unique modules */ /* clear unique modules & reserve memory to relavant vectors */
device_rr_gsb.clear_unique_modules(); device_rr_gsb.clear_unique_modules();
vtr::Point<size_t> grid_coord(g_vpr_ctx.device().grid.width() - 1, vtr::Point<size_t> grid_coord(g_vpr_ctx.device().grid.width() - 1,
g_vpr_ctx.device().grid.height() - 1); g_vpr_ctx.device().grid.height() - 1);
@ -179,8 +181,7 @@ int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name,
instance_coords.push_back(instance_coordinate); instance_coords.push_back(instance_coordinate);
} }
} }
/* get block coordinate and instance coordinate, try to setup device rr /* get block coordinate and instance coordinate, try to setup device_rr_gsb */
* gsb */
if (type == "sb") { if (type == "sb") {
device_rr_gsb.preload_unique_sb_module(block_coordinate, device_rr_gsb.preload_unique_sb_module(block_coordinate,
instance_coords); instance_coords);
@ -198,6 +199,7 @@ int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name,
return 1; return 1;
} }
} }
/* As preloading gsb hasn't been developed, we should build gsb using the preloaded cbs and sbs*/
device_rr_gsb.build_gsb_unique_module(); device_rr_gsb.build_gsb_unique_module();
if (verbose_output) { if (verbose_output) {
report_unique_module_status_read(openfpga_ctx, true); report_unique_module_status_read(openfpga_ctx, true);