Add coverage example

This commit is contained in:
Miical 2024-04-28 14:54:28 +08:00
parent cb39a7518d
commit e319d70709
2 changed files with 23 additions and 7 deletions

View File

@ -1,12 +1,12 @@
TEST_MODULE=FauFTB
TEST=uFTB_raw
TEST=.
TEST_FOLDER=./$(TEST)
COV_FILE_NAME=V$(TEST_MODULE)_coverage.dat
PYTHON=python3
START_CODE="from mlvp.reporter import *;\
set_meta_info('line_grate', 10);\
set_meta_info('test_case', '$(TEST)');\
report = 'report/report.html';\
generate_pytest_report(report, args=['-s', '$(TEST_FOLDER)'], );\
"
@ -14,3 +14,6 @@ generate_pytest_report(report, args=['-s', '$(TEST_FOLDER)'], );\
run:
@echo "Running test $(TEST)..."
@$(PYTHON) -c $(START_CODE)
clean:
rm -rf report/ *.fst *.dat

View File

@ -40,16 +40,29 @@ import mlvp.funcov as fc
from mlvp.reporter import *
def test_uftb(request):
g = fc.CovGroup("coverage_group_1")
g.add_watch_point(uFTB.io_s0_fire_0, {
"s0_fire": fc.Eq(1),
}, name="s0_fire_0")
g = fc.CovGroup("uftb_with_ftq")
g.add_watch_point(uFTB.reset, { "reset": fc.Eq(1), }, name="reset")
g.add_watch_point(uFTB.io_ctrl_ubtb_enable, { "ubtb_enable": fc.Eq(1), }, name="ubtb_enable")
g.add_watch_point(uFTB.io_s0_fire_0, { "s0_fire": fc.Eq(1), }, name="s0_fire_0")
g.add_watch_point(uFTB.io_s1_fire_0, { "s1_fire": fc.Eq(1), }, name="s1_fire_0")
g.add_watch_point(uFTB.io_s2_fire_0, { "s2_fire": fc.Eq(1), }, name="s2_fire_0")
g.add_watch_point(uFTB.io_update_valid, { "update_valid": fc.Eq(1), }, name="update_valid")
g.add_watch_point(uFTB.io_out_s1_full_pred_0_hit, { "hit": fc.Eq(1), "not_hit": fc.Eq(0) }, name="s1_full_pred_0_hit")
g.add_watch_point(uFTB.io_out_s1_full_pred_3_fallThroughErr, { "fallThroughErr": fc.Eq(1), "not_fallThroughErr": fc.Eq(0) }, name="s1_full_pred_3_fallThroughErr")
g.add_watch_point(uFTB.io_out_s1_full_pred_0_slot_valids_0, { "slot_valids_0": fc.Eq(1), "slot_valids_0_invalid": fc.Eq(0) }, name="s1_full_pred_0_slot_valids_0")
g.add_watch_point(uFTB.io_out_s1_full_pred_0_slot_valids_1, { "slot_valids_1": fc.Eq(1), "slot_valids_1_invalid": fc.Eq(0) }, name="s1_full_pred_0_slot_valids_1")
g.add_watch_point(uFTB.io_out_s1_full_pred_0_br_taken_mask_0, { "br_taken_mask_0": fc.Eq(1), "br_taken_mask_0_invalid": fc.Eq(0) }, name="s1_full_pred_0_br_taken_mask_0")
g.add_watch_point(uFTB.io_out_s1_full_pred_0_br_taken_mask_1, { "br_taken_mask_1": fc.Eq(1), "br_taken_mask_1_invalid": fc.Eq(0) }, name="s1_full_pred_0_br_taken_mask_1")
g.add_watch_point(uFTB.io_out_s1_full_pred_0_is_br_sharing, { "is_br_sharing": fc.Eq(1), "is_br_sharing_invalid": fc.Eq(0) }, name="s1_full_pred_0_is_br_sharing")
uFTB.xclock.StepRis(lambda _: g.sample())
set_func_coverage(request, g)
set_line_coverage(request, "VFauFTB_coverage.dat")
mlvp.run(uftb_test())
g.sample()
uFTB.finalize()
pred_stat.summary()