forked from XS-MLVP/env-xs-ov-00-bpu
add ITTAGE useful bit test
This commit is contained in:
parent
e09a48f592
commit
83efaf3b9c
|
@ -0,0 +1,112 @@
|
|||
import sys
|
||||
sys.path.append("../")
|
||||
import os
|
||||
os.sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/..")
|
||||
|
||||
from ITTAGE_raw.test_raw import *
|
||||
|
||||
import mlvp.funcov as fc
|
||||
from mlvp.reporter import set_func_coverage, set_line_coverage
|
||||
|
||||
from UT_ITTage import *
|
||||
|
||||
|
||||
def run_test_useful(ittage: DUTITTage, provider: str, altProvider: str, debug=False):
|
||||
assert(len(altProvider) == 3 and len(provider) == 3)
|
||||
assert(int(altProvider, 2) < int(provider, 2))
|
||||
assert(int(provider, 2) <= 4)
|
||||
assert(int(altProvider, 2) >= 0)
|
||||
pc = random.randint(0, 0x1ffffffffff)
|
||||
ftb_target = 0x11111111
|
||||
targets = [0x111ff11ff11, 0x122ff22ff22, 0x133ff33ff33]
|
||||
folded_hists = FoldedHists()
|
||||
folded_hists.reinit_random_gh()
|
||||
cfi_idx = random.randint(0, 15) # 0~15
|
||||
mispred = 1
|
||||
metas = []
|
||||
|
||||
print(f'-------------- test table-{int(provider, 2)} as provider and table-{int(altProvider, 2)} as alt provider --------------')
|
||||
if debug == True:
|
||||
print(f'pc={hex(pc)}')
|
||||
folded_hists.print()
|
||||
# generate a meta
|
||||
metas.append(drive_full_pred(ittage, pc, ftb_target, folded_hists))
|
||||
metas[0].check_provided('0').set_allocate_bits(altProvider)
|
||||
|
||||
# mispred 1: allocat new table item, this time the item is set as provider
|
||||
# providerCtr==2'b10, providerTarget==targets[0]
|
||||
drive_full_update(ittage, pc, folded_hists, targets[0], cfi_idx, mispred, metas[0])
|
||||
metas.append(drive_full_pred(ittage, pc, ftb_target, folded_hists))
|
||||
if debug == True:
|
||||
print('----- Step-1 -----')
|
||||
metas[1].print()
|
||||
metas[1].check_provided('1').check_provider(altProvider).check_providerU('0')
|
||||
|
||||
# mispred 2: update with mispred set new provider in longest matched table, last item set as altprovider
|
||||
# providerCtr==2'b10, providerTarget==targets[1]
|
||||
# altProviderCtr==2'b01, altProviderTarget==targets[0] (altProvider has weak ctr)
|
||||
metas[1].set_allocate_bits(provider)
|
||||
drive_full_update(ittage, pc, folded_hists, targets[1], cfi_idx, mispred, metas[1])
|
||||
metas.append(drive_full_pred(ittage, pc, ftb_target, folded_hists))
|
||||
if debug == True:
|
||||
print('----- Step-2 -----')
|
||||
metas[2].print()
|
||||
metas[2].check_provided('1').check_provider(provider).check_providerU('0').check_providerCtr('10').check_providerTarget(targets[1])
|
||||
metas[2].check_altProvided('1').check_altProvider(altProvider).check_altProviderCtr('01').check_altProviderTarget(targets[0])
|
||||
|
||||
# provider and altProvider have different targets, correct prediction from provider should set providerU to 1'b1
|
||||
# providerCtr==2'b11, providerTarget==targets[1] (correct), useful==1
|
||||
# altProviderCtr==2'b01, altProviderTarget==targets[0] (incorrect)
|
||||
mispred=0
|
||||
metas[2].set_allocate_valid('0')
|
||||
drive_full_update(ittage, pc, folded_hists, targets[1], cfi_idx, mispred, metas[2])
|
||||
metas.append(drive_full_pred(ittage, pc, ftb_target, folded_hists))
|
||||
if debug == True:
|
||||
print('----- Step-3 -----')
|
||||
metas[3].print()
|
||||
metas[3].check_provided('1').check_provider(provider).check_providerU('1').check_providerCtr('11').check_providerTarget(targets[1])
|
||||
metas[3].check_altProvided('1').check_altProvider(altProvider).check_altProviderTarget(targets[0])
|
||||
|
||||
# provider and altProvider have different targets, incorrect prediction from provider should set providerU to 1'b0
|
||||
# providerCtr==2'b11, providerTarget==targets[1] (incorrect), useful==0
|
||||
# altProviderCtr==2'b01, altProviderTarget==targets[0] (incorrect)
|
||||
mispred=1
|
||||
metas[3].set_allocate_valid('0')
|
||||
drive_full_update(ittage, pc, folded_hists, targets[2], cfi_idx, mispred, metas[3])
|
||||
metas.append(drive_full_pred(ittage, pc, ftb_target, folded_hists))
|
||||
if debug == True:
|
||||
print('----- Step-4 -----')
|
||||
metas[4].print()
|
||||
metas[4].check_provided('1').check_provider(provider).check_providerU('0').check_providerCtr('10').check_providerTarget(targets[1])
|
||||
metas[4].check_altProvided('1').check_altProvider(altProvider).check_altProviderCtr('01').check_altProviderTarget(targets[0])
|
||||
|
||||
print(f'-------------- subtest end --------------')
|
||||
|
||||
|
||||
def test_ittage_useful():
|
||||
# test useful
|
||||
ittage = DUTITTage(waveform_filename='ittage-useful.fst', coverage_filename='ittage-useful.dat')
|
||||
reset_init(ittage)
|
||||
|
||||
print('========================== test ITTAGE useful bit ==========================')
|
||||
# table-0 as altProvider
|
||||
run_test_useful(ittage, '001', '000', True)
|
||||
run_test_useful(ittage, '010', '000')
|
||||
run_test_useful(ittage, '011', '000')
|
||||
run_test_useful(ittage, '100', '000')
|
||||
# table-1 as altProvider
|
||||
run_test_useful(ittage, '010', '001')
|
||||
run_test_useful(ittage, '011', '001')
|
||||
run_test_useful(ittage, '100', '001')
|
||||
# table-2 as altProvider
|
||||
run_test_useful(ittage, '011', '010')
|
||||
run_test_useful(ittage, '100', '010')
|
||||
# table-3 as altProvider
|
||||
run_test_useful(ittage, '100', '011')
|
||||
print('========================== test ITTAGE useful bit end ==========================')
|
||||
|
||||
ittage.finalize()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_ittage_useful()
|
Loading…
Reference in New Issue