diff options
author | David Shah <dave@ds0.me> | 2020-08-31 07:38:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-31 07:38:47 +0100 |
commit | 4512a9de19751916c466ed12a2ba4dce958d77bc (patch) | |
tree | dbc7a35e1d32e9d4bef5142a9091e3f752b814b0 /common | |
parent | f6d436d58b8206aabe287325fc80da5521ed2e75 (diff) | |
parent | c30cadd19caf16edebdc676e17d9f6280ef59361 (diff) | |
download | nextpnr-4512a9de19751916c466ed12a2ba4dce958d77bc.tar.gz nextpnr-4512a9de19751916c466ed12a2ba4dce958d77bc.tar.bz2 nextpnr-4512a9de19751916c466ed12a2ba4dce958d77bc.zip |
Merge pull request #494 from rschlaikjer/rschlaikjer-print-sources-in-time-report
Add option to print critical path source code
Diffstat (limited to 'common')
-rw-r--r-- | common/command.cc | 6 | ||||
-rw-r--r-- | common/nextpnr.h | 3 | ||||
-rw-r--r-- | common/timing.cc | 30 |
3 files changed, 39 insertions, 0 deletions
diff --git a/common/command.cc b/common/command.cc index 3dc0d968..f0d028ce 100644 --- a/common/command.cc +++ b/common/command.cc @@ -158,6 +158,8 @@ po::options_description CommandHandler::getGeneralOptions() general.add_options()("no-tmdriv", "disable timing-driven placement"); general.add_options()("sdf", po::value<std::string>(), "SDF delay back-annotation file to write"); general.add_options()("sdf-cvc", "enable tweaks for SDF file compatibility with the CVC simulator"); + general.add_options()("no-print-critical-path-source", + "disable printing of the source lines associated with each net in the critical path"); general.add_options()("placed-svg", po::value<std::string>(), "write render of placement to SVG file"); general.add_options()("routed-svg", po::value<std::string>(), "write render of routing to SVG file"); @@ -179,6 +181,10 @@ void CommandHandler::setupContext(Context *ctx) ctx->debug = true; } + if (vm.count("no-print-critical-path-source")) { + ctx->disable_critical_path_source_print = true; + } + if (vm.count("force")) { ctx->force = true; } diff --git a/common/nextpnr.h b/common/nextpnr.h index 4d481d06..f9376fea 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -861,6 +861,9 @@ struct Context : Arch, DeterministicRNG bool debug = false; bool force = false; + // Should we disable printing of the location of nets in the critical path? + bool disable_critical_path_source_print = false; + Context(ArchArgs args) : Arch(args) {} // -------------------------------------------------------------- diff --git a/common/timing.cc b/common/timing.cc index d4d33183..8b35e41c 100644 --- a/common/timing.cc +++ b/common/timing.cc @@ -811,6 +811,33 @@ void timing_analysis(Context *ctx, bool print_histogram, bool print_fmax, bool p } if (print_path) { + static auto print_net_source = [](Context *ctx, NetInfo *net) { + // Check if this net is annotated with a source list + auto sources = net->attrs.find(ctx->id("src")); + if (sources == net->attrs.end()) { + // No sources for this net, can't print anything + return; + } + + // Sources are separated by pipe characters. + // There is no guaranteed ordering on sources, so we just print all + auto sourcelist = sources->second.as_string(); + std::vector<std::string> source_entries; + size_t current = 0, prev = 0; + while ((current = sourcelist.find("|", prev)) != std::string::npos) { + source_entries.emplace_back(sourcelist.substr(prev, current - prev)); + prev = current + 1; + } + // Ensure we emplace the final entry + source_entries.emplace_back(sourcelist.substr(prev, current - prev)); + + // Iterate and print our source list at the correct indentation level + log_info(" Defined in:\n"); + for (auto entry : source_entries) { + log_info(" %s\n", entry.c_str()); + } + }; + auto print_path_report = [ctx](ClockPair &clocks, PortRefVector &crit_path) { delay_t total = 0, logic_total = 0, route_total = 0; auto &front = crit_path.front(); @@ -888,6 +915,9 @@ void timing_analysis(Context *ctx, bool print_histogram, bool print_fmax, bool p cursor = ctx->getPipSrcWire(pip); } } + if (!ctx->disable_critical_path_source_print) { + print_net_source(ctx, net); + } last_port = sink->port; } int clockCount = 0; |