Merge pull request #676 from YosysHQ/gatecat/fix-sta-crash
timing: Fix domain init when loops are present
This commit is contained in:
commit
423da76ff2
@ -185,6 +185,7 @@ void TimingAnalyser::topo_sort()
|
||||
}
|
||||
}
|
||||
}
|
||||
have_loops = !no_loops;
|
||||
std::swap(topological_order, topo.sorted);
|
||||
}
|
||||
|
||||
@ -195,10 +196,14 @@ void TimingAnalyser::setup_port_domains()
|
||||
d.endpoints.clear();
|
||||
}
|
||||
// Go forward through the topological order (domains from the PoV of arrival time)
|
||||
bool first_iter = true;
|
||||
do {
|
||||
updated_domains = false;
|
||||
for (auto port : topological_order) {
|
||||
auto &pd = ports.at(port);
|
||||
auto &pi = port_info(port);
|
||||
if (pi.type == PORT_OUT) {
|
||||
if (first_iter) {
|
||||
for (auto &fanin : pd.cell_arcs) {
|
||||
if (fanin.type != CellArc::CLK_TO_Q)
|
||||
continue;
|
||||
@ -208,6 +213,7 @@ void TimingAnalyser::setup_port_domains()
|
||||
pd.arrival[dom];
|
||||
domains.at(dom).startpoints.emplace_back(port, fanin.other_port);
|
||||
}
|
||||
}
|
||||
// copy domains across routing
|
||||
if (pi.net != nullptr)
|
||||
for (auto &usr : pi.net->users)
|
||||
@ -233,15 +239,17 @@ void TimingAnalyser::setup_port_domains()
|
||||
copy_domains(port, CellPortKey(port.cell, fanin.other_port), true);
|
||||
}
|
||||
} else {
|
||||
if (first_iter) {
|
||||
for (auto &fanout : pd.cell_arcs) {
|
||||
if (fanout.type != CellArc::SETUP)
|
||||
continue;
|
||||
// registered inputs are startpoints
|
||||
// registered inputs are endpoints
|
||||
auto dom = domain_id(port.cell, fanout.other_port, fanout.edge);
|
||||
// create per-domain data
|
||||
pd.required[dom];
|
||||
domains.at(dom).endpoints.emplace_back(port, fanout.other_port);
|
||||
}
|
||||
}
|
||||
// copy port to driver
|
||||
if (pi.net != nullptr && pi.net->driver.cell != nullptr)
|
||||
copy_domains(port, CellPortKey(pi.net->driver), true);
|
||||
@ -255,6 +263,10 @@ void TimingAnalyser::setup_port_domains()
|
||||
pd.domain_pairs[domain_pair_id(arr.first, req.first)];
|
||||
}
|
||||
}
|
||||
first_iter = false;
|
||||
// If there are loops, repeat the process until a fixed point is reached, as there might be unusual ways to
|
||||
// visit points, which would result in a missing domain key and therefore crash later on
|
||||
} while (have_loops && updated_domains);
|
||||
}
|
||||
|
||||
void TimingAnalyser::reset_times()
|
||||
@ -561,8 +573,9 @@ domain_id_t TimingAnalyser::domain_pair_id(domain_id_t launch, domain_id_t captu
|
||||
void TimingAnalyser::copy_domains(const CellPortKey &from, const CellPortKey &to, bool backward)
|
||||
{
|
||||
auto &f = ports.at(from), &t = ports.at(to);
|
||||
for (auto &dom : (backward ? f.required : f.arrival))
|
||||
(backward ? t.required : t.arrival)[dom.first];
|
||||
for (auto &dom : (backward ? f.required : f.arrival)) {
|
||||
updated_domains |= (backward ? t.required : t.arrival).emplace(dom.first, ArrivReqTime{}).second;
|
||||
}
|
||||
}
|
||||
|
||||
CellInfo *TimingAnalyser::cell_info(const CellPortKey &key) { return ctx->cells.at(key.cell).get(); }
|
||||
|
@ -142,6 +142,8 @@ struct TimingAnalyser
|
||||
|
||||
bool setup_only = false;
|
||||
bool verbose_mode = false;
|
||||
bool have_loops = false;
|
||||
bool updated_domains = false;
|
||||
|
||||
private:
|
||||
void init_ports();
|
||||
|
Loading…
Reference in New Issue
Block a user