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.
This commit is contained in:
parent
68c16c2db7
commit
a0c9a70a5e
@ -692,11 +692,22 @@ void json_import(Context *ctx, string modname, JsonNode *node)
|
|||||||
|
|
||||||
log_info("Importing module %s\n", modname.c_str());
|
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:
|
// 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
|
// - names with fewer $ are always prefered
|
||||||
// - between equal $ counts, fewer .s are prefered
|
// - between equal $ counts, fewer .s are prefered
|
||||||
// - ties are resolved alphabetically
|
// - 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())
|
if (b.empty())
|
||||||
return true;
|
return true;
|
||||||
long a_dollars = std::count(a.begin(), a.end(), '$'), b_dollars = std::count(b.begin(), b.end(), '$');
|
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")) {
|
if (ports_parent != nullptr) {
|
||||||
JsonNode *ports_parent = node->data_dict.at("ports");
|
|
||||||
|
|
||||||
// N.B. ports must be imported after cells for tristate behaviour
|
// N.B. ports must be imported after cells for tristate behaviour
|
||||||
// to be correct
|
// to be correct
|
||||||
// Loop through all ports, first non-tristate then tristate to handle
|
// Loop through all ports, first non-tristate then tristate to handle
|
||||||
|
2
tests
2
tests
@ -1 +1 @@
|
|||||||
Subproject commit 0d369eb3fe3425fa74c0f6309268a012aac50409
|
Subproject commit 5182fd4bec49a568cc3fa37d62d9f9a82f280917
|
Loading…
Reference in New Issue
Block a user