aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2019-06-07 13:18:43 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2019-06-07 13:19:11 +0200
commita8871ea8aa6e17b2fbc8f70ce0f96cca18bac928 (patch)
tree50d4c4ca34396a0896f68397140e47d85e540d59
parent729e6c1ee93d5c1fadffce88c1c48c93ff75fc42 (diff)
downloadnextpnr-a8871ea8aa6e17b2fbc8f70ce0f96cca18bac928.tar.gz
nextpnr-a8871ea8aa6e17b2fbc8f70ce0f96cca18bac928.tar.bz2
nextpnr-a8871ea8aa6e17b2fbc8f70ce0f96cca18bac928.zip
Cleanup and fixes, flow works now
-rw-r--r--common/command.cc16
-rw-r--r--common/nextpnr.cc35
-rw-r--r--json/jsonparse.cc2
3 files changed, 32 insertions, 21 deletions
diff --git a/common/command.cc b/common/command.cc
index 96008d2b..46d6d014 100644
--- a/common/command.cc
+++ b/common/command.cc
@@ -233,22 +233,6 @@ 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")) {
diff --git a/common/nextpnr.cc b/common/nextpnr.cc
index 89b6ed6c..09fff8d1 100644
--- a/common/nextpnr.cc
+++ b/common/nextpnr.cc
@@ -19,6 +19,7 @@
#include "nextpnr.h"
#include "log.h"
+#include <boost/algorithm/string.hpp>
NEXTPNR_NAMESPACE_BEGIN
@@ -458,6 +459,9 @@ void BaseCtx::commonInfoToAttributes()
for (auto &cell : cells) {
auto ci = cell.second.get();
if (ci->bel != BelId()) {
+ if (ci->attrs.find(id("BEL")) != ci->attrs.end()) {
+ ci->attrs.erase(ci->attrs.find(id("BEL")));
+ }
ci->attrs[id("NEXTPNR_BEL")] = getCtx()->getBelName(ci->bel).c_str(this);
ci->attrs[id("BEL_STRENGTH")] = std::to_string((int)ci->belStrength);
}
@@ -465,10 +469,21 @@ void BaseCtx::commonInfoToAttributes()
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)
+ if (ci->constr_z!= ci->UNCONSTR) {
ci->attrs[id("CONSTR_Z")] = std::to_string(ci->constr_z);
+ ci->attrs[id("CONSTR_ABS_Z")] = std::to_string(ci->constr_abs_z ? 1 : 0);
+ }
if (ci->constr_parent!= nullptr)
ci->attrs[id("CONSTR_PARENT")] = ci->constr_parent->name.c_str(this);
+ if (!ci->constr_children.empty()) {
+ std::string constr = "";
+ for(auto &item : ci->constr_children)
+ {
+ if (!constr.empty()) constr += std::string(";");
+ constr += item->name.c_str(this);
+ }
+ ci->attrs[id("CONSTR_CHILDREN")] = constr;
+ }
}
for (auto &net : getCtx()->nets) {
auto ni = net.second.get();
@@ -506,16 +521,28 @@ void BaseCtx::attributesToCommonInfo()
ci->constr_y = std::stoi(val->second.str);
val = ci->attrs.find(id("CONSTR_Z"));
- if (val != ci->attrs.end()) {
+ 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_ABS_Z"));
+ if (val != ci->attrs.end())
+ ci->constr_abs_z = std::stoi(val->second.str)==1;
+
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();
}
+ val = ci->attrs.find(id("CONSTR_CHILDREN"));
+ if (val != ci->attrs.end()) {
+ std::vector<std::string> strs;
+ boost::split(strs,val->second.str,boost::is_any_of(";"));
+ for(auto val : strs)
+ {
+ ci->constr_children.push_back(cells.find(id(val.c_str()))->second.get());
+ }
+ }
}
}
diff --git a/json/jsonparse.cc b/json/jsonparse.cc
index 41d54188..1ff4f5af 100644
--- a/json/jsonparse.cc
+++ b/json/jsonparse.cc
@@ -880,7 +880,7 @@ bool parse_json_file(std::istream &f, std::string &filename, Context *ctx)
log_info("Checksum: 0x%08x\n", ctx->checksum());
log_break();
ctx->settings.emplace(ctx->id("input/json"), filename);
- ctx->attributesToCommonInfo();
+ ctx->attributesToArchInfo();
return true;
} catch (log_execution_error_exception) {
return false;