From fa675173493a7ff153842f578ec86e600a2b863b Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sat, 16 Jan 2021 18:49:34 -0700 Subject: [PATCH] [Tool] Add repack design constraints to openfpga command 'repack' --- openfpga/src/base/openfpga_bitstream_command.cpp | 3 +++ openfpga/src/base/openfpga_repack.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/openfpga/src/base/openfpga_bitstream_command.cpp b/openfpga/src/base/openfpga_bitstream_command.cpp index fef8dca89..6b7397a1c 100644 --- a/openfpga/src/base/openfpga_bitstream_command.cpp +++ b/openfpga/src/base/openfpga_bitstream_command.cpp @@ -21,6 +21,9 @@ ShellCommandId add_openfpga_repack_command(openfpga::Shell& she const ShellCommandClassId& cmd_class_id, const std::vector& dependent_cmds) { Command shell_cmd("repack"); + /* Add an option '--design_constraints' */ + CommandOptionId opt_design_constraints = shell_cmd.add_option("design_constraints", false, "file path to the design constraints"); + shell_cmd.set_option_require_value(opt_design_constraints, openfpga::OPT_STRING); /* Add an option '--verbose' */ shell_cmd.add_option("verbose", false, "Enable verbose output"); diff --git a/openfpga/src/base/openfpga_repack.cpp b/openfpga/src/base/openfpga_repack.cpp index a0fd143f4..b5a6d8a9a 100644 --- a/openfpga/src/base/openfpga_repack.cpp +++ b/openfpga/src/base/openfpga_repack.cpp @@ -8,10 +8,15 @@ /* Headers from openfpgashell library */ #include "command_exit_codes.h" +/* Headers from librepackdc library */ +#include "repack_design_constraints.h" +#include "read_xml_repack_design_constraints.h" + #include "build_physical_truth_table.h" #include "repack.h" #include "openfpga_repack.h" + /* Include global variables of VPR */ #include "globals.h" @@ -24,8 +29,17 @@ namespace openfpga { int repack(OpenfpgaContext& openfpga_ctx, const Command& cmd, const CommandContext& cmd_context) { + CommandOptionId opt_design_constraints = cmd.option("design_constraints"); CommandOptionId opt_verbose = cmd.option("verbose"); + /* Load design constraints from file */ + RepackDesignConstraints repack_design_constraints; + if (true == cmd_context.option_enable(cmd, opt_design_constraints)) { + std::string dc_fname = cmd_context.option_value(cmd, opt_design_constraints); + VTR_ASSERT(false == dc_fname.empty()); + repack_design_constraints = read_xml_repack_design_constraints(dc_fname.c_str()); + } + pack_physical_pbs(g_vpr_ctx.device(), g_vpr_ctx.atom(), g_vpr_ctx.clustering(),