Add pytest
This commit is contained in:
parent
8931e1b246
commit
cb39a7518d
|
@ -3,5 +3,7 @@ split_verilogs
|
|||
.vscode
|
||||
**/__pycache__/
|
||||
*.fst
|
||||
*.dat
|
||||
**/UT_*
|
||||
NemuBR/
|
||||
report/
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
TEST_MODULE=FauFTB
|
||||
TEST=uFTB_raw
|
||||
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);\
|
||||
report = 'report/report.html';\
|
||||
generate_pytest_report(report, args=['-s', '$(TEST_FOLDER)'], );\
|
||||
"
|
||||
|
||||
run:
|
||||
@echo "Running test $(TEST)..."
|
||||
@$(PYTHON) -c $(START_CODE)
|
|
@ -0,0 +1,14 @@
|
|||
import pytest
|
||||
from mlvp.reporter import process_context, process_func_coverage
|
||||
|
||||
|
||||
@pytest.hookimpl(optionalhook=True)
|
||||
def pytest_reporter_context(context, config):
|
||||
process_context(context, config)
|
||||
|
||||
|
||||
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
|
||||
def pytest_runtest_makereport(item, call):
|
||||
outcome = yield
|
||||
report = outcome.get_result()
|
||||
return process_func_coverage(item, call, report)
|
|
@ -1,7 +1,7 @@
|
|||
from mlvp import *
|
||||
from bundle import *
|
||||
from ftq import *
|
||||
from uftb_model import uFTBModel
|
||||
from .bundle import *
|
||||
from .ftq import *
|
||||
from .uftb_model import uFTBModel
|
||||
|
||||
def assert_equal(a, b):
|
||||
if a != b:
|
|
@ -1,4 +1,4 @@
|
|||
from config import *
|
||||
from .config import *
|
||||
|
||||
import os
|
||||
os.sys.path.append(UTILS_PATH)
|
|
@ -1,4 +1,4 @@
|
|||
from utils import *
|
||||
from .utils import *
|
||||
|
||||
class FTBSlot:
|
||||
def __init__(self):
|
|
@ -1,9 +1,9 @@
|
|||
from bundle import *
|
||||
from config import *
|
||||
from utils import *
|
||||
from executor import Executor
|
||||
from ftb import *
|
||||
from random import random
|
||||
from .bundle import *
|
||||
from .config import *
|
||||
from .utils import *
|
||||
from .executor import Executor
|
||||
from .ftb import *
|
||||
|
||||
class PredictionStatistician:
|
||||
"""Predictive condition statistician for branch instructions"""
|
|
@ -1,5 +1,5 @@
|
|||
from mlvp.utils import PLRU, TwoBitsCounter
|
||||
from ftb import *
|
||||
from .ftb import *
|
||||
|
||||
class uFTBWay:
|
||||
def __init__(self):
|
|
@ -1,4 +1,4 @@
|
|||
from config import *
|
||||
from .config import *
|
||||
|
||||
def get_slot_offset(pc, target):
|
||||
return ((target - pc) >> INST_OFFSET_BITS) & ((1 << PREDICT_WIDTH_OFFSET_BITS) - 1)
|
|
@ -1,10 +1,12 @@
|
|||
import mlvp
|
||||
|
||||
from bundle import *
|
||||
from bpu_top import *
|
||||
from config import MAX_CYCLE
|
||||
|
||||
import os
|
||||
os.sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/..")
|
||||
|
||||
from env.bundle import *
|
||||
from env.bpu_top import *
|
||||
from env.config import *
|
||||
|
||||
os.sys.path.append(DUT_PATH)
|
||||
|
||||
from UT_FauFTB import *
|
||||
|
@ -32,8 +34,22 @@ async def uftb_test():
|
|||
|
||||
await ClockCycles(uFTB, MAX_CYCLE)
|
||||
|
||||
if __name__ == "__main__":
|
||||
mlvp.run(uftb_test())
|
||||
uFTB.finalize()
|
||||
|
||||
|
||||
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")
|
||||
|
||||
set_func_coverage(request, g)
|
||||
set_line_coverage(request, "VFauFTB_coverage.dat")
|
||||
|
||||
mlvp.run(uftb_test())
|
||||
g.sample()
|
||||
|
||||
uFTB.finalize()
|
||||
pred_stat.summary()
|
|
@ -1,3 +1,8 @@
|
|||
import os
|
||||
ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) + "/../.."
|
||||
DUT_PATH = ROOT_PATH + "/out/picker_out_uFTB"
|
||||
os.sys.path.append(DUT_PATH)
|
||||
|
||||
from typing import Any, Tuple
|
||||
from UT_FauFTB import *
|
||||
from FTBEntry import *
|
||||
|
|
|
@ -23,7 +23,7 @@ def get_pred(uFTB: FauFTB, pc: int) -> Tuple[int, FTBEntry, bool, bool]:
|
|||
uFTB.io_s1_fire_0.value = 1
|
||||
uFTB.io_s2_fire_0.value = 1
|
||||
return uFTB.s1_full_pred()
|
||||
|
||||
|
||||
|
||||
|
||||
def set_update(uFTB: FauFTB, entry: Tuple[int, FTBEntry, bool, bool]):
|
||||
|
@ -32,8 +32,12 @@ def set_update(uFTB: FauFTB, entry: Tuple[int, FTBEntry, bool, bool]):
|
|||
# print("set_update", entry[1].brSlot)
|
||||
uFTB.update_ftb_entry(entry[0], entry[1], (entry[2], entry[3]))
|
||||
|
||||
import mlvp.funcov as fc
|
||||
from mlvp.reporter import *
|
||||
|
||||
def main():
|
||||
def test_raw(request):
|
||||
|
||||
set_line_coverage(request, "VFauFTB_coverage.dat")
|
||||
|
||||
uFTB: FauFTB = FauFTB()
|
||||
ftb_entry_list()
|
||||
|
@ -56,4 +60,4 @@ def main():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
test_raw()
|
Loading…
Reference in New Issue