diff options
Diffstat (limited to 'ice40')
-rw-r--r-- | ice40/arch.cc | 41 | ||||
-rw-r--r-- | ice40/arch.h | 28 | ||||
-rw-r--r-- | ice40/arch_pybindings.cc | 64 | ||||
-rw-r--r-- | ice40/arch_pybindings.h | 18 | ||||
-rw-r--r-- | ice40/bitstream.cc | 13 | ||||
-rw-r--r-- | ice40/main.cc | 21 |
6 files changed, 65 insertions, 120 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc index 8f2731c6..4727597b 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -257,47 +257,6 @@ BelRange Arch::getBelsAtSameTile(BelId bel) const } // ----------------------------------------------------------------------- -// Shorthands to ArchProxy - -BelId Arch::getBelByName(IdString name) const { return rproxy().getBelByName(name); } - -void Arch::bindWire(WireId wire, IdString net, PlaceStrength strength) { rwproxy().bindWire(wire, net, strength); } - -void Arch::unbindWire(WireId wire) { rwproxy().unbindWire(wire); } - -void Arch::bindBel(BelId bel, IdString cell, PlaceStrength strength) { rwproxy().bindBel(bel, cell, strength); } - -void Arch::unbindBel(BelId bel) { rwproxy().unbindBel(bel); } - -bool Arch::checkBelAvail(BelId bel) const { return rproxy().checkBelAvail(bel); } - -IdString Arch::getBoundBelCell(BelId bel) const { return rproxy().getBoundBelCell(bel); } - -IdString Arch::getConflictingBelCell(BelId bel) const { return rproxy().getConflictingBelCell(bel); } - -WireId Arch::getWireByName(IdString name) const { return rproxy().getWireByName(name); } - -WireId Arch::getWireBelPin(BelId bel, PortPin pin) const { return rproxy().getWireBelPin(bel, pin); } - -bool Arch::checkWireAvail(WireId wire) const { return rproxy().checkWireAvail(wire); } - -IdString Arch::getBoundWireNet(WireId wire) const { return rproxy().getBoundWireNet(wire); } - -IdString Arch::getConflictingWireNet(WireId wire) const { return rproxy().getConflictingWireNet(wire); } - -PipId Arch::getPipByName(IdString name) const { return rproxy().getPipByName(name); } - -void Arch::bindPip(PipId pip, IdString net, PlaceStrength strength) { return rwproxy().bindPip(pip, net, strength); } - -void Arch::unbindPip(PipId pip) { return rwproxy().unbindPip(pip); } - -bool Arch::checkPipAvail(PipId pip) const { return rproxy().checkPipAvail(pip); } - -IdString Arch::getBoundPipNet(PipId pip) const { return rproxy().getBoundPipNet(pip); } - -IdString Arch::getConflictingPipNet(PipId pip) const { return rproxy().getConflictingPipNet(pip); } - -// ----------------------------------------------------------------------- IdString Arch::getPipName(PipId pip) const { diff --git a/ice40/arch.h b/ice40/arch.h index ec1e456f..25ed8ebf 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -373,34 +373,6 @@ class Arch : public BaseCtx // ------------------------------------------------- - /// Wrappers around getting a r(w)proxy and calling a single method. - // Deprecated: please acquire a proxy yourself and call the methods - // you want on it. - // Warning: these will content with locks taken by the r(w)proxies, and - // thus can cause difficult to debug deadlocks - we'll be getting rid of - // them because of that. - void unbindWire(WireId wire); - void unbindPip(PipId pip); - void unbindBel(BelId bel); - void bindWire(WireId wire, IdString net, PlaceStrength strength); - void bindPip(PipId pip, IdString net, PlaceStrength strength); - void bindBel(BelId bel, IdString cell, PlaceStrength strength); - bool checkWireAvail(WireId wire) const; - bool checkPipAvail(PipId pip) const; - bool checkBelAvail(BelId bel) const; - WireId getWireByName(IdString name) const; - WireId getWireBelPin(BelId bel, PortPin pin) const; - PipId getPipByName(IdString name) const; - IdString getConflictingWireNet(WireId wire) const; - IdString getConflictingPipNet(PipId pip) const; - IdString getConflictingBelCell(BelId bel) const; - IdString getBoundWireNet(WireId wire) const; - IdString getBoundPipNet(PipId pip) const; - IdString getBoundBelCell(BelId bel) const; - BelId getBelByName(IdString name) const; - - // ------------------------------------------------- - /// Methods to get chip info - don't need to use a wrapper, as these are /// static per lifetime of object. diff --git a/ice40/arch_pybindings.cc b/ice40/arch_pybindings.cc index fd5109b4..aeb4348a 100644 --- a/ice40/arch_pybindings.cc +++ b/ice40/arch_pybindings.cc @@ -65,25 +65,25 @@ void arch_wrap_python() fn_wrapper_1a<Context, decltype(&Context::getBelType), &Context::getBelType, conv_to_str<BelType>, conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelType"); - fn_wrapper_1a<Context, decltype(&Context::checkBelAvail), &Context::checkBelAvail, pass_through<bool>, - conv_from_str<BelId>>::def_wrap(ctx_cls, "checkBelAvail"); + //fn_wrapper_1a<Context, decltype(&Context::checkBelAvail), &Context::checkBelAvail, pass_through<bool>, + // conv_from_str<BelId>>::def_wrap(ctx_cls, "checkBelAvail"); fn_wrapper_1a<Context, decltype(&Context::getBelChecksum), &Context::getBelChecksum, pass_through<uint32_t>, conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelChecksum"); - fn_wrapper_3a_v<Context, decltype(&Context::bindBel), &Context::bindBel, conv_from_str<BelId>, - conv_from_str<IdString>, pass_through<PlaceStrength>>::def_wrap(ctx_cls, "bindBel"); - fn_wrapper_1a_v<Context, decltype(&Context::unbindBel), &Context::unbindBel, conv_from_str<BelId>>::def_wrap( - ctx_cls, "unbindBel"); - fn_wrapper_1a<Context, decltype(&Context::getBoundBelCell), &Context::getBoundBelCell, conv_to_str<IdString>, - conv_from_str<BelId>>::def_wrap(ctx_cls, "getBoundBelCell"); - fn_wrapper_1a<Context, decltype(&Context::getConflictingBelCell), &Context::getConflictingBelCell, - conv_to_str<IdString>, conv_from_str<BelId>>::def_wrap(ctx_cls, "getConflictingBelCell"); + //fn_wrapper_3a_v<Context, decltype(&Context::bindBel), &Context::bindBel, conv_from_str<BelId>, + // conv_from_str<IdString>, pass_through<PlaceStrength>>::def_wrap(ctx_cls, "bindBel"); + //fn_wrapper_1a_v<Context, decltype(&Context::unbindBel), &Context::unbindBel, conv_from_str<BelId>>::def_wrap( + // ctx_cls, "unbindBel"); + //fn_wrapper_1a<Context, decltype(&Context::getBoundBelCell), &Context::getBoundBelCell, conv_to_str<IdString>, + // conv_from_str<BelId>>::def_wrap(ctx_cls, "getBoundBelCell"); + //fn_wrapper_1a<Context, decltype(&Context::getConflictingBelCell), &Context::getConflictingBelCell, + // conv_to_str<IdString>, conv_from_str<BelId>>::def_wrap(ctx_cls, "getConflictingBelCell"); fn_wrapper_0a<Context, decltype(&Context::getBels), &Context::getBels, wrap_context<BelRange>>::def_wrap(ctx_cls, "getBels"); fn_wrapper_1a<Context, decltype(&Context::getBelsAtSameTile), &Context::getBelsAtSameTile, wrap_context<BelRange>, conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelsAtSameTile"); - fn_wrapper_2a<Context, decltype(&Context::getWireBelPin), &Context::getWireBelPin, conv_to_str<WireId>, - conv_from_str<BelId>, conv_from_str<PortPin>>::def_wrap(ctx_cls, "getWireBelPin"); + //fn_wrapper_2a<Context, decltype(&Context::getWireBelPin), &Context::getWireBelPin, conv_to_str<WireId>, + // conv_from_str<BelId>, conv_from_str<PortPin>>::def_wrap(ctx_cls, "getWireBelPin"); fn_wrapper_1a<Context, decltype(&Context::getBelPinUphill), &Context::getBelPinUphill, wrap_context<BelPin>, conv_from_str<WireId>>::def_wrap(ctx_cls, "getBelPinUphill"); fn_wrapper_1a<Context, decltype(&Context::getBelPinsDownhill), &Context::getBelPinsDownhill, @@ -91,16 +91,16 @@ void arch_wrap_python() fn_wrapper_1a<Context, decltype(&Context::getWireChecksum), &Context::getWireChecksum, pass_through<uint32_t>, conv_from_str<WireId>>::def_wrap(ctx_cls, "getWireChecksum"); - fn_wrapper_3a_v<Context, decltype(&Context::bindWire), &Context::bindWire, conv_from_str<WireId>, - conv_from_str<IdString>, pass_through<PlaceStrength>>::def_wrap(ctx_cls, "bindWire"); - fn_wrapper_1a_v<Context, decltype(&Context::unbindWire), &Context::unbindWire, conv_from_str<WireId>>::def_wrap( - ctx_cls, "unbindWire"); - fn_wrapper_1a<Context, decltype(&Context::checkWireAvail), &Context::checkWireAvail, pass_through<bool>, - conv_from_str<WireId>>::def_wrap(ctx_cls, "checkWireAvail"); - fn_wrapper_1a<Context, decltype(&Context::getBoundWireNet), &Context::getBoundWireNet, conv_to_str<IdString>, - conv_from_str<WireId>>::def_wrap(ctx_cls, "getBoundWireNet"); - fn_wrapper_1a<Context, decltype(&Context::getConflictingWireNet), &Context::getConflictingWireNet, - conv_to_str<IdString>, conv_from_str<WireId>>::def_wrap(ctx_cls, "getConflictingWireNet"); + //fn_wrapper_3a_v<Context, decltype(&Context::bindWire), &Context::bindWire, conv_from_str<WireId>, + // conv_from_str<IdString>, pass_through<PlaceStrength>>::def_wrap(ctx_cls, "bindWire"); + //fn_wrapper_1a_v<Context, decltype(&Context::unbindWire), &Context::unbindWire, conv_from_str<WireId>>::def_wrap( + // ctx_cls, "unbindWire"); + //fn_wrapper_1a<Context, decltype(&Context::checkWireAvail), &Context::checkWireAvail, pass_through<bool>, + // conv_from_str<WireId>>::def_wrap(ctx_cls, "checkWireAvail"); + //fn_wrapper_1a<Context, decltype(&Context::getBoundWireNet), &Context::getBoundWireNet, conv_to_str<IdString>, + // conv_from_str<WireId>>::def_wrap(ctx_cls, "getBoundWireNet"); + //fn_wrapper_1a<Context, decltype(&Context::getConflictingWireNet), &Context::getConflictingWireNet, + // conv_to_str<IdString>, conv_from_str<WireId>>::def_wrap(ctx_cls, "getConflictingWireNet"); fn_wrapper_0a<Context, decltype(&Context::getWires), &Context::getWires, wrap_context<WireRange>>::def_wrap( ctx_cls, "getWires"); @@ -109,16 +109,16 @@ void arch_wrap_python() ctx_cls, "getPips"); fn_wrapper_1a<Context, decltype(&Context::getPipChecksum), &Context::getPipChecksum, pass_through<uint32_t>, conv_from_str<PipId>>::def_wrap(ctx_cls, "getPipChecksum"); - fn_wrapper_3a_v<Context, decltype(&Context::bindPip), &Context::bindPip, conv_from_str<PipId>, - conv_from_str<IdString>, pass_through<PlaceStrength>>::def_wrap(ctx_cls, "bindPip"); - fn_wrapper_1a_v<Context, decltype(&Context::unbindPip), &Context::unbindPip, conv_from_str<PipId>>::def_wrap( - ctx_cls, "unbindPip"); - fn_wrapper_1a<Context, decltype(&Context::checkPipAvail), &Context::checkPipAvail, pass_through<bool>, - conv_from_str<PipId>>::def_wrap(ctx_cls, "checkPipAvail"); - fn_wrapper_1a<Context, decltype(&Context::getBoundPipNet), &Context::getBoundPipNet, conv_to_str<IdString>, - conv_from_str<PipId>>::def_wrap(ctx_cls, "getBoundPipNet"); - fn_wrapper_1a<Context, decltype(&Context::getConflictingPipNet), &Context::getConflictingPipNet, - conv_to_str<IdString>, conv_from_str<PipId>>::def_wrap(ctx_cls, "getConflictingPipNet"); + //fn_wrapper_3a_v<Context, decltype(&Context::bindPip), &Context::bindPip, conv_from_str<PipId>, + // conv_from_str<IdString>, pass_through<PlaceStrength>>::def_wrap(ctx_cls, "bindPip"); + //fn_wrapper_1a_v<Context, decltype(&Context::unbindPip), &Context::unbindPip, conv_from_str<PipId>>::def_wrap( + // ctx_cls, "unbindPip"); + //fn_wrapper_1a<Context, decltype(&Context::checkPipAvail), &Context::checkPipAvail, pass_through<bool>, + // conv_from_str<PipId>>::def_wrap(ctx_cls, "checkPipAvail"); + //fn_wrapper_1a<Context, decltype(&Context::getBoundPipNet), &Context::getBoundPipNet, conv_to_str<IdString>, + // conv_from_str<PipId>>::def_wrap(ctx_cls, "getBoundPipNet"); + //fn_wrapper_1a<Context, decltype(&Context::getConflictingPipNet), &Context::getConflictingPipNet, + // conv_to_str<IdString>, conv_from_str<PipId>>::def_wrap(ctx_cls, "getConflictingPipNet"); fn_wrapper_1a<Context, decltype(&Context::getPipsDownhill), &Context::getPipsDownhill, wrap_context<PipRange>, conv_from_str<WireId>>::def_wrap(ctx_cls, "getPipsDownhill"); diff --git a/ice40/arch_pybindings.h b/ice40/arch_pybindings.h index e502905f..7440e29d 100644 --- a/ice40/arch_pybindings.h +++ b/ice40/arch_pybindings.h @@ -31,7 +31,11 @@ namespace PythonConversion { template <> struct string_converter<BelId> { - BelId from_str(Context *ctx, std::string name) { return ctx->getBelByName(ctx->id(name)); } + BelId from_str(Context *ctx, std::string name) + { + auto &&proxy = ctx->rproxy(); + return proxy.getBelByName(ctx->id(name)); + } std::string to_str(Context *ctx, BelId id) { @@ -50,14 +54,22 @@ template <> struct string_converter<BelType> template <> struct string_converter<WireId> { - WireId from_str(Context *ctx, std::string name) { return ctx->getWireByName(ctx->id(name)); } + WireId from_str(Context *ctx, std::string name) + { + auto &&proxy = ctx->rproxy(); + return proxy.getWireByName(ctx->id(name)); + } std::string to_str(Context *ctx, WireId id) { return ctx->getWireName(id).str(ctx); } }; template <> struct string_converter<PipId> { - PipId from_str(Context *ctx, std::string name) { return ctx->getPipByName(ctx->id(name)); } + PipId from_str(Context *ctx, std::string name) + { + auto &&proxy = ctx->rproxy(); + return proxy.getPipByName(ctx->id(name)); + } std::string to_str(Context *ctx, PipId id) { return ctx->getPipName(id).str(ctx); } }; diff --git a/ice40/bitstream.cc b/ice40/bitstream.cc index 58a59366..87a96a22 100644 --- a/ice40/bitstream.cc +++ b/ice40/bitstream.cc @@ -92,6 +92,7 @@ char get_hexdigit(int i) { return std::string("0123456789ABCDEF").at(i); } void write_asc(const Context *ctx, std::ostream &out) { + auto &&proxy = ctx->rproxy(); // [y][x][row][col] const ChipInfoPOD &ci = *ctx->chip_info; const BitstreamInfoPOD &bi = *ci.bits_info; @@ -128,7 +129,7 @@ void write_asc(const Context *ctx, std::ostream &out) } // Set pips for (auto pip : ctx->getPips()) { - if (ctx->getBoundPipNet(pip) != IdString()) { + if (proxy.getBoundPipNet(pip) != IdString()) { const PipInfoPOD &pi = ci.pip_data[pip.index]; const SwitchInfoPOD &swi = bi.switches[pi.switch_index]; for (int i = 0; i < swi.num_bits; i++) { @@ -199,8 +200,8 @@ void write_asc(const Context *ctx, std::ostream &out) NPNR_ASSERT(iez != -1); bool input_en = false; - if (!ctx->checkWireAvail(ctx->getWireBelPin(bel, PIN_D_IN_0)) || - !ctx->checkWireAvail(ctx->getWireBelPin(bel, PIN_D_IN_1))) { + if (!proxy.checkWireAvail(proxy.getWireBelPin(bel, PIN_D_IN_0)) || + !proxy.checkWireAvail(proxy.getWireBelPin(bel, PIN_D_IN_1))) { input_en = true; } @@ -271,7 +272,7 @@ void write_asc(const Context *ctx, std::ostream &out) } // Set config bits in unused IO and RAM for (auto bel : ctx->getBels()) { - if (ctx->checkBelAvail(bel) && ctx->getBelType(bel) == TYPE_SB_IO) { + if (proxy.checkBelAvail(bel) && ctx->getBelType(bel) == TYPE_SB_IO) { const TileInfoPOD &ti = bi.tiles_nonrouting[TILE_IO]; const BelInfoPOD &beli = ci.bel_data[bel.index]; int x = beli.x, y = beli.y, z = beli.z; @@ -284,7 +285,7 @@ void write_asc(const Context *ctx, std::ostream &out) set_config(ti, config.at(iey).at(iex), "IoCtrl.REN_" + std::to_string(iez), false); } } - } else if (ctx->checkBelAvail(bel) && ctx->getBelType(bel) == TYPE_ICESTORM_RAM) { + } else if (proxy.checkBelAvail(bel) && ctx->getBelType(bel) == TYPE_ICESTORM_RAM) { const BelInfoPOD &beli = ci.bel_data[bel.index]; int x = beli.x, y = beli.y; const TileInfoPOD &ti = bi.tiles_nonrouting[TILE_RAMB]; @@ -431,7 +432,7 @@ void write_asc(const Context *ctx, std::ostream &out) // Write symbols // const bool write_symbols = 1; for (auto wire : ctx->getWires()) { - IdString net = ctx->getBoundWireNet(wire); + IdString net = proxy.getBoundWireNet(wire); if (net != IdString()) out << ".sym " << wire.index << " " << net.str(ctx) << std::endl; } diff --git a/ice40/main.cc b/ice40/main.cc index d38c786c..fdfe1f25 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -304,31 +304,32 @@ int main(int argc, char *argv[]) } if (vm.count("tmfuzz")) { + auto &&proxy = ctx->rproxy(); std::vector<WireId> src_wires, dst_wires; /*for (auto w : ctx->getWires()) src_wires.push_back(w);*/ for (auto b : ctx->getBels()) { if (ctx->getBelType(b) == TYPE_ICESTORM_LC) { - src_wires.push_back(ctx->getWireBelPin(b, PIN_O)); + src_wires.push_back(proxy.getWireBelPin(b, PIN_O)); } if (ctx->getBelType(b) == TYPE_SB_IO) { - src_wires.push_back(ctx->getWireBelPin(b, PIN_D_IN_0)); + src_wires.push_back(proxy.getWireBelPin(b, PIN_D_IN_0)); } } for (auto b : ctx->getBels()) { if (ctx->getBelType(b) == TYPE_ICESTORM_LC) { - dst_wires.push_back(ctx->getWireBelPin(b, PIN_I0)); - dst_wires.push_back(ctx->getWireBelPin(b, PIN_I1)); - dst_wires.push_back(ctx->getWireBelPin(b, PIN_I2)); - dst_wires.push_back(ctx->getWireBelPin(b, PIN_I3)); - dst_wires.push_back(ctx->getWireBelPin(b, PIN_CEN)); - dst_wires.push_back(ctx->getWireBelPin(b, PIN_CIN)); + dst_wires.push_back(proxy.getWireBelPin(b, PIN_I0)); + dst_wires.push_back(proxy.getWireBelPin(b, PIN_I1)); + dst_wires.push_back(proxy.getWireBelPin(b, PIN_I2)); + dst_wires.push_back(proxy.getWireBelPin(b, PIN_I3)); + dst_wires.push_back(proxy.getWireBelPin(b, PIN_CEN)); + dst_wires.push_back(proxy.getWireBelPin(b, PIN_CIN)); } if (ctx->getBelType(b) == TYPE_SB_IO) { - dst_wires.push_back(ctx->getWireBelPin(b, PIN_D_OUT_0)); - dst_wires.push_back(ctx->getWireBelPin(b, PIN_OUTPUT_ENABLE)); + dst_wires.push_back(proxy.getWireBelPin(b, PIN_D_OUT_0)); + dst_wires.push_back(proxy.getWireBelPin(b, PIN_OUTPUT_ENABLE)); } } |