aboutsummaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-07-20 18:09:22 +0200
committerClifford Wolf <clifford@clifford.at>2018-07-20 18:09:22 +0200
commitfd8239e170a7391d9c25d8681083507d9960abef (patch)
treea051a9eef682ab922c474850d235f301c2c708fd /generic
parentf6fa0300ae95a0896a12b9acf0c7e76851c13d37 (diff)
downloadnextpnr-fd8239e170a7391d9c25d8681083507d9960abef.tar.gz
nextpnr-fd8239e170a7391d9c25d8681083507d9960abef.tar.bz2
nextpnr-fd8239e170a7391d9c25d8681083507d9960abef.zip
Add Location APIs to generic arch
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'generic')
-rw-r--r--generic/arch.cc28
-rw-r--r--generic/arch.h13
2 files changed, 29 insertions, 12 deletions
diff --git a/generic/arch.cc b/generic/arch.cc
index 390830aa..b7ec847e 100644
--- a/generic/arch.cc
+++ b/generic/arch.cc
@@ -29,8 +29,8 @@ void Arch::addWire(IdString name, int x, int y)
NPNR_ASSERT(wires.count(name) == 0);
WireInfo &wi = wires[name];
wi.name = name;
- wi.grid_x = x;
- wi.grid_y = y;
+ wi.x = x;
+ wi.y = y;
wire_ids.push_back(name);
}
@@ -62,18 +62,28 @@ void Arch::addAlias(IdString name, IdString srcWire, IdString dstWire, DelayInfo
pip_ids.push_back(name);
}
-void Arch::addBel(IdString name, IdString type, int x, int y, bool gb)
+void Arch::addBel(IdString name, IdString type, int x, int y, int z, bool gb)
{
+ Loc loc;
+ loc.x = x;
+ loc.y = y;
+ loc.z = z;
+
NPNR_ASSERT(bels.count(name) == 0);
+ NPNR_ASSERT(bel_by_loc.count(loc) == 0);
BelInfo &bi = bels[name];
bi.name = name;
bi.type = type;
- bi.grid_x = x;
- bi.grid_y = y;
+ bi.x = x;
+ bi.y = y;
+ bi.z = z;
bi.gb = gb;
bel_ids.push_back(name);
bel_ids_by_type[type].push_back(name);
+
+ bel_by_loc[loc] = name;
+ bels_by_tile[x][y].push_back(name);
}
void Arch::addBelInput(IdString bel, IdString name, IdString wire)
@@ -348,8 +358,8 @@ const std::vector<GroupId> &Arch::getGroupGroups(GroupId group) const { return g
void Arch::estimatePosition(BelId bel, int &x, int &y, bool &gb) const
{
- x = bels.at(bel).grid_x;
- y = bels.at(bel).grid_y;
+ x = bels.at(bel).x;
+ y = bels.at(bel).y;
gb = bels.at(bel).gb;
}
@@ -357,8 +367,8 @@ delay_t Arch::estimateDelay(WireId src, WireId dst) const
{
const WireInfo &s = wires.at(src);
const WireInfo &d = wires.at(dst);
- int dx = abs(s.grid_x - d.grid_x);
- int dy = abs(s.grid_y - d.grid_y);
+ int dx = abs(s.x - d.x);
+ int dy = abs(s.y - d.y);
return (dx + dy) * grid_distance_to_delay;
}
diff --git a/generic/arch.h b/generic/arch.h
index 5d7ac540..ea4bb565 100644
--- a/generic/arch.h
+++ b/generic/arch.h
@@ -44,7 +44,7 @@ struct WireInfo
BelPin uphill_bel_pin;
std::vector<BelPin> downhill_bel_pins;
DecalXY decalxy;
- int grid_x, grid_y;
+ int x, y;
};
struct PinInfo
@@ -59,7 +59,7 @@ struct BelInfo
IdString name, type, bound_cell;
std::unordered_map<IdString, PinInfo> pins;
DecalXY decalxy;
- int grid_x, grid_y;
+ int x, y, z;
bool gb;
};
@@ -85,6 +85,9 @@ struct Arch : BaseCtx
std::vector<IdString> bel_ids, wire_ids, pip_ids;
std::unordered_map<IdString, std::vector<IdString>> bel_ids_by_type;
+ std::unordered_map<Loc, BelId> bel_by_loc;
+ std::unordered_map<int, std::unordered_map<int, std::vector<BelId>>> bels_by_tile;
+
std::unordered_map<DecalId, std::vector<GraphicElement>> decal_graphics;
DecalXY frame_decalxy;
@@ -94,7 +97,7 @@ struct Arch : BaseCtx
void addPip(IdString name, IdString srcWire, IdString dstWire, DelayInfo delay);
void addAlias(IdString name, IdString srcWire, IdString dstWire, DelayInfo delay);
- void addBel(IdString name, IdString type, int x, int y, bool gb);
+ void addBel(IdString name, IdString type, int x, int y, int z, bool gb);
void addBelInput(IdString bel, IdString name, IdString wire);
void addBelOutput(IdString bel, IdString name, IdString wire);
void addBelInout(IdString bel, IdString name, IdString wire);
@@ -129,6 +132,10 @@ struct Arch : BaseCtx
BelId getBelByName(IdString name) const;
IdString getBelName(BelId bel) const;
+ Loc getBelLocation(BelId bel) const;
+ BelId getBelByLocation(Loc loc) const;
+ std::vector<BelId> getBelsByTile(int x, int y) const;
+ bool getBelGlobalBuf(BelId bel) const;
uint32_t getBelChecksum(BelId bel) const;
void bindBel(BelId bel, IdString cell, PlaceStrength strength);
void unbindBel(BelId bel);