update makefile & /scripts/: rtl links & itlb funcov (#85)

This commit is contained in:
CharlesJunic 2025-03-06 15:34:00 +08:00 committed by GitHub
parent 8fcdd79da7
commit 0ca85ce5ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 134 additions and 77 deletions

View File

@ -1,4 +1,4 @@
.PHONY: dut rtl
.PHONY: dut rtl check_dut
export PYTHONPATH := $(shell pwd):$(shell picker --show_xcom_lib_location_python):$(PYTHONPATH)
export ENABLE_XINFO := 0
@ -6,6 +6,12 @@ export CFG := ""
export DUTS := "*"
export REPORT := "--toffee-report"
comma:= ,
empty:=
space:= $(empty) $(empty)
PROCESSED_DUTS := $(subst $(comma),$(space),$(strip $(DUTS)))
all: rtl dut test_all
update_python_deps:
@ -24,10 +30,40 @@ clean_rtl:
test_all: dut
@python3 run.py --config $(CFG) $(KV) -- $(REPORT) -vs ut_*/ $(args)
test: dut
test: check_dut
@python3 run.py --config $(CFG) $(KV) -- $(REPORT) -vs $(target) $(args)
check_dut:
@if [ -n "$(target)" ]; then \
for t in $(target); do \
MATCHED_LINE=$$(grep ".* --> .* --> $$t" dir_map.f | head -1); \
if [ -n "$$MATCHED_LINE" ]; then \
DUT_NAME=$$(echo "$$MATCHED_LINE" | awk -F' --> ' '{print $$1}'); \
DUT_DIR=dut/$$(echo "$$MATCHED_LINE" | awk -F' --> ' '{print $$2}'); \
if [ ! -d "$$DUT_DIR" ]; then \
echo "Building missing DUT for target $$t: $$DUT_NAME"; \
$(MAKE) dut DUTS="$$DUT_NAME"; \
fi; \
else \
echo "No DUT mapping found for target: $$t, skipping..." >&2; \
fi; \
done; \
fi
dut: rtl
@if [ "$(PROCESSED_DUTS)" = "*" ]; then \
$(MAKE) clean_dut; \
else \
for d in $(PROCESSED_DUTS); do \
dir=$$(awk -F' --> ' -v dut="$$d" '$$1 == dut {print $$2; exit}' dir_map.f); \
if [ -z "$$dir" ]; then \
echo "No mapping found for '$$d' in dir_map.f, skipping deletion" >&2; \
continue; \
fi; \
echo "Cleaning dut/$$dir"; \
rm -rf "dut/$$dir"; \
done; \
fi
@python3 run.py --config $(CFG) --build $(DUTS) $(args)
rtl:

15
dir_map.f Normal file
View File

@ -0,0 +1,15 @@
backend_ctrl_block_decode --> DecodeStage --> ut_backend/ctrl_block/decode
frontend_bpu_ittage --> ITTage --> ut_frontend/bpu/ittage
frontend_bpu_tagesc --> Tage_SC --> ut_frontend/bpu/tagesc
frontend_ifu_f3predecoder --> F3Predecoder --> ut_frontend/ifu/f3predecoder
frontend_ifu_frontend_trigger --> FrontendTrigger --> ut_frontend/ifu/frontend_trigger
frontend_ifu_pred_checker --> PredChecker --> ut_frontend/ifu/pred_checker
frontend_ifu_predecode --> PreDecode --> ut_frontend/ifu/predecode
frontend_ifu_rvc_expander --> RVCExpander --> ut_frontend/ifu/rvc_expander
frontend_ifu_top --> NewIFU -->
frontend_itlb --> TLB --> ut_frontend/itlb/classical_version
frontend_itlb --> TLB --> ut_frontend/itlb/toffee_version
frontend_tlb_fa --> TLBFA --> ut_frontend/itlb/submodules/TLBFA
frontend_tlb_nonblock --> TLBNonBlock --> ut_frontend/itlb/submodules/TLBNonBlock
frontend_tlb_storage_wrapper --> TlbStorageWrapper --> ut_frontend/itlb/submodules/TlbStorageWrapper
frontend_tlbuffer --> TLBuffer --> ut_frontend/itlb/submodules/TLBuffer

View File

@ -1,18 +1,18 @@
../../rtl/rtl/DecodeUnitComp.sv
../../rtl/rtl/DecodeUnit.sv
../../rtl/rtl/indexedLSUopTable_1.sv
../../rtl/rtl/indexedLSUopTable_2.sv
../../rtl/rtl/indexedLSUopTable_3.sv
../../rtl/rtl/indexedLSUopTable_4.sv
../../rtl/rtl/indexedLSUopTable_5.sv
../../rtl/rtl/indexedLSUopTable_6.sv
../../rtl/rtl/indexedLSUopTable_7.sv
../../rtl/rtl/PreDecode.sv
../../rtl/rtl/UopInfoGen.sv
../../rtl/rtl/VecExceptionGen.sv
../../rtl/rtl/VTypeGen.sv
../../rtl/rtl/strdiedLSNumOfUopTable.sv
../../rtl/rtl/indexedLSNumOfUopTable.sv
../../rtl/rtl/VsetModule.sv
../../rtl/rtl/FPDecoder.sv
../../rtl/rtl/RVCExpander.sv
rtl/rtl/DecodeUnitComp.sv
rtl/rtl/DecodeUnit.sv
rtl/rtl/indexedLSUopTable_1.sv
rtl/rtl/indexedLSUopTable_2.sv
rtl/rtl/indexedLSUopTable_3.sv
rtl/rtl/indexedLSUopTable_4.sv
rtl/rtl/indexedLSUopTable_5.sv
rtl/rtl/indexedLSUopTable_6.sv
rtl/rtl/indexedLSUopTable_7.sv
rtl/rtl/PreDecode.sv
rtl/rtl/UopInfoGen.sv
rtl/rtl/VecExceptionGen.sv
rtl/rtl/VTypeGen.sv
rtl/rtl/strdiedLSNumOfUopTable.sv
rtl/rtl/indexedLSNumOfUopTable.sv
rtl/rtl/VsetModule.sv
rtl/rtl/FPDecoder.sv
rtl/rtl/RVCExpander.sv

View File

@ -1,45 +1,45 @@
../../rtl/rtl/Arbiter8_TLBundleD.sv
../../rtl/rtl/Queue2_TLBundleA.sv
../../rtl/rtl/Queue2_TLBundleA_1.sv
../../rtl/rtl/Queue2_TLBundleA_13.sv
../../rtl/rtl/Queue2_TLBundleA_2.sv
../../rtl/rtl/Queue2_TLBundleA_25.sv
../../rtl/rtl/Queue2_TLBundleA_26.sv
../../rtl/rtl/Queue2_TLBundleA_4.sv
../../rtl/rtl/Queue2_TLBundleA_6.sv
../../rtl/rtl/Queue2_TLBundleA_8.sv
../../rtl/rtl/Queue2_TLBundleA_9.sv
../../rtl/rtl/Queue2_TLBundleB.sv
../../rtl/rtl/Queue2_TLBundleB_1.sv
../../rtl/rtl/Queue2_TLBundleC.sv
../../rtl/rtl/Queue2_TLBundleC_1.sv
../../rtl/rtl/Queue2_TLBundleD.sv
../../rtl/rtl/Queue2_TLBundleD_1.sv
../../rtl/rtl/Queue2_TLBundleD_13.sv
../../rtl/rtl/Queue2_TLBundleD_2.sv
../../rtl/rtl/Queue2_TLBundleD_26.sv
../../rtl/rtl/Queue2_TLBundleD_4.sv
../../rtl/rtl/Queue2_TLBundleD_6.sv
../../rtl/rtl/Queue2_TLBundleD_8.sv
../../rtl/rtl/Queue2_TLBundleE.sv
../../rtl/rtl/Queue2_TLBundleE_1.sv
../../rtl/rtl/TLBFA.sv
../../rtl/rtl/TLBFA_1.sv
../../rtl/rtl/TLBFA_2.sv
../../rtl/rtl/TLBFA_3.sv
../../rtl/rtl/TLBNonBlock.sv
../../rtl/rtl/TLBNonBlock_1.sv
../../rtl/rtl/TLBNonBlock_2.sv
../../rtl/rtl/TLBuffer.sv
../../rtl/rtl/TLBuffer_1.sv
../../rtl/rtl/TLBuffer_14.sv
../../rtl/rtl/TLBuffer_16.sv
../../rtl/rtl/TLBuffer_17.sv
../../rtl/rtl/TLBuffer_2.sv
../../rtl/rtl/TLBuffer_3.sv
../../rtl/rtl/TLBuffer_7.sv
../../rtl/rtl/TLBuffer_9.sv
../../rtl/rtl/DelayN_9.sv
../../rtl/rtl/DelayN_10.sv
../../rtl/rtl/DelayN_1.sv
../../rtl/rtl/TlbStorageWrapper.sv
rtl/rtl/Arbiter8_TLBundleD.sv
rtl/rtl/Queue2_TLBundleA.sv
rtl/rtl/Queue2_TLBundleA_1.sv
rtl/rtl/Queue2_TLBundleA_13.sv
rtl/rtl/Queue2_TLBundleA_2.sv
rtl/rtl/Queue2_TLBundleA_25.sv
rtl/rtl/Queue2_TLBundleA_26.sv
rtl/rtl/Queue2_TLBundleA_4.sv
rtl/rtl/Queue2_TLBundleA_6.sv
rtl/rtl/Queue2_TLBundleA_8.sv
rtl/rtl/Queue2_TLBundleA_9.sv
rtl/rtl/Queue2_TLBundleB.sv
rtl/rtl/Queue2_TLBundleB_1.sv
rtl/rtl/Queue2_TLBundleC.sv
rtl/rtl/Queue2_TLBundleC_1.sv
rtl/rtl/Queue2_TLBundleD.sv
rtl/rtl/Queue2_TLBundleD_1.sv
rtl/rtl/Queue2_TLBundleD_13.sv
rtl/rtl/Queue2_TLBundleD_2.sv
rtl/rtl/Queue2_TLBundleD_26.sv
rtl/rtl/Queue2_TLBundleD_4.sv
rtl/rtl/Queue2_TLBundleD_6.sv
rtl/rtl/Queue2_TLBundleD_8.sv
rtl/rtl/Queue2_TLBundleE.sv
rtl/rtl/Queue2_TLBundleE_1.sv
rtl/rtl/TLBFA.sv
rtl/rtl/TLBFA_1.sv
rtl/rtl/TLBFA_2.sv
rtl/rtl/TLBFA_3.sv
rtl/rtl/TLBNonBlock.sv
rtl/rtl/TLBNonBlock_1.sv
rtl/rtl/TLBNonBlock_2.sv
rtl/rtl/TLBuffer.sv
rtl/rtl/TLBuffer_1.sv
rtl/rtl/TLBuffer_14.sv
rtl/rtl/TLBuffer_16.sv
rtl/rtl/TLBuffer_17.sv
rtl/rtl/TLBuffer_2.sv
rtl/rtl/TLBuffer_3.sv
rtl/rtl/TLBuffer_7.sv
rtl/rtl/TLBuffer_9.sv
rtl/rtl/DelayN_9.sv
rtl/rtl/DelayN_10.sv
rtl/rtl/DelayN_1.sv
rtl/rtl/TlbStorageWrapper.sv

View File

@ -1 +1 @@
../../rtl/rtl/TLBFA.sv
rtl/rtl/TLBFA.sv

View File

@ -1,4 +1,4 @@
../../rtl/rtl/Queue2_TLBundleA.sv
../../rtl/rtl/Queue2_TLBundleD.sv
../../rtl/rtl/ram_2x280.sv
../../rtl/rtl/ram_2x354.sv
rtl/rtl/Queue2_TLBundleA.sv
rtl/rtl/Queue2_TLBundleD.sv
rtl/rtl/ram_2x280.sv
rtl/rtl/ram_2x354.sv

View File

@ -22,7 +22,7 @@ import toffee.funcov as fc
from dut.TLB import *
from .itlb_consts import *
from queue import Queue
from comm import get_version_checker, get_out_dir
from comm import get_version_checker, get_out_dir, UT_FCOV
from toffee_test.reporter import set_func_coverage, set_line_coverage
# Set the toffee log level to ERROR
@ -32,7 +32,12 @@ toffee.setup_logging(toffee.ERROR)
version_check = get_version_checker("openxiangshan-kmh-*")
# Create a function coverage group
group = fc.CovGroup("itlb_test")
g = fc.CovGroup(UT_FCOV("../../../CLASSIC"))
def init_itlb_funcov(tlb, g: fc.CovGroup):
"""Add watch points to collect function coverage"""
# TODO: add watchpoint here
@pytest.fixture()
def tlb_fixture(request):
@ -49,13 +54,14 @@ def tlb_fixture(request):
waveform_filename=wave_file,
coverage_filename=coverage_file)
tlb = TLBWrapper(dut)
init_itlb_funcov(tlb, g)
yield tlb
tlb.dut.Finish()
set_line_coverage(request, coverage_file)
set_func_coverage(request, group)
group.clear()
set_func_coverage(request, g)
g.clear()
class ControlBundle(toffee.Bundle):
signals = [

View File

@ -23,13 +23,13 @@ def test_req_from_icache_min_vaddr(tlb_fixture):
# set default value
tlb.set_default_value()
# add function point
group.add_watch_point(tlb.ptw_req_0.vpn,
g.add_watch_point(tlb.ptw_req_0.vpn,
{"ptw_req_0_vpn_1": toffee.funcov.Eq(0)}, name = "ptw_req_0_vpn_1")
group.add_watch_point(tlb.ptw_req_1.vpn,
g.add_watch_point(tlb.ptw_req_1.vpn,
{"ptw_req_1_vpn_1": toffee.funcov.Eq(0)}, name = "ptw_req_1_vpn_1")
# add clock
tlb.dut.xclock.StepRis(lambda _: group.sample())
tlb.dut.xclock.StepRis(lambda _: g.sample())
# start
for _ in range(1000):
# add signal