aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
diff options
context:
space:
mode:
authorSergiusz Bazanski <q3k@q3k.org>2018-07-14 18:50:15 +0100
committerSergiusz Bazanski <q3k@q3k.org>2018-07-14 18:50:15 +0100
commit22330402018a212efd4ef2e337e34af2e79eb875 (patch)
treec9602093138de0424dfe9ffbe37e645ee4a56c48 /ice40
parent339198b394b7f2cdd3bafb2c8c819c1561813f65 (diff)
downloadnextpnr-22330402018a212efd4ef2e337e34af2e79eb875.tar.gz
nextpnr-22330402018a212efd4ef2e337e34af2e79eb875.tar.bz2
nextpnr-22330402018a212efd4ef2e337e34af2e79eb875.zip
Revert "Remove legacy access to state via Arch"
This reverts commit 18b4b316782035daa259d65d26ea733ca4d16bea.
Diffstat (limited to 'ice40')
-rw-r--r--ice40/arch.cc41
-rw-r--r--ice40/arch.h28
-rw-r--r--ice40/arch_pybindings.cc64
-rw-r--r--ice40/arch_pybindings.h18
-rw-r--r--ice40/bitstream.cc13
-rw-r--r--ice40/main.cc21
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
@@ -257,6 +257,47 @@ 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 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<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 7440e29d..e502905f 100644
--- a/ice40/arch_pybindings.h
+++ b/ice40/arch_pybindings.h
@@ -31,11 +31,7 @@ namespace PythonConversion {
template <> struct string_converter<BelId>
{
- 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<BelType>
template <> struct string_converter<WireId>
{
- 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>
{
- 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<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(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));
}
}