aboutsummaryrefslogtreecommitdiffstats
path: root/nexus
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2022-02-16 18:13:22 +0000
committerGitHub <noreply@github.com>2022-02-16 18:13:22 +0000
commit61d1db16be2c68cf6ae8b4d2ff3266b5c7086ad2 (patch)
tree379b38c06745919df0e87c1be1410e16793b0925 /nexus
parent25c47e5b7e12d232cac9408b7d6d339ee11793b7 (diff)
parent76683a1e3c123d28deff750c38467c6377936879 (diff)
downloadnextpnr-61d1db16be2c68cf6ae8b4d2ff3266b5c7086ad2.tar.gz
nextpnr-61d1db16be2c68cf6ae8b4d2ff3266b5c7086ad2.tar.bz2
nextpnr-61d1db16be2c68cf6ae8b4d2ff3266b5c7086ad2.zip
Merge pull request #918 from YosysHQ/gatecat/netlist-ii
Refactor pt2, barnacle cleanup
Diffstat (limited to 'nexus')
-rw-r--r--nexus/arch.cc40
-rw-r--r--nexus/constids.inc21
-rw-r--r--nexus/main.cc6
-rw-r--r--nexus/pack.cc40
-rw-r--r--nexus/post_place.cc2
5 files changed, 65 insertions, 44 deletions
diff --git a/nexus/arch.cc b/nexus/arch.cc
index d553200f..cb8cacf8 100644
--- a/nexus/arch.cc
+++ b/nexus/arch.cc
@@ -186,8 +186,8 @@ Arch::Arch(ArchArgs args) : args(args)
disabled_pips.insert(pip);
}
// TODO: find a better solution to disable these
- WireId dcs_out = getWireByName(
- IdStringList(std::array<IdString, 3>{x_ids.at(37), y_ids.at(10), id("JDCSOUT_DCS_DCSIP")}));
+ WireId dcs_out =
+ getWireByName(IdStringList(std::array<IdString, 3>{x_ids.at(37), y_ids.at(10), id_JDCSOUT_DCS_DCSIP}));
for (auto dcs_pip : getPipsUphill(dcs_out))
disabled_pips.insert(dcs_pip);
NPNR_ASSERT(disabled_pips.size() == 6);
@@ -300,13 +300,13 @@ std::vector<std::pair<IdString, std::string>> Arch::getBelAttrs(BelId bel) const
{
std::vector<std::pair<IdString, std::string>> ret;
- ret.emplace_back(id("INDEX"), stringf("%d", bel.index));
+ ret.emplace_back(id_INDEX, stringf("%d", bel.index));
- ret.emplace_back(id("GRID_X"), stringf("%d", bel.tile % chip_info->width));
- ret.emplace_back(id("GRID_Y"), stringf("%d", bel.tile / chip_info->width));
- ret.emplace_back(id("BEL_Z"), stringf("%d", bel_data(bel).z));
+ ret.emplace_back(id_GRID_X, stringf("%d", bel.tile % chip_info->width));
+ ret.emplace_back(id_GRID_Y, stringf("%d", bel.tile / chip_info->width));
+ ret.emplace_back(id_BEL_Z, stringf("%d", bel_data(bel).z));
- ret.emplace_back(id("BEL_TYPE"), nameOf(getBelType(bel)));
+ ret.emplace_back(id_BEL_TYPE, nameOf(getBelType(bel)));
return ret;
}
@@ -337,11 +337,11 @@ std::vector<std::pair<IdString, std::string>> Arch::getWireAttrs(WireId wire) co
{
std::vector<std::pair<IdString, std::string>> ret;
- ret.emplace_back(id("INDEX"), stringf("%d", wire.index));
+ ret.emplace_back(id_INDEX, stringf("%d", wire.index));
- ret.emplace_back(id("GRID_X"), stringf("%d", wire.tile % chip_info->width));
- ret.emplace_back(id("GRID_Y"), stringf("%d", wire.tile / chip_info->width));
- ret.emplace_back(id("FLAGS"), stringf("%u", wire_data(wire).flags));
+ ret.emplace_back(id_GRID_X, stringf("%d", wire.tile % chip_info->width));
+ ret.emplace_back(id_GRID_Y, stringf("%d", wire.tile / chip_info->width));
+ ret.emplace_back(id_FLAGS, stringf("%u", wire_data(wire).flags));
return ret;
}
@@ -388,13 +388,13 @@ std::vector<std::pair<IdString, std::string>> Arch::getPipAttrs(PipId pip) const
{
std::vector<std::pair<IdString, std::string>> ret;
- ret.emplace_back(id("INDEX"), stringf("%d", pip.index));
+ ret.emplace_back(id_INDEX, stringf("%d", pip.index));
- ret.emplace_back(id("GRID_X"), stringf("%d", pip.tile % chip_info->width));
- ret.emplace_back(id("GRID_Y"), stringf("%d", pip.tile / chip_info->width));
+ ret.emplace_back(id_GRID_X, stringf("%d", pip.tile % chip_info->width));
+ ret.emplace_back(id_GRID_Y, stringf("%d", pip.tile / chip_info->width));
- ret.emplace_back(id("FROM_TILE_WIRE"), nameOf(IdString(loc_data(pip).wires[pip_data(pip).from_wire].name)));
- ret.emplace_back(id("TO_TILE_WIRE"), nameOf(IdString(loc_data(pip).wires[pip_data(pip).to_wire].name)));
+ ret.emplace_back(id_FROM_TILE_WIRE, nameOf(IdString(loc_data(pip).wires[pip_data(pip).from_wire].name)));
+ ret.emplace_back(id_TO_TILE_WIRE, nameOf(IdString(loc_data(pip).wires[pip_data(pip).to_wire].name)));
return ret;
}
@@ -665,7 +665,7 @@ bool Arch::place()
if (getCtx()->settings.count(getCtx()->id("estimate-delay-mult")))
estimate_delay_mult = getCtx()->setting<int>("estimate-delay-mult");
- std::string placer = str_or_default(settings, id("placer"), defaultPlacer);
+ std::string placer = str_or_default(settings, id_placer, defaultPlacer);
if (placer == "heap") {
PlacerHeapCfg cfg(getCtx());
@@ -689,7 +689,7 @@ bool Arch::place()
post_place_opt();
- getCtx()->attrs[getCtx()->id("step")] = std::string("place");
+ getCtx()->attrs[id_step] = std::string("place");
archInfoToAttributes();
return true;
}
@@ -740,7 +740,7 @@ bool Arch::route()
route_globals();
- std::string router = str_or_default(settings, id("router"), defaultRouter);
+ std::string router = str_or_default(settings, id_router, defaultRouter);
bool result;
if (router == "router1") {
result = router1(getCtx(), Router1Cfg(getCtx()));
@@ -752,7 +752,7 @@ bool Arch::route()
} else {
log_error("Nexus architecture does not support router '%s'\n", router.c_str());
}
- getCtx()->attrs[getCtx()->id("step")] = std::string("route");
+ getCtx()->attrs[id_step] = std::string("route");
archInfoToAttributes();
return result;
}
diff --git a/nexus/constids.inc b/nexus/constids.inc
index ca6bed5a..11726d3b 100644
--- a/nexus/constids.inc
+++ b/nexus/constids.inc
@@ -531,3 +531,24 @@ X(Q1)
X(SCLK)
X(LOCAL_VCC)
+
+X(BEL_TYPE)
+X(BEL_Z)
+X(CEOUTMUX)
+X(CLAMP)
+X(FLAGS)
+X(FROM_TILE_WIRE)
+X(GLITCHFILTER)
+X(GRID_X)
+X(GRID_Y)
+X(INDEX)
+X(JDCSOUT_DCS_DCSIP)
+X(PULLMODE)
+X(TO_TILE_WIRE)
+X(carry_lutff_ratio)
+X(no_pack_lutff)
+X(no_post_place_opt)
+X(placer)
+X(router)
+X(step)
+X(syn_useioff)
diff --git a/nexus/main.cc b/nexus/main.cc
index 88dddfe5..bca6661f 100644
--- a/nexus/main.cc
+++ b/nexus/main.cc
@@ -79,15 +79,15 @@ std::unique_ptr<Context> NexusCommandHandler::createContext(dict<std::string, Pr
chipArgs.device = vm["device"].as<std::string>();
auto ctx = std::unique_ptr<Context>(new Context(chipArgs));
if (vm.count("no-post-place-opt"))
- ctx->settings[ctx->id("no_post_place_opt")] = Property::State::S1;
+ ctx->settings[id_no_post_place_opt] = Property::State::S1;
if (vm.count("no-pack-lutff"))
- ctx->settings[ctx->id("no_pack_lutff")] = Property::State::S1;
+ ctx->settings[id_no_pack_lutff] = Property::State::S1;
if (vm.count("carry-lutff-ratio")) {
float ratio = vm["carry-lutff-ratio"].as<float>();
if (ratio < 0.0f || ratio > 1.0f) {
log_error("Carry LUT+FF packing ration must be between 0.0 and 1.0");
}
- ctx->settings[ctx->id("carry_lutff_ratio")] = ratio;
+ ctx->settings[id_carry_lutff_ratio] = ratio;
}
if (vm.count("estimate-delay-mult"))
ctx->settings[ctx->id("estimate-delay-mult")] = vm["estimate-delay-mult"].as<int>();
diff --git a/nexus/pack.cc b/nexus/pack.cc
index 81a729b1..13522c78 100644
--- a/nexus/pack.cc
+++ b/nexus/pack.cc
@@ -1132,7 +1132,7 @@ struct NexusPacker
CellInfo *ci = cell.second.get();
if (ci->type != id_LRAM_CORE)
continue;
- if (str_or_default(ci->params, ctx->id("ECC_BYTE_SEL"), "BYTE_EN") == "BYTE_EN")
+ if (str_or_default(ci->params, id_ECC_BYTE_SEL, "BYTE_EN") == "BYTE_EN")
continue;
for (int i = 0; i < 0x80; i++) {
// FIXME: document ECC and remove this DRC
@@ -1986,7 +1986,7 @@ struct NexusPacker
if (ci->type == id_DCC) {
copy_constraint(ci, id_CLKI, id_CLKO, 1);
} else if (ci->type == id_OSC_CORE) {
- int div = int_or_default(ci->params, ctx->id("HF_CLK_DIV"), 128);
+ int div = int_or_default(ci->params, id_HF_CLK_DIV, 128);
const float tol = 1.07f; // OSCA has +/-7% frequency tolerance, assume the worst case.
set_period(ci, id_HFCLKOUT, delay_t((1.0e6 / 450) * (div + 1) / tol));
set_period(ci, id_LFCLKOUT, delay_t((1.0e3 / 10) / tol));
@@ -2177,26 +2177,26 @@ struct NexusPacker
// We have IDDR+ODDR
if (isODDR && isIDDR) {
- if (!iob->attrs.count(ctx->id("GLITCHFILTER"))) {
- iob->attrs[ctx->id("GLITCHFILTER")] = std::string("ON");
+ if (!iob->attrs.count(id_GLITCHFILTER)) {
+ iob->attrs[id_GLITCHFILTER] = std::string("ON");
}
- if (!iob->attrs.count(ctx->id("CLAMP"))) {
- iob->attrs[ctx->id("CLAMP")] = std::string("ON");
+ if (!iob->attrs.count(id_CLAMP)) {
+ iob->attrs[id_CLAMP] = std::string("ON");
}
- if (!iob->attrs.count(ctx->id("PULLMODE"))) {
- iob->attrs[ctx->id("PULLMODE")] = std::string("DOWN");
+ if (!iob->attrs.count(id_PULLMODE)) {
+ iob->attrs[id_PULLMODE] = std::string("DOWN");
}
}
// We have ODDR only
else if (isODDR && !isIDDR) {
- if (!iob->attrs.count(ctx->id("GLITCHFILTER"))) {
- iob->attrs[ctx->id("GLITCHFILTER")] = std::string("OFF");
+ if (!iob->attrs.count(id_GLITCHFILTER)) {
+ iob->attrs[id_GLITCHFILTER] = std::string("OFF");
}
- if (!iob->attrs.count(ctx->id("CLAMP"))) {
- iob->attrs[ctx->id("CLAMP")] = std::string("OFF");
+ if (!iob->attrs.count(id_CLAMP)) {
+ iob->attrs[id_CLAMP] = std::string("OFF");
}
- if (!iob->attrs.count(ctx->id("PULLMODE"))) {
- iob->attrs[ctx->id("PULLMODE")] = std::string("NONE");
+ if (!iob->attrs.count(id_PULLMODE)) {
+ iob->attrs[id_PULLMODE] = std::string("NONE");
}
}
@@ -2237,8 +2237,8 @@ struct NexusPacker
// Check if the net wants to use the T flip-flop in
// IOLOGIC
bool syn_useioff = false;
- if (iob_t->attrs.count(ctx->id("syn_useioff"))) {
- syn_useioff = iob_t->attrs.at(ctx->id("syn_useioff")).as_bool();
+ if (iob_t->attrs.count(id_syn_useioff)) {
+ syn_useioff = iob_t->attrs.at(id_syn_useioff).as_bool();
}
// Check if the T input is driven by a flip-flop. Store
@@ -2281,7 +2281,7 @@ struct NexusPacker
iol->params[id_REGSET] = ff->params.at(id_REGSET);
// Enable the TSREG
- iol->params[ctx->id("CEOUTMUX")] = std::string("1");
+ iol->params[id_CEOUTMUX] = std::string("1");
iol->params[ctx->id("TSREG.REGSET")] = std::string("SET");
iol->params[ctx->id("IDDRX1_ODDRX1.TRISTATE")] = std::string("ENABLED");
}
@@ -2328,7 +2328,7 @@ struct NexusPacker
log_info("Inferring LUT+FF pairs...\n");
float carry_ratio = 1.0f;
- if (ctx->settings.find(ctx->id("carry_lutff_ratio")) != ctx->settings.end()) {
+ if (ctx->settings.find(id_carry_lutff_ratio) != ctx->settings.end()) {
carry_ratio = ctx->setting<float>("carry_lutff_ratio");
}
@@ -2487,7 +2487,7 @@ struct NexusPacker
pack_ip();
handle_iologic();
- if (!bool_or_default(ctx->settings, ctx->id("no_pack_lutff"))) {
+ if (!bool_or_default(ctx->settings, id_no_pack_lutff)) {
pack_lutffs();
}
@@ -2500,7 +2500,7 @@ struct NexusPacker
bool Arch::pack()
{
(NexusPacker(getCtx()))();
- attrs[id("step")] = std::string("pack");
+ attrs[id_step] = std::string("pack");
archInfoToAttributes();
assignArchInfo();
return true;
diff --git a/nexus/post_place.cc b/nexus/post_place.cc
index eece4008..f42c0f18 100644
--- a/nexus/post_place.cc
+++ b/nexus/post_place.cc
@@ -148,7 +148,7 @@ struct NexusPostPlaceOpt
void Arch::post_place_opt()
{
- if (bool_or_default(settings, id("no_post_place_opt")))
+ if (bool_or_default(settings, id_no_post_place_opt))
return;
log_info("Running post-place optimisations...\n");
NexusPostPlaceOpt opt(getCtx());