Support verilator_coverage --write-info for lcov HTML reports.

This commit is contained in:
Wilson Snyder
2020-05-16 09:18:35 -04:00
parent 6fd7f45cef
commit d33d0301f8
10 changed files with 136 additions and 5 deletions
+55
View File
@@ -77,6 +77,61 @@ void VlcTop::writeCoverage(const string& filename) {
}
}
void VlcTop::writeInfo(const string& filename) {
UINFO(2, "writeInfo " << filename << endl);
std::ofstream os(filename.c_str());
if (!os) {
v3fatal("Can't write " << filename);
return;
}
annotateCalc();
// See 'man lcov' for format details
// TN:<trace_file_name>
// Source file:
// SF:<absolute_path_to_source_file>
// FN:<line_number_of_function_start>,<function_name>
// FNDA:<execution_count>,<function_name>
// FNF:<number_functions_found>
// FNH:<number_functions_hit>
// Branches:
// BRDA:<line_number>,<block_number>,<branch_number>,<taken_count_or_-_for_zero>
// BRF:<number_of_branches_found>
// BRH:<number_of_branches_hit>
// Line counts:
// DA:<line_number>,<execution_count>
// LF:<number_of_lines_found>
// LH:<number_of_lines_hit>
// Section ending:
// end_of_record
os << "TN:verilator_coverage\n";
for (VlcSources::NameMap::iterator sit = m_sources.begin(); sit != m_sources.end(); ++sit) {
VlcSource& source = sit->second;
os << "SF:" << source.name() << endl;
VlcSource::LinenoMap& lines = source.lines();
for (VlcSource::LinenoMap::iterator lit = lines.begin(); lit != lines.end(); ++lit) {
int lineno = lit->first;
VlcSource::ColumnMap& cmap = lit->second;
bool first = true;
vluint64_t min_count = 0; // Minimum across all columns on line
for (VlcSource::ColumnMap::iterator cit = cmap.begin(); cit != cmap.end(); ++cit) {
VlcSourceCount& col = cit->second;
if (first) {
min_count = col.count();
first = false;
} else {
min_count = std::min(min_count, col.count());
}
}
os << "DA:" << lineno << "," << min_count << "\n";
}
os << "end_of_record\n";
}
}
//********************************************************************
struct CmpComputrons {