add sb unique modules

This commit is contained in:
Lin 2024-08-05 02:23:47 -07:00
parent 5ac19ea628
commit c726744154
5 changed files with 141 additions and 94 deletions

View File

@ -560,6 +560,39 @@ size_t DeviceRRGSB::get_cb_unique_module_index(
}
return cb_unique_module_id;
}
void DeviceRRGSB::load_unique_cb_module_from_user_input(int x, int y){
}
void DeviceRRGSB::load_unique_sb_module_from_user_input(int ix, int iy){
vtr::Point<size_t> sb_coordinate(ix, iy);
bool is_unique_module = true;
for (size_t id = 0; id < get_num_sb_unique_module(); ++id) {
/* Check whether the input module exists.*/
if (sb_unique_module_[id].x() == ix && sb_unique_module_[id].y() == iy){
is_unique_module = false;
sb_unique_module_id_[ix][iy] = id;
break;
}
}
if (true == is_unique_module) {
sb_unique_module_.push_back(sb_coordinate);
/* Record the id of unique mirror */
sb_unique_module_id_[ix][iy] =sb_unique_module_.size() - 1;
}
}
void DeviceRRGSB::load_unique_gsb_module_from_user_input(int x, int y){
}
} /* End namespace openfpga*/

View File

@ -95,6 +95,9 @@ class DeviceRRGSB {
automatically identify and update the lists
of unique mirrors and rotatable mirrors */
void clear(); /* clean the content */
void load_unique_cb_module_from_user_input(int x, int y);
void load_unique_sb_module_from_user_input(int x, int y);
void load_unique_gsb_module_from_user_input(int x, int y);
private: /* Internal cleaners */
void clear_gsb(); /* clean the content */
void clear_cb_unique_module(const t_rr_type& cb_type); /* clean the content */

View File

@ -474,7 +474,7 @@ int write_fabric_pin_physical_location_template(
}
template <class T>
int read_unique_blocks_template(const T& openfpga_ctx, const Command& cmd,
int read_unique_blocks_template(T& openfpga_ctx, const Command& cmd,
const CommandContext& cmd_context) {
CommandOptionId opt_verbose = cmd.option("verbose");
CommandOptionId opt_file = cmd.option("file");
@ -490,12 +490,12 @@ int read_unique_blocks_template(const T& openfpga_ctx, const Command& cmd,
std::string file_name = cmd_context.option_value(cmd, opt_file);
std::string file_type = cmd_context.option_value(cmd, opt_type);
/* Write hierarchy to a file */
return read_xml_unique_blocks(file_name.c_str(), file_type.c_str(),
return read_xml_unique_blocks(openfpga_ctx, file_name.c_str(), file_type.c_str(),
cmd_context.option_enable(cmd, opt_verbose));
}
template <class T>
int write_unique_blocks_template(const T& openfpga_ctx, const Command& cmd,
int write_unique_blocks_template(T& openfpga_ctx, const Command& cmd,
const CommandContext& cmd_context) {
CommandOptionId opt_verbose = cmd.option("verbose");
CommandOptionId opt_file = cmd.option("file");
@ -512,7 +512,7 @@ int write_unique_blocks_template(const T& openfpga_ctx, const Command& cmd,
std::string file_type = cmd_context.option_value(cmd, opt_type);
/* Write hierarchy to a file */
return read_xml_unique_blocks(file_name.c_str(), file_type.c_str(),
return read_xml_unique_blocks(openfpga_ctx, file_name.c_str(), file_type.c_str(),
cmd_context.option_enable(cmd, opt_verbose));
}

View File

@ -1,87 +0,0 @@
/********************************************************************
* This file includes the top-level function of this library
* which reads an XML of unique routing blocks to the associated
* data structures
*******************************************************************/
#include <string>
/* Headers from pugi XML library */
#include "pugixml.hpp"
#include "pugixml_util.hpp"
/* Headers from vtr util library */
#include "vtr_assert.h"
#include "vtr_log.h"
#include "vtr_time.h"
/* Headers from libopenfpga util library */
#include "openfpga_port_parser.h"
/* Headers from libarchfpga */
#include "arch_error.h"
#include "read_xml_unique_blocks.h"
#include "read_xml_util.h"
/********************************************************************
* Parse XML codes of a <instance> to an object of unique_blocks
*******************************************************************/
static void read_xml_unique_instance_info(pugi::xml_node& xml_instance_info,
const pugiutil::loc_data& loc_data) {
std::string pass = "pass here";
std::string instance_x = get_attribute(xml_instance_info, "x", loc_data).as_string();
std::string instance_y = get_attribute(xml_instance_info, "y", loc_data).as_string();
}
/********************************************************************
* Parse XML codes about <repack_design_constraints> to an object of
*RepackDesignConstraints
*******************************************************************/
int read_xml_unique_blocks(const char* file_name, const char* file_type,
bool verbose) {
vtr::ScopedStartFinishTimer timer("Read unique blocks xml file");
// RepackDesignConstraints repack_design_constraints;
/* Parse the file */
pugi::xml_document doc;
pugiutil::loc_data loc_data;
try {
loc_data = pugiutil::load_xml(doc, file_name);
pugi::xml_node xml_root = get_single_child(doc, "unique_blocks", loc_data);
// size_t num_design_constraints =
// std::distance(xml_root.children().begin(), xml_root.children().end());
// /* Reserve memory space for the region */
// repack_design_constraints.reserve_design_constraints(
// num_design_constraints);
for (pugi::xml_node xml_block_info : xml_root.children()) {
/* Error out if the XML child has an invalid name! */
if (xml_block_info.name() == std::string("block")) {
std::string type =
get_attribute(xml_block_info, "type", loc_data).as_string();
std::string block_x =
get_attribute(xml_block_info, "x", loc_data).as_string();
std::string block_y =
get_attribute(xml_block_info, "y", loc_data).as_string();
for (pugi::xml_node xml_instance_info : xml_block_info.children()) {
if (xml_instance_info.name() == std::string("instance")) {
read_xml_unique_instance_info(xml_instance_info, loc_data);
}
// read_xml_unique_instance_info(xml_instance_info, loc_data);
}
} else {
bad_tag(xml_block_info, loc_data, xml_root, {"block"});
return 1;
}
// std::cout << "what is the root name: " << xml_block_info.name() <<
// std::endl;
}
} catch (pugiutil::XmlError& e) {
archfpga_throw(file_name, e.line(), "%s", e.what());
}
return 0;
}

View File

@ -2,15 +2,113 @@
#define READ_XML_UNIQUE_BLOCKS_H
/********************************************************************
* Include header files that are required by function declaration
* This file includes the top-level function of this library
* which reads an XML of unique routing blocks to the associated
* data structures
*******************************************************************/
#include <string>
/* Headers from pugi XML library */
#include "pugixml.hpp"
#include "pugixml_util.hpp"
/* Headers from vtr util library */
#include "vtr_assert.h"
#include "vtr_log.h"
#include "vtr_time.h"
/* Headers from libopenfpga util library */
#include "openfpga_port_parser.h"
/* Headers from libarchfpga */
#include "arch_error.h"
#include "read_xml_unique_blocks.h"
#include "read_xml_util.h"
#include "rr_gsb.h"
/********************************************************************
* Function declaration
*******************************************************************/
int read_xml_unique_blocks(const char* file_name, const char* file_type,
bool verbose);
template <class T>
int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name,
const char* file_type, bool verbose);
/********************************************************************
* Parse XML codes of a <instance> to an object of unique_blocks
*******************************************************************/
template <class T>
void read_xml_unique_instance_info(T& device_rr_gsb,
pugi::xml_node& xml_instance_info,
const pugiutil::loc_data& loc_data,
std::string type) {
std::string pass = "pass here";
int instance_x = get_attribute(xml_instance_info, "x", loc_data).as_int();
int instance_y = get_attribute(xml_instance_info, "y", loc_data).as_int();
if (type == "sb") {
device_rr_gsb.load_unique_sb_module_from_user_input(instance_x, instance_y);
} else if (type == "cb") {
// read_cb_unique_blocks();
std::cout << "By pass here" << std::endl;
} else if (type == "gsb") {
std::cout << "By pass here" << std::endl;
// read_gsb_unique_blocks();
}
}
/********************************************************************
* Parse XML codes about <repack_design_constraints> to an object of
*RepackDesignConstraints
*******************************************************************/
template <class T>
int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name,
const char* file_type, bool verbose) {
vtr::ScopedStartFinishTimer timer("Read unique blocks xml file");
// RepackDesignConstraints repack_design_constraints;
/* Parse the file */
pugi::xml_document doc;
pugiutil::loc_data loc_data;
try {
loc_data = pugiutil::load_xml(doc, file_name);
pugi::xml_node xml_root = get_single_child(doc, "unique_blocks", loc_data);
/* get device_rr_gsb data type and initialize it*/
auto device_rr_gsb = openfpga_ctx.mutable_device_rr_gsb();
device_rr_gsb.clear();
/* load unique blocks xml file and set up device_rr_gdb */
for (pugi::xml_node xml_block_info : xml_root.children()) {
/* Error out if the XML child has an invalid name! */
if (xml_block_info.name() == std::string("block")) {
std::string type =
get_attribute(xml_block_info, "type", loc_data).as_string();
std::string block_x =
get_attribute(xml_block_info, "x", loc_data).as_string();
std::string block_y =
get_attribute(xml_block_info, "y", loc_data).as_string();
for (pugi::xml_node xml_instance_info : xml_block_info.children()) {
if (xml_instance_info.name() == std::string("instance")) {
read_xml_unique_instance_info(device_rr_gsb, xml_instance_info,
loc_data, type);
}
// read_xml_unique_instance_info(xml_instance_info, loc_data);
}
} else {
bad_tag(xml_block_info, loc_data, xml_root, {"block"});
return 1;
}
// std::cout << "what is the root name: " << xml_block_info.name() <<
// std::endl;
}
} catch (pugiutil::XmlError& e) {
archfpga_throw(file_name, e.line(), "%s", e.what());
}
return 0;
}
#endif