aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorD. Shah <dave@ds0.me>2021-02-05 13:46:56 +0000
committerD. Shah <dave@ds0.me>2021-02-05 19:19:17 +0000
commit6575bfac3ec6cbf38f4525f997f07ccbaaa043f9 (patch)
tree9f1d8b5ef22ecbf34627c835376335bb894775dd
parentc7ef7e1902e002432ffc54ab1aa25ff85f891ac0 (diff)
downloadnextpnr-6575bfac3ec6cbf38f4525f997f07ccbaaa043f9.tar.gz
nextpnr-6575bfac3ec6cbf38f4525f997f07ccbaaa043f9.tar.bz2
nextpnr-6575bfac3ec6cbf38f4525f997f07ccbaaa043f9.zip
gowin: Switch to BaseArch
Signed-off-by: D. Shah <dave@ds0.me>
-rw-r--r--gowin/arch.cc42
-rw-r--r--gowin/arch.h215
2 files changed, 107 insertions, 150 deletions
diff --git a/gowin/arch.cc b/gowin/arch.cc
index e266c9b5..d4e17a8a 100644
--- a/gowin/arch.cc
+++ b/gowin/arch.cc
@@ -736,17 +736,8 @@ Arch::Arch(ArchArgs args) : args(args)
}
}
}
- // Dummy for empty decals
- decal_graphics[IdString()];
-
- std::unordered_set<IdString> bel_types;
- for (BelId bel : getBels()) {
- bel_types.insert(getBelType(bel));
- }
-
- for (IdString bel_type : bel_types) {
- cell_types.push_back(bel_type);
- }
+ BaseArch::init_cell_types();
+ BaseArch::init_bel_buckets();
}
void IdString::initialize_arch(const BaseCtx *ctx)
@@ -785,8 +776,6 @@ const std::vector<BelId> &Arch::getBelsByTile(int x, int y) const { return bels_
bool Arch::getBelGlobalBuf(BelId bel) const { return bels.at(bel).gb; }
-uint32_t Arch::getBelChecksum(BelId bel) const { return bel.index; }
-
void Arch::bindBel(BelId bel, CellInfo *cell, PlaceStrength strength)
{
bels.at(bel).bound_cell = cell;
@@ -848,12 +837,6 @@ IdString Arch::getWireType(WireId wire) const { return wires.at(wire).type; }
const std::map<IdString, std::string> &Arch::getWireAttrs(WireId wire) const { return wires.at(wire).attrs; }
-uint32_t Arch::getWireChecksum(WireId wire) const
-{
- // FIXME
- return 0;
-}
-
void Arch::bindWire(WireId wire, NetInfo *net, PlaceStrength strength)
{
wires.at(wire).bound_net = net;
@@ -902,8 +885,6 @@ IdString Arch::getPipType(PipId pip) const { return pips.at(pip).type; }
const std::map<IdString, std::string> &Arch::getPipAttrs(PipId pip) const { return pips.at(pip).attrs; }
-uint32_t Arch::getPipChecksum(PipId wire) const { return wire.index; }
-
void Arch::bindPip(PipId pip, NetInfo *net, PlaceStrength strength)
{
WireId wire = pips.at(pip).dstWire;
@@ -1074,25 +1055,6 @@ bool Arch::route()
// ---------------------------------------------------------------
-const std::vector<GraphicElement> &Arch::getDecalGraphics(DecalId decal) const
-{
- if (!decal_graphics.count(decal)) {
- std::cerr << "No decal named " << decal.str(this) << std::endl;
- log_error("No decal named %s!\n", decal.c_str(this));
- }
- return decal_graphics.at(decal);
-}
-
-DecalXY Arch::getBelDecal(BelId bel) const { return bels.at(bel).decalxy; }
-
-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, DelayInfo &delay) const
{
if (!cellTiming.count(cell->name))
diff --git a/gowin/arch.h b/gowin/arch.h
index 4754772b..8f41657c 100644
--- a/gowin/arch.h
+++ b/gowin/arch.h
@@ -243,7 +243,37 @@ struct CellTiming
std::unordered_map<IdString, std::vector<TimingClockingInfo>> clockingInfo;
};
-struct Arch : BaseCtx
+struct ArchRanges
+{
+ // Bels
+ using AllBelsRange = const std::vector<BelId> &;
+ using TileBelsRange = const std::vector<BelId> &;
+ using BelAttrsRange = const std::map<IdString, std::string> &;
+ using BelPinsRange = std::vector<IdString>;
+ // Wires
+ using AllWiresRange = const std::vector<WireId> &;
+ using DownhillPipRange = const std::vector<PipId> &;
+ using UphillPipRange = const std::vector<PipId> &;
+ using WireBelPinRange = const std::vector<BelPin> &;
+ using WireAttrsRange = const std::map<IdString, std::string> &;
+ // Pips
+ using AllPipsRange = const std::vector<PipId> &;
+ using PipAttrsRange = const std::map<IdString, std::string> &;
+ // Groups
+ using AllGroupsRange = std::vector<GroupId>;
+ using GroupBelsRange = const std::vector<BelId> &;
+ using GroupWiresRange = const std::vector<WireId> &;
+ using GroupPipsRange = const std::vector<PipId> &;
+ using GroupGroupsRange = const std::vector<GroupId> &;
+ // Decals
+ using DecalGfxRange = const std::vector<GraphicElement> &;
+ // Placement validity
+ using CellTypeRange = std::vector<IdString>;
+ using BelBucketRange = std::vector<BelBucketId>;
+ using BucketBelRange = std::vector<BelId>;
+};
+
+struct Arch : BaseArch<ArchRanges>
{
std::string family;
std::string device;
@@ -313,14 +343,13 @@ struct Arch : BaseCtx
ArchArgs args;
Arch(ArchArgs args);
- std::string getChipName() const { return device; }
+ std::string getChipName() const override { return device; }
- IdString archId() const { return id("gowin"); }
ArchArgs archArgs() const { return args; }
IdString archArgsToId(ArchArgs args) const { return id("none"); }
- int getGridDimX() const { return gridDimX; }
- int getGridDimY() const { return gridDimY; }
+ int getGridDimX() const override { return gridDimX; }
+ int getGridDimY() const override { return gridDimY; }
int getTileBelDimZ(int x, int y) const { return tileBelDimZ[x][y]; }
int getTilePipDimZ(int x, int y) const { return tilePipDimZ[x][y]; }
char getNameDelimiter() const
@@ -328,74 +357,71 @@ struct Arch : BaseCtx
return ' '; /* use a non-existent delimiter as we aren't using IdStringLists yet */
}
- BelId getBelByName(IdStringList name) const;
- IdStringList getBelName(BelId bel) const;
- Loc getBelLocation(BelId bel) const;
- BelId getBelByLocation(Loc loc) const;
- 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, CellInfo *cell, PlaceStrength strength);
- void unbindBel(BelId bel);
- bool checkBelAvail(BelId bel) const;
- CellInfo *getBoundBelCell(BelId bel) const;
- CellInfo *getConflictingBelCell(BelId bel) const;
- const std::vector<BelId> &getBels() const;
- IdString getBelType(BelId bel) const;
- const std::map<IdString, std::string> &getBelAttrs(BelId bel) const;
- WireId getBelPinWire(BelId bel, IdString pin) const;
- PortType getBelPinType(BelId bel, IdString pin) const;
- std::vector<IdString> getBelPins(BelId bel) const;
-
- WireId getWireByName(IdStringList name) const;
- IdStringList getWireName(WireId wire) const;
- IdString getWireType(WireId wire) const;
- const std::map<IdString, std::string> &getWireAttrs(WireId wire) const;
- uint32_t getWireChecksum(WireId wire) const;
- void bindWire(WireId wire, NetInfo *net, PlaceStrength strength);
- void unbindWire(WireId wire);
- bool checkWireAvail(WireId wire) const;
- NetInfo *getBoundWireNet(WireId wire) const;
- WireId getConflictingWireWire(WireId wire) const { return wire; }
- NetInfo *getConflictingWireNet(WireId wire) const;
- DelayInfo getWireDelay(WireId wire) const { return DelayInfo(); }
- const std::vector<WireId> &getWires() const;
- const std::vector<BelPin> &getWireBelPins(WireId wire) const;
-
- PipId getPipByName(IdStringList name) const;
- IdStringList getPipName(PipId pip) const;
- IdString getPipType(PipId pip) const;
- const std::map<IdString, std::string> &getPipAttrs(PipId pip) const;
- uint32_t getPipChecksum(PipId pip) const;
- void bindPip(PipId pip, NetInfo *net, PlaceStrength strength);
- void unbindPip(PipId pip);
- bool checkPipAvail(PipId pip) const;
- NetInfo *getBoundPipNet(PipId pip) const;
- WireId getConflictingPipWire(PipId pip) const;
- NetInfo *getConflictingPipNet(PipId pip) const;
- const std::vector<PipId> &getPips() const;
- Loc getPipLocation(PipId pip) const;
- WireId getPipSrcWire(PipId pip) const;
- WireId getPipDstWire(PipId pip) const;
- DelayInfo getPipDelay(PipId pip) const;
- const std::vector<PipId> &getPipsDownhill(WireId wire) const;
- const std::vector<PipId> &getPipsUphill(WireId wire) const;
-
- GroupId getGroupByName(IdStringList name) const;
- IdStringList 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;
-
- delay_t estimateDelay(WireId src, WireId dst) const;
- delay_t predictDelay(const NetInfo *net_info, const PortRef &sink) const;
- delay_t getDelayEpsilon() const { return 0.01; }
- delay_t getRipupDelayPenalty() const { return 0.4; }
- float getDelayNS(delay_t v) const { return v; }
-
- DelayInfo getDelayFromNS(float ns) const
+ BelId getBelByName(IdStringList name) const override;
+ IdStringList getBelName(BelId bel) const override;
+ Loc getBelLocation(BelId bel) const override;
+ BelId getBelByLocation(Loc loc) const override;
+ const std::vector<BelId> &getBelsByTile(int x, int y) const override;
+ bool getBelGlobalBuf(BelId bel) const override;
+ void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength) override;
+ void unbindBel(BelId bel) override;
+ bool checkBelAvail(BelId bel) const override;
+ CellInfo *getBoundBelCell(BelId bel) const override;
+ CellInfo *getConflictingBelCell(BelId bel) const override;
+ const std::vector<BelId> &getBels() const override;
+ IdString getBelType(BelId bel) const override;
+ const std::map<IdString, std::string> &getBelAttrs(BelId bel) const override;
+ WireId getBelPinWire(BelId bel, IdString pin) const override;
+ PortType getBelPinType(BelId bel, IdString pin) const override;
+ std::vector<IdString> getBelPins(BelId bel) const override;
+
+ WireId getWireByName(IdStringList name) const override;
+ IdStringList getWireName(WireId wire) const override;
+ IdString getWireType(WireId wire) const override;
+ const std::map<IdString, std::string> &getWireAttrs(WireId wire) const override;
+ void bindWire(WireId wire, NetInfo *net, PlaceStrength strength) override;
+ void unbindWire(WireId wire) override;
+ bool checkWireAvail(WireId wire) const override;
+ NetInfo *getBoundWireNet(WireId wire) const override;
+ WireId getConflictingWireWire(WireId wire) const override { return wire; }
+ NetInfo *getConflictingWireNet(WireId wire) const override;
+ DelayInfo getWireDelay(WireId wire) const override { return DelayInfo(); }
+ const std::vector<WireId> &getWires() const override;
+ const std::vector<BelPin> &getWireBelPins(WireId wire) const override;
+
+ PipId getPipByName(IdStringList name) const override;
+ IdStringList getPipName(PipId pip) const override;
+ IdString getPipType(PipId pip) const override;
+ const std::map<IdString, std::string> &getPipAttrs(PipId pip) const override;
+ void bindPip(PipId pip, NetInfo *net, PlaceStrength strength) override;
+ void unbindPip(PipId pip) override;
+ bool checkPipAvail(PipId pip) const override;
+ NetInfo *getBoundPipNet(PipId pip) const override;
+ WireId getConflictingPipWire(PipId pip) const override;
+ NetInfo *getConflictingPipNet(PipId pip) const override;
+ const std::vector<PipId> &getPips() const override;
+ Loc getPipLocation(PipId pip) const override;
+ WireId getPipSrcWire(PipId pip) const override;
+ WireId getPipDstWire(PipId pip) const override;
+ DelayInfo getPipDelay(PipId pip) const override;
+ const std::vector<PipId> &getPipsDownhill(WireId wire) const override;
+ const std::vector<PipId> &getPipsUphill(WireId wire) const override;
+
+ GroupId getGroupByName(IdStringList name) const override;
+ IdStringList getGroupName(GroupId group) const override;
+ std::vector<GroupId> getGroups() const override;
+ const std::vector<BelId> &getGroupBels(GroupId group) const override;
+ const std::vector<WireId> &getGroupWires(GroupId group) const override;
+ const std::vector<PipId> &getGroupPips(GroupId group) const override;
+ const std::vector<GroupId> &getGroupGroups(GroupId group) const override;
+
+ delay_t estimateDelay(WireId src, WireId dst) const override;
+ delay_t predictDelay(const NetInfo *net_info, const PortRef &sink) const override;
+ delay_t getDelayEpsilon() const override { return 0.01; }
+ delay_t getRipupDelayPenalty() const override { return 0.4; }
+ float getDelayNS(delay_t v) const override { return v; }
+
+ DelayInfo getDelayFromNS(float ns) const override
{
DelayInfo del;
del.maxRaise = ns;
@@ -405,20 +431,14 @@ struct Arch : BaseCtx
return del;
}
- uint32_t getDelayChecksum(delay_t v) const { return 0; }
- bool getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const;
-
- ArcBounds getRouteBoundingBox(WireId src, WireId dst) const;
+ uint32_t getDelayChecksum(delay_t v) const override { return 0; }
+ bool getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const override;
- bool pack();
- bool place();
- bool route();
+ ArcBounds getRouteBoundingBox(WireId src, WireId dst) const override;
- const std::vector<GraphicElement> &getDecalGraphics(DecalId decal) const;
- DecalXY getBelDecal(BelId bel) const;
- DecalXY getWireDecal(WireId wire) const;
- DecalXY getPipDecal(PipId pip) const;
- DecalXY getGroupDecal(GroupId group) const;
+ bool pack() override;
+ bool place() override;
+ bool route() override;
bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayInfo &delay) const;
// Get the port class, also setting clockInfoCount to the number of TimingClockingInfos associated with a port
@@ -426,31 +446,6 @@ struct Arch : BaseCtx
// Get the TimingClockingInfo of a port
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const;
- bool isValidBelForCellType(IdString cell_type, BelId bel) const { return cell_type == getBelType(bel); }
-
- const std::vector<IdString> &getCellTypes() const { return cell_types; }
-
- std::vector<BelBucketId> getBelBuckets() const { return cell_types; }
-
- IdString getBelBucketName(BelBucketId bucket) const { return bucket; }
-
- BelBucketId getBelBucketByName(IdString name) const { return name; }
-
- BelBucketId getBelBucketForBel(BelId bel) const { return getBelType(bel); }
-
- BelBucketId getBelBucketForCellType(IdString cell_type) const { return cell_type; }
-
- std::vector<BelId> getBelsInBucket(BelBucketId bucket) const
- {
- std::vector<BelId> bels;
- for (BelId bel : getBels()) {
- if (getBelType(bel) == bucket) {
- bels.push_back(bel);
- }
- }
- return bels;
- }
-
bool isValidBelForCell(CellInfo *cell, BelId bel) const;
bool isBelLocationValid(BelId bel) const;