aboutsummaryrefslogtreecommitdiffstats
path: root/json
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2019-05-26 16:44:34 +0000
committerwhitequark <whitequark@whitequark.org>2019-05-29 18:05:48 +0000
commita0c9a70a5e6717aea37092720c899a463e482922 (patch)
treeb44884dec87a009ef9b0d4dc565dd596f785d408 /json
parent68c16c2db78dec4af09da7bec5d386422d9264a1 (diff)
downloadnextpnr-a0c9a70a5e6717aea37092720c899a463e482922.tar.gz
nextpnr-a0c9a70a5e6717aea37092720c899a463e482922.tar.bz2
nextpnr-a0c9a70a5e6717aea37092720c899a463e482922.zip
When choosing between labels for one net, always prefer ports.
1. Ports are already used in PCF and LPF files, so it is natural that the developer would use them for constraints as well. 2. Unpredictable (the set of netlabels nextpnr looks at depends on the optimizations during synthesis) net naming makes it impossible for code generators like nMigen to reliably apply clock constraints.
Diffstat (limited to 'json')
-rw-r--r--json/jsonparse.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/json/jsonparse.cc b/json/jsonparse.cc
index a0479c2e..eec7041c 100644
--- a/json/jsonparse.cc
+++ b/json/jsonparse.cc
@@ -692,11 +692,22 @@ void json_import(Context *ctx, string modname, JsonNode *node)
log_info("Importing module %s\n", modname.c_str());
+ JsonNode *ports_parent = nullptr;
+ if (node->data_dict.count("ports") > 0)
+ ports_parent = node->data_dict.at("ports");
+
// Multiple labels might refer to the same net. For now we resolve conflicts thus:
+ // - (toplevel) ports are always preferred
// - names with fewer $ are always prefered
// - between equal $ counts, fewer .s are prefered
// - ties are resolved alphabetically
- auto prefer_netlabel = [](const std::string &a, const std::string &b) {
+ auto prefer_netlabel = [ports_parent](const std::string &a, const std::string &b) {
+ if (ports_parent != nullptr) {
+ if (ports_parent->data_dict.count(a))
+ return true;
+ if (ports_parent->data_dict.count(b))
+ return false;
+ }
if (b.empty())
return true;
long a_dollars = std::count(a.begin(), a.end(), '$'), b_dollars = std::count(b.begin(), b.end(), '$');
@@ -753,9 +764,7 @@ void json_import(Context *ctx, string modname, JsonNode *node)
}
}
- if (node->data_dict.count("ports")) {
- JsonNode *ports_parent = node->data_dict.at("ports");
-
+ if (ports_parent != nullptr) {
// N.B. ports must be imported after cells for tristate behaviour
// to be correct
// Loop through all ports, first non-tristate then tristate to handle