2021-01-27 02:05:23 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
2021-02-05 04:56:12 +08:00
|
|
|
* Copyright (C) 2018 Claire Wolf <claire@symbioticeda.com>
|
2021-01-27 02:05:23 +08:00
|
|
|
* Copyright (C) 2018-19 David Shah <david@symbioticeda.com>
|
2021-02-05 04:56:12 +08:00
|
|
|
* Copyright (C) 2021 Symbiflow Authors
|
2021-01-27 02:05:23 +08:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
#include <boost/range/adaptor/reversed.hpp>
|
|
|
|
#include <cmath>
|
|
|
|
#include <cstring>
|
|
|
|
#include <queue>
|
2021-02-06 06:18:38 +08:00
|
|
|
#include "constraints.impl.h"
|
2021-02-13 08:12:16 +08:00
|
|
|
#include "fpga_interchange.h"
|
2021-01-27 02:05:23 +08:00
|
|
|
#include "log.h"
|
|
|
|
#include "nextpnr.h"
|
|
|
|
#include "placer1.h"
|
|
|
|
#include "placer_heap.h"
|
|
|
|
#include "router1.h"
|
|
|
|
#include "router2.h"
|
|
|
|
#include "timing.h"
|
|
|
|
#include "util.h"
|
2021-02-12 07:29:53 +08:00
|
|
|
#include "xdc.h"
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-16 01:45:52 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
struct SiteBelPair
|
|
|
|
{
|
|
|
|
std::string site;
|
|
|
|
IdString bel;
|
|
|
|
|
|
|
|
SiteBelPair() {}
|
|
|
|
SiteBelPair(std::string site, IdString bel) : site(site), bel(bel) {}
|
|
|
|
|
|
|
|
bool operator==(const SiteBelPair &other) const { return site == other.site && bel == other.bel; }
|
|
|
|
};
|
|
|
|
NEXTPNR_NAMESPACE_END
|
|
|
|
|
|
|
|
template <> struct std::hash<NEXTPNR_NAMESPACE_PREFIX SiteBelPair>
|
|
|
|
{
|
|
|
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX SiteBelPair &site_bel) const noexcept
|
|
|
|
{
|
|
|
|
std::size_t seed = 0;
|
|
|
|
boost::hash_combine(seed, std::hash<std::string>()(site_bel.site));
|
|
|
|
boost::hash_combine(seed, std::hash<NEXTPNR_NAMESPACE_PREFIX IdString>()(site_bel.bel));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
static std::pair<std::string, std::string> split_identifier_name_dot(const std::string &name)
|
|
|
|
{
|
|
|
|
size_t first_dot = name.find('.');
|
|
|
|
NPNR_ASSERT(first_dot != std::string::npos);
|
|
|
|
return std::make_pair(name.substr(0, first_dot), name.substr(first_dot + 1));
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2021-02-06 01:22:55 +08:00
|
|
|
void IdString::initialize_arch(const BaseCtx *ctx) {}
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static const ChipInfoPOD *get_chip_info(const RelPtr<ChipInfoPOD> *ptr) { return ptr->get(); }
|
|
|
|
|
|
|
|
Arch::Arch(ArchArgs args) : args(args)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
blob_file.open(args.chipdb);
|
|
|
|
if (args.chipdb.empty() || !blob_file.is_open())
|
|
|
|
log_error("Unable to read chipdb %s\n", args.chipdb.c_str());
|
|
|
|
const char *blob = reinterpret_cast<const char *>(blob_file.data());
|
|
|
|
chip_info = get_chip_info(reinterpret_cast<const RelPtr<ChipInfoPOD> *>(blob));
|
|
|
|
} catch (...) {
|
|
|
|
log_error("Unable to read chipdb %s\n", args.chipdb.c_str());
|
|
|
|
}
|
|
|
|
|
2021-02-06 06:18:38 +08:00
|
|
|
// Read strings from constids into IdString database, checking that list
|
|
|
|
// is unique and matches expected constid value.
|
2021-02-16 01:45:52 +08:00
|
|
|
const RelSlice<RelPtr<char>> &constids = *chip_info->constids;
|
|
|
|
for (size_t i = 0; i < constids.size(); ++i) {
|
|
|
|
IdString::initialize_add(this, constids[i].get(), i + 1);
|
|
|
|
}
|
|
|
|
|
2021-02-01 23:18:28 +08:00
|
|
|
// Sanity check cell name ids.
|
2021-02-04 06:48:49 +08:00
|
|
|
const CellMapPOD &cell_map = *chip_info->cell_map;
|
2021-02-01 23:18:28 +08:00
|
|
|
int32_t first_cell_id = cell_map.cell_names[0];
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int32_t i = 0; i < cell_map.cell_names.ssize(); ++i) {
|
2021-02-01 23:18:28 +08:00
|
|
|
log_assert(cell_map.cell_names[i] == i + first_cell_id);
|
|
|
|
}
|
2021-02-13 08:12:16 +08:00
|
|
|
|
|
|
|
io_port_types.emplace(this->id("$nextpnr_ibuf"));
|
|
|
|
io_port_types.emplace(this->id("$nextpnr_obuf"));
|
|
|
|
io_port_types.emplace(this->id("$nextpnr_iobuf"));
|
2021-02-16 01:45:52 +08:00
|
|
|
|
|
|
|
if (!this->args.package.empty()) {
|
|
|
|
IdString package = this->id(this->args.package);
|
|
|
|
package_index = -1;
|
|
|
|
for (size_t i = 0; i < chip_info->packages.size(); ++i) {
|
|
|
|
if (IdString(chip_info->packages[i].package) == package) {
|
|
|
|
NPNR_ASSERT(package_index == -1);
|
|
|
|
package_index = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (package_index == -1) {
|
|
|
|
log_error("Could not find package '%s' in chipdb.\n", this->args.package.c_str());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Default to first package.
|
|
|
|
NPNR_ASSERT(chip_info->packages.size() > 0);
|
2021-02-17 18:45:23 +08:00
|
|
|
if (chip_info->packages.size() == 1) {
|
2021-02-17 06:00:01 +08:00
|
|
|
IdString package_name(chip_info->packages[0].package);
|
|
|
|
this->args.package = package_name.str(this);
|
|
|
|
package_index = 0;
|
|
|
|
} else {
|
2021-02-17 18:45:23 +08:00
|
|
|
log_info(
|
|
|
|
"Package must be specified (with --package arg) when multiple packages are available, packages:\n");
|
|
|
|
for (const auto &package : chip_info->packages) {
|
2021-02-17 06:00:01 +08:00
|
|
|
log_info(" - %s\n", IdString(package.package).c_str(this));
|
|
|
|
}
|
|
|
|
log_error("--package is required!\n");
|
|
|
|
}
|
2021-02-16 01:45:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unordered_set<SiteBelPair> site_bel_pads;
|
|
|
|
for (const auto &package_pin : chip_info->packages[package_index].pins) {
|
|
|
|
IdString site(package_pin.site);
|
|
|
|
IdString bel(package_pin.bel);
|
|
|
|
site_bel_pads.emplace(SiteBelPair(site.str(this), bel));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (BelId bel : getBels()) {
|
|
|
|
auto &bel_data = bel_info(chip_info, bel);
|
2021-02-19 05:26:52 +08:00
|
|
|
const SiteInstInfoPOD &site = get_site_inst(bel);
|
2021-02-16 01:45:52 +08:00
|
|
|
auto iter = site_bel_pads.find(SiteBelPair(site.site_name.get(), IdString(bel_data.name)));
|
|
|
|
if (iter != site_bel_pads.end()) {
|
|
|
|
pads.emplace(bel);
|
|
|
|
}
|
|
|
|
}
|
2021-02-06 06:18:38 +08:00
|
|
|
|
|
|
|
explain_constraints = false;
|
|
|
|
|
|
|
|
int tile_type_index = 0;
|
|
|
|
size_t max_tag_count = 0;
|
|
|
|
for (const TileTypeInfoPOD &tile_type : chip_info->tile_types) {
|
|
|
|
max_tag_count = std::max(max_tag_count, tile_type.tags.size());
|
|
|
|
|
2021-02-17 01:45:43 +08:00
|
|
|
auto &type_definition = constraints.definitions[tile_type_index++];
|
2021-02-06 06:18:38 +08:00
|
|
|
for (const ConstraintTagPOD &tag : tile_type.tags) {
|
|
|
|
type_definition.emplace_back();
|
|
|
|
auto &definition = type_definition.back();
|
|
|
|
definition.prefix = IdString(tag.tag_prefix);
|
|
|
|
definition.default_state = IdString(tag.default_state);
|
|
|
|
NPNR_ASSERT(tag.states.size() < kMaxState);
|
|
|
|
|
|
|
|
definition.states.reserve(tag.states.size());
|
|
|
|
for (auto state : tag.states) {
|
|
|
|
definition.states.push_back(IdString(state));
|
|
|
|
}
|
|
|
|
}
|
2021-02-17 09:25:16 +08:00
|
|
|
|
|
|
|
// Logic BELs (e.g. placable BELs) should always appear first in the
|
|
|
|
// bel data list.
|
|
|
|
//
|
|
|
|
// When iterating over BELs this property is depended on to skip
|
|
|
|
// non-placable BELs (e.g. routing BELs and site ports).
|
|
|
|
bool in_logic_bels = true;
|
|
|
|
for (const BelInfoPOD &bel_info : tile_type.bel_data) {
|
|
|
|
if (in_logic_bels && bel_info.category != BEL_CATEGORY_LOGIC) {
|
|
|
|
in_logic_bels = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!in_logic_bels) {
|
|
|
|
NPNR_ASSERT(bel_info.category != BEL_CATEGORY_LOGIC);
|
|
|
|
}
|
|
|
|
}
|
2021-02-06 06:18:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
default_tags.resize(max_tag_count);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
std::string Arch::getChipName() const { return chip_info->name.get(); }
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
IdString Arch::archArgsToId(ArchArgs args) const { return IdString(); }
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Arch::setup_byname() const
|
|
|
|
{
|
|
|
|
if (tile_by_name.empty()) {
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int i = 0; i < chip_info->tiles.ssize(); i++) {
|
2021-02-04 05:37:58 +08:00
|
|
|
tile_by_name[id(chip_info->tiles[i].name.get())] = i;
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (site_by_name.empty()) {
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int i = 0; i < chip_info->tiles.ssize(); i++) {
|
2021-01-27 02:05:23 +08:00
|
|
|
auto &tile = chip_info->tiles[i];
|
|
|
|
auto &tile_type = chip_info->tile_types[tile.type];
|
2021-02-20 01:44:14 +08:00
|
|
|
for (size_t j = 0; j < tile_type.site_types.size(); j++) {
|
2021-01-27 02:05:23 +08:00
|
|
|
auto &site = chip_info->sites[tile.sites[j]];
|
2021-02-04 05:37:58 +08:00
|
|
|
site_by_name[id(site.name.get())] = std::make_pair(i, j);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-04 05:37:58 +08:00
|
|
|
BelId Arch::getBelByName(IdStringList name) const
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
BelId ret;
|
2021-02-04 06:48:49 +08:00
|
|
|
if (name.ids.size() != 2) {
|
2021-02-04 05:37:58 +08:00
|
|
|
return BelId();
|
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
setup_byname();
|
|
|
|
|
|
|
|
int tile, site;
|
2021-02-04 05:37:58 +08:00
|
|
|
std::tie(tile, site) = site_by_name.at(name.ids[0]);
|
2021-01-27 02:05:23 +08:00
|
|
|
auto &tile_info = chip_info->tile_types[chip_info->tiles[tile].type];
|
2021-02-04 05:37:58 +08:00
|
|
|
IdString belname = name.ids[1];
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int i = 0; i < tile_info.bel_data.ssize(); i++) {
|
2021-01-27 02:05:23 +08:00
|
|
|
if (tile_info.bel_data[i].site == site && tile_info.bel_data[i].name == belname.index) {
|
|
|
|
ret.tile = tile;
|
|
|
|
ret.index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
BelRange Arch::getBelsByTile(int x, int y) const
|
|
|
|
{
|
|
|
|
BelRange br;
|
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
br.b.cursor_tile = get_tile_index(x, y);
|
2021-01-27 02:05:23 +08:00
|
|
|
br.e.cursor_tile = br.b.cursor_tile;
|
|
|
|
br.b.cursor_index = 0;
|
2021-02-05 08:05:01 +08:00
|
|
|
br.e.cursor_index = chip_info->tile_types[chip_info->tiles[br.b.cursor_tile].type].bel_data.size();
|
2021-01-27 02:05:23 +08:00
|
|
|
br.b.chip = chip_info;
|
|
|
|
br.e.chip = chip_info;
|
2021-01-28 10:00:43 +08:00
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
if (br.b != br.e) {
|
2021-01-27 02:05:23 +08:00
|
|
|
++br.e;
|
2021-01-28 10:00:43 +08:00
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
return br;
|
|
|
|
}
|
|
|
|
|
|
|
|
WireId Arch::getBelPinWire(BelId bel, IdString pin) const
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
int pin_index = get_bel_pin_index(bel, pin);
|
2021-02-02 06:26:57 +08:00
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
auto &bel_data = bel_info(chip_info, bel);
|
2021-02-02 06:26:57 +08:00
|
|
|
NPNR_ASSERT(pin_index >= 0 && pin_index < bel_data.num_bel_wires);
|
|
|
|
|
|
|
|
const int32_t *wires = bel_data.wires.get();
|
|
|
|
int32_t wire_index = wires[pin_index];
|
2021-02-04 06:48:49 +08:00
|
|
|
if (wire_index < 0) {
|
2021-02-02 06:26:57 +08:00
|
|
|
// This BEL pin is not connected.
|
2021-01-28 10:00:43 +08:00
|
|
|
return WireId();
|
|
|
|
} else {
|
2021-02-05 06:23:12 +08:00
|
|
|
return canonical_wire(chip_info, bel.tile, wire_index);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PortType Arch::getBelPinType(BelId bel, IdString pin) const
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
int pin_index = get_bel_pin_index(bel, pin);
|
|
|
|
auto &bel_data = bel_info(chip_info, bel);
|
2021-01-29 01:28:40 +08:00
|
|
|
NPNR_ASSERT(pin_index >= 0 && pin_index < bel_data.num_bel_wires);
|
|
|
|
const int32_t *types = bel_data.types.get();
|
|
|
|
return PortType(types[pin_index]);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2021-02-04 05:37:58 +08:00
|
|
|
WireId Arch::getWireByName(IdStringList name) const
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
WireId ret;
|
2021-02-04 06:48:49 +08:00
|
|
|
if (name.ids.size() != 2) {
|
2021-02-04 05:37:58 +08:00
|
|
|
return WireId();
|
|
|
|
}
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
setup_byname();
|
|
|
|
|
2021-02-04 05:37:58 +08:00
|
|
|
auto iter = site_by_name.find(name.ids[0]);
|
2021-01-27 02:05:23 +08:00
|
|
|
if (iter != site_by_name.end()) {
|
|
|
|
int tile;
|
|
|
|
int site;
|
|
|
|
std::tie(tile, site) = iter->second;
|
|
|
|
auto &tile_info = chip_info->tile_types[chip_info->tiles[tile].type];
|
2021-02-04 05:37:58 +08:00
|
|
|
IdString wirename = name.ids[1];
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int i = 0; i < tile_info.wire_data.ssize(); i++) {
|
2021-01-27 02:05:23 +08:00
|
|
|
if (tile_info.wire_data[i].site == site && tile_info.wire_data[i].name == wirename.index) {
|
|
|
|
ret.tile = tile;
|
|
|
|
ret.index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2021-02-04 05:37:58 +08:00
|
|
|
int tile = tile_by_name.at(name.ids[0]);
|
2021-01-27 02:05:23 +08:00
|
|
|
auto &tile_info = chip_info->tile_types[chip_info->tiles[tile].type];
|
2021-02-04 05:37:58 +08:00
|
|
|
IdString wirename = name.ids[1];
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int i = 0; i < tile_info.wire_data.ssize(); i++) {
|
2021-01-27 02:05:23 +08:00
|
|
|
if (tile_info.wire_data[i].site == -1 && tile_info.wire_data[i].name == wirename.index) {
|
2021-01-27 10:40:42 +08:00
|
|
|
int32_t node = chip_info->tiles[tile].tile_wire_to_node[i];
|
|
|
|
if (node == -1) {
|
|
|
|
// Not a nodal wire
|
|
|
|
ret.tile = tile;
|
|
|
|
ret.index = i;
|
|
|
|
} else {
|
|
|
|
// Is a nodal wire, set tile to -1
|
|
|
|
ret.tile = -1;
|
|
|
|
ret.index = node;
|
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
IdString Arch::getWireType(WireId wire) const { return id(""); }
|
2021-02-04 06:48:49 +08:00
|
|
|
std::vector<std::pair<IdString, std::string>> Arch::getWireAttrs(WireId wire) const { return {}; }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2021-02-04 05:37:58 +08:00
|
|
|
PipId Arch::getPipByName(IdStringList name) const
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
2021-01-28 10:00:43 +08:00
|
|
|
// PIP name structure:
|
|
|
|
// Tile PIP: <tile name>/<source wire name>.<destination wire name>
|
|
|
|
// Site PIP: <site name>/<bel name>/<input bel pin name>
|
|
|
|
// Site pin: <site name>/<bel name>
|
2021-02-04 05:37:58 +08:00
|
|
|
// Psuedo site PIP: <site name>/<source wire name>.<destination wire name>
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
setup_byname();
|
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
if (name.ids.size() == 3) {
|
2021-02-04 05:37:58 +08:00
|
|
|
// This is a Site PIP.
|
|
|
|
IdString site_name = name.ids[0];
|
|
|
|
IdString belname = name.ids[1];
|
|
|
|
IdString pinname = name.ids[2];
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
int tile;
|
|
|
|
int site;
|
2021-02-04 05:37:58 +08:00
|
|
|
std::tie(tile, site) = site_by_name.at(site_name);
|
2021-01-27 02:05:23 +08:00
|
|
|
auto &tile_info = chip_info->tile_types[chip_info->tiles[tile].type];
|
2021-01-28 10:00:43 +08:00
|
|
|
|
2021-02-04 05:37:58 +08:00
|
|
|
std::array<IdString, 2> ids{name.ids[0], belname};
|
|
|
|
BelId bel = getBelByName(IdStringList(ids));
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2021-01-28 10:00:43 +08:00
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
int pin_index = get_bel_pin_index(bel, pinname);
|
2021-02-04 05:37:58 +08:00
|
|
|
NPNR_ASSERT(pin_index >= 0);
|
2021-01-28 10:00:43 +08:00
|
|
|
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int i = 0; i < tile_info.pip_data.ssize(); i++) {
|
2021-02-04 06:48:49 +08:00
|
|
|
if (tile_info.pip_data[i].site == site && tile_info.pip_data[i].bel == bel.index &&
|
2021-02-04 05:37:58 +08:00
|
|
|
tile_info.pip_data[i].extra_data == pin_index) {
|
|
|
|
|
|
|
|
PipId ret;
|
|
|
|
ret.tile = tile;
|
|
|
|
ret.index = i;
|
|
|
|
return ret;
|
2021-01-28 10:00:43 +08:00
|
|
|
}
|
2021-02-04 05:37:58 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
auto iter = site_by_name.find(name.ids[0]);
|
|
|
|
if (iter != site_by_name.end()) {
|
|
|
|
// This is either a site pin or a psuedo site pip.
|
|
|
|
// psuedo site pips are <site>/<src site wire>.<dst site wire>
|
|
|
|
// site pins are <site>/<bel>
|
|
|
|
int tile;
|
|
|
|
int site;
|
|
|
|
std::tie(tile, site) = iter->second;
|
|
|
|
auto &tile_info = chip_info->tile_types[chip_info->tiles[tile].type];
|
|
|
|
|
|
|
|
std::string pip_second = name.ids[1].str(this);
|
|
|
|
auto split = pip_second.find('.');
|
2021-02-04 06:48:49 +08:00
|
|
|
if (split == std::string::npos) {
|
2021-01-28 10:00:43 +08:00
|
|
|
// This is a site pin!
|
|
|
|
BelId bel = getBelByName(name);
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int i = 0; i < tile_info.pip_data.ssize(); i++) {
|
2021-02-04 06:48:49 +08:00
|
|
|
if (tile_info.pip_data[i].site == site && tile_info.pip_data[i].bel == bel.index) {
|
2021-02-04 05:37:58 +08:00
|
|
|
|
|
|
|
PipId ret;
|
2021-01-28 10:00:43 +08:00
|
|
|
ret.tile = tile;
|
|
|
|
ret.index = i;
|
2021-02-04 05:37:58 +08:00
|
|
|
return ret;
|
2021-01-28 10:00:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// This is a psuedo site pip!
|
2021-02-04 05:37:58 +08:00
|
|
|
IdString src_site_wire = id(pip_second.substr(0, split));
|
2021-02-04 06:48:49 +08:00
|
|
|
IdString dst_site_wire = id(pip_second.substr(split + 1));
|
2021-01-28 10:00:43 +08:00
|
|
|
int32_t src_index = -1;
|
|
|
|
int32_t dst_index = -1;
|
2021-02-04 05:37:58 +08:00
|
|
|
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int i = 0; i < tile_info.wire_data.ssize(); i++) {
|
2021-01-28 10:00:43 +08:00
|
|
|
if (tile_info.wire_data[i].site == site && tile_info.wire_data[i].name == src_site_wire.index) {
|
|
|
|
src_index = i;
|
2021-02-04 06:48:49 +08:00
|
|
|
if (dst_index != -1) {
|
2021-01-28 10:00:43 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tile_info.wire_data[i].site == site && tile_info.wire_data[i].name == dst_site_wire.index) {
|
|
|
|
dst_index = i;
|
2021-02-04 06:48:49 +08:00
|
|
|
if (src_index != -1) {
|
2021-01-28 10:00:43 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NPNR_ASSERT(src_index != -1);
|
|
|
|
NPNR_ASSERT(dst_index != -1);
|
|
|
|
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int i = 0; i < tile_info.pip_data.ssize(); i++) {
|
2021-02-04 06:48:49 +08:00
|
|
|
if (tile_info.pip_data[i].site == site && tile_info.pip_data[i].src_index == src_index &&
|
2021-01-28 10:00:43 +08:00
|
|
|
tile_info.pip_data[i].dst_index == dst_index) {
|
2021-02-04 05:37:58 +08:00
|
|
|
|
|
|
|
PipId ret;
|
2021-01-28 10:00:43 +08:00
|
|
|
ret.tile = tile;
|
|
|
|
ret.index = i;
|
2021-02-04 05:37:58 +08:00
|
|
|
return ret;
|
2021-01-28 10:00:43 +08:00
|
|
|
}
|
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
2021-02-04 05:37:58 +08:00
|
|
|
} else {
|
|
|
|
int tile = tile_by_name.at(name.ids[0]);
|
|
|
|
auto &tile_info = chip_info->tile_types[chip_info->tiles[tile].type];
|
|
|
|
|
|
|
|
std::string pip_second = name.ids[1].str(this);
|
|
|
|
auto spn = split_identifier_name_dot(pip_second);
|
|
|
|
auto src_wire_name = id(spn.first);
|
|
|
|
auto dst_wire_name = id(spn.second);
|
|
|
|
|
|
|
|
int32_t src_index = -1;
|
|
|
|
int32_t dst_index = -1;
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int i = 0; i < tile_info.wire_data.ssize(); i++) {
|
2021-02-04 05:37:58 +08:00
|
|
|
if (tile_info.wire_data[i].site == -1 && tile_info.wire_data[i].name == src_wire_name.index) {
|
|
|
|
src_index = i;
|
2021-02-04 06:48:49 +08:00
|
|
|
if (dst_index != -1) {
|
2021-02-04 05:37:58 +08:00
|
|
|
break;
|
|
|
|
}
|
2021-01-28 10:00:43 +08:00
|
|
|
}
|
2021-02-04 05:37:58 +08:00
|
|
|
if (tile_info.wire_data[i].site == -1 && tile_info.wire_data[i].name == dst_wire_name.index) {
|
|
|
|
dst_index = i;
|
2021-02-04 06:48:49 +08:00
|
|
|
if (src_index != -1) {
|
2021-02-04 05:37:58 +08:00
|
|
|
break;
|
|
|
|
}
|
2021-01-28 10:00:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-04 05:37:58 +08:00
|
|
|
NPNR_ASSERT(src_index != -1);
|
|
|
|
NPNR_ASSERT(dst_index != -1);
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-06 01:32:30 +08:00
|
|
|
for (int i = 0; i < tile_info.pip_data.ssize(); i++) {
|
2021-02-04 06:48:49 +08:00
|
|
|
if (tile_info.pip_data[i].src_index == src_index && tile_info.pip_data[i].dst_index == dst_index) {
|
2021-02-04 05:37:58 +08:00
|
|
|
|
|
|
|
PipId ret;
|
|
|
|
ret.tile = tile;
|
|
|
|
ret.index = i;
|
|
|
|
return ret;
|
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-04 05:37:58 +08:00
|
|
|
return PipId();
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
2021-02-04 05:37:58 +08:00
|
|
|
IdStringList Arch::getPipName(PipId pip) const
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
2021-01-28 10:00:43 +08:00
|
|
|
// PIP name structure:
|
|
|
|
// Tile PIP: <tile name>/<source wire name>.<destination wire name>
|
|
|
|
// Psuedo site PIP: <site name>/<input site wire>.<output site wire>
|
|
|
|
// Site PIP: <site name>/<bel name>/<input bel pin name>
|
|
|
|
// Site pin: <site name>/<bel name>
|
2021-01-27 02:05:23 +08:00
|
|
|
NPNR_ASSERT(pip != PipId());
|
2021-01-28 10:00:43 +08:00
|
|
|
auto &tile = chip_info->tiles[pip.tile];
|
2021-02-05 06:23:12 +08:00
|
|
|
auto &tile_type = loc_info(chip_info, pip);
|
2021-01-28 10:00:43 +08:00
|
|
|
auto &pip_info = tile_type.pip_data[pip.index];
|
|
|
|
if (pip_info.site != -1) {
|
|
|
|
// This is either a site pin or a site pip.
|
2021-02-19 05:26:52 +08:00
|
|
|
auto &site = get_site_inst(pip);
|
2021-01-28 10:00:43 +08:00
|
|
|
auto &bel = tile_type.bel_data[pip_info.bel];
|
|
|
|
IdString bel_name(bel.name);
|
2021-02-04 06:48:49 +08:00
|
|
|
if (bel.category == BEL_CATEGORY_LOGIC) {
|
2021-01-28 10:00:43 +08:00
|
|
|
// This is a psuedo pip
|
2021-02-04 05:37:58 +08:00
|
|
|
IdString src_wire_name = IdString(tile_type.wire_data[pip_info.src_index].name);
|
|
|
|
IdString dst_wire_name = IdString(tile_type.wire_data[pip_info.dst_index].name);
|
|
|
|
IdString pip = id(src_wire_name.str(this) + "." + dst_wire_name.str(this));
|
|
|
|
std::array<IdString, 2> ids{id(site.name.get()), pip};
|
|
|
|
return IdStringList(ids);
|
2021-01-28 10:00:43 +08:00
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
} else if (bel.category == BEL_CATEGORY_ROUTING) {
|
2021-01-28 10:00:43 +08:00
|
|
|
// This is a site pip.
|
|
|
|
IdString pin_name(bel.ports[pip_info.extra_data]);
|
2021-02-04 05:37:58 +08:00
|
|
|
std::array<IdString, 3> ids{id(site.name.get()), bel_name, pin_name};
|
|
|
|
return IdStringList(ids);
|
2021-01-28 10:00:43 +08:00
|
|
|
} else {
|
|
|
|
NPNR_ASSERT(bel.category == BEL_CATEGORY_SITE_PORT);
|
|
|
|
// This is a site pin, just the name of the BEL is a unique identifier.
|
2021-02-04 05:37:58 +08:00
|
|
|
std::array<IdString, 2> ids{id(site.name.get()), bel_name};
|
|
|
|
return IdStringList(ids);
|
2021-01-28 10:00:43 +08:00
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
} else {
|
2021-01-28 10:00:43 +08:00
|
|
|
// This is a tile pip.
|
2021-02-04 05:37:58 +08:00
|
|
|
IdString src_wire_name = IdString(tile_type.wire_data[pip_info.src_index].name);
|
|
|
|
IdString dst_wire_name = IdString(tile_type.wire_data[pip_info.dst_index].name);
|
|
|
|
IdString pip = id(src_wire_name.str(this) + "." + dst_wire_name.str(this));
|
|
|
|
std::array<IdString, 2> ids{id(std::string(tile.name.get())), pip};
|
|
|
|
return IdStringList(ids);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IdString Arch::getPipType(PipId pip) const { return id("PIP"); }
|
|
|
|
|
|
|
|
std::vector<std::pair<IdString, std::string>> Arch::getPipAttrs(PipId pip) const { return {}; }
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
BelId Arch::getBelByLocation(Loc loc) const
|
|
|
|
{
|
|
|
|
BelId bi;
|
|
|
|
if (loc.x >= chip_info->width || loc.y >= chip_info->height)
|
|
|
|
return BelId();
|
2021-02-05 06:23:12 +08:00
|
|
|
bi.tile = get_tile_index(loc);
|
|
|
|
auto &li = loc_info(chip_info, bi);
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-06 01:32:30 +08:00
|
|
|
if (loc.z >= li.bel_data.ssize()) {
|
2021-01-27 02:05:23 +08:00
|
|
|
return BelId();
|
|
|
|
} else {
|
|
|
|
bi.index = loc.z;
|
|
|
|
return bi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::pair<IdString, std::string>> Arch::getBelAttrs(BelId bel) const { return {}; }
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ArcBounds Arch::getRouteBoundingBox(WireId src, WireId dst) const
|
|
|
|
{
|
|
|
|
int dst_tile = dst.tile == -1 ? chip_info->nodes[dst.index].tile_wires[0].tile : dst.tile;
|
|
|
|
int src_tile = src.tile == -1 ? chip_info->nodes[src.index].tile_wires[0].tile : src.tile;
|
|
|
|
|
|
|
|
int x0, x1, y0, y1;
|
|
|
|
x0 = src_tile % chip_info->width;
|
|
|
|
x1 = x0;
|
|
|
|
y0 = src_tile / chip_info->width;
|
|
|
|
y1 = y0;
|
|
|
|
auto expand = [&](int x, int y) {
|
|
|
|
x0 = std::min(x0, x);
|
|
|
|
x1 = std::max(x1, x);
|
|
|
|
y0 = std::min(y0, y);
|
|
|
|
y1 = std::max(y1, y);
|
|
|
|
};
|
|
|
|
|
|
|
|
expand(dst_tile % chip_info->width, dst_tile / chip_info->width);
|
|
|
|
|
|
|
|
if (source_locs.count(src))
|
|
|
|
expand(source_locs.at(src).x, source_locs.at(src).y);
|
|
|
|
|
|
|
|
if (sink_locs.count(dst)) {
|
|
|
|
expand(sink_locs.at(dst).x, sink_locs.at(dst).y);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {x0, y0, x1, y1};
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Arch::getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const { return false; }
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool Arch::pack()
|
|
|
|
{
|
2021-02-06 06:18:38 +08:00
|
|
|
pack_ports();
|
|
|
|
return true;
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Arch::place()
|
|
|
|
{
|
2021-02-06 06:18:38 +08:00
|
|
|
std::string placer = str_or_default(settings, id("placer"), defaultPlacer);
|
|
|
|
|
|
|
|
if (placer == "heap") {
|
|
|
|
PlacerHeapCfg cfg(getCtx());
|
|
|
|
cfg.criticalityExponent = 7;
|
|
|
|
cfg.alpha = 0.08;
|
|
|
|
cfg.beta = 0.4;
|
|
|
|
cfg.placeAllAtOnce = true;
|
|
|
|
cfg.hpwl_scale_x = 1;
|
|
|
|
cfg.hpwl_scale_y = 2;
|
|
|
|
cfg.spread_scale_x = 2;
|
|
|
|
cfg.spread_scale_y = 1;
|
|
|
|
cfg.solverTolerance = 0.6e-6;
|
|
|
|
if (!placer_heap(getCtx(), cfg))
|
|
|
|
return false;
|
|
|
|
} else if (placer == "sa") {
|
|
|
|
if (!placer1(getCtx(), Placer1Cfg(getCtx())))
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
log_error("FPGA interchange architecture does not support placer '%s'\n", placer.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
getCtx()->attrs[getCtx()->id("step")] = std::string("place");
|
|
|
|
archInfoToAttributes();
|
|
|
|
return true;
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Arch::route()
|
|
|
|
{
|
2021-02-06 06:18:38 +08:00
|
|
|
std::string router = str_or_default(settings, id("router"), defaultRouter);
|
|
|
|
|
|
|
|
bool result;
|
|
|
|
if (router == "router1") {
|
|
|
|
result = router1(getCtx(), Router1Cfg(getCtx()));
|
|
|
|
} else if (router == "router2") {
|
|
|
|
router2(getCtx(), Router2Cfg(getCtx()));
|
|
|
|
result = true;
|
|
|
|
} else {
|
|
|
|
log_error("FPGA interchange architecture does not support router '%s'\n", router.c_str());
|
|
|
|
}
|
|
|
|
getCtx()->attrs[getCtx()->id("step")] = std::string("route");
|
|
|
|
archInfoToAttributes();
|
|
|
|
return result;
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const { return {}; }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
DecalXY Arch::getBelDecal(BelId bel) const
|
|
|
|
{
|
|
|
|
DecalXY decalxy;
|
|
|
|
return decalxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
DecalXY Arch::getWireDecal(WireId wire) const
|
|
|
|
{
|
|
|
|
DecalXY decalxy;
|
|
|
|
return decalxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
DecalXY Arch::getPipDecal(PipId pip) const { return {}; };
|
|
|
|
|
|
|
|
DecalXY Arch::getGroupDecal(GroupId pip) const { return {}; };
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
delay_t Arch::estimateDelay(WireId src, WireId dst) const
|
2021-02-02 06:26:57 +08:00
|
|
|
{
|
|
|
|
// FIXME: Implement something to push the A* router in the right direction.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
delay_t Arch::predictDelay(const NetInfo *net_info, const PortRef &sink) const
|
|
|
|
{
|
|
|
|
// FIXME: Implement when adding timing-driven place and route.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-02-19 18:39:57 +08:00
|
|
|
bool Arch::getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayQuad &delay) const
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
2021-01-27 06:45:54 +08:00
|
|
|
// FIXME: Implement when adding timing-driven place and route.
|
2021-01-27 02:05:23 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
TimingPortClass Arch::getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const
|
|
|
|
{
|
2021-01-27 06:45:54 +08:00
|
|
|
// FIXME: Implement when adding timing-driven place and route.
|
2021-01-27 02:05:23 +08:00
|
|
|
return TMG_IGNORE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TimingClockingInfo Arch::getPortClockingInfo(const CellInfo *cell, IdString port, int index) const
|
|
|
|
{
|
2021-01-27 06:45:54 +08:00
|
|
|
// FIXME: Implement when adding timing-driven place and route.
|
2021-01-27 02:05:23 +08:00
|
|
|
TimingClockingInfo info;
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2021-02-12 06:24:49 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2021-02-13 08:12:16 +08:00
|
|
|
void Arch::read_logical_netlist(const std::string &filename)
|
|
|
|
{
|
|
|
|
FpgaInterchange::read_logical_netlist(getCtx(), filename);
|
|
|
|
}
|
|
|
|
void Arch::write_physical_netlist(const std::string &filename) const
|
|
|
|
{
|
|
|
|
FpgaInterchange::write_physical_netlist(getCtx(), filename);
|
|
|
|
}
|
2021-02-12 06:24:49 +08:00
|
|
|
|
2021-02-13 00:14:27 +08:00
|
|
|
void Arch::parse_xdc(const std::string &filename)
|
|
|
|
{
|
2021-02-12 07:29:53 +08:00
|
|
|
TclInterp interp(getCtx());
|
|
|
|
auto result = Tcl_EvalFile(interp.interp, filename.c_str());
|
2021-02-13 00:14:27 +08:00
|
|
|
if (result != TCL_OK) {
|
|
|
|
log_error("Error in %s:%d => %s\n", filename.c_str(), Tcl_GetErrorLine(interp.interp),
|
|
|
|
Tcl_GetStringResult(interp.interp));
|
2021-02-12 07:29:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-13 08:12:16 +08:00
|
|
|
std::string Arch::get_part() const
|
|
|
|
{
|
|
|
|
// FIXME: Need a map between device / package / speed grade and part.
|
|
|
|
return chip_info->name.get() + args.package + "-1";
|
|
|
|
}
|
|
|
|
|
2021-02-12 06:24:49 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
#ifdef WITH_HEAP
|
|
|
|
const std::string Arch::defaultPlacer = "heap";
|
|
|
|
#else
|
|
|
|
const std::string Arch::defaultPlacer = "sa";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const std::vector<std::string> Arch::availablePlacers = {"sa",
|
|
|
|
#ifdef WITH_HEAP
|
|
|
|
"heap"
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
const std::string Arch::defaultRouter = "router2";
|
|
|
|
const std::vector<std::string> Arch::availableRouters = {"router1", "router2"};
|
|
|
|
|
2021-02-16 01:45:52 +08:00
|
|
|
void Arch::map_cell_pins(CellInfo *cell, int32_t mapping) const
|
|
|
|
{
|
|
|
|
cell->cell_mapping = mapping;
|
|
|
|
cell->cell_bel_pins.clear();
|
|
|
|
|
|
|
|
const CellBelMapPOD &cell_pin_map = chip_info->cell_map->cell_bel_map[mapping];
|
|
|
|
|
|
|
|
for (const auto &pin_map : cell_pin_map.common_pins) {
|
|
|
|
IdString cell_pin(pin_map.cell_pin);
|
|
|
|
IdString bel_pin(pin_map.bel_pin);
|
|
|
|
|
|
|
|
if (cell_pin.str(this) == "GND") {
|
|
|
|
// FIXME: Tie this pin to the GND net
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (cell_pin.str(this) == "VCC") {
|
|
|
|
// FIXME: Tie this pin to the VCC net
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
cell->cell_bel_pins[cell_pin].push_back(bel_pin);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto ¶meter_pin_map : cell_pin_map.parameter_pins) {
|
|
|
|
IdString param_key(parameter_pin_map.key);
|
|
|
|
std::string param_value = IdString(parameter_pin_map.value).c_str(this);
|
|
|
|
|
|
|
|
auto iter = cell->params.find(param_key);
|
|
|
|
if (iter == cell->params.end()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (param_value != iter->second.as_string()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto &pin_map : parameter_pin_map.pins) {
|
|
|
|
IdString cell_pin(pin_map.cell_pin);
|
|
|
|
IdString bel_pin(pin_map.bel_pin);
|
|
|
|
|
|
|
|
if (cell_pin.str(this) == "GND") {
|
|
|
|
// FIXME: Tie this pin to the GND net
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (cell_pin.str(this) == "VCC") {
|
|
|
|
// FIXME: Tie this pin to the VCC net
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
cell->cell_bel_pins[cell_pin].push_back(bel_pin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Arch::map_port_pins(BelId bel, CellInfo *cell) const
|
|
|
|
{
|
|
|
|
IdStringRange pins = getBelPins(bel);
|
2021-02-18 02:18:24 +08:00
|
|
|
IdString pin = get_only_value(pins);
|
|
|
|
|
2021-02-16 01:45:52 +08:00
|
|
|
NPNR_ASSERT(cell->ports.size() == 1);
|
|
|
|
cell->cell_bel_pins[cell->ports.begin()->first].clear();
|
|
|
|
cell->cell_bel_pins[cell->ports.begin()->first].push_back(pin);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Arch::is_net_within_site(const NetInfo &net) const
|
|
|
|
{
|
|
|
|
if (net.driver.cell == nullptr || net.driver.cell->bel == BelId()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
BelId driver = net.driver.cell->bel;
|
|
|
|
int32_t site = bel_info(chip_info, driver).site;
|
|
|
|
NPNR_ASSERT(site >= 0);
|
|
|
|
|
|
|
|
for (const auto &user : net.users) {
|
|
|
|
if (user.cell == nullptr || user.cell->bel == BelId()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
BelId user_bel = user.cell->bel;
|
|
|
|
|
|
|
|
if (user_bel.tile != driver.tile) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bel_info(chip_info, user_bel).site != site) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-02-17 06:51:25 +08:00
|
|
|
size_t Arch::get_cell_type_index(IdString cell_type) const
|
|
|
|
{
|
|
|
|
const CellMapPOD &cell_map = *chip_info->cell_map;
|
|
|
|
int cell_offset = cell_type.index - cell_map.cell_names[0];
|
2021-02-17 09:25:16 +08:00
|
|
|
if ((cell_offset < 0 || cell_offset >= cell_map.cell_names.ssize())) {
|
2021-02-17 06:51:25 +08:00
|
|
|
log_error("Cell %s is not a placable element.\n", cell_type.c_str(this));
|
|
|
|
}
|
|
|
|
NPNR_ASSERT(cell_map.cell_names[cell_offset] == cell_type.index);
|
|
|
|
|
|
|
|
return cell_offset;
|
|
|
|
}
|
|
|
|
|
2021-02-06 06:18:38 +08:00
|
|
|
// Instance constraint templates.
|
|
|
|
template void Arch::ArchConstraints::bindBel(Arch::ArchConstraints::TagState *, const Arch::ConstraintRange);
|
|
|
|
template void Arch::ArchConstraints::unbindBel(Arch::ArchConstraints::TagState *, const Arch::ConstraintRange);
|
|
|
|
template bool Arch::ArchConstraints::isValidBelForCellType(const Context *, uint32_t,
|
|
|
|
const Arch::ArchConstraints::TagState *,
|
|
|
|
const Arch::ConstraintRange, IdString, IdString, BelId,
|
|
|
|
bool) const;
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
NEXTPNR_NAMESPACE_END
|