[arch] Add Arch::isGlobalNet() API too
diff --git a/docs/archapi.md b/docs/archapi.md
index 78b2053..6dcbac3 100644
--- a/docs/archapi.md
+++ b/docs/archapi.md
@@ -433,7 +433,7 @@
### bool route()
-run the router.
+Run the router.
Graphics Methods
----------------
@@ -481,6 +481,13 @@
port. Where ports have more than one clock edge associated with them (such as DDR outputs), `index` can be used to obtain
information for all edges. `index` must be in [0, clockInfoCount), behaviour is undefined otherwise.
+Net Methods
+------------------
+
+### bool isGlobalNet(const NetInfo *net) const
+
+Returns true if the given net is driven by a global buffer.
+
Placer Methods
--------------
@@ -492,5 +499,5 @@
### bool isBelLocationValid(BelId bel) const
-Returns true if a bell in the current configuration is valid, i.e. if
+Returns true if a bel in the current configuration is valid, i.e. if
`isValidBelForCell()` would return true for the current mapping.
diff --git a/ecp5/arch.cc b/ecp5/arch.cc
index 380c0d7..f902e75 100644
--- a/ecp5/arch.cc
+++ b/ecp5/arch.cc
@@ -768,6 +768,13 @@
return info;
}
+bool Arch::isGlobalNet(const NetInfo *net) const
+{
+ if (net == nullptr)
+ return false;
+ return net->driver.cell != nullptr && net->driver.port == id_CLKO;
+}
+
std::vector<std::pair<std::string, std::string>> Arch::getTilesAtLocation(int row, int col)
{
std::vector<std::pair<std::string, std::string>> ret;
diff --git a/ecp5/arch.h b/ecp5/arch.h
index 19fe1c4..8fba9c4 100644
--- a/ecp5/arch.h
+++ b/ecp5/arch.h
@@ -955,7 +955,7 @@
TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const;
// Get the TimingClockingInfo of a port
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const;
- // Return true if a port is a net
+ // Return true if net is driven from global buffer
bool isGlobalNet(const NetInfo *net) const;
bool getDelayFromTimingDatabase(IdString tctype, IdString from, IdString to, DelayInfo &delay) const;
diff --git a/generic/arch.cc b/generic/arch.cc
index 7065cc3..3317295 100644
--- a/generic/arch.cc
+++ b/generic/arch.cc
@@ -474,6 +474,11 @@
NPNR_ASSERT_FALSE("no clocking info for generic");
}
+bool Arch::isGlobalNet(const NetInfo *net) const
+{
+ return false;
+}
+
bool Arch::isValidBelForCell(CellInfo *cell, BelId bel) const { return true; }
bool Arch::isBelLocationValid(BelId bel) const { return true; }
diff --git a/generic/arch.h b/generic/arch.h
index de1fca2..d3c1d96 100644
--- a/generic/arch.h
+++ b/generic/arch.h
@@ -238,6 +238,8 @@
TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const;
// Get the TimingClockingInfo of a port
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const;
+ // Return true if net is driven from global buffer
+ bool isGlobalNet(const NetInfo *net) const;
bool isValidBelForCell(CellInfo *cell, BelId bel) const;
bool isBelLocationValid(BelId bel) const;
diff --git a/ice40/arch.h b/ice40/arch.h
index a74528a..51a8ec0 100644
--- a/ice40/arch.h
+++ b/ice40/arch.h
@@ -851,7 +851,7 @@
TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const;
// Get the TimingClockingInfo of a port
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const;
- // Return true if a port is a net
+ // Return true if net is driven from global buffer
bool isGlobalNet(const NetInfo *net) const;
// -------------------------------------------------