Merge pull request #494 from rschlaikjer/rschlaikjer-print-sources-in-time-report

Add option to print critical path source code
This commit is contained in:
David Shah 2020-08-31 07:38:47 +01:00 committed by GitHub
commit 4512a9de19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 0 deletions

View File

@ -158,6 +158,8 @@ po::options_description CommandHandler::getGeneralOptions()
general.add_options()("no-tmdriv", "disable timing-driven placement"); 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", 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()("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()("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"); 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; ctx->debug = true;
} }
if (vm.count("no-print-critical-path-source")) {
ctx->disable_critical_path_source_print = true;
}
if (vm.count("force")) { if (vm.count("force")) {
ctx->force = true; ctx->force = true;
} }

View File

@ -861,6 +861,9 @@ struct Context : Arch, DeterministicRNG
bool debug = false; bool debug = false;
bool force = 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) {} Context(ArchArgs args) : Arch(args) {}
// -------------------------------------------------------------- // --------------------------------------------------------------

View File

@ -811,6 +811,33 @@ void timing_analysis(Context *ctx, bool print_histogram, bool print_fmax, bool p
} }
if (print_path) { 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) { auto print_path_report = [ctx](ClockPair &clocks, PortRefVector &crit_path) {
delay_t total = 0, logic_total = 0, route_total = 0; delay_t total = 0, logic_total = 0, route_total = 0;
auto &front = crit_path.front(); 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); cursor = ctx->getPipSrcWire(pip);
} }
} }
if (!ctx->disable_critical_path_source_print) {
print_net_source(ctx, net);
}
last_port = sink->port; last_port = sink->port;
} }
int clockCount = 0; int clockCount = 0;