diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/command.cc | 51 | ||||
-rw-r--r-- | common/nextpnr.cc | 66 | ||||
-rw-r--r-- | common/nextpnr.h | 3 |
3 files changed, 70 insertions, 50 deletions
diff --git a/common/command.cc b/common/command.cc index d700f4ee..96008d2b 100644 --- a/common/command.cc +++ b/common/command.cc @@ -311,46 +311,7 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx) run_script_hook("pre-pack"); if (!ctx->pack() && !ctx->force) log_error("Packing design failed.\n"); - } else { - for (auto &pair : ctx->cells) { - auto &c = pair.second; - auto constr_main = c->attrs.find(ctx->id("NEXTPNR_CONSTRAINT")); - auto constr_child = c->attrs.find(ctx->id("NEXTPNR_CONSTR_CHILDREN")); - if (constr_main!=c->attrs.end()) - { - std::vector<std::string> val; - boost::split(val,constr_main->second.str,boost::is_any_of(";")); - c->constr_x = std::stoi(val[0]); - c->constr_y = std::stoi(val[1]); - c->constr_z = std::stoi(val[2]); - c->constr_abs_z = val[3]=="1"; - c->constr_parent = nullptr; - if (!val[4].empty()) - c->constr_parent = ctx->cells.find(ctx->id(val[4].c_str()))->second.get(); - #ifdef ARCH_ECP5 - c->sliceInfo.using_dff = val[5]=="1"; - c->sliceInfo.has_l6mux = val[6]=="1"; - c->sliceInfo.is_carry = val[7]=="1"; - c->sliceInfo.clk_sig = ctx->id(val[8]); - c->sliceInfo.lsr_sig = ctx->id(val[9]); - c->sliceInfo.clkmux = ctx->id(val[10]); - c->sliceInfo.lsrmux = ctx->id(val[11]); - c->sliceInfo.srmode = ctx->id(val[12]); - c->sliceInfo.sd0 = std::stoi(val[13]); - c->sliceInfo.sd1 = std::stoi(val[14]); - #endif - } - if (constr_child!=c->attrs.end()) - { - for(auto val : split(constr_child->second.str.c_str(),";")) - { - c->constr_children.push_back(ctx->cells.find(ctx->id(val.c_str()))->second.get()); - } - } - } - ctx->assignArchInfo(); - } - + } assign_budget(ctx.get()); ctx->check(); print_utilisation(ctx.get()); @@ -360,16 +321,6 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx) if (!ctx->place() && !ctx->force) log_error("Placing design failed.\n"); ctx->check(); - } else { - for (auto &pair : ctx->cells) { - auto &c = pair.second; - auto bel = c->attrs.find(ctx->id("NEXTPNR_BEL")); - if (bel!=c->attrs.end()) - { - BelId b = ctx->getBelByName(ctx->id(bel->second.c_str())); - ctx->bindBel(b, c.get(), STRENGTH_USER); - } - } } if (do_route) { diff --git a/common/nextpnr.cc b/common/nextpnr.cc index daaadf28..89b6ed6c 100644 --- a/common/nextpnr.cc +++ b/common/nextpnr.cc @@ -453,4 +453,70 @@ DecalXY BaseCtx::constructDecalXY(DecalId decal, float x, float y) return dxy; } +void BaseCtx::commonInfoToAttributes() +{ + for (auto &cell : cells) { + auto ci = cell.second.get(); + if (ci->bel != BelId()) { + ci->attrs[id("NEXTPNR_BEL")] = getCtx()->getBelName(ci->bel).c_str(this); + ci->attrs[id("BEL_STRENGTH")] = std::to_string((int)ci->belStrength); + } + if (ci->constr_x!= ci->UNCONSTR) + ci->attrs[id("CONSTR_X")] = std::to_string(ci->constr_x); + if (ci->constr_y!= ci->UNCONSTR) + ci->attrs[id("CONSTR_Y")] = std::to_string(ci->constr_y); + if (ci->constr_z!= ci->UNCONSTR) + ci->attrs[id("CONSTR_Z")] = std::to_string(ci->constr_z); + if (ci->constr_parent!= nullptr) + ci->attrs[id("CONSTR_PARENT")] = ci->constr_parent->name.c_str(this); + } + for (auto &net : getCtx()->nets) { + auto ni = net.second.get(); + std::string routing; + for (auto &item : ni->wires) { + routing += getCtx()->getWireName(item.first).c_str(this); + routing += ","; + if (item.second.pip != PipId()) + routing += getCtx()->getPipName(item.second.pip).c_str(this); + } + ni->attrs[id("ROUTING")] = routing; + } +} + +void BaseCtx::attributesToCommonInfo() +{ + for (auto &cell : cells) { + auto ci = cell.second.get(); + auto val = ci->attrs.find(id("NEXTPNR_BEL")); + if (val != ci->attrs.end()) { + auto str = ci->attrs.find(id("BEL_STRENGTH")); + PlaceStrength strength = PlaceStrength::STRENGTH_USER; + if (str != ci->attrs.end()) + strength = (PlaceStrength)std::stoi(str->second.str); + + BelId b = getCtx()->getBelByName(id(val->second.str)); + getCtx()->bindBel(b, ci, strength); + } + val = ci->attrs.find(id("CONSTR_X")); + if (val != ci->attrs.end()) + ci->constr_x = std::stoi(val->second.str); + + val = ci->attrs.find(id("CONSTR_Y")); + if (val != ci->attrs.end()) + ci->constr_y = std::stoi(val->second.str); + + val = ci->attrs.find(id("CONSTR_Z")); + if (val != ci->attrs.end()) { + ci->constr_z = std::stoi(val->second.str); + ci->constr_abs_z = (ci->constr_z == 0); + } + val = ci->attrs.find(id("CONSTR_PARENT")); + if (val != ci->attrs.end()) { + auto parent = cells.find(id(val->second.str)); + if (parent != cells.end()) + ci->constr_parent = parent->second.get(); + } + } +} + NEXTPNR_NAMESPACE_END diff --git a/common/nextpnr.h b/common/nextpnr.h index 02201463..f7f135fb 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -681,6 +681,9 @@ struct BaseCtx // Workaround for lack of wrappable constructors DecalXY constructDecalXY(DecalId decal, float x, float y); + + void commonInfoToAttributes(); + void attributesToCommonInfo(); }; NEXTPNR_NAMESPACE_END |