diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2019-06-02 17:33:37 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2019-06-02 17:33:37 +0200 |
commit | 7c65da417b5a222cc68a83e25c60c1f1326473f2 (patch) | |
tree | f480310a8c93691219e727b08958410ff6e3e5b0 /common/command.cc | |
parent | 1894cb549c368ccd5c932535852d6d9367136865 (diff) | |
download | nextpnr-7c65da417b5a222cc68a83e25c60c1f1326473f2.tar.gz nextpnr-7c65da417b5a222cc68a83e25c60c1f1326473f2.tar.bz2 nextpnr-7c65da417b5a222cc68a83e25c60c1f1326473f2.zip |
Read constraints and placing from file
Diffstat (limited to 'common/command.cc')
-rw-r--r-- | common/command.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/common/command.cc b/common/command.cc index e81967b4..7d4cd252 100644 --- a/common/command.cc +++ b/common/command.cc @@ -232,6 +232,22 @@ void CommandHandler::setupContext(Context *ctx) ctx->timing_driven = false; } +std::vector<std::string> split(const std::string& str, const std::string& delim) +{ + std::vector<std::string> tokens; + size_t prev = 0, pos = 0; + do + { + pos = str.find(delim, prev); + if (pos == std::string::npos) pos = str.length(); + std::string token = str.substr(prev, pos-prev); + if (!token.empty()) tokens.push_back(token); + prev = pos + delim.length(); + } + while (pos < str.length() && prev < str.length()); + return tokens; +} + int CommandHandler::executeMain(std::unique_ptr<Context> ctx) { if (vm.count("test")) { @@ -295,6 +311,30 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx) 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 = split(constr_main->second.str.c_str(),";"); + 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" ? true : false; + c->constr_parent = nullptr; + if (val.size()==5) + c->constr_parent = ctx->cells.find(ctx->id(val[4].c_str()))->second.get(); + + } + 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(); } @@ -307,6 +347,16 @@ 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("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) { |