nexus: Implement IdStringList for all arch object names
Signed-off-by: D. Shah <dave@ds0.me>
This commit is contained in:
parent
b31b21fd51
commit
6566a011b4
@ -181,6 +181,12 @@ template <typename T, size_t N> class SSOArray
|
|||||||
std::fill(begin(), end(), init);
|
std::fill(begin(), end(), init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SSOArray(const SSOArray &other) : m_size(other.size())
|
||||||
|
{
|
||||||
|
alloc();
|
||||||
|
std::copy(other.begin(), other.end(), begin());
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Tother> SSOArray(const Tother &other) : m_size(other.size())
|
template <typename Tother> SSOArray(const Tother &other) : m_size(other.size())
|
||||||
{
|
{
|
||||||
alloc();
|
alloc();
|
||||||
|
@ -32,20 +32,6 @@
|
|||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
namespace {
|
|
||||||
static std::tuple<int, int, std::string> split_identifier_name(const std::string &name)
|
|
||||||
{
|
|
||||||
size_t first_slash = name.find('/');
|
|
||||||
NPNR_ASSERT(first_slash != std::string::npos);
|
|
||||||
size_t second_slash = name.find('/', first_slash + 1);
|
|
||||||
NPNR_ASSERT(second_slash != std::string::npos);
|
|
||||||
return std::make_tuple(std::stoi(name.substr(1, first_slash)),
|
|
||||||
std::stoi(name.substr(first_slash + 2, second_slash - first_slash)),
|
|
||||||
name.substr(second_slash + 1));
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void IdString::initialize_arch(const BaseCtx *ctx)
|
void IdString::initialize_arch(const BaseCtx *ctx)
|
||||||
@ -134,6 +120,17 @@ Arch::Arch(ArchArgs args) : args(args)
|
|||||||
ts.bels_by_z[bel.z].index = j;
|
ts.bels_by_z[bel.z].index = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < chip_info->width; i++) {
|
||||||
|
IdString x_id = id(stringf("X%d", i));
|
||||||
|
x_ids.push_back(x_id);
|
||||||
|
id_to_x[x_id] = i;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < chip_info->height; i++) {
|
||||||
|
IdString y_id = id(stringf("Y%d", i));
|
||||||
|
y_ids.push_back(y_id);
|
||||||
|
id_to_y[y_id] = i;
|
||||||
|
}
|
||||||
init_cell_pin_data();
|
init_cell_pin_data();
|
||||||
// Validate and set up package
|
// Validate and set up package
|
||||||
package_idx = -1;
|
package_idx = -1;
|
||||||
@ -193,17 +190,17 @@ IdString Arch::archArgsToId(ArchArgs args) const { return id(args.device); }
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
BelId Arch::getBelByName(IdString name) const
|
BelId Arch::getBelByName(IdStringList name) const
|
||||||
{
|
{
|
||||||
int x, y;
|
if (name.size() != 3)
|
||||||
std::string belname;
|
return BelId();
|
||||||
std::tie(x, y, belname) = split_identifier_name(name.str(this));
|
int x = id_to_x.at(name[0]);
|
||||||
|
int y = id_to_y.at(name[1]);
|
||||||
NPNR_ASSERT(x >= 0 && x < chip_info->width);
|
NPNR_ASSERT(x >= 0 && x < chip_info->width);
|
||||||
NPNR_ASSERT(y >= 0 && y < chip_info->height);
|
NPNR_ASSERT(y >= 0 && y < chip_info->height);
|
||||||
auto &tile = db->loctypes[chip_info->grid[y * chip_info->width + x].loc_type];
|
auto &tile = db->loctypes[chip_info->grid[y * chip_info->width + x].loc_type];
|
||||||
IdString bn = id(belname);
|
|
||||||
for (size_t i = 0; i < tile.bels.size(); i++) {
|
for (size_t i = 0; i < tile.bels.size(); i++) {
|
||||||
if (tile.bels[i].name == bn.index) {
|
if (tile.bels[i].name == name[2].index) {
|
||||||
BelId ret;
|
BelId ret;
|
||||||
ret.tile = y * chip_info->width + x;
|
ret.tile = y * chip_info->width + x;
|
||||||
ret.index = i;
|
ret.index = i;
|
||||||
@ -305,17 +302,17 @@ std::vector<std::pair<IdString, std::string>> Arch::getBelAttrs(BelId bel) const
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
WireId Arch::getWireByName(IdString name) const
|
WireId Arch::getWireByName(IdStringList name) const
|
||||||
{
|
{
|
||||||
int x, y;
|
if (name.size() != 3)
|
||||||
std::string wirename;
|
return WireId();
|
||||||
std::tie(x, y, wirename) = split_identifier_name(name.str(this));
|
int x = id_to_x.at(name[0]);
|
||||||
|
int y = id_to_y.at(name[1]);
|
||||||
NPNR_ASSERT(x >= 0 && x < chip_info->width);
|
NPNR_ASSERT(x >= 0 && x < chip_info->width);
|
||||||
NPNR_ASSERT(y >= 0 && y < chip_info->height);
|
NPNR_ASSERT(y >= 0 && y < chip_info->height);
|
||||||
auto &tile = db->loctypes[chip_info->grid[y * chip_info->width + x].loc_type];
|
auto &tile = db->loctypes[chip_info->grid[y * chip_info->width + x].loc_type];
|
||||||
IdString wn = id(wirename);
|
|
||||||
for (size_t i = 0; i < tile.wires.size(); i++) {
|
for (size_t i = 0; i < tile.wires.size(); i++) {
|
||||||
if (tile.wires[i].name == wn.index) {
|
if (tile.wires[i].name == name[2].index) {
|
||||||
WireId ret;
|
WireId ret;
|
||||||
ret.tile = y * chip_info->width + x;
|
ret.tile = y * chip_info->width + x;
|
||||||
ret.index = i;
|
ret.index = i;
|
||||||
@ -342,26 +339,27 @@ std::vector<std::pair<IdString, std::string>> Arch::getWireAttrs(WireId wire) co
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
PipId Arch::getPipByName(IdString name) const
|
PipId Arch::getPipByName(IdStringList name) const
|
||||||
{
|
{
|
||||||
int x, y;
|
if (name.size() != 5)
|
||||||
std::string pipname;
|
return PipId();
|
||||||
std::tie(x, y, pipname) = split_identifier_name(name.str(this));
|
int x = id_to_x.at(name[0]);
|
||||||
|
int y = id_to_y.at(name[1]);
|
||||||
NPNR_ASSERT(x >= 0 && x < chip_info->width);
|
NPNR_ASSERT(x >= 0 && x < chip_info->width);
|
||||||
NPNR_ASSERT(y >= 0 && y < chip_info->height);
|
NPNR_ASSERT(y >= 0 && y < chip_info->height);
|
||||||
PipId ret;
|
PipId ret;
|
||||||
ret.tile = y * chip_info->width + x;
|
ret.tile = y * chip_info->width + x;
|
||||||
auto sep_pos = pipname.find(':');
|
ret.index = std::stoi(name[2].str(this));
|
||||||
ret.index = std::stoi(pipname.substr(0, sep_pos));
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IdString Arch::getPipName(PipId pip) const
|
IdStringList Arch::getPipName(PipId pip) const
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(pip != PipId());
|
NPNR_ASSERT(pip != PipId());
|
||||||
return id(stringf("X%d/Y%d/%d:%s->%s", pip.tile % chip_info->width, pip.tile / chip_info->width, pip.index,
|
std::array<IdString, 5> ids{x_ids.at(pip.tile % chip_info->width), y_ids.at(pip.tile / chip_info->width),
|
||||||
nameOf(loc_data(pip).wires[pip_data(pip).from_wire].name),
|
id(stringf("%d", pip.index)), IdString(loc_data(pip).wires[pip_data(pip).to_wire].name),
|
||||||
nameOf(loc_data(pip).wires[pip_data(pip).to_wire].name)));
|
IdString(loc_data(pip).wires[pip_data(pip).from_wire].name)};
|
||||||
|
return IdStringList(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
IdString Arch::getPipType(PipId pip) const { return IdString(); }
|
IdString Arch::getPipType(PipId pip) const { return IdString(); }
|
||||||
|
43
nexus/arch.h
43
nexus/arch.h
@ -897,6 +897,11 @@ struct Arch : BaseCtx
|
|||||||
std::unordered_map<WireId, NetInfo *> wire_to_net;
|
std::unordered_map<WireId, NetInfo *> wire_to_net;
|
||||||
std::unordered_map<PipId, NetInfo *> pip_to_net;
|
std::unordered_map<PipId, NetInfo *> pip_to_net;
|
||||||
|
|
||||||
|
// fast access to X and Y IdStrings for building object names
|
||||||
|
std::vector<IdString> x_ids, y_ids;
|
||||||
|
// inverse of the above for name->object mapping
|
||||||
|
std::unordered_map<IdString, int> id_to_x, id_to_y;
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
std::string getChipName() const;
|
std::string getChipName() const;
|
||||||
@ -913,17 +918,14 @@ struct Arch : BaseCtx
|
|||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
BelId getBelByName(IdString name) const;
|
BelId getBelByName(IdStringList name) const;
|
||||||
|
|
||||||
IdString getBelName(BelId bel) const
|
IdStringList getBelName(BelId bel) const
|
||||||
{
|
{
|
||||||
std::string name = "X";
|
NPNR_ASSERT(bel != BelId());
|
||||||
name += std::to_string(bel.tile % chip_info->width);
|
std::array<IdString, 3> ids{x_ids.at(bel.tile % chip_info->width), y_ids.at(bel.tile / chip_info->width),
|
||||||
name += "/Y";
|
IdString(bel_data(bel).name)};
|
||||||
name += std::to_string(bel.tile / chip_info->width);
|
return IdStringList(ids);
|
||||||
name += "/";
|
|
||||||
name += nameOf(IdString(bel_data(bel).name));
|
|
||||||
return id(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getBelChecksum(BelId bel) const { return (bel.tile << 16) ^ bel.index; }
|
uint32_t getBelChecksum(BelId bel) const { return (bel.tile << 16) ^ bel.index; }
|
||||||
@ -1024,16 +1026,13 @@ struct Arch : BaseCtx
|
|||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
WireId getWireByName(IdString name) const;
|
WireId getWireByName(IdStringList name) const;
|
||||||
IdString getWireName(WireId wire) const
|
IdStringList getWireName(WireId wire) const
|
||||||
{
|
{
|
||||||
std::string name = "X";
|
NPNR_ASSERT(wire != WireId());
|
||||||
name += std::to_string(wire.tile % chip_info->width);
|
std::array<IdString, 3> ids{x_ids.at(wire.tile % chip_info->width), y_ids.at(wire.tile / chip_info->width),
|
||||||
name += "/Y";
|
IdString(wire_data(wire).name)};
|
||||||
name += std::to_string(wire.tile / chip_info->width);
|
return IdStringList(ids);
|
||||||
name += "/";
|
|
||||||
name += nameOf(IdString(wire_data(wire).name));
|
|
||||||
return id(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IdString getWireType(WireId wire) const;
|
IdString getWireType(WireId wire) const;
|
||||||
@ -1137,8 +1136,8 @@ struct Arch : BaseCtx
|
|||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
PipId getPipByName(IdString name) const;
|
PipId getPipByName(IdStringList name) const;
|
||||||
IdString getPipName(PipId pip) const;
|
IdStringList getPipName(PipId pip) const;
|
||||||
|
|
||||||
void bindPip(PipId pip, NetInfo *net, PlaceStrength strength)
|
void bindPip(PipId pip, NetInfo *net, PlaceStrength strength)
|
||||||
{
|
{
|
||||||
@ -1290,8 +1289,8 @@ struct Arch : BaseCtx
|
|||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
GroupId getGroupByName(IdString name) const { return GroupId(); }
|
GroupId getGroupByName(IdStringList name) const { return GroupId(); }
|
||||||
IdString getGroupName(GroupId group) const { return IdString(); }
|
IdStringList getGroupName(GroupId group) const { return IdStringList(); }
|
||||||
std::vector<GroupId> getGroups() const { return {}; }
|
std::vector<GroupId> getGroups() const { return {}; }
|
||||||
std::vector<BelId> getGroupBels(GroupId group) const { return {}; }
|
std::vector<BelId> getGroupBels(GroupId group) const { return {}; }
|
||||||
std::vector<WireId> getGroupWires(GroupId group) const { return {}; }
|
std::vector<WireId> getGroupWires(GroupId group) const { return {}; }
|
||||||
|
@ -544,7 +544,7 @@ struct NexusPacker
|
|||||||
{
|
{
|
||||||
if (!ci->attrs.count(id_BEL))
|
if (!ci->attrs.count(id_BEL))
|
||||||
return BelId();
|
return BelId();
|
||||||
return ctx->getBelByName(ctx->id(ci->attrs.at(id_BEL).as_string()));
|
return ctx->getBelByNameStr(ci->attrs.at(id_BEL).as_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
void pack_io()
|
void pack_io()
|
||||||
|
Loading…
Reference in New Issue
Block a user