Revert "Remove legacy access to state via Arch"

This reverts commit 18b4b31678.
This commit is contained in:
Sergiusz Bazanski 2018-07-14 18:50:15 +01:00
parent 339198b394
commit 2233040201
6 changed files with 120 additions and 65 deletions

View File

@ -256,6 +256,47 @@ BelRange Arch::getBelsAtSameTile(BelId bel) const
return br; 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 IdString Arch::getPipName(PipId pip) const

View File

@ -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 /// Methods to get chip info - don't need to use a wrapper, as these are
/// static per lifetime of object. /// static per lifetime of object.

View File

@ -65,25 +65,25 @@ void arch_wrap_python()
fn_wrapper_1a<Context, decltype(&Context::getBelType), &Context::getBelType, conv_to_str<BelType>, fn_wrapper_1a<Context, decltype(&Context::getBelType), &Context::getBelType, conv_to_str<BelType>,
conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelType"); conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelType");
//fn_wrapper_1a<Context, decltype(&Context::checkBelAvail), &Context::checkBelAvail, pass_through<bool>, fn_wrapper_1a<Context, decltype(&Context::checkBelAvail), &Context::checkBelAvail, pass_through<bool>,
// conv_from_str<BelId>>::def_wrap(ctx_cls, "checkBelAvail"); conv_from_str<BelId>>::def_wrap(ctx_cls, "checkBelAvail");
fn_wrapper_1a<Context, decltype(&Context::getBelChecksum), &Context::getBelChecksum, pass_through<uint32_t>, fn_wrapper_1a<Context, decltype(&Context::getBelChecksum), &Context::getBelChecksum, pass_through<uint32_t>,
conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelChecksum"); conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelChecksum");
//fn_wrapper_3a_v<Context, decltype(&Context::bindBel), &Context::bindBel, conv_from_str<BelId>, 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"); 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( fn_wrapper_1a_v<Context, decltype(&Context::unbindBel), &Context::unbindBel, conv_from_str<BelId>>::def_wrap(
// ctx_cls, "unbindBel"); ctx_cls, "unbindBel");
//fn_wrapper_1a<Context, decltype(&Context::getBoundBelCell), &Context::getBoundBelCell, conv_to_str<IdString>, fn_wrapper_1a<Context, decltype(&Context::getBoundBelCell), &Context::getBoundBelCell, conv_to_str<IdString>,
// conv_from_str<BelId>>::def_wrap(ctx_cls, "getBoundBelCell"); conv_from_str<BelId>>::def_wrap(ctx_cls, "getBoundBelCell");
//fn_wrapper_1a<Context, decltype(&Context::getConflictingBelCell), &Context::getConflictingBelCell, fn_wrapper_1a<Context, decltype(&Context::getConflictingBelCell), &Context::getConflictingBelCell,
// conv_to_str<IdString>, conv_from_str<BelId>>::def_wrap(ctx_cls, "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, fn_wrapper_0a<Context, decltype(&Context::getBels), &Context::getBels, wrap_context<BelRange>>::def_wrap(ctx_cls,
"getBels"); "getBels");
fn_wrapper_1a<Context, decltype(&Context::getBelsAtSameTile), &Context::getBelsAtSameTile, wrap_context<BelRange>, fn_wrapper_1a<Context, decltype(&Context::getBelsAtSameTile), &Context::getBelsAtSameTile, wrap_context<BelRange>,
conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelsAtSameTile"); conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelsAtSameTile");
//fn_wrapper_2a<Context, decltype(&Context::getWireBelPin), &Context::getWireBelPin, conv_to_str<WireId>, 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"); 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>, fn_wrapper_1a<Context, decltype(&Context::getBelPinUphill), &Context::getBelPinUphill, wrap_context<BelPin>,
conv_from_str<WireId>>::def_wrap(ctx_cls, "getBelPinUphill"); conv_from_str<WireId>>::def_wrap(ctx_cls, "getBelPinUphill");
fn_wrapper_1a<Context, decltype(&Context::getBelPinsDownhill), &Context::getBelPinsDownhill, 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>, fn_wrapper_1a<Context, decltype(&Context::getWireChecksum), &Context::getWireChecksum, pass_through<uint32_t>,
conv_from_str<WireId>>::def_wrap(ctx_cls, "getWireChecksum"); conv_from_str<WireId>>::def_wrap(ctx_cls, "getWireChecksum");
//fn_wrapper_3a_v<Context, decltype(&Context::bindWire), &Context::bindWire, conv_from_str<WireId>, 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"); 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( fn_wrapper_1a_v<Context, decltype(&Context::unbindWire), &Context::unbindWire, conv_from_str<WireId>>::def_wrap(
// ctx_cls, "unbindWire"); ctx_cls, "unbindWire");
//fn_wrapper_1a<Context, decltype(&Context::checkWireAvail), &Context::checkWireAvail, pass_through<bool>, fn_wrapper_1a<Context, decltype(&Context::checkWireAvail), &Context::checkWireAvail, pass_through<bool>,
// conv_from_str<WireId>>::def_wrap(ctx_cls, "checkWireAvail"); conv_from_str<WireId>>::def_wrap(ctx_cls, "checkWireAvail");
//fn_wrapper_1a<Context, decltype(&Context::getBoundWireNet), &Context::getBoundWireNet, conv_to_str<IdString>, fn_wrapper_1a<Context, decltype(&Context::getBoundWireNet), &Context::getBoundWireNet, conv_to_str<IdString>,
// conv_from_str<WireId>>::def_wrap(ctx_cls, "getBoundWireNet"); conv_from_str<WireId>>::def_wrap(ctx_cls, "getBoundWireNet");
//fn_wrapper_1a<Context, decltype(&Context::getConflictingWireNet), &Context::getConflictingWireNet, fn_wrapper_1a<Context, decltype(&Context::getConflictingWireNet), &Context::getConflictingWireNet,
// conv_to_str<IdString>, conv_from_str<WireId>>::def_wrap(ctx_cls, "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( fn_wrapper_0a<Context, decltype(&Context::getWires), &Context::getWires, wrap_context<WireRange>>::def_wrap(
ctx_cls, "getWires"); ctx_cls, "getWires");
@ -109,16 +109,16 @@ void arch_wrap_python()
ctx_cls, "getPips"); ctx_cls, "getPips");
fn_wrapper_1a<Context, decltype(&Context::getPipChecksum), &Context::getPipChecksum, pass_through<uint32_t>, fn_wrapper_1a<Context, decltype(&Context::getPipChecksum), &Context::getPipChecksum, pass_through<uint32_t>,
conv_from_str<PipId>>::def_wrap(ctx_cls, "getPipChecksum"); conv_from_str<PipId>>::def_wrap(ctx_cls, "getPipChecksum");
//fn_wrapper_3a_v<Context, decltype(&Context::bindPip), &Context::bindPip, conv_from_str<PipId>, 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"); 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( fn_wrapper_1a_v<Context, decltype(&Context::unbindPip), &Context::unbindPip, conv_from_str<PipId>>::def_wrap(
// ctx_cls, "unbindPip"); ctx_cls, "unbindPip");
//fn_wrapper_1a<Context, decltype(&Context::checkPipAvail), &Context::checkPipAvail, pass_through<bool>, fn_wrapper_1a<Context, decltype(&Context::checkPipAvail), &Context::checkPipAvail, pass_through<bool>,
// conv_from_str<PipId>>::def_wrap(ctx_cls, "checkPipAvail"); conv_from_str<PipId>>::def_wrap(ctx_cls, "checkPipAvail");
//fn_wrapper_1a<Context, decltype(&Context::getBoundPipNet), &Context::getBoundPipNet, conv_to_str<IdString>, fn_wrapper_1a<Context, decltype(&Context::getBoundPipNet), &Context::getBoundPipNet, conv_to_str<IdString>,
// conv_from_str<PipId>>::def_wrap(ctx_cls, "getBoundPipNet"); conv_from_str<PipId>>::def_wrap(ctx_cls, "getBoundPipNet");
//fn_wrapper_1a<Context, decltype(&Context::getConflictingPipNet), &Context::getConflictingPipNet, fn_wrapper_1a<Context, decltype(&Context::getConflictingPipNet), &Context::getConflictingPipNet,
// conv_to_str<IdString>, conv_from_str<PipId>>::def_wrap(ctx_cls, "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>, fn_wrapper_1a<Context, decltype(&Context::getPipsDownhill), &Context::getPipsDownhill, wrap_context<PipRange>,
conv_from_str<WireId>>::def_wrap(ctx_cls, "getPipsDownhill"); conv_from_str<WireId>>::def_wrap(ctx_cls, "getPipsDownhill");

