diff options
Diffstat (limited to 'ice40')
-rw-r--r-- | ice40/chip.cc | 12 | ||||
-rw-r--r-- | ice40/chip.h | 58 | ||||
-rw-r--r-- | ice40/chipdb.py | 2 | ||||
-rw-r--r-- | ice40/pybindings.cc | 12 |
4 files changed, 36 insertions, 48 deletions
diff --git a/ice40/chip.cc b/ice40/chip.cc index 9c6d7a1a..26a2dc6e 100644 --- a/ice40/chip.cc +++ b/ice40/chip.cc @@ -41,7 +41,7 @@ BelType belTypeFromId(IdString id) return TYPE_ICESTORM_RAM; if (id == "SB_IO") return TYPE_SB_IO; - return TYPE_NIL; + return TYPE_NONE; } // ----------------------------------------------------------------------- @@ -67,7 +67,7 @@ PortPin portPinFromId(IdString id) #include "portpins.inc" #undef X - return PIN_NIL; + return PIN_NONE; } // ----------------------------------------------------------------------- @@ -121,7 +121,7 @@ WireId Chip::getWireBelPin(BelId bel, PortPin pin) const { WireId ret; - assert(!bel.nil()); + assert(bel != BelId()); int num_bel_wires = chip_info.bel_data[bel.index].num_bel_wires; BelWirePOD *bel_wires = chip_info.bel_data[bel.index].bel_wires; @@ -178,21 +178,21 @@ PipId Chip::getPipByName(IdString name) const void Chip::getBelPosition(BelId bel, float &x, float &y) const { - assert(!bel.nil()); + assert(bel != BelId()); x = chip_info.bel_data[bel.index].x; y = chip_info.bel_data[bel.index].y; } void Chip::getWirePosition(WireId wire, float &x, float &y) const { - assert(!wire.nil()); + assert(wire != WireId()); x = chip_info.wire_data[wire.index].x; y = chip_info.wire_data[wire.index].y; } void Chip::getPipPosition(PipId pip, float &x, float &y) const { - assert(!pip.nil()); + assert(pip != PipId()); x = chip_info.pip_data[pip.index].x; y = chip_info.pip_data[pip.index].y; } diff --git a/ice40/chip.h b/ice40/chip.h index 87a65b2d..a341bb14 100644 --- a/ice40/chip.h +++ b/ice40/chip.h @@ -42,7 +42,7 @@ struct DelayInfo enum BelType { - TYPE_NIL, + TYPE_NONE, TYPE_ICESTORM_LC, TYPE_ICESTORM_RAM, TYPE_SB_IO @@ -53,7 +53,7 @@ BelType belTypeFromId(IdString id); enum PortPin { - PIN_NIL, + PIN_NONE, #define X(t) PIN_##t, #include "portpins.inc" #undef X @@ -125,8 +125,6 @@ struct BelId { int32_t index = -1; - bool nil() const { return index < 0; } - bool operator==(const BelId &other) const { return index == other.index; } bool operator!=(const BelId &other) const { return index != other.index; } }; @@ -135,8 +133,6 @@ struct WireId { int32_t index = -1; - bool nil() const { return index < 0; } - bool operator==(const WireId &other) const { return index == other.index; } bool operator!=(const WireId &other) const { return index != other.index; } }; @@ -145,8 +141,6 @@ struct PipId { int32_t index = -1; - bool nil() const { return index < 0; } - bool operator==(const PipId &other) const { return index == other.index; } bool operator!=(const PipId &other) const { return index != other.index; } }; @@ -371,33 +365,33 @@ struct Chip IdString getBelName(BelId bel) const { - assert(!bel.nil()); + assert(bel != BelId()); return chip_info.bel_data[bel.index].name; } void bindBel(BelId bel, IdString cell) { - assert(!bel.nil()); + assert(bel != BelId()); assert(bel_to_cell[bel.index] == IdString()); bel_to_cell[bel.index] = cell; } void unbindBel(BelId bel) { - assert(!bel.nil()); + assert(bel != BelId()); assert(bel_to_cell[bel.index] != IdString()); bel_to_cell[bel.index] = IdString(); } bool checkBelAvail(BelId bel) const { - assert(!bel.nil()); + assert(bel != BelId()); return bel_to_cell[bel.index] == IdString(); } IdString getBelCell(BelId bel) const { - assert(!bel.nil()); + assert(bel != BelId()); return bel_to_cell[bel.index]; } @@ -425,7 +419,7 @@ struct Chip BelType getBelType(BelId bel) const { - assert(!bel.nil()); + assert(bel != BelId()); return chip_info.bel_data[bel.index].type; } @@ -434,7 +428,7 @@ struct Chip BelPin getBelPinUphill(WireId wire) const { BelPin ret; - assert(!wire.nil()); + assert(wire != WireId()); if (chip_info.wire_data[wire.index].bel_uphill.bel_index >= 0) { ret.bel.index = @@ -448,7 +442,7 @@ struct Chip BelPinRange getBelPinsDownhill(WireId wire) const { BelPinRange range; - assert(!wire.nil()); + assert(wire != WireId()); range.b.ptr = chip_info.wire_data[wire.index].bels_downhill; range.e.ptr = range.b.ptr + chip_info.wire_data[wire.index].num_bels_downhill; @@ -461,33 +455,33 @@ struct Chip IdString getWireName(WireId wire) const { - assert(!wire.nil()); + assert(wire != WireId()); return chip_info.wire_data[wire.index].name; } void bindWire(WireId wire, IdString net) { - assert(!wire.nil()); + assert(wire != WireId()); assert(wire_to_net[wire.index] == IdString()); wire_to_net[wire.index] = net; } void unbindWire(WireId wire) { - assert(!wire.nil()); + assert(wire != WireId()); assert(wire_to_net[wire.index] != IdString()); wire_to_net[wire.index] = IdString(); } bool checkWireAvail(WireId wire) const { - assert(!wire.nil()); + assert(wire != WireId()); return wire_to_net[wire.index] == IdString(); } IdString getWireNet(WireId wire) const { - assert(!wire.nil()); + assert(wire != WireId()); return wire_to_net[wire.index]; } @@ -505,7 +499,7 @@ struct Chip IdString getPipName(PipId pip) const { - assert(!pip.nil()); + assert(pip != PipId()); std::string src_name = chip_info.wire_data[chip_info.pip_data[pip.index].src].name; std::string dst_name = @@ -515,27 +509,27 @@ struct Chip void bindPip(PipId pip, IdString net) { - assert(!pip.nil()); + assert(pip != PipId()); assert(pip_to_net[pip.index] == IdString()); pip_to_net[pip.index] = net; } void unbindPip(PipId pip) { - assert(!pip.nil()); + assert(pip != PipId()); assert(pip_to_net[pip.index] != IdString()); pip_to_net[pip.index] = IdString(); } bool checkPipAvail(PipId pip) const { - assert(!pip.nil()); + assert(pip != PipId()); return pip_to_net[pip.index] == IdString(); } IdString getPipNet(PipId pip) const { - assert(!pip.nil()); + assert(pip != PipId()); return pip_to_net[pip.index]; } @@ -550,7 +544,7 @@ struct Chip WireId getPipSrcWire(PipId pip) const { WireId wire; - assert(!pip.nil()); + assert(pip != PipId()); wire.index = chip_info.pip_data[pip.index].src; return wire; } @@ -558,7 +552,7 @@ struct Chip WireId getPipDstWire(PipId pip) const { WireId wire; - assert(!pip.nil()); + assert(pip != PipId()); wire.index = chip_info.pip_data[pip.index].dst; return wire; } @@ -566,7 +560,7 @@ struct Chip DelayInfo getPipDelay(PipId pip) const { DelayInfo delay; - assert(!pip.nil()); + assert(pip != PipId()); delay.delay = chip_info.pip_data[pip.index].delay; return delay; } @@ -574,7 +568,7 @@ struct Chip PipRange getPipsDownhill(WireId wire) const { PipRange range; - assert(!wire.nil()); + assert(wire != WireId()); range.b.cursor = chip_info.wire_data[wire.index].pips_downhill; range.e.cursor = range.b.cursor + chip_info.wire_data[wire.index].num_downhill; @@ -584,7 +578,7 @@ struct Chip PipRange getPipsUphill(WireId wire) const { PipRange range; - assert(!wire.nil()); + assert(wire != WireId()); range.b.cursor = chip_info.wire_data[wire.index].pips_uphill; range.e.cursor = range.b.cursor + chip_info.wire_data[wire.index].num_uphill; @@ -594,7 +588,7 @@ struct Chip PipRange getWireAliases(WireId wire) const { PipRange range; - assert(!wire.nil()); + assert(wire != WireId()); range.b.cursor = nullptr; range.e.cursor = nullptr; return range; diff --git a/ice40/chipdb.py b/ice40/chipdb.py index 7b1ba93a..78ba2e46 100644 --- a/ice40/chipdb.py +++ b/ice40/chipdb.py @@ -318,7 +318,7 @@ for wire in range(num_wires): if wire in wire_uphill_belport: info += "{%d, PIN_%s}, " % wire_uphill_belport[wire] else: - info += "{-1, PIN_NIL}, " + info += "{-1, PIN_NONE}, " info += ("wire%d_downbels, " % wire) if num_bels_downhill > 0 else "nullptr, " diff --git a/ice40/pybindings.cc b/ice40/pybindings.cc index f19afce4..f9385153 100644 --- a/ice40/pybindings.cc +++ b/ice40/pybindings.cc @@ -38,17 +38,11 @@ void arch_wrap_python() .value("UP5K", ChipArgs::UP5K) .export_values(); - class_<BelId>("BelId") - .def_readwrite("index", &BelId::index) - .def("nil", &BelId::nil); + class_<BelId>("BelId").def_readwrite("index", &BelId::index); - class_<WireId>("WireId") - .def_readwrite("index", &WireId::index) - .def("nil", &WireId::nil); + class_<WireId>("WireId").def_readwrite("index", &WireId::index); - class_<PipId>("PipId") - .def_readwrite("index", &PipId::index) - .def("nil", &WireId::nil); + class_<PipId>("PipId").def_readwrite("index", &PipId::index); class_<BelPin>("BelPin") .def_readwrite("bel", &BelPin::bel) |