From 5a8c05378e300970b300f985708de0bbc0c6ecbf Mon Sep 17 00:00:00 2001 From: tangxifan Date: Tue, 5 May 2020 16:40:41 -0600 Subject: [PATCH] add --depth option to fabric hierarchy writer --- openfpga/src/base/openfpga_build_fabric.cpp | 14 ++++++++++++++ openfpga/src/base/openfpga_setup_command.cpp | 4 ++++ .../src/fabric/fabric_hierarchy_writer.cpp | 19 ++++++++++++++++--- openfpga/src/fabric/fabric_hierarchy_writer.h | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/openfpga/src/base/openfpga_build_fabric.cpp b/openfpga/src/base/openfpga_build_fabric.cpp index e013ab267..708bef124 100644 --- a/openfpga/src/base/openfpga_build_fabric.cpp +++ b/openfpga/src/base/openfpga_build_fabric.cpp @@ -102,11 +102,25 @@ int write_fabric_hierarchy(const OpenfpgaContext& openfpga_ctx, VTR_ASSERT(true == cmd_context.option_enable(cmd, opt_file)); VTR_ASSERT(false == cmd_context.option_value(cmd, opt_file).empty()); + /* Default depth requirement, will not stop until the leaf */ + int depth = -1; + CommandOptionId opt_depth = cmd.option("depth"); + if (true == cmd_context.option_enable(cmd, opt_depth)) { + depth = std::atoi(cmd_context.option_value(cmd, opt_depth).c_str()); + /* Error out if we have negative depth */ + if (0 > depth) { + VTR_LOG_ERROR("Invalid depth '%d' which should be 0 or a positive number!\n", + depth); + return CMD_EXEC_FATAL_ERROR; + } + } + std::string hie_file_name = cmd_context.option_value(cmd, opt_file); /* Write hierarchy to a file */ return write_fabric_hierarchy_to_text_file(openfpga_ctx.module_graph(), hie_file_name, + size_t(depth), cmd_context.option_enable(cmd, opt_verbose)); } diff --git a/openfpga/src/base/openfpga_setup_command.cpp b/openfpga/src/base/openfpga_setup_command.cpp index 2a3b11227..8af22e7da 100644 --- a/openfpga/src/base/openfpga_setup_command.cpp +++ b/openfpga/src/base/openfpga_setup_command.cpp @@ -255,6 +255,10 @@ ShellCommandId add_openfpga_write_fabric_hierarchy_command(openfpga::Shell