mirror of
https://github.com/YosysHQ/nextpnr.git
synced 2026-09-06 21:02:24 +02:00
router2: Reduce redundancy in PerWireData
Signed-off-by: gatecat <[email protected]>
This commit is contained in:
+13
-18
@@ -95,16 +95,15 @@ struct Router2
|
||||
// Historical congestion cost
|
||||
int curr_cong = 0;
|
||||
float hist_cong_cost = 1.0;
|
||||
// Wire is unavailable as locked to another arc
|
||||
bool unavailable = false;
|
||||
// This wire has to be used for this net
|
||||
int reserved_net = -1;
|
||||
static constexpr int RESERVED_UNAVAILABLE = -2;
|
||||
// The notional location of the wire, to guarantee thread safety
|
||||
int16_t x = 0, y = 0;
|
||||
// Visit data
|
||||
PipId pip_fwd, pip_bwd;
|
||||
bool visited_fwd = false, visited_bwd = false;
|
||||
float cost_fwd = 0.0, cost_bwd = 0.0;
|
||||
static constexpr float NOT_VISITED = std::numeric_limits<float>::max();
|
||||
float cost_fwd = NOT_VISITED, cost_bwd = NOT_VISITED;
|
||||
};
|
||||
|
||||
struct PerResourceData
|
||||
@@ -226,7 +225,7 @@ struct Router2
|
||||
if (bound->wires.at(wire).strength == STRENGTH_PLACER) {
|
||||
pwd.reserved_net = bound->udata;
|
||||
} else if (bound->wires.at(wire).strength > STRENGTH_PLACER) {
|
||||
pwd.unavailable = true;
|
||||
pwd.reserved_net = PerWireData::RESERVED_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -577,7 +576,7 @@ struct Router2
|
||||
// and LUT
|
||||
if (iter_count > 7)
|
||||
return false; // heuristic to assume we've hit general routing
|
||||
if (wire_data(wire).unavailable)
|
||||
if (wire_data(wire).reserved_net == PerWireData::RESERVED_UNAVAILABLE)
|
||||
return true;
|
||||
if (wire_data(wire).reserved_net != -1 && wire_data(wire).reserved_net != net->udata)
|
||||
return true; // reserved for another net
|
||||
@@ -721,10 +720,8 @@ struct Router2
|
||||
for (auto w : t.dirty_wires) {
|
||||
flat_wires[w].pip_fwd = PipId();
|
||||
flat_wires[w].pip_bwd = PipId();
|
||||
flat_wires[w].visited_fwd = false;
|
||||
flat_wires[w].visited_bwd = false;
|
||||
flat_wires[w].cost_fwd = 0.0;
|
||||
flat_wires[w].cost_bwd = 0.0;
|
||||
flat_wires[w].cost_fwd = PerWireData::NOT_VISITED;
|
||||
flat_wires[w].cost_bwd = PerWireData::NOT_VISITED;
|
||||
}
|
||||
t.dirty_wires.clear();
|
||||
}
|
||||
@@ -758,29 +755,27 @@ struct Router2
|
||||
void set_visited_fwd(ThreadContext &t, int wire, PipId pip, float cost)
|
||||
{
|
||||
auto &wd = flat_wires.at(wire);
|
||||
if (!wd.visited_fwd && !wd.visited_bwd)
|
||||
if (wd.cost_fwd == PerWireData::NOT_VISITED && wd.cost_bwd == PerWireData::NOT_VISITED)
|
||||
t.dirty_wires.push_back(wire);
|
||||
wd.pip_fwd = pip;
|
||||
wd.visited_fwd = true;
|
||||
wd.cost_fwd = cost;
|
||||
}
|
||||
void set_visited_bwd(ThreadContext &t, int wire, PipId pip, float cost)
|
||||
{
|
||||
auto &wd = flat_wires.at(wire);
|
||||
if (!wd.visited_fwd && !wd.visited_bwd)
|
||||
if (wd.cost_fwd == PerWireData::NOT_VISITED && wd.cost_bwd == PerWireData::NOT_VISITED)
|
||||
t.dirty_wires.push_back(wire);
|
||||
wd.pip_bwd = pip;
|
||||
wd.visited_bwd = true;
|
||||
wd.cost_bwd = cost;
|
||||
}
|
||||
|
||||
bool was_visited_fwd(int wire, float cost)
|
||||
{
|
||||
return flat_wires.at(wire).visited_fwd && flat_wires.at(wire).cost_fwd <= cost;
|
||||
return flat_wires.at(wire).cost_fwd != PerWireData::NOT_VISITED && flat_wires.at(wire).cost_fwd <= cost;
|
||||
}
|
||||
bool was_visited_bwd(int wire, float cost)
|
||||
{
|
||||
return flat_wires.at(wire).visited_bwd && flat_wires.at(wire).cost_bwd <= cost;
|
||||
return flat_wires.at(wire).cost_bwd != PerWireData::NOT_VISITED && flat_wires.at(wire).cost_bwd <= cost;
|
||||
}
|
||||
|
||||
float get_arc_crit(NetInfo *net, store_index<PortRef> i)
|
||||
@@ -934,7 +929,7 @@ struct Router2
|
||||
continue;
|
||||
}
|
||||
auto &nwd = flat_wires.at(next_idx);
|
||||
if (nwd.unavailable)
|
||||
if (nwd.reserved_net == PerWireData::RESERVED_UNAVAILABLE)
|
||||
continue;
|
||||
// Reserved for another net
|
||||
if (nwd.reserved_net != -1 && nwd.reserved_net != net->udata)
|
||||
@@ -1011,7 +1006,7 @@ struct Router2
|
||||
continue;
|
||||
}
|
||||
auto &nwd = flat_wires.at(next_idx);
|
||||
if (nwd.unavailable)
|
||||
if (nwd.reserved_net == PerWireData::RESERVED_UNAVAILABLE)
|
||||
continue;
|
||||
// Reserved for another net
|
||||
if (nwd.reserved_net != -1 && nwd.reserved_net != net->udata)
|
||||
|
||||
Reference in New Issue
Block a user