Only print filenames for now, default on
This commit is contained in:
parent
a8c110b045
commit
cba4753c22
@ -158,10 +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()("print-critical-path-source",
|
||||
"print the source code associated with each net in the critical path");
|
||||
general.add_options()("critical-path-source-max-lines", po::value<int>(),
|
||||
"max number of source lines to print per critical path report entry");
|
||||
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");
|
||||
@ -183,11 +181,8 @@ void CommandHandler::setupContext(Context *ctx)
|
||||
ctx->debug = true;
|
||||
}
|
||||
|
||||
if (vm.count("print-critical-path-source")) {
|
||||
ctx->print_critical_path_source = true;
|
||||
}
|
||||
if (vm.count("critical-path-source-max-lines")) {
|
||||
ctx->critical_path_source_max_lines = vm["critical-path-source-max-lines"].as<int>();
|
||||
if (vm.count("no-print-critical-path-source")) {
|
||||
ctx->disable_critical_path_source_print = true;
|
||||
}
|
||||
|
||||
if (vm.count("force")) {
|
||||
|
@ -861,10 +861,8 @@ struct Context : Arch, DeterministicRNG
|
||||
bool debug = false;
|
||||
bool force = false;
|
||||
|
||||
// Print verilog sources for nets in critical path?
|
||||
bool print_critical_path_source = false;
|
||||
// Max line count to print for critical path sources
|
||||
int critical_path_source_max_lines = 8;
|
||||
// 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) {}
|
||||
|
||||
|
@ -813,13 +813,15 @@ 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, deepest source last
|
||||
// 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;
|
||||
@ -830,59 +832,10 @@ void timing_analysis(Context *ctx, bool print_histogram, bool print_fmax, bool p
|
||||
// Ensure we emplace the final entry
|
||||
source_entries.emplace_back(sourcelist.substr(prev, current - prev));
|
||||
|
||||
// For each source entry, split iinto filename, start line/character
|
||||
// and end line/character
|
||||
const unsigned entry_count = source_entries.size();
|
||||
// Iterate and print our source list at the correct indentation level
|
||||
log_info(" Defined in:\n");
|
||||
for (unsigned i = 0; i < entry_count; i++) {
|
||||
const std::string source_entry = source_entries[i];
|
||||
const bool is_final_entry = i == entry_count - 1;
|
||||
|
||||
log_info(" %s\n", source_entry.c_str());
|
||||
|
||||
// Split the source entry to get the filename
|
||||
const size_t filename_split = source_entry.find(":");
|
||||
const std::string filename = source_entry.substr(0, filename_split);
|
||||
const std::string location_tuple = source_entry.substr(filename_split + 1);
|
||||
|
||||
// Split the location tuple into start/end groups
|
||||
const size_t start_end_split = location_tuple.find("-");
|
||||
const std::string code_start = location_tuple.substr(0, start_end_split);
|
||||
const std::string code_end = location_tuple.substr(start_end_split + 1);
|
||||
|
||||
// Extract just the line number from those tuples
|
||||
const int code_start_line = std::atoi(code_start.substr(0, code_start.find(".")).c_str());
|
||||
const int code_end_line = std::atoi(code_end.substr(0, code_end.find(".")).c_str());
|
||||
|
||||
// Try and stat the source file
|
||||
std::ifstream in(filename);
|
||||
if (!in) {
|
||||
// Failed to find source file, can't print the actual source
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip through to the start line
|
||||
in.seekg(std::ios::beg);
|
||||
for (int i = 0; i < code_start_line - 1; ++i) {
|
||||
in.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
||||
}
|
||||
// Log each line til we hit the end line / max line count
|
||||
// For non-final entries, just print one line so we don't spam too heavily
|
||||
int max_print_lines = ctx->critical_path_source_max_lines - 1;
|
||||
if (!is_final_entry) {
|
||||
max_print_lines = 0; // Compare is inclusive
|
||||
}
|
||||
const int print_end =
|
||||
((code_end_line < code_start_line + max_print_lines) ? code_end_line
|
||||
: code_start_line + max_print_lines);
|
||||
for (int i = code_start_line; i <= print_end; i++) {
|
||||
std::string line;
|
||||
getline(in, line);
|
||||
// Strip any whitespace from the start of the line, since we are already aligning it
|
||||
line.erase(line.begin(),
|
||||
std::find_if(line.begin(), line.end(), [](char c) { return !(c == ' ' || c == '\t'); }));
|
||||
log_info(" %s\n", line.c_str());
|
||||
}
|
||||
for (auto entry : source_entries) {
|
||||
log_info(" %s\n", entry.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@ -963,7 +916,7 @@ void timing_analysis(Context *ctx, bool print_histogram, bool print_fmax, bool p
|
||||
cursor = ctx->getPipSrcWire(pip);
|
||||
}
|
||||
}
|
||||
if (ctx->print_critical_path_source) {
|
||||
if (!ctx->disable_critical_path_source_print) {
|
||||
print_net_source(ctx, net);
|
||||
}
|
||||
last_port = sink->port;
|
||||
|
Loading…
Reference in New Issue
Block a user