Add crude histogram feature, printed after placement and routing
This commit is contained in:
parent
85a436198c
commit
be481cb130
@ -933,7 +933,7 @@ bool router1(Context *ctx, const Router1Cfg &cfg)
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
ctx->check();
|
ctx->check();
|
||||||
#endif
|
#endif
|
||||||
timing_analysis(ctx, true /* print_path */);
|
timing_analysis(ctx, true /* slack_histogram */, true /* print_path */);
|
||||||
ctx->unlock();
|
ctx->unlock();
|
||||||
return true;
|
return true;
|
||||||
} catch (log_execution_error_exception) {
|
} catch (log_execution_error_exception) {
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
typedef std::vector<const PortRef*> PortRefVector;
|
typedef std::vector<const PortRef*> PortRefVector;
|
||||||
|
typedef std::map<delay_t, unsigned> DelayFrequency;
|
||||||
|
|
||||||
struct Timing
|
struct Timing
|
||||||
{
|
{
|
||||||
@ -35,8 +36,10 @@ struct Timing
|
|||||||
delay_t min_slack;
|
delay_t min_slack;
|
||||||
PortRefVector current_path;
|
PortRefVector current_path;
|
||||||
PortRefVector *crit_path;
|
PortRefVector *crit_path;
|
||||||
|
DelayFrequency *slack_histogram;
|
||||||
|
|
||||||
Timing(Context *ctx, bool update, PortRefVector *crit_path = nullptr): ctx(ctx), update(update), min_slack(1.0e12 / ctx->target_freq), crit_path(crit_path) {}
|
Timing(Context *ctx, bool update, PortRefVector *crit_path = nullptr, DelayFrequency *slack_histogram = nullptr)
|
||||||
|
: ctx(ctx), update(update), min_slack(1.0e12 / ctx->target_freq), crit_path(crit_path), slack_histogram(slack_histogram) {}
|
||||||
|
|
||||||
delay_t follow_net(NetInfo *net, int path_length, delay_t slack)
|
delay_t follow_net(NetInfo *net, int path_length, delay_t slack)
|
||||||
{
|
{
|
||||||
@ -75,6 +78,8 @@ struct Timing
|
|||||||
if (crit_path)
|
if (crit_path)
|
||||||
*crit_path = current_path;
|
*crit_path = current_path;
|
||||||
}
|
}
|
||||||
|
if (slack_histogram)
|
||||||
|
(*slack_histogram)[slack]++;
|
||||||
} else {
|
} else {
|
||||||
// Default to the path ending here, if no further paths found
|
// Default to the path ending here, if no further paths found
|
||||||
value = slack / path_length;
|
value = slack / path_length;
|
||||||
@ -178,11 +183,12 @@ void assign_budget(Context *ctx, bool quiet)
|
|||||||
log_info("Checksum: 0x%08x\n", ctx->checksum());
|
log_info("Checksum: 0x%08x\n", ctx->checksum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void timing_analysis(Context *ctx, bool print_path)
|
void timing_analysis(Context *ctx, bool print_histogram, bool print_path)
|
||||||
{
|
{
|
||||||
PortRefVector crit_path;
|
PortRefVector crit_path;
|
||||||
|
DelayFrequency slack_histogram;
|
||||||
|
|
||||||
Timing timing(ctx, false /* update */, &crit_path);
|
Timing timing(ctx, false /* update */, print_path ? &crit_path : nullptr, print_histogram ? &slack_histogram : nullptr);
|
||||||
auto min_slack = timing.walk_paths();
|
auto min_slack = timing.walk_paths();
|
||||||
|
|
||||||
if (print_path) {
|
if (print_path) {
|
||||||
@ -224,6 +230,28 @@ void timing_analysis(Context *ctx, bool print_path)
|
|||||||
|
|
||||||
delay_t default_slack = delay_t(1.0e12 / ctx->target_freq);
|
delay_t default_slack = delay_t(1.0e12 / ctx->target_freq);
|
||||||
log_info("estimated Fmax = %.2f MHz\n", 1e6 / (default_slack - min_slack));
|
log_info("estimated Fmax = %.2f MHz\n", 1e6 / (default_slack - min_slack));
|
||||||
|
|
||||||
|
if (print_histogram) {
|
||||||
|
constexpr unsigned num_bins = 20;
|
||||||
|
unsigned bar_width = 60;
|
||||||
|
auto min_slack = slack_histogram.begin()->first;
|
||||||
|
auto max_slack = slack_histogram.rbegin()->first;
|
||||||
|
auto bin_size = (max_slack - min_slack) / num_bins;
|
||||||
|
std::vector<unsigned> bins(num_bins+1);
|
||||||
|
unsigned max_freq = 0;
|
||||||
|
for (const auto& i : slack_histogram) {
|
||||||
|
auto& bin = bins[(i.first-min_slack) / bin_size];
|
||||||
|
bin += i.second;
|
||||||
|
max_freq = std::max(max_freq, bin);
|
||||||
|
}
|
||||||
|
bar_width = std::min(bar_width, max_freq);
|
||||||
|
|
||||||
|
log_break();
|
||||||
|
log_info("Slack histogram:\n");
|
||||||
|
log_info(" legend: * represents %d endpoint(s)\n", max_freq / bar_width);
|
||||||
|
for (unsigned i = 0; i < bins.size(); ++i)
|
||||||
|
log_info("%6d < ps < %6d |%s\n", min_slack + bin_size*i, min_slack + bin_size*(i+1), std::string(bins[i] * bar_width / max_freq, '*').c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -29,7 +29,7 @@ void assign_budget(Context *ctx, bool quiet = false);
|
|||||||
|
|
||||||
// Perform timing analysis and print out the fmax, and optionally the
|
// Perform timing analysis and print out the fmax, and optionally the
|
||||||
// critical path
|
// critical path
|
||||||
void timing_analysis(Context *ctx, bool print_path = false);
|
void timing_analysis(Context *ctx, bool slack_histogram = true, bool print_path = false);
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user