45 lines
1.6 KiB
Python
Executable File
45 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# DESCRIPTION: Verilator: FSM coverage negative extraction test
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
# under the terms of either the GNU Lesser General Public License Version 3
|
|
# or the Perl Artistic License Version 2.0.
|
|
# SPDX-FileCopyrightText: 2026 Wilson Snyder
|
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
|
|
|
import os
|
|
|
|
import vltest_bootstrap
|
|
|
|
test.scenarios('simulator')
|
|
|
|
# This test is intentionally "half supported": one case item is a simple
|
|
# direct state assignment, while the others use shapes the extractor should
|
|
# ignore (multiple meaningful statements or assignment to a non-state lhs).
|
|
# That lets us hit the conservative negative branches in directStateAssign()
|
|
# and singleMeaningfulStmt() without changing user-visible behavior.
|
|
test.compile(verilator_flags2=['--cc --coverage-fsm'])
|
|
|
|
test.execute()
|
|
|
|
# Use annotated-source output so the golden locks down which candidate arcs
|
|
# survive extraction and which unsupported shapes are intentionally skipped.
|
|
test.run(cmd=[
|
|
os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage",
|
|
"--annotate",
|
|
test.obj_dir + "/annotated",
|
|
test.obj_dir + "/coverage.dat",
|
|
],
|
|
verilator_run=True)
|
|
|
|
annotated_filename = test.obj_dir + "/annotated/" + test.name + ".v"
|
|
normalized_filename = test.obj_dir + "/annotated/" + test.name + ".normalized.v"
|
|
with open(annotated_filename, encoding="utf-8") as in_file:
|
|
with open(normalized_filename, "w", encoding="utf-8") as out_file:
|
|
for line in in_file:
|
|
out_file.write(line.rstrip() + "\n")
|
|
|
|
test.files_identical(normalized_filename, test.golden_filename)
|
|
|
|
test.passes()
|