From 22330402018a212efd4ef2e337e34af2e79eb875 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Sat, 14 Jul 2018 18:50:15 +0100 Subject: Revert "Remove legacy access to state via Arch" This reverts commit 18b4b316782035daa259d65d26ea733ca4d16bea. --- ice40/arch.cc | 41 +++++++++++++++++++++++++++++++ ice40/arch.h | 28 +++++++++++++++++++++ ice40/arch_pybindings.cc | 64 ++++++++++++++++++++++++------------------------ ice40/arch_pybindings.h | 18 +++----------- ice40/bitstream.cc | 13 +++++----- ice40/main.cc | 21 ++++++++-------- 6 files changed, 120 insertions(+), 65 deletions(-) diff --git a/ice40/arch.cc b/ice40/arch.cc index 4727597b..8f2731c6 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -256,6 +256,47 @@ BelRange Arch::getBelsAtSameTile(BelId bel) const return br; } +// ----------------------------------------------------------------------- +// 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 25ed8ebf..ec1e456f 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -373,6 +373,34 @@ 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 aeb4348a..fd5109b4 100644 --- a/ice40/arch_pybindings.cc +++ b/ice40/arch_pybindings.cc @@ -65,25 +65,25 @@ void arch_wrap_python() fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getBelType"); - //fn_wrapper_1a, - // conv_from_str>::def_wrap(ctx_cls, "checkBelAvail"); + fn_wrapper_1a, + conv_from_str>::def_wrap(ctx_cls, "checkBelAvail"); fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getBelChecksum"); - //fn_wrapper_3a_v, - // conv_from_str, pass_through>::def_wrap(ctx_cls, "bindBel"); - //fn_wrapper_1a_v>::def_wrap( - // ctx_cls, "unbindBel"); - //fn_wrapper_1a, - // conv_from_str>::def_wrap(ctx_cls, "getBoundBelCell"); - //fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getConflictingBelCell"); + fn_wrapper_3a_v, + conv_from_str, pass_through>::def_wrap(ctx_cls, "bindBel"); + fn_wrapper_1a_v>::def_wrap( + ctx_cls, "unbindBel"); + fn_wrapper_1a, + conv_from_str>::def_wrap(ctx_cls, "getBoundBelCell"); + fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getConflictingBelCell"); fn_wrapper_0a>::def_wrap(ctx_cls, "getBels"); fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getBelsAtSameTile"); - //fn_wrapper_2a, - // conv_from_str, conv_from_str>::def_wrap(ctx_cls, "getWireBelPin"); + fn_wrapper_2a, + conv_from_str, conv_from_str>::def_wrap(ctx_cls, "getWireBelPin"); fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getBelPinUphill"); fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getWireChecksum"); - //fn_wrapper_3a_v, - // conv_from_str, pass_through>::def_wrap(ctx_cls, "bindWire"); - //fn_wrapper_1a_v>::def_wrap( - // ctx_cls, "unbindWire"); - //fn_wrapper_1a, - // conv_from_str>::def_wrap(ctx_cls, "checkWireAvail"); - //fn_wrapper_1a, - // conv_from_str>::def_wrap(ctx_cls, "getBoundWireNet"); - //fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getConflictingWireNet"); + fn_wrapper_3a_v, + conv_from_str, pass_through>::def_wrap(ctx_cls, "bindWire"); + fn_wrapper_1a_v>::def_wrap( + ctx_cls, "unbindWire"); + fn_wrapper_1a, + conv_from_str>::def_wrap(ctx_cls, "checkWireAvail"); + fn_wrapper_1a, + conv_from_str>::def_wrap(ctx_cls, "getBoundWireNet"); + fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getConflictingWireNet"); fn_wrapper_0a>::def_wrap( ctx_cls, "getWires"); @@ -109,16 +109,16 @@ void arch_wrap_python() ctx_cls, "getPips"); fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getPipChecksum"); - //fn_wrapper_3a_v, - // conv_from_str, pass_through>::def_wrap(ctx_cls, "bindPip"); - //fn_wrapper_1a_v>::def_wrap( - // ctx_cls, "unbindPip"); - //fn_wrapper_1a, - // conv_from_str>::def_wrap(ctx_cls, "checkPipAvail"); - //fn_wrapper_1a, - // conv_from_str>::def_wrap(ctx_cls, "getBoundPipNet"); - //fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getConflictingPipNet"); + fn_wrapper_3a_v, + conv_from_str, pass_through>::def_wrap(ctx_cls, "bindPip"); + fn_wrapper_1a_v>::def_wrap( + ctx_cls, "unbindPip"); + fn_wrapper_1a, + conv_from_str>::def_wrap(ctx_cls, "checkPipAvail"); + fn_wrapper_1a, + conv_from_str>::def_wrap(ctx_cls, "getBoundPipNet"); + fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getConflictingPipNet"); fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getPipsDownhill"); diff --git a/ice40/arch_pybindings.h b/ice40/arch_pybindings.h index 7440e29d..e502905f 100644 --- a/ice40/arch_pybindings.h +++ b/ice40/arch_pybindings.h @@ -31,11 +31,7 @@ namespace PythonConversion { template <> struct string_converter { - BelId from_str(Context *ctx, std::string name) - { - auto &&proxy = ctx->rproxy(); - return proxy.getBelByName(ctx->id(name)); - } + BelId from_str(Context *ctx, std::string name) { return ctx->getBelByName(ctx->id(name)); } std::string to_str(Context *ctx, BelId id) { @@ -54,22 +50,14 @@ template <> struct string_converter template <> struct string_converter { - WireId from_str(Context *ctx, std::string name) - { - auto &&proxy = ctx->rproxy(); - return proxy.getWireByName(ctx->id(name)); - } + WireId from_str(Context *ctx, std::string name) { return ctx->getWireByName(ctx->id(name)); } std::string to_str(Context *ctx, WireId id) { return ctx->getWireName(id).str(ctx); } }; template <> struct string_converter { - PipId from_str(Context *ctx, std::string name) - { - auto &&proxy = ctx->rproxy(); - return proxy.getPipByName(ctx->id(name)); - } + PipId from_str(Context *ctx, std::string name) { return ctx->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 87a96a22..58a59366 100644 --- a/ice40/bitstream.cc +++ b/ice40/bitstream.cc @@ -92,7 +92,6 @@ 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; @@ -129,7 +128,7 @@ void write_asc(const Context *ctx, std::ostream &out) } // Set pips for (auto pip : ctx->getPips()) { - if (proxy.getBoundPipNet(pip) != IdString()) { + if (ctx->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++) { @@ -200,8 +199,8 @@ void write_asc(const Context *ctx, std::ostream &out) NPNR_ASSERT(iez != -1); bool input_en = false; - if (!proxy.checkWireAvail(proxy.getWireBelPin(bel, PIN_D_IN_0)) || - !proxy.checkWireAvail(proxy.getWireBelPin(bel, PIN_D_IN_1))) { + if (!ctx->checkWireAvail(ctx->getWireBelPin(bel, PIN_D_IN_0)) || + !ctx->checkWireAvail(ctx->getWireBelPin(bel, PIN_D_IN_1))) { input_en = true; } @@ -272,7 +271,7 @@ void write_asc(const Context *ctx, std::ostream &out) } // Set config bits in unused IO and RAM for (auto bel : ctx->getBels()) { - if (proxy.checkBelAvail(bel) && ctx->getBelType(bel) == TYPE_SB_IO) { + if (ctx->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; @@ -285,7 +284,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 (proxy.checkBelAvail(bel) && ctx->getBelType(bel) == TYPE_ICESTORM_RAM) { + } else if (ctx->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]; @@ -432,7 +431,7 @@ void write_asc(const Context *ctx, std::ostream &out) // Write symbols // const bool write_symbols = 1; for (auto wire : ctx->getWires()) { - IdString net = proxy.getBoundWireNet(wire); + IdString net = ctx->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 fdfe1f25..d38c786c 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -304,32 +304,31 @@ int main(int argc, char *argv[]) } if (vm.count("tmfuzz")) { - auto &&proxy = ctx->rproxy(); std::vector 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(proxy.getWireBelPin(b, PIN_O)); + src_wires.push_back(ctx->getWireBelPin(b, PIN_O)); } if (ctx->getBelType(b) == TYPE_SB_IO) { - src_wires.push_back(proxy.getWireBelPin(b, PIN_D_IN_0)); + src_wires.push_back(ctx->getWireBelPin(b, PIN_D_IN_0)); } } for (auto b : ctx->getBels()) { if (ctx->getBelType(b) == TYPE_ICESTORM_LC) { - 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)); + 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)); } if (ctx->getBelType(b) == TYPE_SB_IO) { - dst_wires.push_back(proxy.getWireBelPin(b, PIN_D_OUT_0)); - dst_wires.push_back(proxy.getWireBelPin(b, PIN_OUTPUT_ENABLE)); + dst_wires.push_back(ctx->getWireBelPin(b, PIN_D_OUT_0)); + dst_wires.push_back(ctx->getWireBelPin(b, PIN_OUTPUT_ENABLE)); } } -- cgit v1.2.3