aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
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 /ice40
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 'ice40')
-rw-r--r--ice40/arch.cc64
-rw-r--r--ice40/arch.h11
-rw-r--r--ice40/archdefs.h52
3 files changed, 115 insertions, 12 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc
index 1e6b4569..26c3b003 100644
--- a/ice40/arch.cc
+++ b/ice40/arch.cc
@@ -369,6 +369,52 @@ std::string Arch::getBelPackagePin(BelId bel) const
}
return "";
}
+
+// -----------------------------------------------------------------------
+
+GroupId Arch::getGroupByName(IdString name) const
+{
+ for (auto g : getGroups())
+ if (getGroupName(g) == name)
+ return g;
+ return GroupId();
+}
+
+IdString Arch::getGroupName(GroupId group) const
+{
+ return IdString();
+}
+
+std::vector<GroupId> Arch::getGroups() const
+{
+ std::vector<GroupId> ret;
+ return ret;
+}
+
+std::vector<BelId> Arch::getGroupBels(GroupId group) const
+{
+ std::vector<BelId> ret;
+ return ret;
+}
+
+std::vector<WireId> Arch::getGroupWires(GroupId group) const
+{
+ std::vector<WireId> ret;
+ return ret;
+}
+
+std::vector<PipId> Arch::getGroupPips(GroupId group) const
+{
+ std::vector<PipId> ret;
+ return ret;
+}
+
+std::vector<GroupId> Arch::getGroupGroups(GroupId group) const
+{
+ std::vector<GroupId> ret;
+ return ret;
+}
+
// -----------------------------------------------------------------------
void Arch::estimatePosition(BelId bel, int &x, int &y, bool &gb) const
@@ -417,15 +463,15 @@ bool Arch::route()
DecalXY Arch::getFrameDecal() const
{
DecalXY decalxy;
- decalxy.decal.type = 'f';
+ decalxy.decal.type = DecalId::TYPE_FRAME;
return decalxy;
}
DecalXY Arch::getBelDecal(BelId bel) const
{
DecalXY decalxy;
- decalxy.decal.type = 'b';
- decalxy.decal.z = bel.index;
+ decalxy.decal.type = DecalId::TYPE_BEL;
+ decalxy.decal.index = bel.index;
return decalxy;
}
@@ -441,11 +487,17 @@ DecalXY Arch::getPipDecal(PipId pip) const
return decalxy;
};
+DecalXY Arch::getGroupDecal(GroupId group) const
+{
+ DecalXY decalxy;
+ return decalxy;
+};
+
std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
{
std::vector<GraphicElement> ret;
- if (decal.type == 'f')
+ if (decal.type == DecalId::TYPE_FRAME)
{
for (int x = 0; x <= chip_info->width; x++)
for (int y = 0; y <= chip_info->height; y++) {
@@ -458,10 +510,10 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
}
}
- if (decal.type == 'b')
+ if (decal.type == DecalId::TYPE_BEL)
{
BelId bel;
- bel.index = decal.z;
+ bel.index = decal.index;
auto bel_type = getBelType(bel);
diff --git a/ice40/arch.h b/ice40/arch.h
index 659139a6..96d0d209 100644
--- a/ice40/arch.h
+++ b/ice40/arch.h
@@ -634,6 +634,16 @@ struct Arch : BaseCtx
// -------------------------------------------------
+ GroupId getGroupByName(IdString name) const;
+ IdString getGroupName(GroupId group) const;
+ std::vector<GroupId> getGroups() const;
+ std::vector<BelId> getGroupBels(GroupId group) const;
+ std::vector<WireId> getGroupWires(GroupId group) const;
+ std::vector<PipId> getGroupPips(GroupId group) 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 20; }
@@ -654,6 +664,7 @@ struct Arch : BaseCtx
DecalXY getBelDecal(BelId bel) const;
DecalXY getWireDecal(WireId wire) const;
DecalXY getPipDecal(PipId pip) const;
+ DecalXY getGroupDecal(GroupId group) const;
// -------------------------------------------------
diff --git a/ice40/archdefs.h b/ice40/archdefs.h
index 061e9b44..62c248c7 100644
--- a/ice40/archdefs.h
+++ b/ice40/archdefs.h
@@ -109,11 +109,42 @@ struct PipId
bool operator!=(const PipId &other) const { return index != other.index; }
};
+struct GroupId
+{
+ enum : int8_t {
+ TYPE_NONE,
+ TYPE_FRAME,
+ TYPE_MAIN_SW,
+ TYPE_LOCAL_SW,
+ TYPE_LC0_SW,
+ TYPE_LC1_SW,
+ TYPE_LC2_SW,
+ TYPE_LC3_SW,
+ TYPE_LC4_SW,
+ TYPE_LC5_SW,
+ TYPE_LC6_SW,
+ TYPE_LC7_SW
+ } type = TYPE_NONE;
+ int8_t x = 0, y = 0;
+
+ bool operator==(const GroupId &other) const { return (type == other.type) && (x == other.x) && (y == other.y); }
+ bool operator!=(const GroupId &other) const { return (type != other.type) || (x != other.x) || (y == other.y); }
+};
+
struct DecalId
{
- char type = 0; // Bel/Wire/Pip/Frame (b/w/p/f)
- uint8_t x = 0, y = 0;
- uint32_t z = 0;
+ enum : int8_t {
+ TYPE_NONE,
+ TYPE_FRAME,
+ TYPE_BEL,
+ TYPE_WIRE,
+ TYPE_PIP,
+ TYPE_GROUP
+ } type = TYPE_NONE;
+ int32_t index = -1;
+
+ bool operator==(const DecalId &other) const { return (type == other.type) && (index == other.index); }
+ bool operator!=(const DecalId &other) const { return (type != other.type) || (index != other.index); }
};
NEXTPNR_NAMESPACE_END
@@ -145,14 +176,23 @@ template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PortPin> : hash<int>
{
};
+template <> struct hash<NEXTPNR_NAMESPACE_PREFIX GroupId>
+{
+ std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX GroupId &group) const noexcept {
+ std::size_t seed = 0;
+ boost::hash_combine(seed, hash<int>()(group.type));
+ boost::hash_combine(seed, hash<int>()(group.x));
+ boost::hash_combine(seed, hash<int>()(group.y));
+ return seed;
+ }
+};
+
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX DecalId>
{
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX DecalId &decal) const noexcept {
std::size_t seed = 0;
boost::hash_combine(seed, hash<int>()(decal.type));
- boost::hash_combine(seed, hash<int>()(decal.x));
- boost::hash_combine(seed, hash<int>()(decal.y));
- boost::hash_combine(seed, hash<int>()(decal.z));
+ boost::hash_combine(seed, hash<int>()(decal.index));
return seed;
}
};