View File

@ -31,11 +31,7 @@ namespace PythonConversion {
template <> struct string_converter<BelId> template <> struct string_converter<BelId>
{ {
BelId from_str(Context *ctx, std::string name) BelId from_str(Context *ctx, std::string name) { return ctx->getBelByName(ctx->id(name)); }
{
auto &&proxy = ctx->rproxy();
return proxy.getBelByName(ctx->id(name));
}
std::string to_str(Context *ctx, BelId id) std::string to_str(Context *ctx, BelId id)
{ {
@ -54,22 +50,14 @@ template <> struct string_converter<BelType>
template <> struct string_converter<WireId> template <> struct string_converter<WireId>
{ {
WireId from_str(Context *ctx, std::string name) WireId from_str(Context *ctx, std::string name) { return ctx->getWireByName(ctx->id(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); } std::string to_str(Context *ctx, WireId id) { return ctx->getWireName(id).str(ctx); }
}; };
template <> struct string_converter<PipId> template <> struct string_converter<PipId>
{ {
PipId from_str(Context *ctx, std::string name) PipId from_str(Context *ctx, std::string name) { return ctx->getPipByName(ctx->id(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); } std::string to_str(Context *ctx, PipId id) { return ctx->getPipName(id).str(ctx); }
}; };

View File

@ -92,7 +92,6 @@ char get_hexdigit(int i) { return std::string("0123456789ABCDEF").at(i); }
void write_asc(const Context *ctx, std::ostream &out) void write_asc(const Context *ctx, std::ostream &out)
{ {
auto &&proxy = ctx->rproxy();
// [y][x][row][col] // [y][x][row][col]
const ChipInfoPOD &ci = *ctx->chip_info; const ChipInfoPOD &ci = *ctx->chip_info;
const BitstreamInfoPOD &bi = *ci.bits_info; const BitstreamInfoPOD &bi = *ci.bits_info;
@ -129,7 +128,7 @@ void write_asc(const Context *ctx, std::ostream &out)
} }
// Set pips // Set pips
for (auto pip : ctx->getPips()) { for (auto pip : ctx->getPips()) {
if (proxy.getBoundPipNet(pip) != IdString()) { if (ctx->getBoundPipNet(pip) != IdString()) {
const PipInfoPOD &pi = ci.pip_data[pip.index]; const PipInfoPOD &pi = ci.pip_data[pip.index];
const SwitchInfoPOD &swi = bi.switches[pi.switch_index]; const SwitchInfoPOD &swi = bi.switches[pi.switch_index];
for (int i = 0; i < swi.num_bits; i++) { 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); NPNR_ASSERT(iez != -1);
bool input_en = false; bool input_en = false;
if (!proxy.checkWireAvail(proxy.getWireBelPin(bel, PIN_D_IN_0)) || if (!ctx->checkWireAvail(ctx->getWireBelPin(bel, PIN_D_IN_0)) ||
!proxy.checkWireAvail(proxy.getWireBelPin(bel, PIN_D_IN_1))) { !ctx->checkWireAvail(ctx->getWireBelPin(bel, PIN_D_IN_1))) {
input_en = true; input_en = true;
} }
@ -272,7 +271,7 @@ void write_asc(const Context *ctx, std::ostream &out)
} }
// Set config bits in unused IO and RAM // Set config bits in unused IO and RAM
for (auto bel : ctx->getBels()) { 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 TileInfoPOD &ti = bi.tiles_nonrouting[TILE_IO];
const BelInfoPOD &beli = ci.bel_data[bel.index]; const BelInfoPOD &beli = ci.bel_data[bel.index];
int x = beli.x, y = beli.y, z = beli.z; 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); 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]; const BelInfoPOD &beli = ci.bel_data[bel.index];
int x = beli.x, y = beli.y; int x = beli.x, y = beli.y;
const TileInfoPOD &ti = bi.tiles_nonrouting[TILE_RAMB]; const TileInfoPOD &ti = bi.tiles_nonrouting[TILE_RAMB];
@ -432,7 +431,7 @@ void write_asc(const Context *ctx, std::ostream &out)
// Write symbols // Write symbols
// const bool write_symbols = 1; // const bool write_symbols = 1;
for (auto wire : ctx->getWires()) { for (auto wire : ctx->getWires()) {
IdString net = proxy.getBoundWireNet(wire); IdString net = ctx->getBoundWireNet(wire);
if (net != IdString()) if (net != IdString())
out << ".sym " << wire.index << " " << net.str(ctx) << std::endl; out << ".sym " << wire.index << " " << net.str(ctx) << std::endl;
} }

View File

@ -304,32 +304,31 @@ int main(int argc, char *argv[])
} }
if (vm.count("tmfuzz")) { if (vm.count("tmfuzz")) {
auto &&proxy = ctx->rproxy();
std::vector<WireId> src_wires, dst_wires; std::vector<WireId> src_wires, dst_wires;
/*for (auto w : ctx->getWires()) /*for (auto w : ctx->getWires())
src_wires.push_back(w);*/ src_wires.push_back(w);*/
for (auto b : ctx->getBels()) { for (auto b : ctx->getBels()) {
if (ctx->getBelType(b) == TYPE_ICESTORM_LC) { 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) { 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()) { for (auto b : ctx->getBels()) {
if (ctx->getBelType(b) == TYPE_ICESTORM_LC) { if (ctx->getBelType(b) == TYPE_ICESTORM_LC) {
dst_wires.push_back(proxy.getWireBelPin(b, PIN_I0)); dst_wires.push_back(ctx->getWireBelPin(b, PIN_I0));
dst_wires.push_back(proxy.getWireBelPin(b, PIN_I1)); dst_wires.push_back(ctx->getWireBelPin(b, PIN_I1));
dst_wires.push_back(proxy.getWireBelPin(b, PIN_I2)); dst_wires.push_back(ctx->getWireBelPin(b, PIN_I2));
dst_wires.push_back(proxy.getWireBelPin(b, PIN_I3)); dst_wires.push_back(ctx->getWireBelPin(b, PIN_I3));
dst_wires.push_back(proxy.getWireBelPin(b, PIN_CEN)); dst_wires.push_back(ctx->getWireBelPin(b, PIN_CEN));
dst_wires.push_back(proxy.getWireBelPin(b, PIN_CIN)); dst_wires.push_back(ctx->getWireBelPin(b, PIN_CIN));
} }
if (ctx->getBelType(b) == TYPE_SB_IO) { if (ctx->getBelType(b) == TYPE_SB_IO) {
dst_wires.push_back(proxy.getWireBelPin(b, PIN_D_OUT_0)); dst_wires.push_back(ctx->getWireBelPin(b, PIN_D_OUT_0));
dst_wires.push_back(proxy.getWireBelPin(b, PIN_OUTPUT_ENABLE)); dst_wires.push_back(ctx->getWireBelPin(b, PIN_OUTPUT_ENABLE));
} }
} }