[lib] add io_net_place data structure

This commit is contained in:
tangxifan 2022-07-27 20:48:26 -07:00
parent 2f1d3d0ea5
commit 2b044b1b0b
3 changed files with 119 additions and 2 deletions

View File

@ -0,0 +1,64 @@
/******************************************************************************
* Memember functions for data structure IoNetPlace
******************************************************************************/
/* Headers from vtrutil library */
#include "vtr_log.h"
#include "vtr_assert.h"
#include "vtr_time.h"
/* Headers from openfpgautil library */
#include "openfpga_digest.h"
#include "io_net_place.h"
/* begin namespace openfpga */
namespace openfpga {
/**************************************************
* Public Accessors
*************************************************/
size_t IoNetPlace::io_x(const std::string& net) const {
auto result = io_coords_.find(net);
if (result == io_coords_.end()) {
return size_t(-1);
}
return result->second[0];
}
size_t IoNetPlace::io_y(const std::string& net) const {
auto result = io_coords_.find(net);
if (result == io_coords_.end()) {
return size_t(-1);
}
return result->second[1];
}
size_t IoNetPlace::io_z(const std::string& net) const {
auto result = io_coords_.find(net);
if (result == io_coords_.end()) {
return size_t(-1);
}
return result->second[2];
}
void IoNetPlace::set_net_coord(const std::string& net,
const size_t& x,
const size_t& y,
const size_t& z) {
/* Warn when there is an attempt to overwrite */
auto result = io_coords_.find(net);
if (result != io_coords_.end()) {
VTR_LOG_WARN("Overwrite net '%s' coordinate from (%lu, %lu, %lu) to (%lu, %lu, %lu)!\n",
net.c_str(),
result->second[0], result->second[1], result->second[2],
x, y, z);
}
io_coords_[net][0] = x;
io_coords_[net][1] = y;
io_coords_[net][2] = z;
}
} /* end namespace openfpga */

View File

@ -0,0 +1,49 @@
#ifndef IO_NET_PLACE_H
#define IO_NET_PLACE_H
/********************************************************************
* Include header files required by the data structure definition
*******************************************************************/
#include <stddef.h>
#include <vector>
#include <string>
#include <map>
/* Begin namespace openfpga */
namespace openfpga {
/********************************************************************
* I/O net place is a data structure to store the coordinate of each nets
* defined in users' HDL designs on FPGA fabric.
*
* For example:
* netA netB
* | |
* v v
* ioA[0] ioA[1] ioB[0] ioB[1] ioA[2]
* +-----------------+ +--------+--------+ +--------+
* | | | | | | | |
* | I/O | I/O | | I/O | I/O | | I/O |
* | [0][y] | [0][y] | | [1][y] | [1][y] | | [2][y] | ...
* | [0] | [1] | | [0] | [1] | | [0] |
* +-----------------+ +--------+--------+ +--------+
*
*******************************************************************/
class IoNetPlace {
public: /* Public aggregators */
size_t io_x(const std::string& net) const;
size_t io_y(const std::string& net) const;
size_t io_z(const std::string& net) const;
public: /* Public mutators */
void set_net_coord(const std::string& net,
const size_t& x,
const size_t& y,
const size_t& z);
private: /* Internal Data */
/* I/O coordinate fast lookup by net name */
std::map<std::string, std::array<size_t, 3>> io_coords_;
};
} /* End namespace openfpga*/
#endif

View File

@ -57,7 +57,7 @@ int pcf2place(const PcfData& pcf_data,
} else {
/* Cannot find the pin, error out! */
VTR_LOG_ERROR("Net '%s' from .pcf is neither defined as input nor output in .blif!\n",
net_name.c_str());
net.c_str());
num_err++;
return 1;
}
@ -67,8 +67,12 @@ int pcf2place(const PcfData& pcf_data,
size_t x = io_location_map.io_x(int_pin);
size_t y = io_location_map.io_y(int_pin);
size_t z = io_location_map.io_z(int_pin);
/* Add a fixed prefix to net namei, this is hard coded by VPR */
if (OUTPUT == pin_direction) {
net = "out:" + net;
}
/* Add the information to I/O place data */
io_net_place.add_net_coord(net_name, x, y, z, pin_direction);
io_net_place.set_net_coord(net, x, y, z);
}
return num_err;