From 13fadd0f910adf89bc99be90fcbfcce72260035b Mon Sep 17 00:00:00 2001 From: tangxifan Date: Wed, 12 Feb 2020 15:49:47 -0700 Subject: [PATCH] move compact routing hierarchy to build_fabric command --- ...ierarchy.cpp => openfpga_build_fabric.cpp} | 29 ++++++++++++++----- ...ng_hierarchy.h => openfpga_build_fabric.h} | 8 ++--- openfpga/src/base/openfpga_setup_command.cpp | 22 +++++++------- openfpga/test_script/s298_k6_frac.openfpga | 10 ++++--- 4 files changed, 44 insertions(+), 25 deletions(-) rename openfpga/src/base/{compact_routing_hierarchy.cpp => openfpga_build_fabric.cpp} (77%) rename openfpga/src/base/{compact_routing_hierarchy.h => openfpga_build_fabric.h} (70%) diff --git a/openfpga/src/base/compact_routing_hierarchy.cpp b/openfpga/src/base/openfpga_build_fabric.cpp similarity index 77% rename from openfpga/src/base/compact_routing_hierarchy.cpp rename to openfpga/src/base/openfpga_build_fabric.cpp index e520b5e3f..4671f3169 100644 --- a/openfpga/src/base/compact_routing_hierarchy.cpp +++ b/openfpga/src/base/openfpga_build_fabric.cpp @@ -7,7 +7,8 @@ #include "device_rr_gsb.h" #include "device_rr_gsb_utils.h" -#include "compact_routing_hierarchy.h" +//#include "build_device_module.h" +#include "openfpga_build_fabric.h" /* Include global variables of VPR */ #include "globals.h" @@ -19,17 +20,14 @@ namespace openfpga { * Identify the unique GSBs from the Device RR GSB arrays * This function should only be called after the GSB builder is done *******************************************************************/ -void compact_routing_hierarchy(OpenfpgaContext& openfpga_context, - const Command& cmd, const CommandContext& cmd_context) { +static +void compress_routing_hierarchy(OpenfpgaContext& openfpga_context, + const bool& verbose_output) { vtr::ScopedStartFinishTimer timer("Identify unique General Switch Blocks (GSBs)"); - CommandOptionId opt_verbose = cmd.option("verbose"); - /* Build unique module lists */ openfpga_context.mutable_device_rr_gsb().build_unique_module(g_vpr_ctx.device().rr_graph); - bool verbose_output = cmd_context.option_enable(cmd, opt_verbose); - /* Report the stats */ VTR_LOGV(verbose_output, "Detected %lu unique X-direction connection blocks from a total of %d (compression rate=%d%)\n", @@ -54,7 +52,24 @@ void compact_routing_hierarchy(OpenfpgaContext& openfpga_context, openfpga_context.device_rr_gsb().get_num_gsb_unique_module(), find_device_rr_gsb_num_gsb_modules(openfpga_context.device_rr_gsb()), 100 * (openfpga_context.device_rr_gsb().get_num_gsb_unique_module() / find_device_rr_gsb_num_gsb_modules(openfpga_context.device_rr_gsb()) - 1)); +} +/******************************************************************** + * Build the module graph for FPGA device + *******************************************************************/ +void build_fabric(OpenfpgaContext& openfpga_context, + const Command& cmd, const CommandContext& cmd_context) { + + CommandOptionId opt_compress_routing = cmd.option("compress_routing"); + CommandOptionId opt_verbose = cmd.option("verbose"); + + if (true == cmd_context.option_enable(cmd, opt_compress_routing)) { + compress_routing_hierarchy(openfpga_context, cmd_context.option_enable(cmd, opt_verbose)); + } + + /* + openfpga_context.mutable_module_graph() = build_device_module_graph(); + */ } } /* end namespace openfpga */ diff --git a/openfpga/src/base/compact_routing_hierarchy.h b/openfpga/src/base/openfpga_build_fabric.h similarity index 70% rename from openfpga/src/base/compact_routing_hierarchy.h rename to openfpga/src/base/openfpga_build_fabric.h index bd3eeefe2..44aa3632c 100644 --- a/openfpga/src/base/compact_routing_hierarchy.h +++ b/openfpga/src/base/openfpga_build_fabric.h @@ -1,5 +1,5 @@ -#ifndef COMPACT_ROUTING_HIERARCHY_H -#define COMPACT_ROUTING_HIERARCHY_H +#ifndef OPENFPGA_BUILD_FABRIC_H +#define OPENFPGA_BUILD_FABRIC_H /******************************************************************** * Include header files that are required by function declaration @@ -15,8 +15,8 @@ /* begin namespace openfpga */ namespace openfpga { -void compact_routing_hierarchy(OpenfpgaContext& openfpga_context, - const Command& cmd, const CommandContext& cmd_context); +void build_fabric(OpenfpgaContext& openfpga_context, + const Command& cmd, const CommandContext& cmd_context); } /* end namespace openfpga */ diff --git a/openfpga/src/base/openfpga_setup_command.cpp b/openfpga/src/base/openfpga_setup_command.cpp index e992875bd..1b6971167 100644 --- a/openfpga/src/base/openfpga_setup_command.cpp +++ b/openfpga/src/base/openfpga_setup_command.cpp @@ -8,7 +8,7 @@ #include "openfpga_pb_pin_fixup.h" #include "openfpga_lut_truth_table_fixup.h" #include "check_netlist_naming_conflict.h" -#include "compact_routing_hierarchy.h" +#include "openfpga_build_fabric.h" #include "openfpga_setup_command.h" /* begin namespace openfpga */ @@ -121,20 +121,22 @@ void add_openfpga_setup_commands(openfpga::Shell& shell) { shell.set_command_dependency(shell_cmd_lut_truth_table_fixup_id, cmd_dependency_lut_truth_table_fixup); /******************************** - * Command 'compact_routing_hierarchy' + * Command 'build_fabric' */ - Command shell_cmd_compact_routing_hierarchy("compact_routing_hierarchy"); + Command shell_cmd_build_fabric("build_fabric"); /* Add an option '--verbose' */ - shell_cmd_compact_routing_hierarchy.add_option("verbose", false, "Show verbose outputs"); + shell_cmd_build_fabric.add_option("compress_routing", false, "Compress the number of unique routing modules by identifying the unique GSBs"); + shell_cmd_build_fabric.add_option("duplicate_grid_pin", false, "Duplicate the pins on the same side of a grid"); + shell_cmd_build_fabric.add_option("verbose", false, "Show verbose outputs"); /* Add command 'compact_routing_hierarchy' to the Shell */ - ShellCommandId shell_cmd_compact_routing_hierarchy_id = shell.add_command(shell_cmd_compact_routing_hierarchy, "Identify the unique GSBs in the routing architecture so that the routing hierarchy of fabric can be compressed"); - shell.set_command_class(shell_cmd_compact_routing_hierarchy_id, openfpga_setup_cmd_class); - shell.set_command_execute_function(shell_cmd_compact_routing_hierarchy_id, compact_routing_hierarchy); - /* The 'compact_routing_hierarchy' command should NOT be executed before 'link_openfpga_arch' */ - std::vector cmd_dependency_compact_routing_hierarchy; + ShellCommandId shell_cmd_build_fabric_id = shell.add_command(shell_cmd_build_fabric, "Build the FPGA fabric in a graph of modules"); + shell.set_command_class(shell_cmd_build_fabric_id, openfpga_setup_cmd_class); + shell.set_command_execute_function(shell_cmd_build_fabric_id, build_fabric); + /* The 'build_fabric' command should NOT be executed before 'link_openfpga_arch' */ + std::vector cmd_dependency_build_fabric; cmd_dependency_lut_truth_table_fixup.push_back(shell_cmd_link_openfpga_arch_id); - shell.set_command_dependency(shell_cmd_compact_routing_hierarchy_id, cmd_dependency_compact_routing_hierarchy); + shell.set_command_dependency(shell_cmd_build_fabric_id, cmd_dependency_build_fabric); } } /* end namespace openfpga */ diff --git a/openfpga/test_script/s298_k6_frac.openfpga b/openfpga/test_script/s298_k6_frac.openfpga index dd87c77df..9d4edcced 100644 --- a/openfpga/test_script/s298_k6_frac.openfpga +++ b/openfpga/test_script/s298_k6_frac.openfpga @@ -11,13 +11,15 @@ link_openfpga_arch check_netlist_naming_conflict --fix --report ./netlist_renaming.xml # Apply fix-up to clustering nets based on routing results -pb_pin_fixup --verbose +pb_pin_fixup #--verbose # Apply fix-up to Look-Up Table truth tables based on packing results -lut_truth_table_fixup --verbose +lut_truth_table_fixup #--verbose -# Compress the routing hierarchy -compact_routing_hierarchy --verbose +# Build the module graph +# - Enabled compression on routing architecture modules +# - Enable pin duplication on grid modules +build_fabric --compress_routing --duplicate_grid_pin --verbose # Finish and exit OpenFPGA exit