[Engine] Support coordinate definition in fabric key file format; Now QL memory bank can accept fabric key

This commit is contained in:
tangxifan 2021-09-21 15:08:08 -07:00
parent 8a3ce62d70
commit 7688c0570f
5 changed files with 53 additions and 1 deletions

View File

@ -54,6 +54,12 @@ std::string FabricKey::key_alias(const FabricKeyId& key_id) const {
return key_alias_[key_id];
}
vtr::Point<int> FabricKey::key_coordinate(const FabricKeyId& key_id) const {
/* validate the key_id */
VTR_ASSERT(valid_key_id(key_id));
return key_coordinates_[key_id];
}
bool FabricKey::empty() const {
return 0 == key_ids_.size();
}
@ -124,6 +130,7 @@ void FabricKey::reserve_keys(const size_t& num_keys) {
key_values_.reserve(num_keys);
key_regions_.reserve(num_keys);
key_alias_.reserve(num_keys);
key_coordinates_.reserve(num_keys);
}
FabricKeyId FabricKey::create_key() {
@ -134,6 +141,7 @@ FabricKeyId FabricKey::create_key() {
key_values_.emplace_back();
key_regions_.emplace_back(FabricRegionId::INVALID());
key_alias_.emplace_back();
key_coordinates_.emplace_back(vtr::Point<int>(-1, -1));
return key;
}
@ -162,6 +170,14 @@ void FabricKey::set_key_alias(const FabricKeyId& key_id,
key_alias_[key_id] = alias;
}
void FabricKey::set_key_coordinate(const FabricKeyId& key_id,
const vtr::Point<int>& coord) {
/* validate the key_id */
VTR_ASSERT(valid_key_id(key_id));
key_coordinates_[key_id] = coord;
}
/************************************************************************
* Internal invalidators/validators
***********************************************************************/
@ -173,3 +189,7 @@ bool FabricKey::valid_region_id(const FabricRegionId& region_id) const {
bool FabricKey::valid_key_id(const FabricKeyId& key_id) const {
return ( size_t(key_id) < key_ids_.size() ) && ( key_id == key_ids_[key_id] );
}
bool FabricKey::valid_key_coordinate(const vtr::Point<int>& coord) const {
return coord.x() > -1 && coord.y() > -1;
}

View File

@ -10,6 +10,7 @@
/* Headers from vtrutil library */
#include "vtr_vector.h"
#include "vtr_geometry.h"
#include "fabric_key_fwd.h"
@ -58,6 +59,9 @@ class FabricKey {
/* Access the alias of a key */
std::string key_alias(const FabricKeyId& key_id) const;
/* Access the coordinate of a key */
vtr::Point<int> key_coordinate(const FabricKeyId& key_id) const;
/* Check if there are any keys */
bool empty() const;
@ -93,9 +97,14 @@ class FabricKey {
void set_key_alias(const FabricKeyId& key_id,
const std::string& alias);
void set_key_coordinate(const FabricKeyId& key_id,
const vtr::Point<int>& coord);
public: /* Public invalidators/validators */
bool valid_region_id(const FabricRegionId& region_id) const;
bool valid_key_id(const FabricKeyId& key_id) const;
/* Identify if key coordinate is acceptable to fabric key convention */
bool valid_key_coordinate(const vtr::Point<int>& coord) const;
private: /* Internal data */
/* Unique ids for each region */
vtr::vector<FabricRegionId, FabricRegionId> region_ids_;
@ -112,6 +121,9 @@ class FabricKey {
/* Values for each key */
vtr::vector<FabricKeyId, size_t> key_values_;
/* Values for each key */
vtr::vector<FabricKeyId, vtr::Point<int>> key_coordinates_;
/* Region for each key */
vtr::vector<FabricKeyId, FabricRegionId> key_regions_;

View File

@ -60,6 +60,19 @@ void read_xml_region_key(pugi::xml_node& xml_component_key,
fabric_key.set_key_name(FabricKeyId(id), name);
fabric_key.set_key_value(FabricKeyId(id), value);
fabric_key.add_key_to_region(fabric_region, FabricKeyId(id));
/* Parse coordinates */
vtr::Point<int> coord;
coord.set_x(get_attribute(xml_component_key, "column", loc_data, pugiutil::ReqOpt::OPTIONAL).as_int(-1));
coord.set_y(get_attribute(xml_component_key, "row", loc_data, pugiutil::ReqOpt::OPTIONAL).as_int(-1));
/* Require positive coordinate all the time */
if (!fabric_key.valid_key_coordinate(coord)) {
archfpga_throw(loc_data.filename_c_str(), loc_data.line(xml_component_key),
"Invalid coordinate '(%d, %d)' which contain negative numbers\n",
coord.x(), coord.y());
} else {
fabric_key.set_key_coordinate(FabricKeyId(id), coord);
}
}
/********************************************************************

View File

@ -52,6 +52,12 @@ int write_xml_fabric_component_key(std::fstream& fp,
write_xml_attribute(fp, "alias", fabric_key.key_alias(component_key).c_str());
}
vtr::Point<int> coord = fabric_key.key_coordinate(component_key);
if (fabric_key.valid_key_coordinate(coord)) {
write_xml_attribute(fp, "column", coord.x());
write_xml_attribute(fp, "row", coord.y());
}
fp << "/>" << "\n";
return 0;

View File

@ -636,7 +636,8 @@ int load_top_module_memory_modules_from_fabric_key(ModuleManager& module_manager
/* Now we can add the child to configurable children of the top module */
module_manager.add_configurable_child(top_module,
instance_info.first,
instance_info.second);
instance_info.second,
fabric_key.key_coordinate(key));
module_manager.add_configurable_child_to_region(top_module,
top_module_config_region,
instance_info.first,