added a new XML syntax: initial offset for physical mode pin mapping
This commit is contained in:
parent
f631245b2b
commit
3eea12ceae
|
@ -86,11 +86,11 @@ std::vector<std::string> PbTypeAnnotation::port_names() const {
|
|||
return keys;
|
||||
}
|
||||
|
||||
std::map<BasicPort, int> PbTypeAnnotation::physical_pb_type_port(const std::string& port_name) const {
|
||||
std::map<std::string, std::map<BasicPort, int>>::const_iterator it = operating_pb_type_ports_.find(port_name);
|
||||
std::map<BasicPort, std::array<int, 2>> PbTypeAnnotation::physical_pb_type_port(const std::string& port_name) const {
|
||||
std::map<std::string, std::map<BasicPort, std::array<int, 2>>>::const_iterator it = operating_pb_type_ports_.find(port_name);
|
||||
if (it == operating_pb_type_ports_.end()) {
|
||||
/* Return an empty port */
|
||||
return std::map<BasicPort, int>();
|
||||
return std::map<BasicPort, std::array<int, 2>>();
|
||||
}
|
||||
return operating_pb_type_ports_.at(port_name);
|
||||
}
|
||||
|
@ -169,25 +169,25 @@ void PbTypeAnnotation::set_physical_pb_type_index_offset(const int& value) {
|
|||
void PbTypeAnnotation::add_pb_type_port_pair(const std::string& operating_pb_port_name,
|
||||
const BasicPort& physical_pb_port) {
|
||||
/* Give a warning if the operating_pb_port_name already exist */
|
||||
std::map<std::string, std::map<BasicPort, int>>::const_iterator it = operating_pb_type_ports_.find(operating_pb_port_name);
|
||||
std::map<std::string, std::map<BasicPort, std::array<int, 2>>>::const_iterator it = operating_pb_type_ports_.find(operating_pb_port_name);
|
||||
|
||||
/* If not exist, initialize and set a default value */
|
||||
if (it == operating_pb_type_ports_.end()) {
|
||||
operating_pb_type_ports_[operating_pb_port_name][physical_pb_port] = 0;
|
||||
operating_pb_type_ports_[operating_pb_port_name][physical_pb_port] = {0, 0};
|
||||
/* We can return early */
|
||||
return;
|
||||
}
|
||||
|
||||
/* If the physical port is not in the list, we create one and set a default value */
|
||||
if (0 == operating_pb_type_ports_[operating_pb_port_name].count(physical_pb_port)) {
|
||||
operating_pb_type_ports_[operating_pb_port_name][physical_pb_port] = 0;
|
||||
operating_pb_type_ports_[operating_pb_port_name][physical_pb_port] = {0, 0};
|
||||
}
|
||||
}
|
||||
|
||||
void PbTypeAnnotation::set_physical_pin_rotate_offset(const std::string& operating_pb_port_name,
|
||||
const BasicPort& physical_pb_port,
|
||||
const int& physical_pin_rotate_offset) {
|
||||
std::map<std::string, std::map<BasicPort, int>>::const_iterator it = operating_pb_type_ports_.find(operating_pb_port_name);
|
||||
void PbTypeAnnotation::set_physical_pin_initial_offset(const std::string& operating_pb_port_name,
|
||||
const BasicPort& physical_pb_port,
|
||||
const int& physical_pin_initial_offset) {
|
||||
std::map<std::string, std::map<BasicPort, std::array<int, 2>>>::const_iterator it = operating_pb_type_ports_.find(operating_pb_port_name);
|
||||
|
||||
if (it == operating_pb_type_ports_.end()) {
|
||||
VTR_LOG_ERROR("The operating pb_type port '%s' is not valid!\n",
|
||||
|
@ -204,7 +204,30 @@ void PbTypeAnnotation::set_physical_pin_rotate_offset(const std::string& operati
|
|||
exit(1);
|
||||
}
|
||||
|
||||
operating_pb_type_ports_[operating_pb_port_name][physical_pb_port] = physical_pin_rotate_offset;
|
||||
operating_pb_type_ports_[operating_pb_port_name][physical_pb_port][0] = physical_pin_initial_offset;
|
||||
}
|
||||
|
||||
void PbTypeAnnotation::set_physical_pin_rotate_offset(const std::string& operating_pb_port_name,
|
||||
const BasicPort& physical_pb_port,
|
||||
const int& physical_pin_rotate_offset) {
|
||||
std::map<std::string, std::map<BasicPort, std::array<int, 2>>>::const_iterator it = operating_pb_type_ports_.find(operating_pb_port_name);
|
||||
|
||||
if (it == operating_pb_type_ports_.end()) {
|
||||
VTR_LOG_ERROR("The operating pb_type port '%s' is not valid!\n",
|
||||
operating_pb_port_name.c_str());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (operating_pb_type_ports_[operating_pb_port_name].end() == operating_pb_type_ports_[operating_pb_port_name].find(physical_pb_port)) {
|
||||
VTR_LOG_ERROR("The physical pb_type port '%s[%lu:%lu]' definition for operating pb_type port '%s' is not valid!\n",
|
||||
physical_pb_port.get_name().c_str(),
|
||||
physical_pb_port.get_lsb(),
|
||||
physical_pb_port.get_msb(),
|
||||
operating_pb_port_name.c_str());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
operating_pb_type_ports_[operating_pb_port_name][physical_pb_port][1] = physical_pin_rotate_offset;
|
||||
}
|
||||
|
||||
void PbTypeAnnotation::add_interconnect_circuit_model_pair(const std::string& interc_name,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*******************************************************************/
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <array>
|
||||
|
||||
#include "openfpga_port.h"
|
||||
|
||||
|
@ -48,7 +49,7 @@ class PbTypeAnnotation {
|
|||
float physical_pb_type_index_factor() const;
|
||||
int physical_pb_type_index_offset() const;
|
||||
std::vector<std::string> port_names() const;
|
||||
std::map<BasicPort, int> physical_pb_type_port(const std::string& port_name) const;
|
||||
std::map<BasicPort, std::array<int, 2>> physical_pb_type_port(const std::string& port_name) const;
|
||||
std::vector<std::string> interconnect_names() const;
|
||||
std::string interconnect_circuit_model_name(const std::string& interc_name) const;
|
||||
public: /* Public mutators */
|
||||
|
@ -66,6 +67,9 @@ class PbTypeAnnotation {
|
|||
void set_physical_pb_type_index_offset(const int& value);
|
||||
void add_pb_type_port_pair(const std::string& operating_pb_port_name,
|
||||
const BasicPort& physical_pb_port);
|
||||
void set_physical_pin_initial_offset(const std::string& operating_pb_port_name,
|
||||
const BasicPort& physical_pb_port,
|
||||
const int& physical_pin_initial_offset);
|
||||
void set_physical_pin_rotate_offset(const std::string& operating_pb_port_name,
|
||||
const BasicPort& physical_pb_port,
|
||||
const int& physical_pin_rotate_offset);
|
||||
|
@ -134,8 +138,12 @@ class PbTypeAnnotation {
|
|||
int physical_pb_type_index_offset_;
|
||||
|
||||
/* Link from the pins under an operating pb_type to pairs of
|
||||
* its physical pb_type and its pin rotating offset
|
||||
* The offset aims to align the pin indices for port of pb_type
|
||||
* its physical pb_type and its pin initial & rotating offset
|
||||
*
|
||||
* Note that initial offset is the first element of the std::array
|
||||
* Note that rotating offset is the second element of the std::array
|
||||
*
|
||||
* The offsets aim to align the pin indices for port of pb_type
|
||||
* between operating and physical modes, especially when an operating
|
||||
* mode contains multiple pb_type (num_pb>1) that are linked to
|
||||
* the same physical pb_type.
|
||||
|
@ -143,11 +151,21 @@ class PbTypeAnnotation {
|
|||
* the pin index of pb_type (whose index is large than 1)
|
||||
* will be shifted by the given offset.
|
||||
*
|
||||
* For example, an offset of 1 is used to map
|
||||
* operating pb_type adder[0].pin[0] with a full path clb.fle[arith].adder[0]
|
||||
* to physical pb_type adder[0].pin[1] with a full path clb.fle[physical].adder[0]
|
||||
* For example, an initial offset of -32 is used to map
|
||||
* operating pb_type bram[0].dout[32] with a full path memory[dual_port].bram[0]
|
||||
* operating pb_type bram[0].dout[33] with a full path memory[dual_port].bram[0]
|
||||
* to
|
||||
* physical pb_type bram[0].dout_a[0] with a full path memory[physical].bram[0]
|
||||
* physical pb_type bram[0].dout_a[1] with a full path memory[physical].bram[0]
|
||||
*
|
||||
* For example, a rotating offset of 1 is used to map
|
||||
* operating pb_type mult_9x9[0].a[0:8] with a full path mult[frac].mult_9x9[0]
|
||||
* operating pb_type mult_9x9[1].a[0:8] with a full path mult[frac].mult_9x9[1]
|
||||
* to
|
||||
* physical pb_type mult_36x36.a[0:8] with a full path mult[physical].mult_36x36[0]
|
||||
* physical pb_type mult_36x36.a[9:17] with a full path mult[physical].mult_36x36[0]
|
||||
*/
|
||||
std::map<std::string, std::map<BasicPort, int>> operating_pb_type_ports_;
|
||||
std::map<std::string, std::map<BasicPort, std::array<int, 2>>> operating_pb_type_ports_;
|
||||
|
||||
/* Link between the interconnects under this pb_type and circuit model names */
|
||||
std::map<std::string, std::string> interconnect_circuit_model_names_;
|
||||
|
|
|
@ -65,6 +65,31 @@ void read_xml_pb_port_annotation(pugi::xml_node& xml_port,
|
|||
pb_type_annotation.add_pb_type_port_pair(name_attr, port_parser.port());
|
||||
}
|
||||
|
||||
/* We have an optional attribute: physical_mode_pin_initial_offset
|
||||
* Split based on the number of physical pb_type ports that have been defined
|
||||
*/
|
||||
const std::string& physical_pin_initial_offset_attr = get_attribute(xml_port, "physical_mode_pin_initial_offset", loc_data, pugiutil::ReqOpt::OPTIONAL).as_string();
|
||||
|
||||
if (false == physical_pin_initial_offset_attr.empty()) {
|
||||
/* Split the physical mode port attributes with space */
|
||||
openfpga::StringToken offset_tokenizer(physical_pin_initial_offset_attr);
|
||||
const std::vector<std::string> initial_offsets = offset_tokenizer.split();
|
||||
|
||||
/* Error out if the offset does not match the port definition */
|
||||
if (physical_mode_ports.size() != initial_offsets.size()) {
|
||||
archfpga_throw(loc_data.filename_c_str(), loc_data.line(xml_port),
|
||||
"Defined %lu physical mode ports but only %lu physical pin initial offset are defined! Expect size matching.\n",
|
||||
physical_mode_ports.size(), initial_offsets.size());
|
||||
}
|
||||
|
||||
for (size_t iport = 0; iport < physical_mode_ports.size(); ++iport) {
|
||||
openfpga::PortParser port_parser(physical_mode_ports[iport]);
|
||||
pb_type_annotation.set_physical_pin_initial_offset(name_attr,
|
||||
port_parser.port(),
|
||||
std::stoi(initial_offsets[iport]));
|
||||
}
|
||||
}
|
||||
|
||||
/* We have an optional attribute: physical_mode_pin_rotate_offset
|
||||
* Split based on the number of physical pb_type ports that have been defined
|
||||
*/
|
||||
|
|
|
@ -126,13 +126,21 @@ void write_xml_pb_port_annotation(std::fstream& fp,
|
|||
}
|
||||
write_xml_attribute(fp, "physical_mode_port", physical_mode_port_attr.c_str());
|
||||
|
||||
std::string physical_mode_pin_initial_offset_attr;
|
||||
for (const auto& physical_pb_port_pair : pb_type_annotation.physical_pb_type_port(port_name)) {
|
||||
if (false == physical_mode_pin_initial_offset_attr.empty()) {
|
||||
physical_mode_pin_initial_offset_attr += " ";
|
||||
}
|
||||
physical_mode_pin_initial_offset_attr += std::to_string(physical_pb_port_pair.second[0]);
|
||||
}
|
||||
write_xml_attribute(fp, "physical_mode_pin_initial_offset", physical_mode_pin_initial_offset_attr.c_str());
|
||||
|
||||
std::string physical_mode_pin_rotate_offset_attr;
|
||||
for (const auto& physical_pb_port_pair : pb_type_annotation.physical_pb_type_port(port_name)) {
|
||||
if (false == physical_mode_pin_rotate_offset_attr.empty()) {
|
||||
physical_mode_pin_rotate_offset_attr += " ";
|
||||
}
|
||||
physical_mode_pin_rotate_offset_attr += std::to_string(physical_pb_port_pair.second);
|
||||
physical_mode_pin_rotate_offset_attr += std::to_string(physical_pb_port_pair.second[1]);
|
||||
}
|
||||
write_xml_attribute(fp, "physical_mode_pin_rotate_offset", physical_mode_pin_rotate_offset_attr.c_str());
|
||||
|
||||
|
|
|
@ -308,16 +308,23 @@ bool try_match_pb_graph_pin(t_pb_graph_pin* operating_pb_graph_pin,
|
|||
/* If the parent ports of the two pins are not paired, fail */
|
||||
for (t_port* candidate_port : vpr_device_annotation.physical_pb_port(operating_pb_graph_pin->port)) {
|
||||
if (physical_pb_graph_pin->port != candidate_port) {
|
||||
return false;
|
||||
/* Not the one we want, try the next candidate */
|
||||
continue;
|
||||
}
|
||||
/* Check the pin number of physical pb_graph_pin matches the pin number of
|
||||
* operating pb_graph_pin plus a rotation offset
|
||||
* operating port physical port
|
||||
* LSB port_range.lsb() pin_number pin_number MSB
|
||||
* | | |
|
||||
* Operating port | | +------ |
|
||||
* | |<----offset--->|
|
||||
* Physical port | + + +
|
||||
* operating pb_graph_pin plus a rotation offset with an initial offset,
|
||||
* which is to align the lsb between operating and physical ports
|
||||
*
|
||||
* For example:
|
||||
* We can align the operating_port[32] to physical_port[0] with an initial offset
|
||||
* which is -32
|
||||
*
|
||||
* operating port physical port
|
||||
* LSB port_range.lsb() pin_number pin_number MSB
|
||||
* | | init_offset |
|
||||
* Operating port | | +------ + |
|
||||
* | |<----acc_offset--->|
|
||||
* Physical port | + + +
|
||||
*
|
||||
* Note:
|
||||
* - accumulated offset is NOT the pin rotate offset specified by users
|
||||
|
@ -327,11 +334,14 @@ bool try_match_pb_graph_pin(t_pb_graph_pin* operating_pb_graph_pin,
|
|||
* The accumulated offset will be reset to 0 when it exceeds the msb() of the physical port
|
||||
*/
|
||||
int acc_offset = vpr_device_annotation.physical_pb_pin_offset(operating_pb_graph_pin->port, candidate_port);
|
||||
int init_offset = vpr_device_annotation.physical_pb_pin_initial_offset(operating_pb_graph_pin->port, candidate_port);
|
||||
const BasicPort& physical_port_range = vpr_device_annotation.physical_pb_port_range(operating_pb_graph_pin->port, candidate_port);
|
||||
if (physical_pb_graph_pin->pin_number != operating_pb_graph_pin->pin_number
|
||||
+ (int)physical_port_range.get_lsb()
|
||||
+ init_offset
|
||||
+ acc_offset) {
|
||||
return false;
|
||||
/* Not the one we want, try the next candidate */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Reach here, it means all the requirements have been met */
|
||||
|
|
|
@ -211,7 +211,7 @@ bool pair_operating_and_physical_pb_types(t_pb_type* operating_pb_type,
|
|||
* if not found, we assume that the physical port is the same as the operating pb_port
|
||||
*/
|
||||
for (t_port* operating_pb_port : pb_type_ports(operating_pb_type)) {
|
||||
std::map<BasicPort, int> expected_physical_pb_ports = pb_type_annotation.physical_pb_type_port(std::string(operating_pb_port->name));
|
||||
std::map<BasicPort, std::array<int, 2>> expected_physical_pb_ports = pb_type_annotation.physical_pb_type_port(std::string(operating_pb_port->name));
|
||||
|
||||
/* If not defined in the annotation, set the default pair:
|
||||
* rotate_offset is 0 by default!
|
||||
|
@ -220,7 +220,7 @@ bool pair_operating_and_physical_pb_types(t_pb_type* operating_pb_type,
|
|||
BasicPort expected_physical_pb_port;
|
||||
expected_physical_pb_port.set_name(std::string(operating_pb_port->name));
|
||||
expected_physical_pb_port.set_width(operating_pb_port->num_pins);
|
||||
expected_physical_pb_ports[expected_physical_pb_port] = 0;
|
||||
expected_physical_pb_ports[expected_physical_pb_port] = {0, 0};
|
||||
}
|
||||
|
||||
for (const auto& expected_physical_pb_port : expected_physical_pb_ports) {
|
||||
|
@ -241,7 +241,8 @@ bool pair_operating_and_physical_pb_types(t_pb_type* operating_pb_type,
|
|||
*/
|
||||
vpr_device_annotation.add_physical_pb_port(operating_pb_port, physical_pb_port);
|
||||
vpr_device_annotation.add_physical_pb_port_range(operating_pb_port, physical_pb_port, expected_physical_pb_port.first);
|
||||
vpr_device_annotation.add_physical_pb_pin_rotate_offset(operating_pb_port, physical_pb_port, expected_physical_pb_port.second);
|
||||
vpr_device_annotation.add_physical_pb_pin_initial_offset(operating_pb_port, physical_pb_port, expected_physical_pb_port.second[0]);
|
||||
vpr_device_annotation.add_physical_pb_pin_rotate_offset(operating_pb_port, physical_pb_port, expected_physical_pb_port.second[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -190,6 +190,21 @@ int VprDeviceAnnotation::physical_pb_type_index_offset(t_pb_type* pb_type) const
|
|||
return physical_pb_type_index_offsets_.at(pb_type);
|
||||
}
|
||||
|
||||
int VprDeviceAnnotation::physical_pb_pin_initial_offset(t_port* operating_pb_port,
|
||||
t_port* physical_pb_port) const {
|
||||
/* Ensure that the pb_type is in the list */
|
||||
std::map<t_port*, std::map<t_port*, int>>::const_iterator it = physical_pb_pin_initial_offsets_.find(operating_pb_port);
|
||||
if (it == physical_pb_pin_initial_offsets_.end()) {
|
||||
/* Default value is 0 */
|
||||
return 0;
|
||||
}
|
||||
if (0 == physical_pb_pin_initial_offsets_.at(operating_pb_port).count(physical_pb_port)) {
|
||||
/* Default value is 0 */
|
||||
return 0;
|
||||
}
|
||||
return physical_pb_pin_initial_offsets_.at(operating_pb_port).at(physical_pb_port);
|
||||
}
|
||||
|
||||
int VprDeviceAnnotation::physical_pb_pin_rotate_offset(t_port* operating_pb_port,
|
||||
t_port* physical_pb_port) const {
|
||||
/* Ensure that the pb_type is in the list */
|
||||
|
@ -220,7 +235,6 @@ int VprDeviceAnnotation::physical_pb_pin_offset(t_port* operating_pb_port,
|
|||
return physical_pb_pin_offsets_.at(operating_pb_port).at(physical_pb_port);
|
||||
}
|
||||
|
||||
|
||||
t_pb_graph_pin* VprDeviceAnnotation::physical_pb_graph_pin(const t_pb_graph_pin* pb_graph_pin) const {
|
||||
/* Ensure that the pb_type is in the list */
|
||||
std::map<const t_pb_graph_pin*, t_pb_graph_pin*>::const_iterator it = physical_pb_graph_pins_.find(pb_graph_pin);
|
||||
|
@ -410,6 +424,20 @@ void VprDeviceAnnotation::add_physical_pb_type_index_offset(t_pb_type* pb_type,
|
|||
physical_pb_type_index_offsets_[pb_type] = offset;
|
||||
}
|
||||
|
||||
void VprDeviceAnnotation::add_physical_pb_pin_initial_offset(t_port* operating_pb_port,
|
||||
t_port* physical_pb_port,
|
||||
const int& offset) {
|
||||
/* Warn any override attempt */
|
||||
std::map<t_port*, std::map<t_port*, int>>::const_iterator it = physical_pb_pin_initial_offsets_.find(operating_pb_port);
|
||||
if ( (it != physical_pb_pin_initial_offsets_.end())
|
||||
&& (0 < physical_pb_pin_initial_offsets_[operating_pb_port].count(physical_pb_port)) ) {
|
||||
VTR_LOG_WARN("Override the annotation between operating pb_port '%s' and it physical pb_port '%s' pin rotate offset '%d'!\n",
|
||||
operating_pb_port->name, offset);
|
||||
}
|
||||
|
||||
physical_pb_pin_initial_offsets_[operating_pb_port][physical_pb_port] = offset;
|
||||
}
|
||||
|
||||
void VprDeviceAnnotation::add_physical_pb_pin_rotate_offset(t_port* operating_pb_port,
|
||||
t_port* physical_pb_port,
|
||||
const int& offset) {
|
||||
|
|
|
@ -61,6 +61,9 @@ class VprDeviceAnnotation {
|
|||
float physical_pb_type_index_factor(t_pb_type* pb_type) const;
|
||||
int physical_pb_type_index_offset(t_pb_type* pb_type) const;
|
||||
|
||||
int physical_pb_pin_initial_offset(t_port* operating_pb_port,
|
||||
t_port* physical_pb_port) const;
|
||||
|
||||
int physical_pb_pin_rotate_offset(t_port* operating_pb_port,
|
||||
t_port* physical_pb_port) const;
|
||||
|
||||
|
@ -96,6 +99,9 @@ class VprDeviceAnnotation {
|
|||
t_pb_graph_node* physical_pb_graph_node);
|
||||
void add_physical_pb_type_index_factor(t_pb_type* pb_type, const float& factor);
|
||||
void add_physical_pb_type_index_offset(t_pb_type* pb_type, const int& offset);
|
||||
void add_physical_pb_pin_initial_offset(t_port* operating_pb_port,
|
||||
t_port* physical_pb_port,
|
||||
const int& offset);
|
||||
void add_physical_pb_pin_rotate_offset(t_port* operating_pb_port,
|
||||
t_port* physical_pb_port,
|
||||
const int& offset);
|
||||
|
@ -148,6 +154,7 @@ class VprDeviceAnnotation {
|
|||
* - the parent of physical pb_port MUST be a physical pb_type
|
||||
*/
|
||||
std::map<t_port*, std::vector<t_port*>> physical_pb_ports_;
|
||||
std::map<t_port*, std::map<t_port*, int>> physical_pb_pin_initial_offsets_;
|
||||
std::map<t_port*, std::map<t_port*, int>> physical_pb_pin_rotate_offsets_;
|
||||
|
||||
/* Accumulated offsets for a physical pb_type port, just for internal usage */
|
||||
|
|
Loading…
Reference in New Issue