diff --git a/.gitignore b/.gitignore index 2597fae..de7084d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ split_verilogs .vscode **/__pycache__/ *.fst +*.fst.hier *.log *.dat **/UT_* diff --git a/tests/Makefile b/tests/Makefile index ae9cb86..eb75702 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,5 @@ -TEST_MODULE=FauFTB TEST=. TEST_FOLDER=./$(TEST) -COV_FILE_NAME=V$(TEST_MODULE)_coverage.dat PYTHON=python3 @@ -16,4 +14,4 @@ run: @$(PYTHON) -c $(START_CODE) clean: - rm -rf report/ *.fst *.dat + rm -rf report/ *.fst *.dat *.log *.hier diff --git a/tests/uFTB-with-ftq/tests/test_with_ftq.py b/tests/uFTB-with-ftq/tests/test_with_ftq.py index eb8a75a..3b49980 100644 --- a/tests/uFTB-with-ftq/tests/test_with_ftq.py +++ b/tests/uFTB-with-ftq/tests/test_with_ftq.py @@ -1,4 +1,5 @@ import mlvp +import logging import os os.sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/..") @@ -10,10 +11,10 @@ from env.config import * os.sys.path.append(DUT_PATH) from UT_FauFTB import * -uFTB = DUTFauFTB() -uFTB.init_clock("clock") -def set_imm_mode(): + + +def set_imm_mode(uFTB): imm_mode = uFTB.io_s0_fire_0.xdata.Imme need_to_write_imm = ["io_s0_fire_0", "io_s0_fire_1", "io_s0_fire_2", "io_s0_fire_3", "io_s1_fire_0", "io_s2_fire_0", "io_in_bits_s0_pc_0", "io_in_bits_s0_pc_1", @@ -21,9 +22,8 @@ def set_imm_mode(): for name in need_to_write_imm: getattr(uFTB, name).xdata.SetWriteMode(imm_mode) -set_imm_mode() -async def uftb_test(): +async def uftb_test(uFTB): uFTB_update = UpdateBundle.from_prefix(uFTB, "io_update_") uFTB_out = BranchPredictionResp.from_prefix(uFTB, "io_out_") pipeline_ctrl = PipelineCtrlBundle.from_prefix(uFTB, "io_") @@ -40,32 +40,37 @@ import mlvp.funcov as fc from mlvp.reporter import * def test_uftb(request): - g = fc.CovGroup("uftb_with_ftq") + # Create DUT + uFTB = DUTFauFTB(waveform_filename="uftb_with_ftq.fst", coverage_filename="uftb_with_ftq_coverage.dat") + uFTB.init_clock("clock") + set_imm_mode(uFTB) - 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") + # Set Coverage + g1 = fc.CovGroup("interaction") + g1.add_watch_point(uFTB.reset, { "reset": fc.Eq(1), }, name="reset") + g1.add_watch_point(uFTB.io_ctrl_ubtb_enable, { "ubtb_enable": fc.Eq(1), }, name="ubtb_enable") + g1.add_watch_point(uFTB.io_s0_fire_0, { "s0_fire": fc.Eq(1), }, name="s0_fire_0") + g1.add_watch_point(uFTB.io_s1_fire_0, { "s1_fire": fc.Eq(1), }, name="s1_fire_0") + g1.add_watch_point(uFTB.io_s2_fire_0, { "s2_fire": fc.Eq(1), }, name="s2_fire_0") + g1.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") + g2 = fc.CovGroup("ftb_entry") + g2.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") + g2.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") + g2.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") + g2.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") + g2.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") + g2.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") + g2.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 _: g1.sample()) + uFTB.xclock.StepRis(lambda _: g2.sample()) - uFTB.xclock.StepRis(lambda _: g.sample()) - set_func_coverage(request, g) - set_line_coverage(request, "VFauFTB_coverage.dat") - - import logging + # Run the test mlvp.setup_logging(log_level=logging.INFO, log_file="uftb_with_ftq.log") - - mlvp.run(uftb_test()) - + mlvp.run(uftb_test(uFTB)) uFTB.finalize() + pred_stat.summary() + set_func_coverage(request, [g1, g2]) + set_line_coverage(request, "uftb_with_ftq_coverage.dat") diff --git a/tests/uFTB_raw/FauFTB.py b/tests/uFTB_raw/FauFTB.py index eaf1975..c332d59 100644 --- a/tests/uFTB_raw/FauFTB.py +++ b/tests/uFTB_raw/FauFTB.py @@ -142,8 +142,8 @@ class FauFTB(DUTFauFTB): ] ) - def __init__(self): - super().__init__() + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) self.io_in_bits_s0_pc = self.Io_in_bits_s0_pc(self) self.io_out_s1_pc = self.Io_out_s1_pc(self) self.io_s0_fire = self.Io_s0_fire(self) diff --git a/tests/uFTB_raw/test_raw.py b/tests/uFTB_raw/test_raw.py index b689ffb..b78b6ee 100644 --- a/tests/uFTB_raw/test_raw.py +++ b/tests/uFTB_raw/test_raw.py @@ -37,9 +37,7 @@ from mlvp.reporter import * def test_raw(request): - set_line_coverage(request, "VFauFTB_coverage.dat") - - uFTB: FauFTB = FauFTB() + uFTB: FauFTB = FauFTB(waveform_filename="uftb_raw.fst", coverage_filename="uftb_raw_coverage.dat") ftb_entry_list() uFTB.reset.value = 1 uFTB.Step(100) @@ -58,6 +56,8 @@ def test_raw(request): uFTB.finalize() + set_line_coverage(request, "uftb_raw_coverage.dat") + if __name__ == "__main__": test_raw()