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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NEXTPNR_H
|
|
|
|
#error Include "arch.h" via "nextpnr.h" only.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <boost/iostreams/device/mapped_file.hpp>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2021-02-06 06:18:38 +08:00
|
|
|
#include "constraints.h"
|
2021-02-20 08:18:59 +08:00
|
|
|
#include "dedicated_interconnect.h"
|
2021-02-06 06:18:38 +08:00
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/**** Everything in this section must be kept in sync with chipdb.py ****/
|
|
|
|
|
2021-02-05 08:05:01 +08:00
|
|
|
#include "relptr.h"
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// Flattened site indexing.
|
|
|
|
//
|
|
|
|
// To enable flat BelId.z spaces, every tile and sites within that tile are
|
|
|
|
// flattened.
|
|
|
|
//
|
|
|
|
// This has implications on BelId's, WireId's and PipId's.
|
|
|
|
// The flattened site space works as follows:
|
|
|
|
// - Objects that belong to the tile are first. BELs are always part of Sites,
|
|
|
|
// so no BEL objects are in this category.
|
|
|
|
// - All site alternative modes are exposed as a "full" site.
|
|
|
|
// - Each site appends it's BEL's, wires (site wires) and PIP's.
|
|
|
|
// - Sites add two types of pips. Sites will add pip data first for site
|
|
|
|
// pips, and then for site pin edges.
|
|
|
|
// 1. The first type is site pips, which connect site wires to other site
|
|
|
|
// wires.
|
|
|
|
// 2. The second type is site pin edges, which connect site wires to tile
|
|
|
|
// wires (or vise-versa).
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct BelInfoPOD {
|
2021-02-04 06:48:49 +08:00
|
|
|
int32_t name; // bel name (in site) constid
|
|
|
|
int32_t type; // Type name constid
|
|
|
|
int32_t bel_bucket; // BEL bucket constid.
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
int32_t num_bel_wires;
|
|
|
|
RelPtr<int32_t> ports; // port name constid
|
2021-01-28 10:00:43 +08:00
|
|
|
RelPtr<int32_t> types; // port type (IN/OUT/BIDIR)
|
2021-01-27 02:05:23 +08:00
|
|
|
RelPtr<int32_t> wires; // connected wire index in tile, or -1 if NA
|
|
|
|
|
|
|
|
int16_t site;
|
|
|
|
int16_t site_variant; // some sites have alternative types
|
2021-01-28 10:00:43 +08:00
|
|
|
int16_t category;
|
2021-02-19 08:51:36 +08:00
|
|
|
int16_t synthetic;
|
2021-02-01 23:18:28 +08:00
|
|
|
|
2021-02-16 01:45:52 +08:00
|
|
|
RelPtr<int32_t> pin_map; // Index into CellMapPOD::cell_bel_map
|
2021-01-27 02:05:23 +08:00
|
|
|
});
|
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
enum BELCategory
|
|
|
|
{
|
2021-01-28 10:00:43 +08:00
|
|
|
// BEL is a logic element
|
|
|
|
BEL_CATEGORY_LOGIC = 0,
|
|
|
|
// BEL is a site routing mux
|
|
|
|
BEL_CATEGORY_ROUTING = 1,
|
|
|
|
// BEL is a site port, e.g. boundry between site and routing graph.
|
|
|
|
BEL_CATEGORY_SITE_PORT = 2
|
|
|
|
};
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct BelPortPOD {
|
|
|
|
int32_t bel_index;
|
|
|
|
int32_t port;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct TileWireInfoPOD {
|
2021-01-27 06:45:54 +08:00
|
|
|
int32_t name; // wire name constid
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// Pip index inside tile
|
2021-02-05 08:05:01 +08:00
|
|
|
RelSlice<int32_t> pips_uphill;
|
2021-01-27 06:45:54 +08:00
|
|
|
|
|
|
|
// Pip index inside tile
|
2021-02-05 08:05:01 +08:00
|
|
|
RelSlice<int32_t> pips_downhill;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// Bel index inside tile
|
2021-02-05 08:05:01 +08:00
|
|
|
RelSlice<BelPortPOD> bel_pins;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
int16_t site; // site index in tile
|
|
|
|
int16_t site_variant; // site variant index in tile
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct PipInfoPOD {
|
|
|
|
int32_t src_index, dst_index;
|
|
|
|
int16_t site; // site index in tile
|
|
|
|
int16_t site_variant; // site variant index in tile
|
|
|
|
int16_t bel; // BEL this pip belongs to if site pip.
|
|
|
|
int16_t extra_data;
|
|
|
|
});
|
|
|
|
|
2021-02-16 01:45:52 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct ConstraintTagPOD {
|
|
|
|
int32_t tag_prefix; // constid
|
|
|
|
int32_t default_state; // constid
|
|
|
|
RelSlice<int32_t> states; // constid
|
|
|
|
});
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct TileTypeInfoPOD {
|
|
|
|
int32_t name; // Tile type constid
|
|
|
|
|
2021-02-05 08:05:01 +08:00
|
|
|
RelSlice<BelInfoPOD> bel_data;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-05 08:05:01 +08:00
|
|
|
RelSlice<TileWireInfoPOD> wire_data;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-05 08:05:01 +08:00
|
|
|
RelSlice<PipInfoPOD> pip_data;
|
2021-02-16 01:45:52 +08:00
|
|
|
|
|
|
|
RelSlice<ConstraintTagPOD> tags;
|
2021-02-18 10:08:26 +08:00
|
|
|
|
2021-02-19 08:51:36 +08:00
|
|
|
RelSlice<int32_t> site_types; // constid
|
2021-01-27 02:05:23 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct SiteInstInfoPOD {
|
|
|
|
RelPtr<char> name;
|
2021-02-16 01:45:52 +08:00
|
|
|
RelPtr<char> site_name;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// Which site type is this site instance?
|
|
|
|
// constid
|
|
|
|
int32_t site_type;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct TileInstInfoPOD {
|
|
|
|
// Name of this tile.
|
|
|
|
RelPtr<char> name;
|
|
|
|
|
|
|
|
// Index into root.tile_types.
|
|
|
|
int32_t type;
|
|
|
|
|
2021-02-18 10:08:26 +08:00
|
|
|
// This array is root.tile_types[type].site_types.size() long.
|
2021-01-27 06:45:54 +08:00
|
|
|
// Index into root.sites
|
2021-02-16 01:45:52 +08:00
|
|
|
RelSlice<int32_t> sites;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// Number of tile wires; excluding any site-internal wires
|
|
|
|
// which come after general wires and are not stored here
|
|
|
|
// as they will never be nodal
|
|
|
|
// -1 if a tile-local wire; node index if nodal wire
|
2021-02-05 08:05:01 +08:00
|
|
|
RelSlice<int32_t> tile_wire_to_node;
|
2021-01-27 02:05:23 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct TileWireRefPOD {
|
|
|
|
int32_t tile;
|
|
|
|
int32_t index;
|
|
|
|
});
|
|
|
|
|
2021-02-06 01:22:55 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct NodeInfoPOD { RelSlice<TileWireRefPOD> tile_wires; });
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-16 01:45:52 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct CellBelPinPOD {
|
|
|
|
int32_t cell_pin; // constid
|
|
|
|
int32_t bel_pin; // constid
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct ParameterPinsPOD {
|
|
|
|
int32_t key; // constid
|
|
|
|
int32_t value; // constid
|
|
|
|
RelSlice<CellBelPinPOD> pins;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct CellConstraintPOD {
|
|
|
|
int32_t tag; // Tag index
|
|
|
|
int32_t constraint_type; // Constraint::ConstraintType
|
|
|
|
RelSlice<int32_t> states; // State indicies
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct CellBelMapPOD {
|
|
|
|
RelSlice<CellBelPinPOD> common_pins;
|
|
|
|
RelSlice<ParameterPinsPOD> parameter_pins;
|
|
|
|
RelSlice<CellConstraintPOD> constraints;
|
|
|
|
});
|
|
|
|
|
2021-02-01 23:18:28 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct CellMapPOD {
|
|
|
|
// Cell names supported in this arch.
|
2021-02-05 08:05:01 +08:00
|
|
|
RelSlice<int32_t> cell_names; // constids
|
|
|
|
RelSlice<int32_t> cell_bel_buckets; // constids
|
2021-02-16 01:45:52 +08:00
|
|
|
|
|
|
|
RelSlice<CellBelMapPOD> cell_bel_map;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct PackagePinPOD {
|
|
|
|
int32_t package_pin; // constid
|
|
|
|
int32_t site; // constid
|
|
|
|
int32_t bel; // constid
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct PackagePOD {
|
|
|
|
int32_t package; // constid
|
|
|
|
RelSlice<PackagePinPOD> pins;
|
2021-02-01 23:18:28 +08:00
|
|
|
});
|
|
|
|
|
2021-02-18 10:08:26 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct ConstantsPOD {
|
|
|
|
// Cell type and port for the GND and VCC global source.
|
|
|
|
int32_t gnd_cell_name; // constid
|
|
|
|
int32_t gnd_cell_port; // constid
|
|
|
|
|
|
|
|
int32_t vcc_cell_name; // constid
|
|
|
|
int32_t vcc_cell_port; // constid
|
|
|
|
|
|
|
|
int32_t gnd_bel_tile;
|
|
|
|
int32_t gnd_bel_index;
|
2021-02-19 08:57:09 +08:00
|
|
|
int32_t gnd_bel_pin; // constid
|
2021-02-18 10:08:26 +08:00
|
|
|
|
|
|
|
int32_t vcc_bel_tile;
|
|
|
|
int32_t vcc_bel_index;
|
2021-02-19 08:57:09 +08:00
|
|
|
int32_t vcc_bel_pin; // constid
|
2021-02-18 10:08:26 +08:00
|
|
|
|
|
|
|
// Name to use for the global GND constant net
|
|
|
|
int32_t gnd_net_name; // constid
|
|
|
|
|
|
|
|
// Name to use for the global VCC constant net
|
|
|
|
int32_t vcc_net_name; // constid
|
|
|
|
});
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct ChipInfoPOD {
|
|
|
|
RelPtr<char> name;
|
|
|
|
RelPtr<char> generator;
|
|
|
|
|
|
|
|
int32_t version;
|
|
|
|
int32_t width, height;
|
2021-01-27 06:45:54 +08:00
|
|
|
|
2021-02-05 08:05:01 +08:00
|
|
|
RelSlice<TileTypeInfoPOD> tile_types;
|
|
|
|
RelSlice<SiteInstInfoPOD> sites;
|
|
|
|
RelSlice<TileInstInfoPOD> tiles;
|
|
|
|
RelSlice<NodeInfoPOD> nodes;
|
2021-02-16 01:45:52 +08:00
|
|
|
RelSlice<PackagePOD> packages;
|
2021-02-01 23:18:28 +08:00
|
|
|
|
2021-02-02 05:31:31 +08:00
|
|
|
// BEL bucket constids.
|
2021-02-05 08:05:01 +08:00
|
|
|
RelSlice<int32_t> bel_buckets;
|
2021-02-02 05:31:31 +08:00
|
|
|
|
|
|
|
RelPtr<CellMapPOD> cell_map;
|
2021-02-18 10:08:26 +08:00
|
|
|
RelPtr<ConstantsPOD> constants;
|
2021-02-06 01:22:55 +08:00
|
|
|
|
2021-02-06 01:32:30 +08:00
|
|
|
// Constid string data.
|
2021-02-06 01:22:55 +08:00
|
|
|
RelPtr<RelSlice<RelPtr<char>>> constids;
|
2021-01-27 02:05:23 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
/************************ End of chipdb section. ************************/
|
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
inline const TileTypeInfoPOD &tile_info(const ChipInfoPOD *chip_info, int32_t tile)
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
return chip_info->tile_types[chip_info->tiles[tile].type];
|
|
|
|
}
|
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
template <typename Id> const TileTypeInfoPOD &loc_info(const ChipInfoPOD *chip_info, Id &id)
|
|
|
|
{
|
|
|
|
return chip_info->tile_types[chip_info->tiles[id.tile].type];
|
|
|
|
}
|
|
|
|
|
2021-02-06 01:22:55 +08:00
|
|
|
inline const BelInfoPOD &bel_info(const ChipInfoPOD *chip_info, BelId bel)
|
|
|
|
{
|
2021-02-05 06:23:12 +08:00
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
return loc_info(chip_info, bel).bel_data[bel.index];
|
|
|
|
}
|
|
|
|
|
2021-02-13 08:12:16 +08:00
|
|
|
inline const PipInfoPOD &pip_info(const ChipInfoPOD *chip_info, PipId pip)
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
|
|
|
return loc_info(chip_info, pip).pip_data[pip.index];
|
|
|
|
}
|
|
|
|
|
2021-02-19 05:26:52 +08:00
|
|
|
inline const SiteInstInfoPOD &site_inst_info(const ChipInfoPOD *chip_info, int32_t tile, int32_t site)
|
|
|
|
{
|
|
|
|
return chip_info->sites[chip_info->tiles[tile].sites[site]];
|
|
|
|
}
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
struct BelIterator
|
|
|
|
{
|
|
|
|
const ChipInfoPOD *chip;
|
|
|
|
int cursor_index;
|
|
|
|
int cursor_tile;
|
|
|
|
|
|
|
|
BelIterator operator++()
|
|
|
|
{
|
|
|
|
cursor_index++;
|
2021-02-06 01:32:30 +08:00
|
|
|
while (cursor_tile < chip->tiles.ssize() && cursor_index >= tile_info(chip, cursor_tile).bel_data.ssize()) {
|
2021-01-27 02:05:23 +08:00
|
|
|
cursor_index = 0;
|
|
|
|
cursor_tile++;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
BelIterator operator++(int)
|
|
|
|
{
|
|
|
|
BelIterator prior(*this);
|
|
|
|
++(*this);
|
|
|
|
return prior;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const BelIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index != other.cursor_index || cursor_tile != other.cursor_tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const BelIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index == other.cursor_index && cursor_tile == other.cursor_tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
BelId operator*() const
|
|
|
|
{
|
|
|
|
BelId ret;
|
|
|
|
ret.tile = cursor_tile;
|
|
|
|
ret.index = cursor_index;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BelRange
|
|
|
|
{
|
|
|
|
BelIterator b, e;
|
|
|
|
BelIterator begin() const { return b; }
|
|
|
|
BelIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
2021-02-01 23:18:28 +08:00
|
|
|
struct FilteredBelIterator
|
|
|
|
{
|
|
|
|
std::function<bool(BelId)> filter;
|
|
|
|
BelIterator b, e;
|
|
|
|
|
|
|
|
FilteredBelIterator operator++()
|
|
|
|
{
|
|
|
|
++b;
|
2021-02-04 06:48:49 +08:00
|
|
|
while (b != e) {
|
|
|
|
if (filter(*b)) {
|
2021-02-01 23:18:28 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++b;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const FilteredBelIterator &other) const
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(e == other.e);
|
|
|
|
return b != other.b;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const FilteredBelIterator &other) const
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(e == other.e);
|
|
|
|
return b == other.b;
|
|
|
|
}
|
|
|
|
|
|
|
|
BelId operator*() const
|
|
|
|
{
|
2021-02-02 05:31:31 +08:00
|
|
|
BelId bel = *b;
|
|
|
|
NPNR_ASSERT(filter(bel));
|
|
|
|
return bel;
|
2021-02-01 23:18:28 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FilteredBelRange
|
|
|
|
{
|
2021-02-04 06:48:49 +08:00
|
|
|
FilteredBelRange(BelIterator bel_b, BelIterator bel_e, std::function<bool(BelId)> filter)
|
|
|
|
{
|
2021-02-01 23:18:28 +08:00
|
|
|
b.filter = filter;
|
|
|
|
b.b = bel_b;
|
|
|
|
b.e = bel_e;
|
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
if (b.b != b.e && !filter(*b.b)) {
|
2021-02-02 05:31:31 +08:00
|
|
|
++b;
|
2021-02-01 23:18:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
e.b = bel_e;
|
|
|
|
e.e = bel_e;
|
2021-02-02 05:31:31 +08:00
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
if (b != e) {
|
2021-02-02 05:31:31 +08:00
|
|
|
NPNR_ASSERT(filter(*b.b));
|
|
|
|
}
|
2021-02-01 23:18:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
FilteredBelIterator b, e;
|
|
|
|
FilteredBelIterator begin() const { return b; }
|
|
|
|
FilteredBelIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Iterate over TileWires for a wire (will be more than one if nodal)
|
|
|
|
struct TileWireIterator
|
|
|
|
{
|
|
|
|
const ChipInfoPOD *chip;
|
|
|
|
WireId baseWire;
|
|
|
|
int cursor = -1;
|
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
void operator++() { cursor++; }
|
2021-01-28 10:00:43 +08:00
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
bool operator==(const TileWireIterator &other) const { return cursor == other.cursor; }
|
|
|
|
bool operator!=(const TileWireIterator &other) const { return cursor != other.cursor; }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// Returns a *denormalised* identifier always pointing to a tile wire rather than a node
|
|
|
|
WireId operator*() const
|
|
|
|
{
|
|
|
|
if (baseWire.tile == -1) {
|
|
|
|
WireId tw;
|
|
|
|
const auto &node_wire = chip->nodes[baseWire.index].tile_wires[cursor];
|
|
|
|
tw.tile = node_wire.tile;
|
|
|
|
tw.index = node_wire.index;
|
|
|
|
return tw;
|
|
|
|
} else {
|
|
|
|
return baseWire;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TileWireRange
|
|
|
|
{
|
|
|
|
TileWireIterator b, e;
|
|
|
|
TileWireIterator begin() const { return b; }
|
|
|
|
TileWireIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
inline WireId canonical_wire(const ChipInfoPOD *chip_info, int32_t tile, int32_t wire)
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
WireId id;
|
|
|
|
|
2021-02-06 01:32:30 +08:00
|
|
|
if (wire >= chip_info->tiles[tile].tile_wire_to_node.ssize()) {
|
2021-01-27 02:05:23 +08:00
|
|
|
// Cannot be a nodal wire
|
|
|
|
id.tile = tile;
|
|
|
|
id.index = wire;
|
|
|
|
} else {
|
|
|
|
int32_t node = chip_info->tiles[tile].tile_wire_to_node[wire];
|
|
|
|
if (node == -1) {
|
|
|
|
// Not a nodal wire
|
|
|
|
id.tile = tile;
|
|
|
|
id.index = wire;
|
|
|
|
} else {
|
|
|
|
// Is a nodal wire, set tile to -1
|
|
|
|
id.tile = -1;
|
|
|
|
id.index = node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct WireIterator
|
|
|
|
{
|
|
|
|
const ChipInfoPOD *chip;
|
|
|
|
int cursor_index = 0;
|
|
|
|
int cursor_tile = -1;
|
|
|
|
|
|
|
|
WireIterator operator++()
|
|
|
|
{
|
|
|
|
// Iterate over nodes first, then tile wires that aren't nodes
|
|
|
|
do {
|
|
|
|
cursor_index++;
|
2021-02-06 01:32:30 +08:00
|
|
|
if (cursor_tile == -1 && cursor_index >= chip->nodes.ssize()) {
|
2021-01-27 02:05:23 +08:00
|
|
|
cursor_tile = 0;
|
|
|
|
cursor_index = 0;
|
|
|
|
}
|
2021-02-06 01:32:30 +08:00
|
|
|
while (cursor_tile != -1 && cursor_tile < chip->tiles.ssize() &&
|
|
|
|
cursor_index >= chip->tile_types[chip->tiles[cursor_tile].type].wire_data.ssize()) {
|
2021-01-27 02:05:23 +08:00
|
|
|
cursor_index = 0;
|
|
|
|
cursor_tile++;
|
|
|
|
}
|
|
|
|
|
2021-02-06 01:32:30 +08:00
|
|
|
} while ((cursor_tile != -1 && cursor_tile < chip->tiles.ssize() &&
|
|
|
|
cursor_index < chip->tiles[cursor_tile].tile_wire_to_node.ssize() &&
|
2021-01-27 02:05:23 +08:00
|
|
|
chip->tiles[cursor_tile].tile_wire_to_node[cursor_index] != -1));
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
WireIterator operator++(int)
|
|
|
|
{
|
|
|
|
WireIterator prior(*this);
|
|
|
|
++(*this);
|
|
|
|
return prior;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const WireIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index != other.cursor_index || cursor_tile != other.cursor_tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const WireIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index == other.cursor_index && cursor_tile == other.cursor_tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
WireId operator*() const
|
|
|
|
{
|
|
|
|
WireId ret;
|
|
|
|
ret.tile = cursor_tile;
|
|
|
|
ret.index = cursor_index;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WireRange
|
|
|
|
{
|
|
|
|
WireIterator b, e;
|
|
|
|
WireIterator begin() const { return b; }
|
|
|
|
WireIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
struct AllPipIterator
|
|
|
|
{
|
|
|
|
const ChipInfoPOD *chip;
|
|
|
|
int cursor_index;
|
|
|
|
int cursor_tile;
|
|
|
|
|
|
|
|
AllPipIterator operator++()
|
|
|
|
{
|
|
|
|
cursor_index++;
|
2021-02-06 01:32:30 +08:00
|
|
|
while (cursor_tile < chip->tiles.ssize() &&
|
|
|
|
cursor_index >= chip->tile_types[chip->tiles[cursor_tile].type].pip_data.ssize()) {
|
2021-01-27 02:05:23 +08:00
|
|
|
cursor_index = 0;
|
|
|
|
cursor_tile++;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
AllPipIterator operator++(int)
|
|
|
|
{
|
|
|
|
AllPipIterator prior(*this);
|
|
|
|
++(*this);
|
|
|
|
return prior;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const AllPipIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index != other.cursor_index || cursor_tile != other.cursor_tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const AllPipIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index == other.cursor_index && cursor_tile == other.cursor_tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
PipId operator*() const
|
|
|
|
{
|
|
|
|
PipId ret;
|
|
|
|
ret.tile = cursor_tile;
|
|
|
|
ret.index = cursor_index;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AllPipRange
|
|
|
|
{
|
|
|
|
AllPipIterator b, e;
|
|
|
|
AllPipIterator begin() const { return b; }
|
|
|
|
AllPipIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct UphillPipIterator
|
|
|
|
{
|
|
|
|
const ChipInfoPOD *chip;
|
|
|
|
TileWireIterator twi, twi_end;
|
|
|
|
int cursor = -1;
|
|
|
|
|
|
|
|
void operator++()
|
|
|
|
{
|
|
|
|
cursor++;
|
|
|
|
while (true) {
|
|
|
|
if (!(twi != twi_end))
|
|
|
|
break;
|
|
|
|
WireId w = *twi;
|
|
|
|
auto &tile = chip->tile_types[chip->tiles[w.tile].type];
|
2021-02-06 01:32:30 +08:00
|
|
|
if (cursor < tile.wire_data[w.index].pips_uphill.ssize())
|
2021-01-27 02:05:23 +08:00
|
|
|
break;
|
|
|
|
++twi;
|
|
|
|
cursor = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool operator!=(const UphillPipIterator &other) const { return twi != other.twi || cursor != other.cursor; }
|
|
|
|
|
|
|
|
PipId operator*() const
|
|
|
|
{
|
|
|
|
PipId ret;
|
|
|
|
WireId w = *twi;
|
|
|
|
ret.tile = w.tile;
|
|
|
|
ret.index = chip->tile_types[chip->tiles[w.tile].type].wire_data[w.index].pips_uphill[cursor];
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UphillPipRange
|
|
|
|
{
|
|
|
|
UphillPipIterator b, e;
|
|
|
|
UphillPipIterator begin() const { return b; }
|
|
|
|
UphillPipIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DownhillPipIterator
|
|
|
|
{
|
|
|
|
const ChipInfoPOD *chip;
|
|
|
|
TileWireIterator twi, twi_end;
|
|
|
|
int cursor = -1;
|
|
|
|
|
|
|
|
void operator++()
|
|
|
|
{
|
|
|
|
cursor++;
|
|
|
|
while (true) {
|
|
|
|
if (!(twi != twi_end))
|
|
|
|
break;
|
|
|
|
WireId w = *twi;
|
|
|
|
auto &tile = chip->tile_types[chip->tiles[w.tile].type];
|
2021-02-06 01:32:30 +08:00
|
|
|
if (cursor < tile.wire_data[w.index].pips_downhill.ssize())
|
2021-01-27 02:05:23 +08:00
|
|
|
break;
|
|
|
|
++twi;
|
|
|
|
cursor = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool operator!=(const DownhillPipIterator &other) const { return twi != other.twi || cursor != other.cursor; }
|
|
|
|
|
|
|
|
PipId operator*() const
|
|
|
|
{
|
|
|
|
PipId ret;
|
|
|
|
WireId w = *twi;
|
|
|
|
ret.tile = w.tile;
|
|
|
|
ret.index = chip->tile_types[chip->tiles[w.tile].type].wire_data[w.index].pips_downhill[cursor];
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DownhillPipRange
|
|
|
|
{
|
|
|
|
DownhillPipIterator b, e;
|
|
|
|
DownhillPipIterator begin() const { return b; }
|
|
|
|
DownhillPipIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BelPinIterator
|
|
|
|
{
|
|
|
|
const ChipInfoPOD *chip;
|
|
|
|
TileWireIterator twi, twi_end;
|
|
|
|
int cursor = -1;
|
|
|
|
|
|
|
|
void operator++()
|
|
|
|
{
|
|
|
|
cursor++;
|
2021-01-28 10:00:43 +08:00
|
|
|
|
|
|
|
while (twi != twi_end) {
|
2021-01-27 02:05:23 +08:00
|
|
|
WireId w = *twi;
|
2021-02-05 06:23:12 +08:00
|
|
|
auto &tile = tile_info(chip, w.tile);
|
2021-02-06 01:32:30 +08:00
|
|
|
if (cursor < tile.wire_data[w.index].bel_pins.ssize())
|
2021-01-27 02:05:23 +08:00
|
|
|
break;
|
2021-01-28 10:00:43 +08:00
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
++twi;
|
|
|
|
cursor = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool operator!=(const BelPinIterator &other) const { return twi != other.twi || cursor != other.cursor; }
|
|
|
|
|
|
|
|
BelPin operator*() const
|
|
|
|
{
|
|
|
|
BelPin ret;
|
|
|
|
WireId w = *twi;
|
|
|
|
ret.bel.tile = w.tile;
|
2021-02-05 06:23:12 +08:00
|
|
|
ret.bel.index = tile_info(chip, w.tile).wire_data[w.index].bel_pins[cursor].bel_index;
|
|
|
|
ret.pin.index = tile_info(chip, w.tile).wire_data[w.index].bel_pins[cursor].port;
|
2021-01-27 02:05:23 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BelPinRange
|
|
|
|
{
|
|
|
|
BelPinIterator b, e;
|
|
|
|
BelPinIterator begin() const { return b; }
|
|
|
|
BelPinIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
2021-02-18 02:18:24 +08:00
|
|
|
struct IdStringIterator : std::iterator<std::forward_iterator_tag,
|
|
|
|
/*T=*/IdString,
|
|
|
|
/*Distance=*/ptrdiff_t,
|
|
|
|
/*pointer=*/IdString *,
|
|
|
|
/*reference=*/IdString>
|
2021-02-01 23:18:28 +08:00
|
|
|
{
|
|
|
|
const int32_t *cursor;
|
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
void operator++() { cursor += 1; }
|
2021-02-01 23:18:28 +08:00
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
bool operator!=(const IdStringIterator &other) const { return cursor != other.cursor; }
|
2021-02-01 23:18:28 +08:00
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
bool operator==(const IdStringIterator &other) const { return cursor == other.cursor; }
|
2021-02-01 23:18:28 +08:00
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
IdString operator*() const { return IdString(*cursor); }
|
2021-02-01 23:18:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct IdStringRange
|
|
|
|
{
|
|
|
|
IdStringIterator b, e;
|
|
|
|
IdStringIterator begin() const { return b; }
|
|
|
|
IdStringIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BelBucketIterator
|
|
|
|
{
|
|
|
|
IdStringIterator cursor;
|
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
void operator++() { ++cursor; }
|
2021-02-01 23:18:28 +08:00
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
bool operator!=(const BelBucketIterator &other) const { return cursor != other.cursor; }
|
2021-02-01 23:18:28 +08:00
|
|
|
|
2021-02-04 06:48:49 +08:00
|
|
|
bool operator==(const BelBucketIterator &other) const { return cursor == other.cursor; }
|
2021-02-01 23:18:28 +08:00
|
|
|
|
|
|
|
BelBucketId operator*() const
|
|
|
|
{
|
|
|
|
BelBucketId bucket;
|
|
|
|
bucket.name = IdString(*cursor);
|
|
|
|
return bucket;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BelBucketRange
|
|
|
|
{
|
|
|
|
BelBucketIterator b, e;
|
|
|
|
BelBucketIterator begin() const { return b; }
|
|
|
|
BelBucketIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
struct ArchArgs
|
|
|
|
{
|
|
|
|
std::string chipdb;
|
2021-02-12 06:24:49 +08:00
|
|
|
std::string package;
|
2021-01-27 02:05:23 +08:00
|
|
|
};
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
struct ArchRanges
|
|
|
|
{
|
|
|
|
using ArchArgsT = ArchArgs;
|
|
|
|
// Bels
|
|
|
|
using AllBelsRangeT = BelRange;
|
|
|
|
using TileBelsRangeT = BelRange;
|
|
|
|
using BelAttrsRangeT = std::vector<std::pair<IdString, std::string>>;
|
|
|
|
using BelPinsRangeT = IdStringRange;
|
2021-02-16 01:45:52 +08:00
|
|
|
using CellBelPinRangeT = const std::vector<IdString> &;
|
2021-02-08 18:41:03 +08:00
|
|
|
// Wires
|
|
|
|
using AllWiresRangeT = WireRange;
|
|
|
|
using DownhillPipRangeT = DownhillPipRange;
|
|
|
|
using UphillPipRangeT = UphillPipRange;
|
|
|
|
using WireBelPinRangeT = BelPinRange;
|
|
|
|
using WireAttrsRangeT = std::vector<std::pair<IdString, std::string>>;
|
|
|
|
// Pips
|
|
|
|
using AllPipsRangeT = AllPipRange;
|
|
|
|
using PipAttrsRangeT = std::vector<std::pair<IdString, std::string>>;
|
|
|
|
// Groups
|
|
|
|
using AllGroupsRangeT = std::vector<GroupId>;
|
|
|
|
using GroupBelsRangeT = std::vector<BelId>;
|
|
|
|
using GroupWiresRangeT = std::vector<WireId>;
|
|
|
|
using GroupPipsRangeT = std::vector<PipId>;
|
|
|
|
using GroupGroupsRangeT = std::vector<GroupId>;
|
|
|
|
// Decals
|
|
|
|
using DecalGfxRangeT = std::vector<GraphicElement>;
|
|
|
|
// Placement validity
|
|
|
|
using CellTypeRangeT = const IdStringRange;
|
|
|
|
using BelBucketRangeT = const BelBucketRange;
|
|
|
|
using BucketBelRangeT = FilteredBelRange;
|
|
|
|
};
|
|
|
|
|
2021-02-20 08:18:59 +08:00
|
|
|
struct DedicatedInterconnect;
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
struct Arch : ArchAPI<ArchRanges>
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
boost::iostreams::mapped_file_source blob_file;
|
|
|
|
const ChipInfoPOD *chip_info;
|
2021-02-16 01:45:52 +08:00
|
|
|
int32_t package_index;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-04 05:37:58 +08:00
|
|
|
mutable std::unordered_map<IdString, int> tile_by_name;
|
|
|
|
mutable std::unordered_map<IdString, std::pair<int, int>> site_by_name;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
std::unordered_map<WireId, NetInfo *> wire_to_net;
|
|
|
|
std::unordered_map<PipId, NetInfo *> pip_to_net;
|
|
|
|
|
2021-02-06 06:18:38 +08:00
|
|
|
static constexpr size_t kMaxState = 8;
|
2021-02-17 01:45:43 +08:00
|
|
|
|
|
|
|
struct TileStatus;
|
|
|
|
struct SiteRouter
|
|
|
|
{
|
|
|
|
SiteRouter(int16_t site) : site(site), dirty(false), site_ok(true) {}
|
|
|
|
|
|
|
|
std::unordered_set<CellInfo *> cells_in_site;
|
|
|
|
const int16_t site;
|
|
|
|
|
|
|
|
mutable bool dirty;
|
|
|
|
mutable bool site_ok;
|
|
|
|
|
|
|
|
void bindBel(CellInfo *cell);
|
|
|
|
void unbindBel(CellInfo *cell);
|
|
|
|
bool checkSiteRouting(const Context *ctx, const TileStatus &tile_status) const;
|
|
|
|
};
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
struct TileStatus
|
|
|
|
{
|
2021-02-06 06:18:38 +08:00
|
|
|
std::vector<ExclusiveStateGroup<kMaxState>> tags;
|
2021-01-27 02:05:23 +08:00
|
|
|
std::vector<CellInfo *> boundcells;
|
2021-02-17 01:45:43 +08:00
|
|
|
std::vector<SiteRouter> sites;
|
2021-01-27 02:05:23 +08:00
|
|
|
};
|
|
|
|
|
2021-02-20 08:18:59 +08:00
|
|
|
DedicatedInterconnect dedicated_interconnect;
|
2021-02-06 06:18:38 +08:00
|
|
|
std::unordered_map<int32_t, TileStatus> tileStatus;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
ArchArgs args;
|
|
|
|
Arch(ArchArgs args);
|
2021-02-20 08:18:59 +08:00
|
|
|
void init();
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
std::string getChipName() const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
IdString archId() const override { return id(chip_info->name.get()); }
|
|
|
|
ArchArgs archArgs() const override { return args; }
|
|
|
|
IdString archArgsToId(ArchArgs args) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
uint32_t get_tile_index(int x, int y) const { return (y * chip_info->width + x); }
|
|
|
|
uint32_t get_tile_index(Loc loc) const { return get_tile_index(loc.x, loc.y); }
|
2021-02-04 06:48:49 +08:00
|
|
|
template <typename TileIndex, typename CoordIndex>
|
2021-02-05 06:23:12 +08:00
|
|
|
void get_tile_x_y(TileIndex tile_index, CoordIndex *x, CoordIndex *y) const
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
2021-01-27 02:05:23 +08:00
|
|
|
*x = tile_index % chip_info->width;
|
|
|
|
*y = tile_index / chip_info->width;
|
|
|
|
}
|
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
template <typename TileIndex> void get_tile_loc(TileIndex tile_index, Loc *loc) const
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
2021-02-05 06:23:12 +08:00
|
|
|
get_tile_x_y(tile_index, &loc->x, &loc->y);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
int getGridDimX() const override { return chip_info->width; }
|
|
|
|
int getGridDimY() const override { return chip_info->height; }
|
|
|
|
int getTileBelDimZ(int x, int y) const override
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
2021-02-05 08:05:01 +08:00
|
|
|
return chip_info->tile_types[chip_info->tiles[get_tile_index(x, y)].type].bel_data.size();
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
2021-02-08 18:41:03 +08:00
|
|
|
int getTilePipDimZ(int x, int y) const override
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
2021-02-18 10:08:26 +08:00
|
|
|
return chip_info->tile_types[chip_info->tiles[get_tile_index(x, y)].type].site_types.size();
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
2021-02-08 18:41:03 +08:00
|
|
|
char getNameDelimiter() const override { return '/'; }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-13 08:12:16 +08:00
|
|
|
std::string get_part() const;
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
// -------------------------------------------------
|
|
|
|
|
|
|
|
void setup_byname() const;
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
BelId getBelByName(IdStringList name) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
IdStringList getBelName(BelId bel) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2021-02-19 05:26:52 +08:00
|
|
|
const SiteInstInfoPOD &site = get_site_inst(bel);
|
2021-02-05 06:23:12 +08:00
|
|
|
std::array<IdString, 2> ids{id(site.name.get()), IdString(bel_info(chip_info, bel).name)};
|
2021-02-04 05:37:58 +08:00
|
|
|
return IdStringList(ids);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
uint32_t getBelChecksum(BelId bel) const override { return bel.index; }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-16 01:45:52 +08:00
|
|
|
void map_cell_pins(CellInfo *cell, int32_t mapping) const;
|
|
|
|
void map_port_pins(BelId bel, CellInfo *cell) const;
|
|
|
|
|
2021-02-06 06:18:38 +08:00
|
|
|
TileStatus &get_tile_status(int32_t tile)
|
|
|
|
{
|
|
|
|
auto result = tileStatus.emplace(tile, TileStatus());
|
|
|
|
if (result.second) {
|
|
|
|
auto &tile_type = chip_info->tile_types[chip_info->tiles[tile].type];
|
|
|
|
result.first->second.boundcells.resize(tile_type.bel_data.size());
|
|
|
|
result.first->second.tags.resize(default_tags.size());
|
2021-02-17 01:45:43 +08:00
|
|
|
|
2021-02-18 10:08:26 +08:00
|
|
|
result.first->second.sites.reserve(tile_type.site_types.size());
|
|
|
|
for (size_t i = 0; i < tile_type.site_types.size(); ++i) {
|
2021-02-17 01:45:43 +08:00
|
|
|
result.first->second.sites.push_back(SiteRouter(i));
|
|
|
|
}
|
2021-02-06 06:18:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return result.first->second;
|
|
|
|
}
|
|
|
|
|
2021-02-17 01:45:43 +08:00
|
|
|
const SiteRouter &get_site_status(const TileStatus &tile_status, const BelInfoPOD &bel_data) const
|
|
|
|
{
|
|
|
|
return tile_status.sites.at(bel_data.site);
|
|
|
|
}
|
|
|
|
|
|
|
|
SiteRouter &get_site_status(TileStatus &tile_status, const BelInfoPOD &bel_data)
|
|
|
|
{
|
|
|
|
return tile_status.sites.at(bel_data.site);
|
|
|
|
}
|
|
|
|
|
2021-02-19 08:57:09 +08:00
|
|
|
BelId get_vcc_bel() const
|
|
|
|
{
|
2021-02-19 11:03:05 +08:00
|
|
|
auto &constants = *chip_info->constants;
|
2021-02-18 10:08:26 +08:00
|
|
|
BelId bel;
|
2021-02-19 11:03:05 +08:00
|
|
|
bel.tile = constants.vcc_bel_tile;
|
|
|
|
bel.index = constants.vcc_bel_index;
|
2021-02-18 10:08:26 +08:00
|
|
|
return bel;
|
|
|
|
}
|
|
|
|
|
2021-02-19 08:57:09 +08:00
|
|
|
BelId get_gnd_bel() const
|
|
|
|
{
|
2021-02-19 11:03:05 +08:00
|
|
|
auto &constants = *chip_info->constants;
|
2021-02-18 10:08:26 +08:00
|
|
|
BelId bel;
|
2021-02-19 11:03:05 +08:00
|
|
|
bel.tile = constants.gnd_bel_tile;
|
|
|
|
bel.index = constants.gnd_bel_index;
|
2021-02-18 10:08:26 +08:00
|
|
|
return bel;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength) override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
|
2021-02-06 06:18:38 +08:00
|
|
|
TileStatus &tile_status = get_tile_status(bel.tile);
|
|
|
|
NPNR_ASSERT(tile_status.boundcells[bel.index] == nullptr);
|
2021-02-16 01:45:52 +08:00
|
|
|
|
|
|
|
const auto &bel_data = bel_info(chip_info, bel);
|
|
|
|
NPNR_ASSERT(bel_data.category == BEL_CATEGORY_LOGIC);
|
|
|
|
|
|
|
|
if (io_port_types.count(cell->type) == 0) {
|
|
|
|
int32_t mapping = bel_info(chip_info, bel).pin_map[get_cell_type_index(cell->type)];
|
|
|
|
NPNR_ASSERT(mapping >= 0);
|
|
|
|
|
|
|
|
if (cell->cell_mapping != mapping) {
|
|
|
|
map_cell_pins(cell, mapping);
|
|
|
|
}
|
2021-02-06 06:18:38 +08:00
|
|
|
constraints.bindBel(tile_status.tags.data(), get_cell_constraints(bel, cell->type));
|
2021-02-16 01:45:52 +08:00
|
|
|
} else {
|
|
|
|
map_port_pins(bel, cell);
|
2021-02-06 06:18:38 +08:00
|
|
|
// FIXME: Probably need to actually constraint io port cell/bel,
|
|
|
|
// but the current BBA emission doesn't support that. This only
|
|
|
|
// really matters if the placer can choose IO port locations.
|
2021-02-16 01:45:52 +08:00
|
|
|
}
|
2021-02-06 06:18:38 +08:00
|
|
|
|
2021-02-17 01:45:43 +08:00
|
|
|
get_site_status(tile_status, bel_data).bindBel(cell);
|
|
|
|
|
2021-02-06 06:18:38 +08:00
|
|
|
tile_status.boundcells[bel.index] = cell;
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
cell->bel = bel;
|
|
|
|
cell->belStrength = strength;
|
2021-02-06 06:18:38 +08:00
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
refreshUiBel(bel);
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
void unbindBel(BelId bel) override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2021-02-06 06:18:38 +08:00
|
|
|
|
|
|
|
TileStatus &tile_status = get_tile_status(bel.tile);
|
|
|
|
NPNR_ASSERT(tile_status.boundcells[bel.index] != nullptr);
|
|
|
|
|
|
|
|
CellInfo *cell = tile_status.boundcells[bel.index];
|
|
|
|
tile_status.boundcells[bel.index] = nullptr;
|
|
|
|
|
|
|
|
cell->bel = BelId();
|
|
|
|
cell->belStrength = STRENGTH_NONE;
|
|
|
|
|
|
|
|
// FIXME: Probably need to actually constraint io port cell/bel,
|
|
|
|
// but the current BBA emission doesn't support that. This only
|
|
|
|
// really matters if the placer can choose IO port locations.
|
|
|
|
if (io_port_types.count(cell->type) == 0) {
|
|
|
|
constraints.unbindBel(tile_status.tags.data(), get_cell_constraints(bel, cell->type));
|
|
|
|
}
|
|
|
|
|
2021-02-17 01:45:43 +08:00
|
|
|
const auto &bel_data = bel_info(chip_info, bel);
|
|
|
|
get_site_status(tile_status, bel_data).unbindBel(cell);
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
refreshUiBel(bel);
|
|
|
|
}
|
|
|
|
|
2021-02-06 06:18:38 +08:00
|
|
|
bool checkBelAvail(BelId bel) const override
|
|
|
|
{
|
|
|
|
// FIXME: This could consult the constraint system to see if this BEL
|
|
|
|
// is blocked (e.g. site type is wrong).
|
|
|
|
return getBoundBelCell(bel) == nullptr;
|
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
CellInfo *getBoundBelCell(BelId bel) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2021-02-06 06:18:38 +08:00
|
|
|
auto iter = tileStatus.find(bel.tile);
|
|
|
|
if (iter == tileStatus.end()) {
|
|
|
|
return nullptr;
|
|
|
|
} else {
|
|
|
|
return iter->second.boundcells[bel.index];
|
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
CellInfo *getConflictingBelCell(BelId bel) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2021-02-06 06:18:38 +08:00
|
|
|
// FIXME: This could consult the constraint system to see why this BEL
|
|
|
|
// is blocked.
|
|
|
|
return getBoundBelCell(bel);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
BelRange getBels() const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
BelRange range;
|
|
|
|
range.b.cursor_tile = 0;
|
|
|
|
range.b.cursor_index = -1;
|
|
|
|
range.b.chip = chip_info;
|
|
|
|
++range.b; //-1 and then ++ deals with the case of no Bels in the first tile
|
|
|
|
range.e.cursor_tile = chip_info->width * chip_info->height;
|
|
|
|
range.e.cursor_index = 0;
|
|
|
|
range.e.chip = chip_info;
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
Loc getBelLocation(BelId bel) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
Loc loc;
|
2021-02-05 06:23:12 +08:00
|
|
|
get_tile_x_y(bel.tile, &loc.x, &loc.y);
|
2021-01-27 02:05:23 +08:00
|
|
|
loc.z = bel.index;
|
|
|
|
return loc;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
BelId getBelByLocation(Loc loc) const override;
|
|
|
|
BelRange getBelsByTile(int x, int y) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
bool getBelGlobalBuf(BelId bel) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
2021-02-02 06:26:57 +08:00
|
|
|
// FIXME: This probably needs to be fixed!
|
2021-01-27 02:05:23 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-02-12 06:10:03 +08:00
|
|
|
bool getBelHidden(BelId bel) const override { return bel_info(chip_info, bel).category != BEL_CATEGORY_LOGIC; }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
IdString getBelType(BelId bel) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2021-02-05 06:23:12 +08:00
|
|
|
return IdString(bel_info(chip_info, bel).type);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
std::vector<std::pair<IdString, std::string>> getBelAttrs(BelId bel) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
int get_bel_pin_index(BelId bel, IdString pin) const
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
2021-01-28 10:00:43 +08:00
|
|
|
NPNR_ASSERT(bel != BelId());
|
2021-02-05 06:23:12 +08:00
|
|
|
int num_bel_wires = bel_info(chip_info, bel).num_bel_wires;
|
|
|
|
const int32_t *ports = bel_info(chip_info, bel).ports.get();
|
2021-01-28 10:00:43 +08:00
|
|
|
for (int i = 0; i < num_bel_wires; i++) {
|
|
|
|
if (ports[i] == pin.index) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
WireId getBelPinWire(BelId bel, IdString pin) const override;
|
|
|
|
PortType getBelPinType(BelId bel, IdString pin) const override;
|
2021-02-02 06:26:57 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
IdStringRange getBelPins(BelId bel) const override
|
2021-02-02 06:26:57 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
int num_bel_wires = bel_info(chip_info, bel).num_bel_wires;
|
|
|
|
const int32_t *ports = bel_info(chip_info, bel).ports.get();
|
2021-02-02 06:26:57 +08:00
|
|
|
|
|
|
|
IdStringRange str_range;
|
|
|
|
str_range.b.cursor = &ports[0];
|
2021-02-16 01:45:52 +08:00
|
|
|
str_range.e.cursor = &ports[num_bel_wires];
|
2021-02-02 06:26:57 +08:00
|
|
|
|
|
|
|
return str_range;
|
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-24 05:49:01 +08:00
|
|
|
const std::vector<IdString> &getBelPinsForCellPin(const CellInfo *cell_info, IdString pin) const override
|
2021-02-16 01:45:52 +08:00
|
|
|
{
|
|
|
|
return cell_info->cell_bel_pins.at(pin);
|
|
|
|
}
|
2021-02-10 19:54:54 +08:00
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
// -------------------------------------------------
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
WireId getWireByName(IdStringList name) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
const TileWireInfoPOD &wire_info(WireId wire) const
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
if (wire.tile == -1) {
|
|
|
|
const TileWireRefPOD &wr = chip_info->nodes[wire.index].tile_wires[0];
|
|
|
|
return chip_info->tile_types[chip_info->tiles[wr.tile].type].wire_data[wr.index];
|
|
|
|
} else {
|
2021-02-05 06:23:12 +08:00
|
|
|
return loc_info(chip_info, wire).wire_data[wire.index];
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
IdStringList getWireName(WireId wire) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2021-02-05 08:05:01 +08:00
|
|
|
if (wire.tile != -1) {
|
2021-02-06 01:22:55 +08:00
|
|
|
const auto &tile_type = loc_info(chip_info, wire);
|
|
|
|
if (tile_type.wire_data[wire.index].site != -1) {
|
2021-02-19 05:26:52 +08:00
|
|
|
const SiteInstInfoPOD &site = get_site_inst(wire);
|
2021-02-05 08:05:01 +08:00
|
|
|
std::array<IdString, 2> ids{id(site.name.get()), IdString(tile_type.wire_data[wire.index].name)};
|
|
|
|
return IdStringList(ids);
|
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
2021-02-05 08:05:01 +08:00
|
|
|
|
|
|
|
int32_t tile = wire.tile == -1 ? chip_info->nodes[wire.index].tile_wires[0].tile : wire.tile;
|
|
|
|
IdString tile_name = id(chip_info->tiles[tile].name.get());
|
|
|
|
std::array<IdString, 2> ids{tile_name, IdString(wire_info(wire).name)};
|
|
|
|
return IdStringList(ids);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
IdString getWireType(WireId wire) const override;
|
|
|
|
std::vector<std::pair<IdString, std::string>> getWireAttrs(WireId wire) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
uint32_t getWireChecksum(WireId wire) const override { return wire.index; }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
void bindWire(WireId wire, NetInfo *net, PlaceStrength strength) override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
|
|
|
NPNR_ASSERT(wire_to_net[wire] == nullptr);
|
|
|
|
wire_to_net[wire] = net;
|
|
|
|
net->wires[wire].pip = PipId();
|
|
|
|
net->wires[wire].strength = strength;
|
|
|
|
refreshUiWire(wire);
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
void unbindWire(WireId wire) override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
|
|
|
NPNR_ASSERT(wire_to_net[wire] != nullptr);
|
|
|
|
|
|
|
|
auto &net_wires = wire_to_net[wire]->wires;
|
|
|
|
auto it = net_wires.find(wire);
|
|
|
|
NPNR_ASSERT(it != net_wires.end());
|
|
|
|
|
|
|
|
auto pip = it->second.pip;
|
|
|
|
if (pip != PipId()) {
|
|
|
|
pip_to_net[pip] = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
net_wires.erase(it);
|
|
|
|
wire_to_net[wire] = nullptr;
|
|
|
|
refreshUiWire(wire);
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
bool checkWireAvail(WireId wire) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
|
|
|
auto w2n = wire_to_net.find(wire);
|
|
|
|
return w2n == wire_to_net.end() || w2n->second == nullptr;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
NetInfo *getBoundWireNet(WireId wire) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
|
|
|
auto w2n = wire_to_net.find(wire);
|
|
|
|
return w2n == wire_to_net.end() ? nullptr : w2n->second;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
WireId getConflictingWireWire(WireId wire) const override { return wire; }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
NetInfo *getConflictingWireNet(WireId wire) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
|
|
|
auto w2n = wire_to_net.find(wire);
|
|
|
|
return w2n == wire_to_net.end() ? nullptr : w2n->second;
|
|
|
|
}
|
|
|
|
|
2021-02-19 18:39:57 +08:00
|
|
|
DelayQuad getWireDelay(WireId wire) const override { return DelayQuad(0); }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
TileWireRange get_tile_wire_range(WireId wire) const
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
TileWireRange range;
|
|
|
|
range.b.chip = chip_info;
|
|
|
|
range.b.baseWire = wire;
|
|
|
|
range.b.cursor = -1;
|
|
|
|
++range.b;
|
|
|
|
|
|
|
|
range.e.chip = chip_info;
|
|
|
|
range.e.baseWire = wire;
|
2021-01-28 10:00:43 +08:00
|
|
|
if (wire.tile == -1) {
|
2021-02-05 08:05:01 +08:00
|
|
|
range.e.cursor = chip_info->nodes[wire.index].tile_wires.size();
|
2021-01-28 10:00:43 +08:00
|
|
|
} else {
|
2021-01-27 02:05:23 +08:00
|
|
|
range.e.cursor = 1;
|
2021-01-28 10:00:43 +08:00
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
BelPinRange getWireBelPins(WireId wire) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
BelPinRange range;
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2021-01-28 10:00:43 +08:00
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
TileWireRange twr = get_tile_wire_range(wire);
|
2021-01-27 02:05:23 +08:00
|
|
|
range.b.chip = chip_info;
|
|
|
|
range.b.twi = twr.b;
|
|
|
|
range.b.twi_end = twr.e;
|
|
|
|
range.b.cursor = -1;
|
|
|
|
++range.b;
|
2021-01-28 10:00:43 +08:00
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
range.e.chip = chip_info;
|
|
|
|
range.e.twi = twr.e;
|
|
|
|
range.e.twi_end = twr.e;
|
|
|
|
range.e.cursor = 0;
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
WireRange getWires() const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
WireRange range;
|
|
|
|
range.b.chip = chip_info;
|
|
|
|
range.b.cursor_tile = -1;
|
|
|
|
range.b.cursor_index = 0;
|
|
|
|
range.e.chip = chip_info;
|
2021-02-05 08:05:01 +08:00
|
|
|
range.e.cursor_tile = chip_info->tiles.size();
|
2021-01-27 02:05:23 +08:00
|
|
|
range.e.cursor_index = 0;
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
PipId getPipByName(IdStringList name) const override;
|
|
|
|
IdStringList getPipName(PipId pip) const override;
|
|
|
|
IdString getPipType(PipId pip) const override;
|
|
|
|
std::vector<std::pair<IdString, std::string>> getPipAttrs(PipId pip) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
void bindPip(PipId pip, NetInfo *net, PlaceStrength strength) override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
|
|
|
NPNR_ASSERT(pip_to_net[pip] == nullptr);
|
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
WireId dst = getPipDstWire(pip);
|
2021-01-27 02:05:23 +08:00
|
|
|
NPNR_ASSERT(wire_to_net[dst] == nullptr || wire_to_net[dst] == net);
|
|
|
|
|
|
|
|
pip_to_net[pip] = net;
|
|
|
|
|
|
|
|
wire_to_net[dst] = net;
|
|
|
|
net->wires[dst].pip = pip;
|
|
|
|
net->wires[dst].strength = strength;
|
|
|
|
refreshUiPip(pip);
|
|
|
|
refreshUiWire(dst);
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
void unbindPip(PipId pip) override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
|
|
|
NPNR_ASSERT(pip_to_net[pip] != nullptr);
|
|
|
|
|
2021-02-05 06:23:12 +08:00
|
|
|
WireId dst = getPipDstWire(pip);
|
2021-01-27 02:05:23 +08:00
|
|
|
NPNR_ASSERT(wire_to_net[dst] != nullptr);
|
|
|
|
wire_to_net[dst] = nullptr;
|
|
|
|
pip_to_net[pip]->wires.erase(dst);
|
|
|
|
|
|
|
|
pip_to_net[pip] = nullptr;
|
|
|
|
refreshUiPip(pip);
|
|
|
|
refreshUiWire(dst);
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
bool checkPipAvail(PipId pip) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
|
|
|
return pip_to_net.find(pip) == pip_to_net.end() || pip_to_net.at(pip) == nullptr;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
NetInfo *getBoundPipNet(PipId pip) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
|
|
|
auto p2n = pip_to_net.find(pip);
|
|
|
|
return p2n == pip_to_net.end() ? nullptr : p2n->second;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
WireId getConflictingPipWire(PipId pip) const override { return getPipDstWire(pip); }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
NetInfo *getConflictingPipNet(PipId pip) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
auto p2n = pip_to_net.find(pip);
|
|
|
|
return p2n == pip_to_net.end() ? nullptr : p2n->second;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
AllPipRange getPips() const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
AllPipRange range;
|
|
|
|
range.b.cursor_tile = 0;
|
|
|
|
range.b.cursor_index = -1;
|
|
|
|
range.b.chip = chip_info;
|
|
|
|
++range.b; //-1 and then ++ deals with the case of no wries in the first tile
|
|
|
|
range.e.cursor_tile = chip_info->width * chip_info->height;
|
|
|
|
range.e.cursor_index = 0;
|
|
|
|
range.e.chip = chip_info;
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
Loc getPipLocation(PipId pip) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
Loc loc;
|
2021-02-05 06:23:12 +08:00
|
|
|
get_tile_loc(pip.tile, &loc);
|
2021-01-27 02:05:23 +08:00
|
|
|
loc.z = 0;
|
|
|
|
return loc;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
uint32_t getPipChecksum(PipId pip) const override { return pip.index; }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
WireId getPipSrcWire(PipId pip) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
2021-02-05 06:23:12 +08:00
|
|
|
return canonical_wire(chip_info, pip.tile, loc_info(chip_info, pip).pip_data[pip.index].src_index);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
WireId getPipDstWire(PipId pip) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
2021-02-05 06:23:12 +08:00
|
|
|
return canonical_wire(chip_info, pip.tile, loc_info(chip_info, pip).pip_data[pip.index].dst_index);
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
2021-02-19 18:39:57 +08:00
|
|
|
DelayQuad getPipDelay(PipId pip) const override { return DelayQuad(0); }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
DownhillPipRange getPipsDownhill(WireId wire) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
DownhillPipRange range;
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2021-02-05 06:23:12 +08:00
|
|
|
TileWireRange twr = get_tile_wire_range(wire);
|
2021-01-27 02:05:23 +08:00
|
|
|
range.b.chip = chip_info;
|
|
|
|
range.b.twi = twr.b;
|
|
|
|
range.b.twi_end = twr.e;
|
|
|
|
range.b.cursor = -1;
|
|
|
|
++range.b;
|
|
|
|
range.e.chip = chip_info;
|
|
|
|
range.e.twi = twr.e;
|
|
|
|
range.e.twi_end = twr.e;
|
|
|
|
range.e.cursor = 0;
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
UphillPipRange getPipsUphill(WireId wire) const override
|
2021-01-27 02:05:23 +08:00
|
|
|
{
|
|
|
|
UphillPipRange range;
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2021-02-05 06:23:12 +08:00
|
|
|
TileWireRange twr = get_tile_wire_range(wire);
|
2021-01-27 02:05:23 +08:00
|
|
|
range.b.chip = chip_info;
|
|
|
|
range.b.twi = twr.b;
|
|
|
|
range.b.twi_end = twr.e;
|
|
|
|
range.b.cursor = -1;
|
|
|
|
++range.b;
|
|
|
|
range.e.chip = chip_info;
|
|
|
|
range.e.twi = twr.e;
|
|
|
|
range.e.twi_end = twr.e;
|
|
|
|
range.e.cursor = 0;
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
2021-02-02 06:26:57 +08:00
|
|
|
// FIXME: Use groups to get access to sites.
|
2021-02-08 18:41:03 +08:00
|
|
|
GroupId getGroupByName(IdStringList name) const override { return GroupId(); }
|
|
|
|
IdStringList getGroupName(GroupId group) const override { return IdStringList(); }
|
|
|
|
std::vector<GroupId> getGroups() const override { return {}; }
|
|
|
|
std::vector<BelId> getGroupBels(GroupId group) const override { return {}; }
|
|
|
|
std::vector<WireId> getGroupWires(GroupId group) const override { return {}; }
|
|
|
|
std::vector<PipId> getGroupPips(GroupId group) const override { return {}; }
|
|
|
|
std::vector<GroupId> getGroupGroups(GroupId group) const override { return {}; }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------
|
2021-02-08 18:41:03 +08:00
|
|
|
delay_t estimateDelay(WireId src, WireId dst) const override;
|
|
|
|
delay_t predictDelay(const NetInfo *net_info, const PortRef &sink) const override;
|
|
|
|
ArcBounds getRouteBoundingBox(WireId src, WireId dst) const override;
|
|
|
|
delay_t getDelayEpsilon() const override { return 20; }
|
|
|
|
delay_t getRipupDelayPenalty() const override { return 120; }
|
|
|
|
float getDelayNS(delay_t v) const override { return v * 0.001; }
|
2021-02-19 18:39:57 +08:00
|
|
|
delay_t getDelayFromNS(float ns) const override { return delay_t(ns * 1000); }
|
2021-02-08 18:41:03 +08:00
|
|
|
uint32_t getDelayChecksum(delay_t v) const override { return v; }
|
|
|
|
bool getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
2021-02-06 06:18:38 +08:00
|
|
|
void place_iobufs(WireId pad_wire, NetInfo *net, const std::unordered_set<CellInfo *> &tightly_attached_bels,
|
|
|
|
std::unordered_set<CellInfo *> *placed_cells);
|
|
|
|
void pack_ports();
|
2021-02-08 18:41:03 +08:00
|
|
|
bool pack() override;
|
|
|
|
bool place() override;
|
|
|
|
bool route() override;
|
2021-01-27 02:05:23 +08:00
|
|
|
// -------------------------------------------------
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
std::vector<GraphicElement> getDecalGraphics(DecalId decal) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
DecalXY getBelDecal(BelId bel) const override;
|
|
|
|
DecalXY getWireDecal(WireId wire) const override;
|
|
|
|
DecalXY getPipDecal(PipId pip) const override;
|
|
|
|
DecalXY getGroupDecal(GroupId group) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
|
|
|
// Get the delay through a cell from one port to another, returning false
|
|
|
|
// if no path exists. This only considers combinational delays, as required by the Arch API
|
2021-02-19 18:39:57 +08:00
|
|
|
bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayQuad &delay) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
// Get the port class, also setting clockInfoCount to the number of TimingClockingInfos associated with a port
|
2021-02-08 18:41:03 +08:00
|
|
|
TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
// Get the TimingClockingInfo of a port
|
2021-02-08 18:41:03 +08:00
|
|
|
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const override;
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
const BelBucketRange getBelBuckets() const override
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
2021-02-01 23:18:28 +08:00
|
|
|
BelBucketRange bel_bucket_range;
|
2021-02-05 08:05:01 +08:00
|
|
|
bel_bucket_range.b.cursor.cursor = chip_info->bel_buckets.begin();
|
|
|
|
bel_bucket_range.e.cursor.cursor = chip_info->bel_buckets.end();
|
2021-02-01 23:18:28 +08:00
|
|
|
return bel_bucket_range;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
BelBucketId getBelBucketForBel(BelId bel) const override
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
2021-02-01 23:18:28 +08:00
|
|
|
BelBucketId bel_bucket;
|
2021-02-05 06:23:12 +08:00
|
|
|
bel_bucket.name = IdString(bel_info(chip_info, bel).bel_bucket);
|
2021-02-01 23:18:28 +08:00
|
|
|
return bel_bucket;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
const IdStringRange getCellTypes() const override
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
|
|
|
const CellMapPOD &cell_map = *chip_info->cell_map;
|
2021-02-01 23:18:28 +08:00
|
|
|
|
|
|
|
IdStringRange id_range;
|
2021-02-05 08:05:01 +08:00
|
|
|
id_range.b.cursor = cell_map.cell_names.begin();
|
|
|
|
id_range.e.cursor = cell_map.cell_names.end();
|
2021-02-01 23:18:28 +08:00
|
|
|
|
|
|
|
return id_range;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
IdString getBelBucketName(BelBucketId bucket) const override { return bucket.name; }
|
2021-02-01 23:18:28 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
BelBucketId getBelBucketByName(IdString name) const override
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
|
|
|
for (BelBucketId bel_bucket : getBelBuckets()) {
|
|
|
|
if (bel_bucket.name == name) {
|
2021-02-01 23:18:28 +08:00
|
|
|
return bel_bucket;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NPNR_ASSERT_FALSE("Failed to find BEL bucket for name.");
|
|
|
|
return BelBucketId();
|
|
|
|
}
|
|
|
|
|
2021-02-17 06:51:25 +08:00
|
|
|
size_t get_cell_type_index(IdString cell_type) const;
|
2021-02-01 23:18:28 +08:00
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
BelBucketId getBelBucketForCellType(IdString cell_type) const override
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
2021-02-16 01:45:52 +08:00
|
|
|
if (io_port_types.count(cell_type)) {
|
|
|
|
BelBucketId bucket;
|
|
|
|
bucket.name = id("IOPORTS");
|
|
|
|
return bucket;
|
|
|
|
}
|
|
|
|
|
2021-02-01 23:18:28 +08:00
|
|
|
BelBucketId bucket;
|
2021-02-04 06:48:49 +08:00
|
|
|
const CellMapPOD &cell_map = *chip_info->cell_map;
|
2021-02-08 18:41:03 +08:00
|
|
|
bucket.name = IdString(cell_map.cell_bel_buckets[get_cell_type_index(cell_type)]);
|
2021-02-01 23:18:28 +08:00
|
|
|
return bucket;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
FilteredBelRange getBelsInBucket(BelBucketId bucket) const override
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
2021-02-01 23:18:28 +08:00
|
|
|
BelRange range = getBels();
|
2021-02-04 06:48:49 +08:00
|
|
|
FilteredBelRange filtered_range(range.begin(), range.end(),
|
|
|
|
[this, bucket](BelId bel) { return getBelBucketForBel(bel) == bucket; });
|
2021-02-01 23:18:28 +08:00
|
|
|
|
|
|
|
return filtered_range;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
bool isValidBelForCellType(IdString cell_type, BelId bel) const override
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
2021-02-16 01:45:52 +08:00
|
|
|
if (io_port_types.count(cell_type)) {
|
|
|
|
return pads.count(bel) > 0;
|
|
|
|
}
|
2021-02-06 06:18:38 +08:00
|
|
|
|
|
|
|
const auto &bel_data = bel_info(chip_info, bel);
|
|
|
|
if (bel_data.category != BEL_CATEGORY_LOGIC) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-02-17 06:51:25 +08:00
|
|
|
|
|
|
|
auto cell_type_index = get_cell_type_index(cell_type);
|
2021-02-06 06:18:38 +08:00
|
|
|
return bel_data.pin_map[cell_type_index] != -1;
|
2021-02-01 23:18:28 +08:00
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
|
2021-02-17 01:45:43 +08:00
|
|
|
bool is_cell_valid_constraints(const CellInfo *cell, const TileStatus &tile_status, bool explain) const
|
|
|
|
{
|
|
|
|
if (io_port_types.count(cell->type)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
BelId bel = cell->bel;
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
|
|
|
|
return constraints.isValidBelForCellType(getCtx(), get_constraint_prototype(bel), tile_status.tags.data(),
|
|
|
|
get_cell_constraints(bel, cell->type),
|
|
|
|
id(chip_info->tiles[bel.tile].name.get()), cell->name, bel, explain);
|
|
|
|
}
|
|
|
|
|
2021-01-27 02:05:23 +08:00
|
|
|
// Return true whether all Bels at a given location are valid
|
2021-02-08 18:41:03 +08:00
|
|
|
bool isBelLocationValid(BelId bel) const override
|
2021-02-04 06:48:49 +08:00
|
|
|
{
|
2021-02-06 06:18:38 +08:00
|
|
|
auto iter = tileStatus.find(bel.tile);
|
|
|
|
if (iter == tileStatus.end()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
const TileStatus &tile_status = iter->second;
|
|
|
|
const CellInfo *cell = tile_status.boundcells[bel.index];
|
|
|
|
if (cell == nullptr) {
|
|
|
|
return true;
|
|
|
|
} else {
|
2021-02-20 08:18:59 +08:00
|
|
|
if(!dedicated_interconnect.isBelLocationValid(bel, cell)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-02-06 06:18:38 +08:00
|
|
|
if (io_port_types.count(cell->type)) {
|
|
|
|
// FIXME: Probably need to actually constraint io port cell/bel,
|
|
|
|
// but the current BBA emission doesn't support that. This only
|
|
|
|
// really matters if the placer can choose IO port locations.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-02-17 01:45:43 +08:00
|
|
|
if (!is_cell_valid_constraints(cell, tile_status, explain_constraints)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto &bel_data = bel_info(chip_info, bel);
|
|
|
|
return get_site_status(tile_status, bel_data).checkSiteRouting(getCtx(), tile_status);
|
2021-02-06 06:18:38 +08:00
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
}
|
|
|
|
|
2021-02-08 18:41:03 +08:00
|
|
|
IdString get_bel_tiletype(BelId bel) const { return IdString(loc_info(chip_info, bel).name); }
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
std::unordered_map<WireId, Loc> sink_locs, source_locs;
|
|
|
|
// -------------------------------------------------
|
2021-02-08 18:41:03 +08:00
|
|
|
void assignArchInfo() override {}
|
2021-01-27 02:05:23 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
|
|
|
static const std::string defaultPlacer;
|
|
|
|
static const std::vector<std::string> availablePlacers;
|
|
|
|
|
|
|
|
static const std::string defaultRouter;
|
|
|
|
static const std::vector<std::string> availableRouters;
|
|
|
|
|
|
|
|
// -------------------------------------------------
|
2021-02-12 06:24:49 +08:00
|
|
|
void read_logical_netlist(const std::string &filename);
|
|
|
|
void write_physical_netlist(const std::string &filename) const;
|
|
|
|
void parse_xdc(const std::string &filename);
|
2021-02-13 08:12:16 +08:00
|
|
|
|
|
|
|
std::unordered_set<IdString> io_port_types;
|
2021-02-16 01:45:52 +08:00
|
|
|
std::unordered_set<BelId> pads;
|
|
|
|
|
|
|
|
bool is_site_port(PipId pip) const
|
|
|
|
{
|
|
|
|
const PipInfoPOD &pip_data = pip_info(chip_info, pip);
|
|
|
|
if (pip_data.site == -1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
BelId bel;
|
|
|
|
bel.tile = pip.tile;
|
|
|
|
bel.index = pip_data.bel;
|
|
|
|
|
|
|
|
const BelInfoPOD &bel_data = bel_info(chip_info, bel);
|
|
|
|
|
|
|
|
return bel_data.category == BEL_CATEGORY_SITE_PORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is the driver and all users of this net located within the same site?
|
|
|
|
//
|
|
|
|
// Returns false if any element of the net is not placed.
|
|
|
|
bool is_net_within_site(const NetInfo &net) const;
|
2021-02-06 06:18:38 +08:00
|
|
|
|
|
|
|
using ArchConstraints = Constraints<kMaxState>;
|
|
|
|
ArchConstraints constraints;
|
|
|
|
std::vector<ArchConstraints::TagState> default_tags;
|
|
|
|
bool explain_constraints;
|
|
|
|
|
|
|
|
struct StateRange
|
|
|
|
{
|
|
|
|
const int32_t *b;
|
|
|
|
const int32_t *e;
|
|
|
|
|
|
|
|
const int32_t *begin() const { return b; }
|
|
|
|
const int32_t *end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Constraint : ArchConstraints::Constraint<StateRange>
|
|
|
|
{
|
|
|
|
const CellConstraintPOD *constraint;
|
|
|
|
Constraint(const CellConstraintPOD *constraint) : constraint(constraint) {}
|
|
|
|
|
|
|
|
size_t tag() const override { return constraint->tag; }
|
|
|
|
|
|
|
|
ArchConstraints::ConstraintType constraint_type() const override
|
|
|
|
{
|
|
|
|
return Constraints<kMaxState>::ConstraintType(constraint->constraint_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
ArchConstraints::ConstraintStateType state() const override
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(constraint_type() == Constraints<kMaxState>::CONSTRAINT_TAG_IMPLIES);
|
|
|
|
NPNR_ASSERT(constraint->states.size() == 1);
|
|
|
|
return constraint->states[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
StateRange states() const override
|
|
|
|
{
|
|
|
|
StateRange range;
|
|
|
|
range.b = constraint->states.get();
|
|
|
|
range.e = range.b + constraint->states.size();
|
|
|
|
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ConstraintIterator
|
|
|
|
{
|
|
|
|
const CellConstraintPOD *constraint;
|
|
|
|
ConstraintIterator() {}
|
|
|
|
|
|
|
|
ConstraintIterator operator++()
|
|
|
|
{
|
|
|
|
++constraint;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const ConstraintIterator &other) const { return constraint != other.constraint; }
|
|
|
|
|
|
|
|
bool operator==(const ConstraintIterator &other) const { return constraint == other.constraint; }
|
|
|
|
|
|
|
|
Constraint operator*() const { return Constraint(constraint); }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ConstraintRange
|
|
|
|
{
|
|
|
|
ConstraintIterator b, e;
|
|
|
|
|
|
|
|
ConstraintIterator begin() const { return b; }
|
|
|
|
ConstraintIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t get_constraint_prototype(BelId bel) const { return chip_info->tiles[bel.tile].type; }
|
|
|
|
|
|
|
|
ConstraintRange get_cell_constraints(BelId bel, IdString cell_type) const
|
|
|
|
{
|
|
|
|
const auto &bel_data = bel_info(chip_info, bel);
|
|
|
|
NPNR_ASSERT(bel_data.category == BEL_CATEGORY_LOGIC);
|
|
|
|
|
|
|
|
int32_t mapping = bel_data.pin_map[get_cell_type_index(cell_type)];
|
|
|
|
NPNR_ASSERT(mapping >= 0);
|
|
|
|
|
|
|
|
auto &cell_bel_map = chip_info->cell_map->cell_bel_map[mapping];
|
|
|
|
ConstraintRange range;
|
|
|
|
range.b.constraint = cell_bel_map.constraints.get();
|
|
|
|
range.e.constraint = range.b.constraint + cell_bel_map.constraints.size();
|
|
|
|
|
|
|
|
return range;
|
|
|
|
}
|
2021-02-19 05:26:52 +08:00
|
|
|
|
|
|
|
const char *get_site_name(int32_t tile, size_t site) const
|
|
|
|
{
|
|
|
|
return site_inst_info(chip_info, tile, site).name.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *get_site_name(BelId bel) const
|
|
|
|
{
|
|
|
|
auto &bel_data = bel_info(chip_info, bel);
|
|
|
|
return get_site_name(bel.tile, bel_data.site);
|
|
|
|
}
|
|
|
|
|
|
|
|
const SiteInstInfoPOD &get_site_inst(BelId bel) const
|
|
|
|
{
|
|
|
|
auto &bel_data = bel_info(chip_info, bel);
|
|
|
|
return site_inst_info(chip_info, bel.tile, bel_data.site);
|
|
|
|
}
|
|
|
|
|
|
|
|
const SiteInstInfoPOD &get_site_inst(WireId wire) const
|
|
|
|
{
|
|
|
|
auto &wire_data = wire_info(wire);
|
|
|
|
NPNR_ASSERT(wire_data.site != -1);
|
|
|
|
return site_inst_info(chip_info, wire.tile, wire_data.site);
|
|
|
|
}
|
|
|
|
|
|
|
|
const SiteInstInfoPOD &get_site_inst(PipId pip) const
|
|
|
|
{
|
|
|
|
auto &pip_data = pip_info(chip_info, pip);
|
|
|
|
return site_inst_info(chip_info, pip.tile, pip_data.site);
|
|
|
|
}
|
2021-02-19 08:51:36 +08:00
|
|
|
|
|
|
|
// Is this bel synthetic (e.g. added during import process)?
|
|
|
|
//
|
|
|
|
// This is generally used for constant networks, but can also be used for
|
|
|
|
// static partitions.
|
|
|
|
bool is_bel_synthetic(BelId bel) const
|
|
|
|
{
|
2021-02-19 08:57:09 +08:00
|
|
|
const BelInfoPOD &bel_data = bel_info(chip_info, bel);
|
2021-02-19 08:51:36 +08:00
|
|
|
|
|
|
|
return bel_data.synthetic != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is this pip synthetic (e.g. added during import process)?
|
|
|
|
//
|
|
|
|
// This is generally used for constant networks, but can also be used for
|
|
|
|
// static partitions.
|
|
|
|
bool is_pip_synthetic(PipId pip) const
|
|
|
|
{
|
|
|
|
auto &pip_data = pip_info(chip_info, pip);
|
2021-02-19 08:57:09 +08:00
|
|
|
if (pip_data.site == -1) {
|
2021-02-19 08:51:36 +08:00
|
|
|
return pip_data.extra_data == -1;
|
|
|
|
} else {
|
|
|
|
BelId bel;
|
|
|
|
bel.tile = pip.tile;
|
|
|
|
bel.index = pip_data.bel;
|
|
|
|
return is_bel_synthetic(bel);
|
|
|
|
}
|
|
|
|
}
|
2021-01-27 02:05:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_END
|