[Engine] Add a new option ``--unique`` to command ``write_gsb_to_xml``

This commit is contained in:
tangxifan 2022-01-26 11:10:29 -08:00
parent 04e280b050
commit a9a56686e2
7 changed files with 39 additions and 3 deletions

View File

@ -111,6 +111,10 @@ write_gsb_to_xml
Specify the output directory of the XML files. Each GSB will be written to an indepedent XML file
For example, ``--file /temp/gsb_output``
.. option:: --unique
Only output unique GSBs to XML files
.. option:: --verbose
Show verbose log

View File

@ -86,6 +86,13 @@ size_t DeviceRRGSB::get_num_gsb_unique_module() const {
return gsb_unique_module_.size();
}
/* Get a rr switch block which a unique mirror */
const RRGSB& DeviceRRGSB::get_gsb_unique_module(const size_t& index) const {
VTR_ASSERT (validate_gsb_unique_module_index(index));
return rr_gsb_[gsb_unique_module_[index].x()][gsb_unique_module_[index].y()];
}
/* Get a rr switch block which a unique mirror */
const RRGSB& DeviceRRGSB::get_sb_unique_module(const size_t& index) const {
VTR_ASSERT (validate_sb_unique_module_index(index));
@ -461,6 +468,11 @@ bool DeviceRRGSB::validate_coordinate(const vtr::Point<size_t>& coordinate) cons
return (coordinate.y() < rr_gsb_[coordinate.x()].capacity());
}
/* Validate if the index in the range of unique_mirror vector*/
bool DeviceRRGSB::validate_gsb_unique_module_index(const size_t& index) const {
return (index < gsb_unique_module_.size());
}
/* Validate if the index in the range of unique_mirror vector*/
bool DeviceRRGSB::validate_sb_unique_module_index(const size_t& index) const {
return (index < sb_unique_module_.size());

View File

@ -32,6 +32,7 @@ class DeviceRRGSB {
const RRGSB& get_gsb(const size_t& x, const size_t& y) const; /* Get a rr switch block in the array with a coordinate */
size_t get_num_gsb_unique_module() const; /* get the number of unique mirrors of GSB */
size_t get_num_sb_unique_module() const; /* get the number of unique mirrors of switch blocks */
const RRGSB& get_gsb_unique_module(const size_t& index) const; /* Get a rr-gsb which is a unique mirror */
const RRGSB& get_sb_unique_module(const size_t& index) const; /* Get a rr switch block which a unique mirror */
const RRGSB& get_sb_unique_module(const vtr::Point<size_t>& coordinate) const; /* Get a rr switch block which a unique mirror */
const RRGSB& get_cb_unique_module(const t_rr_type& cb_type, const size_t& index) const; /* Get a rr switch block which a unique mirror */
@ -58,6 +59,7 @@ class DeviceRRGSB {
private: /* Validators */
bool validate_coordinate(const vtr::Point<size_t>& coordinate) const; /* Validate if the (x,y) is the range of this device */
bool validate_side(const e_side& side) const; /* validate if side is in the range of unique_side_module_ */
bool validate_gsb_unique_module_index(const size_t& index) const; /* Validate if the index in the range of unique_mirror vector*/
bool validate_sb_unique_module_index(const size_t& index) const; /* Validate if the index in the range of unique_mirror vector*/
bool validate_cb_unique_module_index(const t_rr_type& cb_type, const size_t& index) const; /* Validate if the index in the range of unique_mirror vector*/
bool validate_cb_type(const t_rr_type& cb_type) const;

View File

@ -184,6 +184,7 @@ void write_rr_switch_block_to_xml(const std::string fname_prefix,
void write_device_rr_gsb_to_xml(const char* sb_xml_dir,
const RRGraph& rr_graph,
const DeviceRRGSB& device_rr_gsb,
const bool& unique,
const bool& verbose) {
std::string xml_dir_name = format_dir_path(std::string(sb_xml_dir));
@ -195,11 +196,22 @@ void write_device_rr_gsb_to_xml(const char* sb_xml_dir,
size_t gsb_counter = 0;
/* For each switch block, an XML file will be outputted */
for (size_t ix = 0; ix < sb_range.x(); ++ix) {
for (size_t iy = 0; iy < sb_range.y(); ++iy) {
const RRGSB& rr_gsb = device_rr_gsb.get_gsb(ix, iy);
if (unique) {
/* Only output unique GSB modules */
VTR_LOG("Only output unique GSB modules to XML\n");
for (size_t igsb = 0; igsb < device_rr_gsb.get_num_gsb_unique_module(); ++igsb) {
const RRGSB& rr_gsb = device_rr_gsb.get_gsb_unique_module(igsb);
write_rr_switch_block_to_xml(xml_dir_name, rr_graph, rr_gsb, verbose);
gsb_counter++;
}
} else {
/* Output all GSB instances in the fabric (some instances may share the same module) */
for (size_t ix = 0; ix < sb_range.x(); ++ix) {
for (size_t iy = 0; iy < sb_range.y(); ++iy) {
const RRGSB& rr_gsb = device_rr_gsb.get_gsb(ix, iy);
write_rr_switch_block_to_xml(xml_dir_name, rr_graph, rr_gsb, verbose);
gsb_counter++;
}
}
}

View File

@ -18,6 +18,7 @@ namespace openfpga {
void write_device_rr_gsb_to_xml(const char* sb_xml_dir,
const RRGraph& rr_graph,
const DeviceRRGSB& device_rr_gsb,
const bool& unique,
const bool& verbose);
} /* end namespace openfpga */

View File

@ -209,6 +209,9 @@ ShellCommandId add_openfpga_write_gsb_command(openfpga::Shell<OpenfpgaContext>&
shell_cmd.set_option_short_name(opt_file, "f");
shell_cmd.set_option_require_value(opt_file, openfpga::OPT_STRING);
/* Add an option '--unique' */
shell_cmd.add_option("unique", false, "Only output unique GSB blocks");
/* Add an option '--verbose' */
shell_cmd.add_option("verbose", false, "Show verbose outputs");

View File

@ -33,6 +33,7 @@ int write_gsb(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());
CommandOptionId opt_unique = cmd.option("unique");
CommandOptionId opt_verbose = cmd.option("verbose");
std::string sb_file_name = cmd_context.option_value(cmd, opt_file);
@ -40,6 +41,7 @@ int write_gsb(const OpenfpgaContext& openfpga_ctx,
write_device_rr_gsb_to_xml(sb_file_name.c_str(),
g_vpr_ctx.device().rr_graph,
openfpga_ctx.device_rr_gsb(),
cmd_context.option_enable(cmd, opt_unique),
cmd_context.option_enable(cmd, opt_verbose));
/* TODO: should identify the error code from internal function execution */