2020-02-11 18:40:37 -06:00
|
|
|
/********************************************************************
|
|
|
|
* This file includes functions to compress the hierachy of routing architecture
|
|
|
|
*******************************************************************/
|
|
|
|
/* Headers from vtrutil library */
|
|
|
|
#include "vtr_time.h"
|
|
|
|
#include "vtr_log.h"
|
|
|
|
|
|
|
|
#include "device_rr_gsb.h"
|
|
|
|
#include "device_rr_gsb_utils.h"
|
2020-02-12 18:53:23 -06:00
|
|
|
#include "build_device_module.h"
|
2020-02-12 16:49:47 -06:00
|
|
|
#include "openfpga_build_fabric.h"
|
2020-02-11 18:40:37 -06:00
|
|
|
|
|
|
|
/* Include global variables of VPR */
|
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
/* begin namespace openfpga */
|
|
|
|
namespace openfpga {
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* Identify the unique GSBs from the Device RR GSB arrays
|
|
|
|
* This function should only be called after the GSB builder is done
|
|
|
|
*******************************************************************/
|
2020-02-12 16:49:47 -06:00
|
|
|
static
|
2020-02-26 20:58:18 -06:00
|
|
|
void compress_routing_hierarchy(OpenfpgaContext& openfpga_ctx,
|
2020-02-12 16:49:47 -06:00
|
|
|
const bool& verbose_output) {
|
2020-02-11 18:40:37 -06:00
|
|
|
vtr::ScopedStartFinishTimer timer("Identify unique General Switch Blocks (GSBs)");
|
|
|
|
|
|
|
|
/* Build unique module lists */
|
2020-02-26 20:58:18 -06:00
|
|
|
openfpga_ctx.mutable_device_rr_gsb().build_unique_module(g_vpr_ctx.device().rr_graph);
|
2020-02-11 18:40:37 -06:00
|
|
|
|
|
|
|
/* Report the stats */
|
|
|
|
VTR_LOGV(verbose_output,
|
2020-03-21 19:07:00 -05:00
|
|
|
"Detected %lu unique X-direction connection blocks from a total of %d (compression rate=%.2f%)\n",
|
2020-02-26 20:58:18 -06:00
|
|
|
openfpga_ctx.device_rr_gsb().get_num_cb_unique_module(CHANX),
|
|
|
|
find_device_rr_gsb_num_cb_modules(openfpga_ctx.device_rr_gsb(), CHANX),
|
2020-03-22 17:13:04 -05:00
|
|
|
100. * ((float)find_device_rr_gsb_num_cb_modules(openfpga_ctx.device_rr_gsb(), CHANX) / (float)openfpga_ctx.device_rr_gsb().get_num_cb_unique_module(CHANX) - 1.));
|
2020-02-11 18:40:37 -06:00
|
|
|
|
|
|
|
VTR_LOGV(verbose_output,
|
2020-03-21 19:07:00 -05:00
|
|
|
"Detected %lu unique Y-direction connection blocks from a total of %d (compression rate=%.2f%)\n",
|
2020-02-26 20:58:18 -06:00
|
|
|
openfpga_ctx.device_rr_gsb().get_num_cb_unique_module(CHANY),
|
|
|
|
find_device_rr_gsb_num_cb_modules(openfpga_ctx.device_rr_gsb(), CHANY),
|
2020-03-22 17:13:04 -05:00
|
|
|
100. * ((float)find_device_rr_gsb_num_cb_modules(openfpga_ctx.device_rr_gsb(), CHANY) / (float)openfpga_ctx.device_rr_gsb().get_num_cb_unique_module(CHANY) - 1.));
|
2020-02-11 18:40:37 -06:00
|
|
|
|
|
|
|
VTR_LOGV(verbose_output,
|
2020-03-21 19:07:00 -05:00
|
|
|
"Detected %lu unique switch blocks from a total of %d (compression rate=%.2f%)\n",
|
2020-02-26 20:58:18 -06:00
|
|
|
openfpga_ctx.device_rr_gsb().get_num_sb_unique_module(),
|
|
|
|
find_device_rr_gsb_num_sb_modules(openfpga_ctx.device_rr_gsb()),
|
2020-03-22 17:13:04 -05:00
|
|
|
100. * ((float)find_device_rr_gsb_num_sb_modules(openfpga_ctx.device_rr_gsb()) / (float)openfpga_ctx.device_rr_gsb().get_num_sb_unique_module() - 1.));
|
2020-02-11 18:40:37 -06:00
|
|
|
|
2020-03-21 19:07:00 -05:00
|
|
|
VTR_LOG("Detected %lu unique general switch blocks from a total of %d (compression rate=%.2f%)\n",
|
|
|
|
openfpga_ctx.device_rr_gsb().get_num_gsb_unique_module(),
|
|
|
|
find_device_rr_gsb_num_gsb_modules(openfpga_ctx.device_rr_gsb()),
|
2020-03-22 17:13:04 -05:00
|
|
|
100. * ((float)find_device_rr_gsb_num_gsb_modules(openfpga_ctx.device_rr_gsb()) / (float)openfpga_ctx.device_rr_gsb().get_num_gsb_unique_module() - 1.));
|
2020-02-12 16:49:47 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* Build the module graph for FPGA device
|
|
|
|
*******************************************************************/
|
2020-02-26 20:58:18 -06:00
|
|
|
void build_fabric(OpenfpgaContext& openfpga_ctx,
|
2020-02-12 16:49:47 -06:00
|
|
|
const Command& cmd, const CommandContext& cmd_context) {
|
|
|
|
|
|
|
|
CommandOptionId opt_compress_routing = cmd.option("compress_routing");
|
2020-02-13 16:27:16 -06:00
|
|
|
CommandOptionId opt_duplicate_grid_pin = cmd.option("duplicate_grid_pin");
|
2020-02-12 16:49:47 -06:00
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
|
|
|
|
|
|
|
if (true == cmd_context.option_enable(cmd, opt_compress_routing)) {
|
2020-02-26 20:58:18 -06:00
|
|
|
compress_routing_hierarchy(openfpga_ctx, cmd_context.option_enable(cmd, opt_verbose));
|
2020-03-22 16:26:15 -05:00
|
|
|
/* Update flow manager to enable compress routing */
|
|
|
|
openfpga_ctx.mutable_flow_manager().set_compress_routing(true);
|
2020-02-12 16:49:47 -06:00
|
|
|
}
|
2020-02-11 18:40:37 -06:00
|
|
|
|
2020-02-12 18:53:23 -06:00
|
|
|
VTR_LOG("\n");
|
|
|
|
|
2020-02-26 20:58:18 -06:00
|
|
|
openfpga_ctx.mutable_module_graph() = build_device_module_graph(openfpga_ctx.mutable_io_location_map(),
|
|
|
|
g_vpr_ctx.device(),
|
|
|
|
const_cast<const OpenfpgaContext&>(openfpga_ctx),
|
|
|
|
cmd_context.option_enable(cmd, opt_compress_routing),
|
|
|
|
cmd_context.option_enable(cmd, opt_duplicate_grid_pin),
|
|
|
|
cmd_context.option_enable(cmd, opt_verbose));
|
2020-02-11 18:40:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* end namespace openfpga */
|