aboutsummaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-07-12 17:22:29 +0200
committerClifford Wolf <clifford@clifford.at>2018-07-12 17:22:29 +0200
commita436035424368b3d424822c7b72f99044c93dafd (patch)
tree9bbf888bc6db482b42677656f4ee3fd4357355e8 /generic
parent1245eb6343f272b6aeb096b0d41407c5ea6bc5cd (diff)
downloadnextpnr-a436035424368b3d424822c7b72f99044c93dafd.tar.gz
nextpnr-a436035424368b3d424822c7b72f99044c93dafd.tar.bz2
nextpnr-a436035424368b3d424822c7b72f99044c93dafd.zip
Add Groups API
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'generic')
-rw-r--r--generic/arch.cc50
-rw-r--r--generic/arch.h26
-rw-r--r--generic/archdefs.h1
3 files changed, 76 insertions, 1 deletions
diff --git a/generic/arch.cc b/generic/arch.cc
index 60874e1e..1e1434d3 100644
--- a/generic/arch.cc
+++ b/generic/arch.cc
@@ -109,6 +109,26 @@ void Arch::addBelInout(IdString bel, IdString name, IdString wire)
wires.at(wire).downhill_bel_pins.push_back(BelPin{bel, name});
}
+void Arch::addGroupBel(IdString group, IdString bel)
+{
+ groups[group].bels.push_back(bel);
+}
+
+void Arch::addGroupWire(IdString group, IdString wire)
+{
+ groups[group].wires.push_back(wire);
+}
+
+void Arch::addGroupPip(IdString group, IdString pip)
+{
+ groups[group].pips.push_back(pip);
+}
+
+void Arch::addGroupGroup(IdString group, IdString grp)
+{
+ groups[group].groups.push_back(grp);
+}
+
void Arch::addDecalGraphic(DecalId decal, const GraphicElement &graphic)
{
decal_graphics[decal].push_back(graphic);
@@ -139,6 +159,12 @@ void Arch::setBelDecal(BelId bel, DecalXY decalxy)
refreshUiBel(bel);
}
+void Arch::setGroupDecal(GroupId group, DecalXY decalxy)
+{
+ groups[group].decalxy = decalxy;
+ refreshUiGroup(group);
+}
+
// ---------------------------------------------------------------
Arch::Arch(ArchArgs) {}
@@ -300,6 +326,27 @@ const std::vector<PipId> &Arch::getWireAliases(WireId wire) const { return wires
// ---------------------------------------------------------------
+GroupId Arch::getGroupByName(IdString name) const { return name; }
+
+IdString Arch::getGroupName(GroupId group) const { return group; }
+
+std::vector<GroupId> Arch::getGroups() const {
+ std::vector<GroupId> ret;
+ for (auto &it : groups)
+ ret.push_back(it.first);
+ return ret;
+}
+
+const std::vector<BelId> &Arch::getGroupBels(GroupId group) const { return groups.at(group).bels; }
+
+const std::vector<WireId> &Arch::getGroupWires(GroupId group) const { return groups.at(group).wires; }
+
+const std::vector<PipId> &Arch::getGroupPips(GroupId group) const { return groups.at(group).pips; }
+
+const std::vector<GroupId> &Arch::getGroupGroups(GroupId group) const { return groups.at(group).groups; }
+
+// ---------------------------------------------------------------
+
void Arch::estimatePosition(BelId bel, int &x, int &y, bool &gb) const
{
x = bels.at(bel).grid_x;
@@ -330,7 +377,6 @@ bool Arch::route()
// ---------------------------------------------------------------
-
const std::vector<GraphicElement> &Arch::getDecalGraphics(DecalId decal) const { return decal_graphics.at(decal); }
DecalXY Arch::getFrameDecal() const { return frame_decalxy; }
@@ -341,6 +387,8 @@ DecalXY Arch::getWireDecal(WireId wire) const { return wires.at(wire).decalxy; }
DecalXY Arch::getPipDecal(PipId pip) const { return pips.at(pip).decalxy; }
+DecalXY Arch::getGroupDecal(GroupId group) const { return groups.at(group).decalxy; }
+
// ---------------------------------------------------------------
bool Arch::getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, delay_t &delay) const
diff --git a/generic/arch.h b/generic/arch.h
index 85f469f9..f6243404 100644
--- a/generic/arch.h
+++ b/generic/arch.h
@@ -63,6 +63,16 @@ struct BelInfo
bool gb;
};
+struct GroupInfo
+{
+ IdString name;
+ std::vector<BelId> bels;
+ std::vector<WireId> wires;
+ std::vector<PipId> pips;
+ std::vector<GroupId> groups;
+ DecalXY decalxy;
+};
+
struct Arch : BaseCtx
{
std::string chipName;
@@ -70,6 +80,7 @@ struct Arch : BaseCtx
std::unordered_map<IdString, WireInfo> wires;
std::unordered_map<IdString, PipInfo> pips;
std::unordered_map<IdString, BelInfo> bels;
+ std::unordered_map<GroupId, GroupInfo> groups;
std::vector<IdString> bel_ids, wire_ids, pip_ids;
std::unordered_map<IdString, std::vector<IdString>> bel_ids_by_type;
@@ -88,11 +99,17 @@ struct Arch : BaseCtx
void addBelOutput(IdString bel, IdString name, IdString wire);
void addBelInout(IdString bel, IdString name, IdString wire);
+ void addGroupBel(IdString group, IdString bel);
+ void addGroupWire(IdString group, IdString wire);
+ void addGroupPip(IdString group, IdString pip);
+ void addGroupGroup(IdString group, IdString grp);
+
void addDecalGraphic(DecalId decal, const GraphicElement &graphic);
void setFrameDecal(DecalXY decalxy);
void setWireDecal(WireId wire, DecalXY decalxy);
void setPipDecal(PipId pip, DecalXY decalxy);
void setBelDecal(BelId bel, DecalXY decalxy);
+ void setGroupDecal(GroupId group, DecalXY decalxy);
// ---------------------------------------------------------------
// Common Arch API. Every arch must provide the following methods.
@@ -151,6 +168,14 @@ struct Arch : BaseCtx
const std::vector<PipId> &getPipsUphill(WireId wire) const;
const std::vector<PipId> &getWireAliases(WireId wire) const;
+ GroupId getGroupByName(IdString name) const;
+ IdString getGroupName(GroupId group) const;
+ std::vector<GroupId> getGroups() const;
+ const std::vector<BelId> &getGroupBels(GroupId group) const;
+ const std::vector<WireId> &getGroupWires(GroupId group) const;
+ const std::vector<PipId> &getGroupPips(GroupId group) const;
+ const std::vector<GroupId> &getGroupGroups(GroupId group) const;
+
void estimatePosition(BelId bel, int &x, int &y, bool &gb) const;
delay_t estimateDelay(WireId src, WireId dst) const;
delay_t getDelayEpsilon() const { return 0.01; }
@@ -166,6 +191,7 @@ struct Arch : BaseCtx
DecalXY getBelDecal(BelId bel) const;
DecalXY getWireDecal(WireId wire) const;
DecalXY getPipDecal(PipId pip) const;
+ DecalXY getGroupDecal(GroupId group) const;
bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, delay_t &delay) const;
IdString getPortClock(const CellInfo *cell, IdString port) const;
diff --git a/generic/archdefs.h b/generic/archdefs.h
index 8e6dcb2f..9969014b 100644
--- a/generic/archdefs.h
+++ b/generic/archdefs.h
@@ -49,6 +49,7 @@ typedef IdString PortPin;
typedef IdString BelId;
typedef IdString WireId;
typedef IdString PipId;
+typedef IdString GroupId;
typedef IdString DecalId;
NEXTPNR_NAMESPACE_END