Consider clocked cells with COUT, consider constant nets

This commit is contained in:
Eddie Hung 2018-08-06 12:03:58 -07:00
parent 266b761f41
commit 3f5c0373a5

View File

@ -155,7 +155,7 @@ struct Timing
for (auto &cell : ctx->cells) { for (auto &cell : ctx->cells) {
input_ports.clear(); input_ports.clear();
output_ports.clear(); output_ports.clear();
bool is_io = cell.second->type == ctx->id_sb_io; bool is_io = cell.second->type == ctx->id_sb_io; // HACK HACK HACK
for (auto& port : cell.second->ports) { for (auto& port : cell.second->ports) {
if (!port.second.net) continue; if (!port.second.net) continue;
if (port.second.type == PORT_OUT) if (port.second.type == PORT_OUT)
@ -187,18 +187,32 @@ struct Timing
} }
} }
auto it = ctx->nets.find(ctx->id("$PACKER_VCC_NET"));
if (it != ctx->nets.end()) {
topographical_order.emplace_back(it->second.get());
net_data.emplace(it->second.get(), TimingData{});
}
it = ctx->nets.find(ctx->id("$PACKER_GND_NET"));
if (it != ctx->nets.end()) {
topographical_order.emplace_back(it->second.get());
net_data.emplace(it->second.get(), TimingData{});
}
std::deque<NetInfo*> queue(topographical_order.begin(), topographical_order.end()); std::deque<NetInfo*> queue(topographical_order.begin(), topographical_order.end());
while (!queue.empty()) { while (!queue.empty()) {
const auto net = queue.front(); const auto net = queue.front();
queue.pop_front(); queue.pop_front();
DelayInfo clkToQ;
for (auto &usr : net->users) { for (auto &usr : net->users) {
if (ctx->getPortClock(usr.cell, usr.port) != IdString()) { auto clock_domain = ctx->getPortClock(usr.cell, usr.port);
} else {
// Follow outputs of the user // Follow outputs of the user
for (auto& port : usr.cell->ports) { for (auto& port : usr.cell->ports) {
if (port.second.type == PORT_OUT && port.second.net) { if (port.second.type == PORT_OUT && port.second.net) {
// Skip if this is a clocked output
if (clock_domain != IdString() && ctx->getCellDelay(usr.cell, clock_domain, port.first, clkToQ))
continue;
DelayInfo comb_delay; DelayInfo comb_delay;
bool is_path = ctx->getCellDelay(usr.cell, usr.port, port.first, comb_delay); bool is_path = ctx->getCellDelay(usr.cell, usr.port, port.first, comb_delay);
if (is_path) { if (is_path) {
@ -214,7 +228,9 @@ struct Timing
} }
} }
} }
}
NPNR_ASSERT(port_fanin.empty());
port_fanin.clear();
// Find the maximum arrival time and max path length for each net // Find the maximum arrival time and max path length for each net
for (auto net : topographical_order) { for (auto net : topographical_order) {
@ -225,7 +241,7 @@ struct Timing
for (auto &usr : net->users) { for (auto &usr : net->users) {
if (ctx->getPortClock(usr.cell, usr.port) != IdString()) { if (ctx->getPortClock(usr.cell, usr.port) != IdString()) {
} else { } else {
auto net_delay = ctx->getNetinfoRouteDelay(net, usr); auto net_delay = net_delays ? ctx->getNetinfoRouteDelay(net, usr) : delay_t();
auto budget_override = ctx->getBudgetOverride(net, usr, net_delay); auto budget_override = ctx->getBudgetOverride(net, usr, net_delay);
auto usr_arrival = net_arrival + net_delay; auto usr_arrival = net_arrival + net_delay;
// Follow outputs of the user // Follow outputs of the user
@ -254,12 +270,13 @@ struct Timing
const delay_t net_length_plus_one = nd.max_path_length + 1; const delay_t net_length_plus_one = nd.max_path_length + 1;
auto& net_min_remaining_budget = nd.min_remaining_budget; auto& net_min_remaining_budget = nd.min_remaining_budget;
for (auto &usr : net->users) { for (auto &usr : net->users) {
const auto net_delay = ctx->getNetinfoRouteDelay(net, usr); auto net_delay = net_delays ? ctx->getNetinfoRouteDelay(net, usr) : delay_t();
auto budget_override = ctx->getBudgetOverride(net, usr, net_delay); auto budget_override = ctx->getBudgetOverride(net, usr, net_delay);
if (ctx->getPortClock(usr.cell, usr.port) != IdString()) { if (ctx->getPortClock(usr.cell, usr.port) != IdString()) {
const auto net_arrival = nd.max_arrival; const auto net_arrival = nd.max_arrival;
auto path_budget = clk_period - (net_arrival + net_delay); auto path_budget = clk_period - (net_arrival + net_delay);
auto budget_share = budget_override ? 0 : path_budget / net_length_plus_one; auto budget_share = budget_override ? 0 : path_budget / net_length_plus_one;
if (update)
usr.budget = std::min(usr.budget, net_delay + budget_share); usr.budget = std::min(usr.budget, net_delay + budget_share);
net_min_remaining_budget = std::min(net_min_remaining_budget, path_budget - budget_share); net_min_remaining_budget = std::min(net_min_remaining_budget, path_budget - budget_share);
@ -278,6 +295,7 @@ struct Timing
if (is_path) { if (is_path) {
auto path_budget = net_data.at(port.second.net).min_remaining_budget; auto path_budget = net_data.at(port.second.net).min_remaining_budget;
auto budget_share = budget_override ? 0 : path_budget / net_length_plus_one; auto budget_share = budget_override ? 0 : path_budget / net_length_plus_one;
if (update)
usr.budget = std::min(usr.budget, net_delay + budget_share); usr.budget = std::min(usr.budget, net_delay + budget_share);
net_min_remaining_budget = std::min(net_min_remaining_budget, path_budget - budget_share); net_min_remaining_budget = std::min(net_min_remaining_budget, path_budget - budget_share);
} }