Update uftb-with-ftq to mlvp v0.1.0

This commit is contained in:
Miical 2024-09-05 20:35:35 +08:00
parent 5ff250c113
commit 97d0e6f46b
9 changed files with 31 additions and 44 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ split_verilogs
**/UT_*
NemuBR/
report/
reports/

View File

@ -74,13 +74,13 @@ if __name__ == "__main__":
# Create DUT
uftb = DUTFauFTB()
# Init DUT with clock pin name
uftb.init_clock("clock")
uftb.InitClock("clock")
# Your testcases here
# ...
# Destroy DUT
utb.finalize()
utb.Finish()
```
其他待验证模块,例如 TAGE-SCFTB也可以通过类似命令生成。
@ -166,7 +166,7 @@ def test_mydut(request):
# ...
# 结束测试,并录入覆盖率信息,覆盖率文件名称应该与上述指定的覆盖率文件名称相同
my_dut.finalize()
my_dut.Finish()
set_func_coverage(request, [g1, g2])
set_line_coverage(request, "my_test_coverage.dat")
```
@ -218,7 +218,7 @@ def setup_logging(
**2. 阅读代码封装并驱动DUT。** 代码中包含了所有实现细节基于其可对DUT的基本功能封装为一个个函数。然后测试这些函数功能是否正常。
**3. 根据测试点编写对应测试用例。** 基于测点和DUT基本功能函数完成绝大部分功能的测试。**不要一来就写参考模型**
**3. 根据测试点编写对应测试用例。** 基于测点和DUT基本功能函数完成绝大部分功能的测试。**不要一来就写参考模型**
**4. 编写参考模型。** 当所有基本功能点都测试完成后,再基于自己理解完成参考模型编写。(如果所有功能点都完成测试,且功能、代码行覆盖率已达到要求,可忽略参考模型)

View File

@ -74,13 +74,13 @@ if __name__ == "__main__":
# Create DUT
uftb = DUTFauFTB()
# Init DUT with clock pin name
uftb.init_clock("clock")
uftb.InitClock("clock")
# Your testcases here
# ...
# Destroy DUT
utb.finalize()
utb.Finish()
```
Other modules to be verified, such as TAGE-SC, FTB can also be generated by similar commands.
@ -167,7 +167,7 @@ def test_mydut(request):
# ...
# End the test, and enter the coverage information. The coverage file name should be the same as the coverage file name specified above
my_dut.finalize()
my_dut.Finish()
set_func_coverage(request, [g1, g2])
set_line_coverage(request, "my_test_coverage.dat")
```

View File

@ -1,18 +1,9 @@
TEST=.
TEST_FOLDER=./$(TEST)
PYTHON=python3
START_CODE="from mlvp.reporter import *;\
set_meta_info('test_case', '$(TEST)');\
report = 'report/$(TEST)/report.html';\
generate_pytest_report(report, args=['-s', '$(TEST_FOLDER)'], );\
"
run:
@echo "Running test $(TEST)..."
@mkdir report/$(TEST) -p
@$(PYTHON) -c $(START_CODE)
pytest --mlvp-report -sv $(TEST_FOLDER)
clean:
rm -rf report/ *.fst *.dat *.log *.hier
rm -rf reports/

View File

@ -150,10 +150,10 @@ class FauFTB(DUTFauFTB):
self.io_out_s1_full_pred = self.Io_out_s1_full_pred(self)
self._io_out_last_stage_meta = self.Io_out_last_stage_meta(self)
self.io_update_bits_ftb_entry = self.Io_update_bits_ftb_entry(self)
self.init_clock("clock")
self.InitClock("clock")
def finalize(self):
super().finalize()
super().Finish()
def check_dup_equation(self, *inputs):
return all(i == inputs[0] for i in inputs)

View File

@ -57,7 +57,7 @@ def test_raw(request):
print("main", pred[0], pred[1].__dict__)
uFTB.Step(1)
uFTB.finalize()
uFTB.Finish()
set_line_coverage(request, "report/uftb_raw_coverage.dat")

View File

@ -1,4 +1,5 @@
from mlvp import *
from mlvp.triggers import *
from .bundle import *
from .ftq import *
from .uftb_model import uFTBModel

View File

@ -1,4 +1,4 @@
from mlvp.modules import PLRU, TwoBitsCounter
from mlvp.utils import PLRU, TwoBitsCounter
from mlvp import *
from .ftb import *

View File

@ -1,5 +1,6 @@
import mlvp
import logging
import pytest
from mlvp.triggers import *
import os
os.sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/..")
@ -12,8 +13,6 @@ os.sys.path.append(DUT_PATH)
from UT_FauFTB import *
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",
@ -23,27 +22,31 @@ def set_imm_mode(uFTB):
getattr(uFTB, name).xdata.SetWriteMode(imm_mode)
async def uftb_test(uFTB):
@pytest.mark.mlvp_async
async def test_uftb(mlvp_request):
uFTB = mlvp_request
set_imm_mode(uFTB)
uFTB_update = UpdateBundle.from_prefix("io_update_").set_name("uFTB_update").bind(uFTB)
uFTB_out = BranchPredictionResp.from_prefix("io_out_").set_name("uFTB_out").bind(uFTB)
pipeline_ctrl = PipelineCtrlBundle.from_prefix("io_").set_name("pipeline_ctrl").bind(uFTB)
enable_ctrl = EnableCtrlBundle.from_prefix("io_ctrl_").set_name("enable_ctrl").bind(uFTB)
mlvp.create_task(mlvp.start_clock(uFTB))
mlvp.start_clock(uFTB)
mlvp.create_task(BPUTop(uFTB, uFTB_out, uFTB_update, pipeline_ctrl, enable_ctrl).run())
await ClockCycles(uFTB, MAX_CYCLE)
pred_stat.summary()
import mlvp.funcov as fc
from mlvp.reporter import *
from mlvp import PreRequest
def test_uftb(request):
# Create DUT
uFTB = DUTFauFTB(waveform_filename="report/uftb_with_ftq.fst", coverage_filename="report/uftb_with_ftq_coverage.dat")
uFTB.init_clock("clock")
set_imm_mode(uFTB)
@pytest.fixture()
def mlvp_request(mlvp_pre_request: PreRequest):
mlvp.setup_logging(mlvp.INFO)
uFTB = mlvp_pre_request.create_dut(DUTFauFTB, "clock")
# Set Coverage
g1 = fc.CovGroup("interaction")
@ -63,15 +66,6 @@ def test_uftb(request):
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())
# Run the test
mlvp.setup_logging(log_level=logging.INFO, log_file="report/uftb_with_ftq.log")
mlvp.run(uftb_test(uFTB))
uFTB.finalize()
pred_stat.summary()
set_func_coverage(request, [g1, g2])
set_line_coverage(request, "report/uftb_with_ftq_coverage.dat")
mlvp_pre_request.add_cov_groups([g1, g2])
return uFTB