From 699131ad58c38007b1425f7a5016d94c80644b02 Mon Sep 17 00:00:00 2001 From: Lin Date: Mon, 19 Aug 2024 01:18:06 -0700 Subject: [PATCH] full flow with bugs --- openfpga/src/annotation/device_rr_gsb.cpp | 19 +++++++++++++------ openfpga/src/annotation/device_rr_gsb.h | 2 +- .../src/base/openfpga_build_fabric_template.h | 12 +++++++++--- .../base/openfpga_setup_command_template.h | 4 ++++ openfpga/src/fabric/read_xml_unique_blocks.h | 3 ++- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/openfpga/src/annotation/device_rr_gsb.cpp b/openfpga/src/annotation/device_rr_gsb.cpp index 5831c3638..dc6c2b397 100644 --- a/openfpga/src/annotation/device_rr_gsb.cpp +++ b/openfpga/src/annotation/device_rr_gsb.cpp @@ -421,6 +421,19 @@ void DeviceRRGSB::clear() { clear_sb_unique_module_id(); } +void DeviceRRGSB::clear_unique_modules(){ + /* clean unique module lists */ + clear_cb_unique_module(CHANX); + clear_cb_unique_module_id(CHANX); + + clear_cb_unique_module(CHANY); + clear_cb_unique_module_id(CHANY); + + clear_sb_unique_module(); + clear_sb_unique_module_id(); +} + + void DeviceRRGSB::clear_gsb() { /* clean gsb array */ for (size_t x = 0; x < rr_gsb_.size(); ++x) { @@ -572,18 +585,15 @@ void DeviceRRGSB::preload_unique_cb_module( switch (cb_type) { case CHANX: limit_x = cbx_unique_module_id_.size(); - limit_y = cbx_unique_module_id_[0].size(); break; case CHANY: limit_x = cby_unique_module_id_.size(); - limit_y = cby_unique_module_id_[0].size(); break; default: VTR_LOG_ERROR("Invalid type"); } VTR_ASSERT(block_coordinate.x() < limit_x); - VTR_ASSERT(block_coordinate.y() < limit_y); add_cb_unique_module(cb_type, block_coordinate); /* Record the id of unique mirror */ set_cb_unique_module_id(cb_type, block_coordinate, @@ -593,7 +603,6 @@ void DeviceRRGSB::preload_unique_cb_module( for (auto instance_location : instance_coords) { /* Record the id of unique mirror */ VTR_ASSERT(instance_location.x() < limit_x); - VTR_ASSERT(instance_location.y() < limit_y); set_cb_unique_module_id( cb_type, instance_location, cbx_unique_module_id_[block_coordinate.x()][block_coordinate.y()]); @@ -605,7 +614,6 @@ void DeviceRRGSB::preload_unique_sb_module( const std::vector> instance_coords) { /*input block coordinate should be within gsb coord range*/ VTR_ASSERT(block_coordinate.x() < sb_unique_module_id_.size()); - VTR_ASSERT(block_coordinate.y() < sb_unique_module_id_[0].size()); sb_unique_module_.push_back(block_coordinate); /* Record the id of unique module */ sb_unique_module_id_[block_coordinate.x()][block_coordinate.y()] = @@ -615,7 +623,6 @@ void DeviceRRGSB::preload_unique_sb_module( * the unique module */ for (auto instance_location : instance_coords) { VTR_ASSERT(instance_location.x() < sb_unique_module_id_.size()); - VTR_ASSERT(instance_location.y() < sb_unique_module_id_[0].size()); sb_unique_module_id_[instance_location.x()][instance_location.y()] = sb_unique_module_id_[block_coordinate.x()][block_coordinate.y()]; } diff --git a/openfpga/src/annotation/device_rr_gsb.h b/openfpga/src/annotation/device_rr_gsb.h index 513d4b003..699119f63 100644 --- a/openfpga/src/annotation/device_rr_gsb.h +++ b/openfpga/src/annotation/device_rr_gsb.h @@ -102,7 +102,7 @@ class DeviceRRGSB { void preload_unique_sb_module( const vtr::Point block_coordinate, const std::vector> instance_coords); - + void clear_unique_modules(); void get_id_sb_instance_map( std::map>>& id_instance_map) const; void get_id_unique_sb_block_map( diff --git a/openfpga/src/base/openfpga_build_fabric_template.h b/openfpga/src/base/openfpga_build_fabric_template.h index 0e16efc74..259e74569 100644 --- a/openfpga/src/base/openfpga_build_fabric_template.h +++ b/openfpga/src/base/openfpga_build_fabric_template.h @@ -101,6 +101,7 @@ int build_fabric_template(T& openfpga_ctx, const Command& cmd, const CommandContext& cmd_context) { CommandOptionId opt_frame_view = cmd.option("frame_view"); CommandOptionId opt_compress_routing = cmd.option("compress_routing"); + CommandOptionId opt_preload = cmd.option("preload"); CommandOptionId opt_duplicate_grid_pin = cmd.option("duplicate_grid_pin"); CommandOptionId opt_gen_random_fabric_key = cmd.option("generate_random_fabric_key"); @@ -143,13 +144,18 @@ int build_fabric_template(T& openfpga_ctx, const Command& cmd, } } - if (true == cmd_context.option_enable(cmd, opt_compress_routing)) { + if (true == cmd_context.option_enable(cmd, opt_compress_routing) && + false == cmd_context.option_enable(cmd, opt_preload)) { compress_routing_hierarchy_template( openfpga_ctx, cmd_context.option_enable(cmd, opt_verbose)); /* Update flow manager to enable compress routing */ openfpga_ctx.mutable_flow_manager().set_compress_routing(true); } + if (cmd_context.option_enable(cmd, opt_preload)){ + openfpga_ctx.mutable_flow_manager().set_compress_routing(true); + } + VTR_LOG("\n"); /* Record the execution status in curr_status for each command @@ -518,8 +524,8 @@ int write_unique_blocks_template(T& openfpga_ctx, const Command& cmd, /* Write hierarchy to a file */ return write_xml_unique_blocks(openfpga_ctx, file_name.c_str(), - file_type.c_str(), - cmd_context.option_enable(cmd, opt_verbose)); + file_type.c_str(), + cmd_context.option_enable(cmd, opt_verbose)); } } /* end namespace openfpga */ diff --git a/openfpga/src/base/openfpga_setup_command_template.h b/openfpga/src/base/openfpga_setup_command_template.h index 01e2f78cb..9d2631a61 100644 --- a/openfpga/src/base/openfpga_setup_command_template.h +++ b/openfpga/src/base/openfpga_setup_command_template.h @@ -391,6 +391,10 @@ ShellCommandId add_build_fabric_command_template( "Compress the number of unique routing modules by " "identifying the unique GSBs"); + /* Add an option '--preload' */ + shell_cmd.add_option("preload", false, + "preload unique routing modules from user input xml file"); + /* Add an option '--duplicate_grid_pin' */ shell_cmd.add_option("duplicate_grid_pin", false, "Duplicate the pins on the same side of a grid"); diff --git a/openfpga/src/fabric/read_xml_unique_blocks.h b/openfpga/src/fabric/read_xml_unique_blocks.h index 395f44afd..e132828de 100644 --- a/openfpga/src/fabric/read_xml_unique_blocks.h +++ b/openfpga/src/fabric/read_xml_unique_blocks.h @@ -111,7 +111,8 @@ int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name, /* get device_rr_gsb data type and initialize it*/ openfpga::DeviceRRGSB& device_rr_gsb = openfpga_ctx.mutable_device_rr_gsb(); - device_rr_gsb.clear(); + /* clear unique modules */ + device_rr_gsb.clear_unique_modules(); /* load unique blocks xml file and set up device_rr_gdb */ for (pugi::xml_node xml_block_info : xml_root.children()) {