Skip to content

Commit 0020877

Browse files
committed
Add arch API function for pip inversion
1 parent e4115e8 commit 0020877

File tree

6 files changed

+28
-3
lines changed

6 files changed

+28
-3
lines changed

common/kernel/arch_api.h

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ template <typename R> struct ArchAPI : BaseCtx
102102
virtual WireId getPipDstWire(PipId pip) const = 0;
103103
virtual DelayQuad getPipDelay(PipId pip) const = 0;
104104
virtual Loc getPipLocation(PipId pip) const = 0;
105+
virtual bool isPipInverting(PipId pip) const = 0;
105106
// Group methods
106107
virtual GroupId getGroupByName(IdStringList name) const = 0;
107108
virtual IdStringList getGroupName(GroupId group) const = 0;

common/kernel/base_arch.h

+1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ template <typename R> struct BaseArch : ArchAPI<R>
288288
}
289289
virtual WireId getConflictingPipWire(PipId /*pip*/) const override { return WireId(); }
290290
virtual NetInfo *getConflictingPipNet(PipId pip) const override { return getBoundPipNet(pip); }
291+
virtual bool isPipInverting(PipId /*pip*/) const override { return false; }
291292

292293
// Group methods
293294
virtual GroupId getGroupByName(IdStringList /*name*/) const override { return GroupId(); };

docs/archapi.md

+6
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,12 @@ pip is already bound to that net.
417417

418418
*BaseArch default: returns `getBoundPipNet(pip) == nullptr || getBoundPipNet(pip) == net`*
419419

420+
### bool isPipInverting(PipId pip) const
421+
422+
Returns true if the given pip inverts the net passing through it.
423+
424+
*BaseArch default: returns `false`*
425+
420426
### NetInfo \*getBoundPipNet(PipId pip) const
421427

422428
Return the net this pip is bound to.

himbaechel/arch.cc

+16-3
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,19 @@ IdStringList Arch::getWireName(WireId wire) const
285285

286286
PipId Arch::getPipByName(IdStringList name) const
287287
{
288-
NPNR_ASSERT(name.size() == 3);
288+
NPNR_ASSERT(name.size() == 3 || (name.size() == 4 && name[4] == getCtx()->id("INV")));
289289
int tile = tile_name2idx.at(name[0]);
290290
const auto &tdata = chip_tile_info(chip_info, tile);
291291
for (int pip = 0; pip < tdata.pips.ssize(); pip++) {
292292
if (IdString(tdata.wires[tdata.pips[pip].dst_wire].name) == name[1] &&
293-
IdString(tdata.wires[tdata.pips[pip].src_wire].name) == name[2])
294-
return PipId(tile, pip);
293+
IdString(tdata.wires[tdata.pips[pip].src_wire].name) == name[2]) {
294+
295+
auto tmp_pip = PipId(tile, pip);
296+
if ((name.size() == 3 && !getCtx()->isPipInverting(tmp_pip)) ||
297+
(name.size() == 4 && getCtx()->isPipInverting(tmp_pip))) {
298+
return tmp_pip;
299+
}
300+
}
295301
}
296302
return PipId();
297303
}
@@ -300,6 +306,13 @@ IdStringList Arch::getPipName(PipId pip) const
300306
{
301307
auto &tdata = chip_tile_info(chip_info, pip.tile);
302308
auto &pdata = tdata.pips[pip.index];
309+
if (getCtx()->isPipInverting(pip)) {
310+
// TODO: variadic IdStringList::concat? this is messy.
311+
return IdStringList::concat(tile_name.at(pip.tile),
312+
IdStringList::concat(IdString(tdata.wires[pdata.dst_wire].name),
313+
IdStringList::concat(IdString(tdata.wires[pdata.src_wire].name),
314+
getCtx()->id("INV"))));
315+
}
303316
return IdStringList::concat(tile_name.at(pip.tile),
304317
IdStringList::concat(IdString(tdata.wires[pdata.dst_wire].name),
305318
IdString(tdata.wires[pdata.src_wire].name)));

himbaechel/arch.h

+3
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,9 @@ struct Arch : BaseArch<ArchRanges>
662662
uarch->notifyPipChange(pip, nullptr);
663663
BaseArch::unbindPip(pip);
664664
}
665+
bool isPipInverting(PipId pip) const override {
666+
return uarch->isPipInverting(pip);
667+
}
665668

666669
// -------------------------------------------------
667670

himbaechel/himbaechel_api.h

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct HimbaechelAPI
8989
virtual bool checkWireAvail(WireId wire) const { return true; }
9090
virtual bool checkPipAvail(PipId pip) const { return true; }
9191
virtual bool checkPipAvailForNet(PipId pip, const NetInfo *net) const { return checkPipAvail(pip); };
92+
virtual bool isPipInverting(PipId pip) const { return false; }
9293

9394
// --- Route lookahead ---
9495
virtual delay_t estimateDelay(WireId src, WireId dst) const;

0 commit comments

Comments
 (0)