diff --git a/libopenfpga/libfpgabitstream/src/report_arch_bitstream_distribution.cpp b/libopenfpga/libfpgabitstream/src/report_arch_bitstream_distribution.cpp
index b6bf66d96..b5237cda5 100644
--- a/libopenfpga/libfpgabitstream/src/report_arch_bitstream_distribution.cpp
+++ b/libopenfpga/libfpgabitstream/src/report_arch_bitstream_distribution.cpp
@@ -23,29 +23,6 @@
/* begin namespace openfpga */
namespace openfpga {
-/********************************************************************
- * This function write header information for an XML file of bitstream distribution
- *******************************************************************/
-static
-void report_architecture_bitstream_distribution_xml_file_head(std::fstream& fp,
- const bool& include_time_stamp) {
- valid_file_stream(fp);
-
- fp << " " << std::endl;
- fp << std::endl;
-}
-
/********************************************************************
* Recursively report the bitstream distribution of a block to a file
* This function will use a Depth-First Search in outputting bitstream
@@ -91,27 +68,19 @@ void rec_report_block_bitstream_distribution_to_xml_file(std::fstream& fp,
* Notes:
* - The output format is a table whose format is compatible with RST files
*******************************************************************/
-int report_architecture_bitstream_distribution(const BitstreamManager& bitstream_manager,
- const std::string& fname,
- const bool& include_time_stamp,
- const size_t& max_hierarchy_level) {
- /* Ensure that we have a valid file name */
- if (true == fname.empty()) {
- VTR_LOG_ERROR("Received empty file name to report bitstream!\n\tPlease specify a valid file name.\n");
- return 1;
- }
-
- std::string timer_message = std::string("Report architecture bitstream distribution into XML file '") + fname + std::string("'");
+int report_architecture_bitstream_distribution(std::fstream& fp,
+ const BitstreamManager& bitstream_manager,
+ const size_t& max_hierarchy_level,
+ const size_t& hierarchy_level) {
+ std::string timer_message = std::string("Report architecture bitstream distribution");
vtr::ScopedStartFinishTimer timer(timer_message);
- /* Create the file stream */
- std::fstream fp;
- fp.open(fname, std::fstream::out | std::fstream::trunc);
+ /* Check the file stream */
+ valid_file_stream(fp);
- check_file_stream(fname.c_str(), fp);
-
- /* Put down a brief introduction */
- report_architecture_bitstream_distribution_xml_file_head(fp, include_time_stamp);
+ int curr_level = hierarchy_level;
+ write_tab_to_file(fp, curr_level);
+ fp << "" < top_block = find_bitstream_manager_top_blocks(bitstream_manager);
@@ -119,10 +88,9 @@ int report_architecture_bitstream_distribution(const BitstreamManager& bitstream
VTR_ASSERT(1 == top_block.size());
/* Write bitstream, block by block, in a recursive way */
- rec_report_block_bitstream_distribution_to_xml_file(fp, bitstream_manager, top_block[0], max_hierarchy_level, 0);
+ rec_report_block_bitstream_distribution_to_xml_file(fp, bitstream_manager, top_block[0], max_hierarchy_level, curr_level + 1);
- /* Close file handler */
- fp.close();
+ fp << "" <
/* Headers from vtrutils */
#include "vtr_assert.h"
#include "vtr_log.h"
@@ -36,11 +37,12 @@ int main(int argc, const char** argv) {
* This is optional only used when there is a third argument
*/
if (4 <= argc) {
- openfpga::report_architecture_bitstream_distribution(test_bitstream, argv[3], true);
- VTR_LOG("Echo the bitstream distribution (with time stamp) to an XML file: %s.\n",
- argv[3]);
- openfpga::report_architecture_bitstream_distribution(test_bitstream, argv[3], false);
- VTR_LOG("Echo the bitstream distribution (w/o time stamp) to an XML file: %s.\n",
+ /* Create the file stream */
+ std::fstream fp;
+ fp.open(argv[3], std::fstream::out | std::fstream::trunc);
+
+ openfpga::report_architecture_bitstream_distribution(fp, test_bitstream, 1, 0);
+ VTR_LOG("Echo the bitstream distribution to an XML file: %s.\n",
argv[3]);
}
diff --git a/openfpga/src/base/openfpga_bitstream.cpp b/openfpga/src/base/openfpga_bitstream.cpp
index 43d9801b3..91362f55c 100644
--- a/openfpga/src/base/openfpga_bitstream.cpp
+++ b/openfpga/src/base/openfpga_bitstream.cpp
@@ -15,7 +15,7 @@
/* Headers from fpgabitstream library */
#include "read_xml_arch_bitstream.h"
#include "write_xml_arch_bitstream.h"
-#include "report_arch_bitstream_distribution.h"
+#include "report_bitstream_distribution.h"
#include "openfpga_naming.h"
@@ -218,10 +218,11 @@ int report_bitstream_distribution(const OpenfpgaContext& openfpga_ctx,
}
}
- status = report_architecture_bitstream_distribution(openfpga_ctx.bitstream_manager(),
- cmd_context.option_value(cmd, opt_file),
- !cmd_context.option_enable(cmd, opt_no_time_stamp),
- depth);
+ status = report_bitstream_distribution(cmd_context.option_value(cmd, opt_file),
+ openfpga_ctx.bitstream_manager(),
+ openfpga_ctx.fabric_bitstream(),
+ !cmd_context.option_enable(cmd, opt_no_time_stamp),
+ depth);
return status;
}
diff --git a/openfpga/src/fpga_bitstream/report_bitstream_distribution.cpp b/openfpga/src/fpga_bitstream/report_bitstream_distribution.cpp
new file mode 100644
index 000000000..3b3b14998
--- /dev/null
+++ b/openfpga/src/fpga_bitstream/report_bitstream_distribution.cpp
@@ -0,0 +1,96 @@
+/********************************************************************
+ * This file includes functions that report distribution of bitstream by regions
+ *******************************************************************/
+#include
+#include
+#include
+
+/* Headers from vtrutil library */
+#include "vtr_assert.h"
+#include "vtr_log.h"
+#include "vtr_time.h"
+
+/* Headers from openfpgautil library */
+#include "openfpga_digest.h"
+#include "openfpga_tokenizer.h"
+#include "openfpga_version.h"
+
+#include "openfpga_reserved_words.h"
+
+#include "report_arch_bitstream_distribution.h"
+#include "report_fabric_bitstream_distribution.h"
+#include "report_bitstream_distribution.h"
+
+/* begin namespace openfpga */
+namespace openfpga {
+
+/********************************************************************
+ * This function write header information for an XML file of bitstream distribution
+ *******************************************************************/
+static
+void report_bitstream_distribution_xml_file_head(std::fstream& fp,
+ const bool& include_time_stamp) {
+ valid_file_stream(fp);
+
+ fp << " " << std::endl;
+ fp << std::endl;
+}
+
+/********************************************************************
+ * Report the distribution of bitstream at architecture-level and fabric-level
+ * This function can generate a report to a file
+ *******************************************************************/
+int report_bitstream_distribution(const std::string& fname,
+ const BitstreamManager& bitstream_manager,
+ const FabricBitstream& fabric_bitstream,
+ const bool& include_time_stamp,
+ const size_t& max_hierarchy_level) {
+ /* Ensure that we have a valid file name */
+ if (true == fname.empty()) {
+ VTR_LOG_ERROR("Received empty file name to report bitstream!\n\tPlease specify a valid file name.\n");
+ return 1;
+ }
+
+ std::string timer_message = std::string("Report bitstream distribution into XML file '") + fname + std::string("'");
+ vtr::ScopedStartFinishTimer timer(timer_message);
+
+ /* Create the file stream */
+ std::fstream fp;
+ fp.open(fname, std::fstream::out | std::fstream::trunc);
+
+ check_file_stream(fname.c_str(), fp);
+
+ /* Put down a brief introduction */
+ report_bitstream_distribution_xml_file_head(fp, include_time_stamp);
+
+ int curr_level = 0;
+ write_tab_to_file(fp, curr_level);
+ fp << "" <" <
+#include "fabric_bitstream.h"
+
+/********************************************************************
+ * Function declaration
+ *******************************************************************/
+
+/* begin namespace openfpga */
+namespace openfpga {
+
+int report_bitstream_distribution(const std::string& fname,
+ const BitstreamManager& bitstream_manager,
+ const FabricBitstream& fabric_bitstream,
+ const bool& include_time_stamp,
+ const size_t& max_hierarchy_level = 1);
+
+} /* end namespace openfpga */
+
+#endif
diff --git a/openfpga/src/fpga_bitstream/report_fabric_bitstream_distribution.cpp b/openfpga/src/fpga_bitstream/report_fabric_bitstream_distribution.cpp
new file mode 100644
index 000000000..87f81df10
--- /dev/null
+++ b/openfpga/src/fpga_bitstream/report_fabric_bitstream_distribution.cpp
@@ -0,0 +1,78 @@
+/********************************************************************
+ * This file includes functions that report distribution of bitstream by regions
+ *******************************************************************/
+#include
+#include
+#include
+
+/* Headers from vtrutil library */
+#include "vtr_assert.h"
+#include "vtr_log.h"
+#include "vtr_time.h"
+
+/* Headers from openfpgautil library */
+#include "openfpga_digest.h"
+#include "openfpga_tokenizer.h"
+#include "openfpga_version.h"
+
+#include "openfpga_reserved_words.h"
+
+#include "bitstream_manager_utils.h"
+#include "report_fabric_bitstream_distribution.h"
+
+/* begin namespace openfpga */
+namespace openfpga {
+
+/********************************************************************
+ * Recursively report the bitstream distribution of a block to a file
+ * This function will use a Depth-First Search in outputting bitstream
+ * for each block
+ * For block with child blocks, we visit each child recursively
+ * The reporting can be stopped at a given maximum hierarchy level
+ * which is used to limit the length of the report
+ *******************************************************************/
+static
+void report_region_bitstream_distribution_to_xml_file(std::fstream& fp,
+ const FabricBitstream& fabric_bitstream,
+ const FabricBitRegionId& region,
+ const int& hierarchy_level) {
+ valid_file_stream(fp);
+
+ /* Write the bitstream distribution of this block */
+ write_tab_to_file(fp, hierarchy_level);
+ fp << "" << std::endl;
+
+ write_tab_to_file(fp, hierarchy_level);
+ fp << "" <" <" <
+#include "fabric_bitstream.h"
+
+/********************************************************************
+ * Function declaration
+ *******************************************************************/
+
+/* begin namespace openfpga */
+namespace openfpga {
+
+int report_fabric_bitstream_distribution(std::fstream& fp,
+ const FabricBitstream& fabric_bitstream,
+ const int& hierarchy_level);
+
+} /* end namespace openfpga */
+
+#endif