forked from XS-MLVP/env-xs-ov-00-bpu
515 lines
24 KiB
Python
515 lines
24 KiB
Python
#from mlvp import Bundle, Signals
|
|
from mlvp import *
|
|
import mlvp
|
|
|
|
from config import *
|
|
import os
|
|
os.sys.path.append(TESTS_PATH)
|
|
os.sys.path.append(DUT_PATH)
|
|
|
|
from UT_Predictor import *
|
|
import random
|
|
|
|
ENV_PATH = os.path.dirname(os.path.abspath(__file__))+"/../"
|
|
os.sys.path.append(ENV_PATH)
|
|
|
|
from mlvp.agent import *
|
|
from env.bpu_bundle import *
|
|
|
|
###########################################################################################
|
|
#################################################### Agent ################################
|
|
###########################################################################################
|
|
|
|
class SubPrediCtrlAgent(Agent):
|
|
#Self-define var
|
|
en_dict = {
|
|
'ubtb_en' : 1,
|
|
'btb_en' : 1,
|
|
'tage_en' : 1,
|
|
'sc_en' : 1,
|
|
'ras_en' : 1
|
|
}
|
|
|
|
def __init__(self, bundle: SubPrediCtrlBundle):
|
|
super().__init__(bundle.step)
|
|
self.bundle = bundle
|
|
|
|
#Self-define func
|
|
@driver_method()
|
|
async def reset(self, step=1, reset_vector=0x1000):
|
|
self.bundle.set_all(0)
|
|
self.bundle.reset.value = 1
|
|
self.bundle.io_reset_vector.value = reset_vector
|
|
await self.bundle.step(step)
|
|
self.bundle.reset.value = 0
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
@driver_method()
|
|
async def set_sub_predic_ctrl_en(self, en_dict: dict = en_dict):
|
|
# async def set_sub_predic_ctrl_en(self,dut, en_dict: dict):
|
|
print("set_sub_predic_ctrl_en Begin exec")
|
|
# mlvp.start_clock(dut)
|
|
|
|
self.bundle.io_ctrl_ubtb_enable.value = en_dict['ubtb_en']
|
|
self.bundle.io_ctrl_btb_enable.value = en_dict['btb_en']
|
|
self.bundle.io_ctrl_tage_enable.value = en_dict['tage_en']
|
|
self.bundle.io_ctrl_sc_enable.value = en_dict['sc_en']
|
|
self.bundle.io_ctrl_ras_enable.value = en_dict['ras_en']
|
|
# why the clock is sync with DUT's clock
|
|
await self.bundle.step()
|
|
|
|
## 2 Can't use monitor_method
|
|
@monitor_method()
|
|
async def mon_ubtb_enable(self):
|
|
if self.bundle.io_ctrl_ubtb_enable.value > 0:
|
|
print(self.bundle.io_ctrl_ubtb_enable.value)
|
|
return self.bundle.as_dict()
|
|
|
|
## update_FTB_entry Signals
|
|
class Ftq2BpuUpdateFtbEntryAgent(Agent):
|
|
#Self-define var
|
|
update_ftb_entry_dict = {
|
|
'ftb_entry_valid' : 1,
|
|
'tailSlot_valid' : 1,
|
|
'tailSlot_tarStat' : 0b10,
|
|
'tailSlot_sharing' : 1,
|
|
'tailSlot_offset' : 0b0100,
|
|
'tailSlot_lower' : 0x20,
|
|
'pftAddr' : 0b1000,
|
|
'may_be_rvi_call' : 1,
|
|
'isRet' : 1,
|
|
'isJalr' : 1,
|
|
'isCall' : 1,
|
|
'carry' : 1,
|
|
'always_taken_0' : 1,
|
|
'always_taken_1' : 1,
|
|
|
|
'brSlots_0_valid' : 1,
|
|
'brSlots_0_tarStat' : 0b10,
|
|
'brSlots_0_sharing' : 1,
|
|
'brSlots_0_offset' : 0b0100,
|
|
'brSlots_0_lower' : 0x200
|
|
}
|
|
|
|
def __init__(self,bundle: Ftq2BpuUpdateFtbEntryBundle):
|
|
super().__init__(bundle.step)
|
|
self.bundle = bundle
|
|
|
|
@driver_method()
|
|
async def reset(self, step=1, reset_vector=0x1000):
|
|
self.bundle.set_all(0)
|
|
self.bundle.reset.value = 1
|
|
self.bundle.io_reset_vector.value = reset_vector
|
|
await self.bundle.step(step)
|
|
self.bundle.reset.value = 0
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
@driver_method()
|
|
async def set_update_ftb_entry_value(self, update_pc = 0x1280, update_ftb_entry_dict: dict = update_ftb_entry_dict):
|
|
#demo update_ftb_entry_dict
|
|
self.bundle.io_ftq_to_bpu_update_valid.value = 1
|
|
self.bundle.io_ftq_to_bpu_update_bits_pc.value = update_pc
|
|
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_valid.value = update_ftb_entry_dict['ftb_entry_valid']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_tailSlot_valid.value = update_ftb_entry_dict['tailSlot_valid']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_tailSlot_offset.value = update_ftb_entry_dict['tailSlot_offset']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_tailSlot_lower.value = update_ftb_entry_dict['tailSlot_lower']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_tailSlot_tarStat.value = update_ftb_entry_dict['tailSlot_tarStat']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_tailSlot_sharing.value = update_ftb_entry_dict['tailSlot_sharing']
|
|
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_brSlots_0_valid.value = update_ftb_entry_dict['brSlots_0_valid']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_brSlots_0_offset.value = update_ftb_entry_dict['brSlots_0_offset']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_brSlots_0_lower.value = update_ftb_entry_dict['brSlots_0_lower']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_brSlots_0_sharing.value = update_ftb_entry_dict['brSlots_0_sharing']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_brSlots_0_tarStat.value = update_ftb_entry_dict['brSlots_0_tarStat']
|
|
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_pftAddr.value = update_ftb_entry_dict['pftAddr']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_carry.value = update_ftb_entry_dict['carry']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_isCall.value = update_ftb_entry_dict['isCall']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_isRet.value = update_ftb_entry_dict['isRet']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_isJalr.value = update_ftb_entry_dict['isJalr']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_last_may_be_rvi_call.value = update_ftb_entry_dict['may_be_rvi_call']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_always_taken_0.value= update_ftb_entry_dict['always_taken_0']
|
|
self.bundle.io_ftq_to_bpu_update_bits_ftb_entry_always_taken_1.value= update_ftb_entry_dict['always_taken_1']
|
|
await self.bundle.step(1)
|
|
self.bundle.set_all(0)
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
#@driver_method()
|
|
#async def set_update_valid_and_pc(self, update_valid = 1, update_bits_pc = 0x2000):
|
|
# self.bundle.io_ftq_to_bpu_update_valid.value = update_valid
|
|
# self.bundle.io_ftq_to_bpu_update_bits_pc.value = update_bits_pc
|
|
# await self.bundle.step(1)
|
|
# self.bundle.io_ftq_to_bpu_update_valid.value = 0
|
|
# self.bundle.io_ftq_to_bpu_update_bits_pc.value = 0
|
|
|
|
class Ftq2BpuUpdateOtherAgent(Agent):
|
|
## Varia
|
|
update_other_dict = {
|
|
'cfi_idx_valid' : 1,
|
|
'cfi_idx_bits' : 0b1000,
|
|
'br_taken_mask_0' : 1,
|
|
'br_taken_mask_1' : 1,
|
|
'jmp_taken' : 1,
|
|
'mispred_mask_0' : 1,
|
|
'mispred_mask_1' : 1,
|
|
'mispred_mask_2' : 1,
|
|
'old_entry' : 1,
|
|
'meta' : 1,
|
|
'full_target' : 1
|
|
}
|
|
##__init__
|
|
def __init__(self,bundle: Ftq2BpuUpdateOtherBundle):
|
|
super().__init__(bundle.step)
|
|
self.bundle = bundle
|
|
|
|
@driver_method()
|
|
async def reset(self, step=1, reset_vector=0x1000):
|
|
self.bundle.set_all(0)
|
|
self.bundle.reset.value = 1
|
|
self.bundle.io_reset_vector.value = reset_vector
|
|
await self.bundle.step(step)
|
|
self.bundle.reset.value = 0
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
@driver_method()
|
|
async def set_update_other_value(self,update_pc = 0x1280 ,update_other_dict: dict = update_other_dict ):
|
|
#demo update_ftb_entry_dict
|
|
self.bundle.io_ftq_to_bpu_update_valid.value = 1
|
|
self.bundle.io_ftq_to_bpu_update_bits_pc.value = update_pc
|
|
|
|
self.bundle.io_ftq_to_bpu_update_bits_cfi_idx_valid.value = update_other_dict['cfi_idx_valid']
|
|
self.bundle.io_ftq_to_bpu_update_bits_cfi_idx_bits.value = update_other_dict['cfi_idx_bits']
|
|
self.bundle.io_ftq_to_bpu_update_bits_br_taken_mask_0.value = update_other_dict['br_taken_mask_0']
|
|
self.bundle.io_ftq_to_bpu_update_bits_br_taken_mask_1.value = update_other_dict['br_taken_mask_1']
|
|
self.bundle.io_ftq_to_bpu_update_bits_jmp_taken.value = update_other_dict['jmp_taken']
|
|
self.bundle.io_ftq_to_bpu_update_bits_mispred_mask_0.value = update_other_dict['mispred_mask_0']
|
|
self.bundle.io_ftq_to_bpu_update_bits_mispred_mask_1.value = update_other_dict['mispred_mask_1']
|
|
self.bundle.io_ftq_to_bpu_update_bits_mispred_mask_2.value = update_other_dict['mispred_mask_2']
|
|
self.bundle.io_ftq_to_bpu_update_bits_old_entry.value = update_other_dict['old_entry']
|
|
self.bundle.io_ftq_to_bpu_update_bits_meta.value = update_other_dict['meta']
|
|
self.bundle.io_ftq_to_bpu_update_bits_full_target.value = update_other_dict['full_target']
|
|
await self.bundle.step(1)
|
|
self.bundle.set_all(0)
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
|
|
class Ftq2BpuUpdateFoldHistAgent(Agent):
|
|
## Varia
|
|
update_fold_hist_dict = {
|
|
'folded_hist_1' : 0b1111,
|
|
'folded_hist_2' : 0b1111,
|
|
'folded_hist_3' : 0b1111,
|
|
'folded_hist_4' : 0b1111,
|
|
'folded_hist_5' : 0b1111,
|
|
'folded_hist_6' : 0b1111,
|
|
'folded_hist_7' : 0b1111,
|
|
'folded_hist_8' : 0b1111,
|
|
'folded_hist_9' : 0b1111,
|
|
'folded_hist_10' : 0b1011,
|
|
'folded_hist_11' : 0b1011,
|
|
'folded_hist_12' : 0b1011,
|
|
'folded_hist_13' : 0b1011,
|
|
'folded_hist_14' : 0b1011,
|
|
'folded_hist_15' : 0b1011,
|
|
'folded_hist_16' : 0b1011,
|
|
'folded_hist_17' : 0b1011
|
|
}
|
|
## Method
|
|
def __init__(self,bundle: Ftq2BpuUpdateFoldHistBundle):
|
|
super().__init__(bundle.step)
|
|
self.bundle = bundle
|
|
|
|
@driver_method()
|
|
async def reset(self, step=1, reset_vector=0x1000):
|
|
self.bundle.set_all(0)
|
|
self.bundle.reset.value = 1
|
|
self.bundle.io_reset_vector.value = reset_vector
|
|
await self.bundle.step(step)
|
|
self.bundle.reset.value = 0
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
@driver_method()
|
|
async def set_update_fold_hist_value(self, update_pc = 0x1280, hist_dict: dict = update_fold_hist_dict):
|
|
self.bundle.io_ftq_to_bpu_update_valid.value = 1
|
|
self.bundle.io_ftq_to_bpu_update_bits_pc.value = update_pc
|
|
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_17_folded_hist.value = hist_dict['folded_hist_17']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_16_folded_hist.value = hist_dict['folded_hist_16']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_15_folded_hist.value = hist_dict['folded_hist_15']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_14_folded_hist.value = hist_dict['folded_hist_14']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_13_folded_hist.value = hist_dict['folded_hist_13']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_12_folded_hist.value = hist_dict['folded_hist_12']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_11_folded_hist.value = hist_dict['folded_hist_11']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_10_folded_hist.value = hist_dict['folded_hist_10']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_9_folded_hist.value = hist_dict['folded_hist_9']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_8_folded_hist.value = hist_dict['folded_hist_8']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_7_folded_hist.value = hist_dict['folded_hist_7']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_6_folded_hist.value = hist_dict['folded_hist_6']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_5_folded_hist.value = hist_dict['folded_hist_5']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_4_folded_hist.value = hist_dict['folded_hist_4']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_3_folded_hist.value = hist_dict['folded_hist_3']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_2_folded_hist.value = hist_dict['folded_hist_2']
|
|
self.bundle.io_ftq_to_bpu_update_bits_spec_info_folded_hist_hist_1_folded_hist.value = hist_dict['folded_hist_1']
|
|
await self.bundle.step(1)
|
|
self.bundle.set_all(0)
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
|
|
class Ftq2BpuRedirectOtherAgent(Agent):
|
|
## Varia
|
|
rediretc_ohter_dict = {
|
|
'level' : 1,
|
|
'cfiUpdate_pc' : 0x1280,
|
|
'cfiUpdate_pd_isRVC' : 1,
|
|
'cfiUpdate_pd_isCall' : 1,
|
|
'cfiUpdate_pd_isRet' : 1,
|
|
'cfiUpdate_ssp' : 1,
|
|
'cfiUpdate_sctr' : 1,
|
|
'cfiUpdate_TOSW_flag' : 1,
|
|
'cfiUpdate_TOSW_value' : 1,
|
|
'cfiUpdate_TOSR_flag' : 1,
|
|
'cfiUpdate_TOSR_value' : 1,
|
|
'cfiUpdate_NOS_flag' : 1,
|
|
'cfiUpdate_NOS_value' : 1,
|
|
|
|
'cfiUpdate_lastBrNumOH' : 1,
|
|
'cfiUpdate_histPtr_flag': 1,
|
|
'cfiUpdate_histPtr_value':1,
|
|
'cfiUpdate_target' : 1,
|
|
'cfiUpdate_taken' : 1,
|
|
'cfiUpdate_shift' : 1,
|
|
'cfiUpdate_addIntoHist' : 1
|
|
}
|
|
|
|
## Method
|
|
def __init__(self,bundle: Ftq2BpuRedirectOtherBundle):
|
|
super().__init__(bundle.step)
|
|
self.bundle = bundle
|
|
|
|
@driver_method()
|
|
async def reset(self, step=1, reset_vector=0x1000):
|
|
self.bundle.set_all(0)
|
|
self.bundle.reset.value = 1
|
|
self.bundle.io_reset_vector.value = reset_vector
|
|
await self.bundle.step(step)
|
|
self.bundle.reset.value = 0
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
@driver_method()
|
|
async def set_redirect_other_value(self, rediretc_ohter_dict: dict = rediretc_ohter_dict):
|
|
self.bundle.io_ftq_to_bpu_redirect_valid.value = 1
|
|
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_level.value = rediretc_ohter_dict['level']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_pc.value = rediretc_ohter_dict['cfiUpdate_pc']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_pd_isRVC.value = rediretc_ohter_dict['cfiUpdate_pd_isRVC']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_pd_isCall.value = rediretc_ohter_dict['cfiUpdate_pd_isCall']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_pd_isRet.value = rediretc_ohter_dict['cfiUpdate_pd_isRet']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_ssp.value = rediretc_ohter_dict['cfiUpdate_ssp']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_sctr.value = rediretc_ohter_dict['cfiUpdate_sctr']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_TOSW_flag.value = rediretc_ohter_dict['cfiUpdate_TOSW_flag']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_TOSW_value.value = rediretc_ohter_dict['cfiUpdate_TOSW_value']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_TOSR_flag.value = rediretc_ohter_dict['cfiUpdate_TOSR_flag']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_TOSR_value.value = rediretc_ohter_dict['cfiUpdate_TOSR_value']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_NOS_flag.value = rediretc_ohter_dict['cfiUpdate_NOS_flag']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_NOS_value.value = rediretc_ohter_dict['cfiUpdate_NOS_value']
|
|
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_lastBrNumOH.value = rediretc_ohter_dict['cfiUpdate_lastBrNumOH']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_histPtr_flag.value= rediretc_ohter_dict['cfiUpdate_histPtr_flag']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_histPtr_value.value=rediretc_ohter_dict['cfiUpdate_histPtr_value']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_target.value = rediretc_ohter_dict['cfiUpdate_target']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_taken.value = rediretc_ohter_dict['cfiUpdate_taken']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_shift.value = rediretc_ohter_dict['cfiUpdate_shift']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_addIntoHist.value = rediretc_ohter_dict['cfiUpdate_addIntoHist']
|
|
await self.bundle.step(1)
|
|
self.bundle.set_all(0)
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
|
|
class Ftq2BpuRedirectFoldHistAgent(Agent):
|
|
## Varia
|
|
redirect_fold_hist_dict = {
|
|
'cfiUpdate_folded_hist_0' : 0b100,
|
|
'cfiUpdate_folded_hist_1' : 0b100,
|
|
'cfiUpdate_folded_hist_2' : 0b100,
|
|
'cfiUpdate_folded_hist_3' : 0b100,
|
|
'cfiUpdate_folded_hist_4' : 0b100,
|
|
'cfiUpdate_folded_hist_5' : 0b100,
|
|
'cfiUpdate_folded_hist_6' : 0b100,
|
|
'cfiUpdate_folded_hist_7' : 0b100,
|
|
'cfiUpdate_folded_hist_8' : 0b100,
|
|
'cfiUpdate_folded_hist_9' : 0b100,
|
|
|
|
'cfiUpdate_folded_hist_10': 0b100,
|
|
'cfiUpdate_folded_hist_11': 0b100,
|
|
'cfiUpdate_folded_hist_12': 0b100,
|
|
'cfiUpdate_folded_hist_13': 0b100,
|
|
'cfiUpdate_folded_hist_14': 0b100,
|
|
'cfiUpdate_folded_hist_15': 0b100,
|
|
'cfiUpdate_folded_hist_16': 0b100,
|
|
'cfiUpdate_folded_hist_17': 0b100
|
|
}
|
|
|
|
## Method
|
|
def __init__(self,bundle: Ftq2BpuRedirectFoldHistBundle):
|
|
super().__init__(bundle.step)
|
|
self.bundle = bundle
|
|
|
|
@driver_method()
|
|
async def reset(self, step=1, reset_vector=0x1000):
|
|
self.bundle.set_all(0)
|
|
self.bundle.reset.value = 1
|
|
self.bundle.io_reset_vector.value = reset_vector
|
|
await self.bundle.step(step)
|
|
self.bundle.reset.value = 0
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
@driver_method()
|
|
async def set_redirect_fold_hist_value(self, fold_hist_dict: dict = redirect_fold_hist_dict):
|
|
self.bundle.io_ftq_to_bpu_redirect_valid.value = 1
|
|
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_17_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_17']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_16_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_16']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_15_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_15']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_14_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_14']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_13_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_13']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_12_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_12']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_11_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_11']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_10_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_10']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_9_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_9']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_8_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_8']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_7_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_7']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_6_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_6']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_5_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_5']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_4_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_4']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_3_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_3']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_2_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_2']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_1_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_1']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_folded_hist_hist_0_folded_hist.value = fold_hist_dict['cfiUpdate_folded_hist_0']
|
|
await self.bundle.step(1)
|
|
self.bundle.set_all(0)
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
|
|
class Ftq2BpuRedirectAfhobAgent(Agent):
|
|
## Varia
|
|
redirect_afhob_dict = {
|
|
'afhob_0_bits_0' : 0b1,
|
|
'afhob_0_bits_1' : 0b1,
|
|
'afhob_0_bits_2' : 0b1,
|
|
'afhob_0_bits_3' : 0b1,
|
|
'afhob_1_bits_0' : 0b1,
|
|
'afhob_1_bits_1' : 0b1,
|
|
'afhob_1_bits_2' : 0b1,
|
|
'afhob_1_bits_3' : 0b1,
|
|
'afhob_2_bits_0' : 0b1,
|
|
'afhob_2_bits_1' : 0b1,
|
|
'afhob_2_bits_2' : 0b1,
|
|
'afhob_2_bits_3' : 0b1,
|
|
'afhob_3_bits_0' : 0b1,
|
|
'afhob_3_bits_1' : 0b1,
|
|
'afhob_3_bits_2' : 0b1,
|
|
'afhob_3_bits_3' : 0b1,
|
|
'afhob_4_bits_0' : 0b1,
|
|
'afhob_4_bits_1' : 0b1,
|
|
'afhob_4_bits_2' : 0b1,
|
|
'afhob_5_bits_0' : 0b1,
|
|
'afhob_5_bits_1' : 0b1,
|
|
'afhob_5_bits_2' : 0b1,
|
|
'afhob_5_bits_3' : 0b1
|
|
}
|
|
|
|
## Method
|
|
def __init__(self,bundle: Ftq2BpuRedirectAfhobBundle):
|
|
super().__init__(bundle.step)
|
|
self.bundle = bundle
|
|
|
|
@driver_method()
|
|
async def reset(self, step=1, reset_vector=0x1000):
|
|
self.bundle.set_all(0)
|
|
self.bundle.reset.value = 1
|
|
self.bundle.io_reset_vector.value = reset_vector
|
|
await self.bundle.step(step)
|
|
self.bundle.reset.value = 0
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
@driver_method()
|
|
async def set_redirect_afhob_value(self, afhob_dict: dict = redirect_afhob_dict):
|
|
self.bundle.io_ftq_to_bpu_redirect_valid.value = 1
|
|
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_5_bits_0.value = afhob_dict['afhob_5_bits_0']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_5_bits_1.value = afhob_dict['afhob_5_bits_1']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_5_bits_2.value = afhob_dict['afhob_5_bits_2']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_5_bits_3.value = afhob_dict['afhob_5_bits_3']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_4_bits_0.value = afhob_dict['afhob_4_bits_0']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_4_bits_1.value = afhob_dict['afhob_4_bits_1']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_4_bits_2.value = afhob_dict['afhob_4_bits_2']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_3_bits_0.value = afhob_dict['afhob_3_bits_0']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_3_bits_1.value = afhob_dict['afhob_3_bits_1']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_3_bits_2.value = afhob_dict['afhob_3_bits_2']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_3_bits_3.value = afhob_dict['afhob_3_bits_3']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_2_bits_0.value = afhob_dict['afhob_2_bits_0']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_2_bits_1.value = afhob_dict['afhob_2_bits_1']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_2_bits_2.value = afhob_dict['afhob_2_bits_2']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_2_bits_3.value = afhob_dict['afhob_2_bits_3']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_1_bits_0.value = afhob_dict['afhob_1_bits_0']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_1_bits_1.value = afhob_dict['afhob_1_bits_1']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_1_bits_2.value = afhob_dict['afhob_1_bits_2']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_1_bits_3.value = afhob_dict['afhob_1_bits_3']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_0_bits_0.value = afhob_dict['afhob_0_bits_0']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_0_bits_1.value = afhob_dict['afhob_0_bits_1']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_0_bits_2.value = afhob_dict['afhob_0_bits_2']
|
|
self.bundle.io_ftq_to_bpu_redirect_bits_cfiUpdate_afhob_afhob_0_bits_3.value = afhob_dict['afhob_0_bits_3']
|
|
await self.bundle.step(1)
|
|
self.bundle.set_all(0)
|
|
self.bundle.io_bpu_to_ftq_resp_ready.value = 1
|
|
|
|
|
|
################################ Only for agent_test#################0
|
|
async def agent_test():
|
|
sub_predic_ctrl_bundle = SubPrediCtrlBundle()
|
|
dut: DUTPredictor = DUTPredictor()
|
|
sub_predic_ctrl_bundle.bind(dut)
|
|
|
|
sub_predi_ctrl_agent = SubPrediCtrlAgent(sub_predic_ctrl_bundle)
|
|
|
|
enable_dict = {
|
|
'ubtb_en' : 1,
|
|
'btb_en' : 1,
|
|
'tage_en' : 1,
|
|
'sc_en' : 1,
|
|
'ras_en' : 1
|
|
}
|
|
# print(enable_dict)
|
|
|
|
## 1 Can't use driver_method
|
|
mlvp.run(sub_predi_ctrl_agent.set_sub_predic_ctrl_en(dut, enable_dict))
|
|
|
|
spec_info_dict = {
|
|
'spec_info_folded_hist_hist_17_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_16_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_15_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_14_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_13_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_12_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_11_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_10_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_9_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_8_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_7_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_6_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_5_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_4_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_3_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_2_folded_hist' : 1,
|
|
'spec_info_folded_hist_hist_1_folded_hist' : 1
|
|
}
|
|
|
|
spec_info_dict['spec_info_folded_hist_hist_1_folded_hist'] = 2
|
|
print(spec_info_dict['spec_info_folded_hist_hist_1_folded_hist'])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print("bpu_agent exec!")
|
|
# mlvp.run(agent_test())
|