Add Fsm coverage to print summary (#7462)
This commit is contained in:
parent
c1d1b333ac
commit
72bbccb543
|
|
@ -372,7 +372,8 @@ void VlcTop::annotate(const string& dirname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VlcTop::printTypeSummary() {
|
void VlcTop::printTypeSummary() {
|
||||||
static const std::vector<std::string> orderedTypes = {"line", "toggle", "branch", "expr"};
|
static const std::vector<std::string> orderedTypes = {"line", "toggle", "branch", "expr",
|
||||||
|
"fsm_state", "fsm_arc"};
|
||||||
std::map<std::string, std::pair<uint64_t, uint64_t>> tally;
|
std::map<std::string, std::pair<uint64_t, uint64_t>> tally;
|
||||||
for (const auto& i : m_points) {
|
for (const auto& i : m_points) {
|
||||||
const VlcPoint& pt = m_points.pointNumber(i.second);
|
const VlcPoint& pt = m_points.pointNumber(i.second);
|
||||||
|
|
@ -385,6 +386,8 @@ void VlcTop::printTypeSummary() {
|
||||||
std::set<std::string> printed;
|
std::set<std::string> printed;
|
||||||
size_t typeWidth = 0;
|
size_t typeWidth = 0;
|
||||||
size_t countWidth = 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) {
|
for (const auto& it : tally) {
|
||||||
typeWidth = std::max(typeWidth, it.first.size());
|
typeWidth = std::max(typeWidth, it.first.size());
|
||||||
countWidth = std::max(countWidth, cvtToStr(it.second.first).size());
|
countWidth = std::max(countWidth, cvtToStr(it.second.first).size());
|
||||||
|
|
@ -393,10 +396,9 @@ void VlcTop::printTypeSummary() {
|
||||||
std::cout << "Coverage Summary:\n";
|
std::cout << "Coverage Summary:\n";
|
||||||
for (const string& type : orderedTypes) {
|
for (const string& type : orderedTypes) {
|
||||||
const auto it = tally.find(type);
|
const auto it = tally.find(type);
|
||||||
if (it == tally.end()) continue;
|
|
||||||
printed.insert(type);
|
printed.insert(type);
|
||||||
const uint64_t hit = it->second.first;
|
const uint64_t hit = (it == tally.end()) ? 0 : it->second.first;
|
||||||
const uint64_t total = it->second.second;
|
const uint64_t total = (it == tally.end()) ? 0 : it->second.second;
|
||||||
const double pct
|
const double pct
|
||||||
= total ? (100.0 * static_cast<double>(hit) / static_cast<double>(total)) : 0.0;
|
= total ? (100.0 * static_cast<double>(hit) / static_cast<double>(total)) : 0.0;
|
||||||
std::cout << " " << std::left << std::setw(typeWidth) << type << " : " << std::right
|
std::cout << " " << std::left << std::setw(typeWidth) << type << " : " << std::right
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,16 @@ test.compile(verilator_flags2=['--cc --coverage-fsm'])
|
||||||
|
|
||||||
test.execute()
|
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=[
|
test.run(cmd=[
|
||||||
os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage",
|
os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage",
|
||||||
"--annotate",
|
"--annotate",
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
@ -22,8 +22,12 @@ test.run(cmd=[
|
||||||
"--include-reset-arcs",
|
"--include-reset-arcs",
|
||||||
test.obj_dir + "/coverage.dat",
|
test.obj_dir + "/coverage.dat",
|
||||||
],
|
],
|
||||||
|
logfile=test.obj_dir + "/summary.log",
|
||||||
|
tee=False,
|
||||||
verilator_run=True)
|
verilator_run=True)
|
||||||
|
|
||||||
|
test.files_identical(test.obj_dir + "/summary.log", "t/" + test.name + "_summary.out")
|
||||||
|
|
||||||
test.run(cmd=[
|
test.run(cmd=[
|
||||||
os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage",
|
os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage",
|
||||||
"--annotate",
|
"--annotate",
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
Coverage Summary:
|
Coverage Summary:
|
||||||
line : 88.6% ( 39/ 44)
|
line : 88.6% ( 39/ 44)
|
||||||
toggle : 33.3% ( 35/105)
|
toggle : 33.3% ( 35/105)
|
||||||
branch : 78.1% ( 50/ 64)
|
branch : 78.1% ( 50/ 64)
|
||||||
expr : 66.7% ( 8/ 12)
|
expr : 66.7% ( 8/ 12)
|
||||||
|
fsm_state : 0.0% ( 0/ 0)
|
||||||
|
fsm_arc : 0.0% ( 0/ 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue