diff --git a/src/VlcTop.cpp b/src/VlcTop.cpp index 37cee819d..78d97d9b1 100644 --- a/src/VlcTop.cpp +++ b/src/VlcTop.cpp @@ -372,7 +372,8 @@ void VlcTop::annotate(const string& dirname) { } void VlcTop::printTypeSummary() { - static const std::vector orderedTypes = {"line", "toggle", "branch", "expr"}; + static const std::vector orderedTypes = {"line", "toggle", "branch", "expr", + "fsm_state", "fsm_arc"}; std::map> tally; for (const auto& i : m_points) { const VlcPoint& pt = m_points.pointNumber(i.second); @@ -385,6 +386,8 @@ void VlcTop::printTypeSummary() { std::set printed; size_t typeWidth = 0; size_t countWidth = 0; + for (const string& type : orderedTypes) typeWidth = std::max(typeWidth, type.size()); + countWidth = std::max(countWidth, cvtToStr(0).size()); for (const auto& it : tally) { typeWidth = std::max(typeWidth, it.first.size()); countWidth = std::max(countWidth, cvtToStr(it.second.first).size()); @@ -393,10 +396,9 @@ void VlcTop::printTypeSummary() { std::cout << "Coverage Summary:\n"; for (const string& type : orderedTypes) { const auto it = tally.find(type); - if (it == tally.end()) continue; printed.insert(type); - const uint64_t hit = it->second.first; - const uint64_t total = it->second.second; + const uint64_t hit = (it == tally.end()) ? 0 : it->second.first; + const uint64_t total = (it == tally.end()) ? 0 : it->second.second; const double pct = total ? (100.0 * static_cast(hit) / static_cast(total)) : 0.0; std::cout << " " << std::left << std::setw(typeWidth) << type << " : " << std::right diff --git a/test_regress/t/t_cover_fsm_basic.py b/test_regress/t/t_cover_fsm_basic.py index 628914b4f..728bcebef 100755 --- a/test_regress/t/t_cover_fsm_basic.py +++ b/test_regress/t/t_cover_fsm_basic.py @@ -17,6 +17,16 @@ test.compile(verilator_flags2=['--cc --coverage-fsm']) test.execute() +test.run(cmd=[ + os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage", + test.obj_dir + "/coverage.dat", +], + logfile=test.obj_dir + "/summary.log", + tee=False, + verilator_run=True) + +test.files_identical(test.obj_dir + "/summary.log", "t/" + test.name + "_summary.out") + test.run(cmd=[ os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage", "--annotate", diff --git a/test_regress/t/t_cover_fsm_basic_summary.out b/test_regress/t/t_cover_fsm_basic_summary.out new file mode 100644 index 000000000..a0e1606ad --- /dev/null +++ b/test_regress/t/t_cover_fsm_basic_summary.out @@ -0,0 +1,7 @@ +Coverage Summary: + line : 0.0% (0/0) + toggle : 0.0% (0/0) + branch : 0.0% (0/0) + expr : 0.0% (0/0) + fsm_state : 50.0% (2/4) + fsm_arc : 100.0% (5/5) diff --git a/test_regress/t/t_cover_fsm_reset.py b/test_regress/t/t_cover_fsm_reset.py index c250cbe45..ee7db650a 100755 --- a/test_regress/t/t_cover_fsm_reset.py +++ b/test_regress/t/t_cover_fsm_reset.py @@ -22,8 +22,12 @@ test.run(cmd=[ "--include-reset-arcs", test.obj_dir + "/coverage.dat", ], + logfile=test.obj_dir + "/summary.log", + tee=False, verilator_run=True) +test.files_identical(test.obj_dir + "/summary.log", "t/" + test.name + "_summary.out") + test.run(cmd=[ os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage", "--annotate", diff --git a/test_regress/t/t_cover_fsm_reset_summary.out b/test_regress/t/t_cover_fsm_reset_summary.out new file mode 100644 index 000000000..32439a8ea --- /dev/null +++ b/test_regress/t/t_cover_fsm_reset_summary.out @@ -0,0 +1,7 @@ +Coverage Summary: + line : 100.0% (8/8) + toggle : 75.0% (6/8) + branch : 100.0% (8/8) + expr : 0.0% (0/0) + fsm_state : 50.0% (2/4) + fsm_arc : 100.0% (4/4) diff --git a/test_regress/t/t_vlcov_summary_typed.out b/test_regress/t/t_vlcov_summary_typed.out index a059cd732..e4b3d14f6 100644 --- a/test_regress/t/t_vlcov_summary_typed.out +++ b/test_regress/t/t_vlcov_summary_typed.out @@ -1,5 +1,7 @@ Coverage Summary: - line : 88.6% ( 39/ 44) - toggle : 33.3% ( 35/105) - branch : 78.1% ( 50/ 64) - expr : 66.7% ( 8/ 12) + line : 88.6% ( 39/ 44) + toggle : 33.3% ( 35/105) + branch : 78.1% ( 50/ 64) + expr : 66.7% ( 8/ 12) + fsm_state : 0.0% ( 0/ 0) + fsm_arc : 0.0% ( 0/ 0)