From f26dbfe0805c31a2f7365508f8c1c0a47771d8c5 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Wed, 23 Oct 2019 20:24:52 -0600 Subject: [PATCH] add instance name for top-level modules to ease readability --- .../vpr/SRC/fpga_x2p/base/fpga_x2p_naming.cpp | 20 ++++++++++++++ .../vpr/SRC/fpga_x2p/base/fpga_x2p_naming.h | 6 +++++ .../module_builder/build_top_module.cpp | 26 ++++++++++++++++--- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/vpr7_x2p/vpr/SRC/fpga_x2p/base/fpga_x2p_naming.cpp b/vpr7_x2p/vpr/SRC/fpga_x2p/base/fpga_x2p_naming.cpp index 97f5068a9..43beec5a2 100644 --- a/vpr7_x2p/vpr/SRC/fpga_x2p/base/fpga_x2p_naming.cpp +++ b/vpr7_x2p/vpr/SRC/fpga_x2p/base/fpga_x2p_naming.cpp @@ -734,6 +734,26 @@ std::string generate_grid_block_module_name(const std::string& prefix, return module_name; } +/********************************************************************* + * Generate the instance name of a grid block + **********************************************************************/ +std::string generate_grid_block_instance_name(const std::string& prefix, + const std::string& block_name, + const bool& is_block_io, + const e_side& io_side, + const vtr::Point& grid_coord) { + std::string module_name(prefix); + + module_name += generate_grid_block_netlist_name(block_name, is_block_io, io_side, std::string()); + module_name += std::string("_"); + module_name += std::to_string(grid_coord.x()); + module_name += std::string("_"); + module_name += std::to_string(grid_coord.y()); + + return module_name; +} + + /********************************************************************* * Generate the module name of a physical block * To ensure a unique name for each physical block inside the graph of complex blocks diff --git a/vpr7_x2p/vpr/SRC/fpga_x2p/base/fpga_x2p_naming.h b/vpr7_x2p/vpr/SRC/fpga_x2p/base/fpga_x2p_naming.h index 6ab310f5c..a602dc4be 100644 --- a/vpr7_x2p/vpr/SRC/fpga_x2p/base/fpga_x2p_naming.h +++ b/vpr7_x2p/vpr/SRC/fpga_x2p/base/fpga_x2p_naming.h @@ -145,6 +145,12 @@ std::string generate_grid_block_module_name(const std::string& prefix, const bool& is_block_io, const e_side& io_side); +std::string generate_grid_block_instance_name(const std::string& prefix, + const std::string& block_name, + const bool& is_block_io, + const e_side& io_side, + const vtr::Point& grid_coord); + std::string generate_physical_block_module_name(const std::string& prefix, t_pb_type* physical_pb_type); diff --git a/vpr7_x2p/vpr/SRC/fpga_x2p/module_builder/build_top_module.cpp b/vpr7_x2p/vpr/SRC/fpga_x2p/module_builder/build_top_module.cpp index 032ccb90a..01af77409 100644 --- a/vpr7_x2p/vpr/SRC/fpga_x2p/module_builder/build_top_module.cpp +++ b/vpr7_x2p/vpr/SRC/fpga_x2p/module_builder/build_top_module.cpp @@ -92,7 +92,8 @@ static size_t add_top_module_grid_instance(ModuleManager& module_manager, const ModuleId& top_module, t_type_ptr grid_type, - const e_side& border_side) { + const e_side& border_side, + const vtr::Point& grid_coord) { /* Find the module name for this type of grid */ std::string grid_module_name_prefix(grid_verilog_file_name_prefix); std::string grid_module_name = generate_grid_block_module_name(grid_module_name_prefix, std::string(grid_type->name), IO_TYPE == grid_type, border_side); @@ -102,6 +103,11 @@ size_t add_top_module_grid_instance(ModuleManager& module_manager, size_t grid_instance = module_manager.num_instance(top_module, grid_module); /* Add the module to top_module */ module_manager.add_child_module(top_module, grid_module); + /* Set an unique name to the instance + * Note: it is your risk to gurantee the name is unique! + */ + std::string instance_name = generate_grid_block_instance_name(grid_module_name_prefix, std::string(grid_type->name), IO_TYPE == grid_type, border_side, grid_coord); + module_manager.set_child_instance_name(top_module, grid_module, grid_instance, instance_name); return grid_instance; } @@ -164,9 +170,10 @@ std::vector> add_top_module_grid_instances(ModuleManager& mo /* We should not meet any I/O grid */ VTR_ASSERT(IO_TYPE != grids[ix][iy].type); /* Add a grid module to top_module*/ + vtr::Point grid_coord(ix, iy); grid_instance_ids[ix][iy] = add_top_module_grid_instance(module_manager, top_module, grids[ix][iy].type, - NUM_SIDES); + NUM_SIDES, grid_coord); } } @@ -209,7 +216,7 @@ std::vector> add_top_module_grid_instances(ModuleManager& mo /* We should not meet any I/O grid */ VTR_ASSERT(IO_TYPE == grids[io_coordinate.x()][io_coordinate.y()].type); /* Add a grid module to top_module*/ - grid_instance_ids[io_coordinate.x()][io_coordinate.y()] = add_top_module_grid_instance(module_manager, top_module, grids[io_coordinate.x()][io_coordinate.y()].type, io_side); + grid_instance_ids[io_coordinate.x()][io_coordinate.y()] = add_top_module_grid_instance(module_manager, top_module, grids[io_coordinate.x()][io_coordinate.y()].type, io_side, io_coordinate); } } @@ -255,6 +262,12 @@ std::vector> add_top_module_switch_block_instances(ModuleMan sb_instance_ids[rr_gsb.get_sb_x()][rr_gsb.get_sb_y()] = module_manager.num_instance(top_module, sb_module); /* Add the module to top_module */ module_manager.add_child_module(top_module, sb_module); + /* Set an unique name to the instance + * Note: it is your risk to gurantee the name is unique! + */ + module_manager.set_child_instance_name(top_module, sb_module, + sb_instance_ids[rr_gsb.get_sb_x()][rr_gsb.get_sb_y()], + generate_switch_block_module_name(vtr::Point(rr_gsb.get_sb_x(), rr_gsb.get_sb_y()))); } } @@ -307,6 +320,13 @@ std::vector> add_top_module_connection_block_instances(Modul cb_instance_ids[rr_gsb.get_cb_x(cb_type)][rr_gsb.get_cb_y(cb_type)] = module_manager.num_instance(top_module, cb_module); /* Add the module to top_module */ module_manager.add_child_module(top_module, cb_module); + /* Set an unique name to the instance + * Note: it is your risk to gurantee the name is unique! + */ + module_manager.set_child_instance_name(top_module, cb_module, + cb_instance_ids[rr_gsb.get_cb_x(cb_type)][rr_gsb.get_cb_y(cb_type)], + generate_connection_block_module_name(cb_type, vtr::Point(rr_gsb.get_cb_x(cb_type), rr_gsb.get_cb_y(cb_type)))); + } }