add check_xxx functions for LastStageMeta

This commit is contained in:
llyyqq 2024-08-19 18:22:08 +08:00
parent 7e3872663f
commit 0a3d2fb8eb
1 changed files with 42 additions and 5 deletions

View File

@ -73,6 +73,12 @@ class FoldedHists:
return self.t4_fh, self.t4_fh1
def get_t5_fh(self):
return self.t5_fh, self.t5_fh1
def print(self):
print(f'folded history: table-0: {hex(self.t1_fh)}')
print(f' table-1: {hex(self.t2_fh)}')
print(f' table-2: {hex(self.t3_fh)} {hex(self.t3_fh1)}')
print(f' table-3: {hex(self.t4_fh)} {hex(self.t4_fh1)}')
print(f' table-4: {hex(self.t5_fh)} {hex(self.t5_fh1)}')
class LastStageMeta:
@ -97,53 +103,84 @@ class LastStageMeta:
def set_provided(self, provided: str):
assert(provided == '1' or provided == '0')
self.s3_provided = provided
return self
def set_provider(self, provider: str):
assert(len(provider) == 3)
self.s3_provider = provider
return self
def set_altProvided(self, provided: str):
assert(provided == '1' or provided == '0')
self.s3_altProvided = provided
return self
def set_altProvider(self, provider: str):
assert(len(provider) == 3)
self.s3_altProvider = provider
return self
def set_altDiffers(self, altDiffers: str):
assert(altDiffers == '0' or altDiffers == '1')
self.resp_meta_altDiffers = altDiffers
return self
def set_providerU(self, useful: str):
assert(useful == '0' or useful == '1')
self.s3_providerU = useful
return self
def set_providerCtr(self, ctr: str):
assert(len(ctr) == 2)
self.s3_providerCtr = ctr
return self
def set_altProviderCtr(self, ctr: str):
assert(len(ctr) == 2)
self.s3_altProviderCtr = ctr
return self
def set_allocate_valid(self, valid: str):
assert(valid == '0' or valid == '1')
self.resp_meta_allocate_valid_r = valid
return self
def set_allocate_bits(self, table: str):
assert(len(table) == 3)
self.resp_meta_allocate_bits_r = table
return self
def set_providerTarget(self, target: hex):
self.s3_providerTarget = bin(int(target))[2:].zfill(41)[:41]
return self
def set_altProviderTarget(self, target: hex):
self.s3_altProviderTarget = bin(int(target))[2:].zfill(41)[:41]
return self
def check_provided(self, provided: str):
if self.s3_provided != provided:
print(f'provided={self.s3_provided} should be {hex(provided)}')
print(f'\033[91m[ERROR]: provided={self.s3_provided} should be {provided}\033[0m')
return self
def check_provider(self, provider: str):
if self.s3_provider != provider:
print(f'provider={self.s3_provider} should be {hex(provider)}')
print(f'\033[91m[ERROR]: provider={self.s3_provider} should be {provider}\033[0m')
return self
def check_altProvided(self, provided: str):
if self.s3_altProvided != provided:
print(f'\033[91m[ERROR]: altProvided={self.s3_altProvided} should be {provided}\033[0m')
return self
def check_altProvider(self, provider: str):
if self.s3_altProvider != provider:
print(f'\033[91m[ERROR]: altProvider={self.s3_altProvider} should be {provider}\033[0m')
return self
def check_altDiffers(self, altDiffers: str):
if self.resp_meta_altDiffers != altDiffers:
print(f'\033[91m[ERROR]: altDiffers={self.resp_meta_altDiffers} should be {altDiffers}\033[0m')
return self
def check_providerCtr(self, ctr: str):
if self.s3_providerCtr != ctr:
print(f'providerCtr={self.s3_providerCtr} should be {hex(ctr)}')
print(f'\033[91m[ERROR]: providerCtr={self.s3_providerCtr} should be {ctr}\033[0m')
return self
def check_altProviderCtr(self, ctr: str):
if self.s3_altProviderCtr != ctr:
print(f'\033[91m[ERROR]: altProviderCtr={self.s3_altProviderCtr} should be {ctr}\033[0m')
return self
def check_providerTarget(self, target: hex):
if self.s3_providerTarget != hex(target):
print(f'providerTarget={self.s3_providerTarget} should be {hex(target)}')
print(f'\033[91m[ERROR]: providerTarget={self.s3_providerTarget} should be {hex(target)}\033[0m')
return self
def check_altProviderTarget(self, target: hex):
if self.s3_altProviderTarget != hex(target):
print(f'\033[91m[ERROR]: altProviderTarget={self.s3_altProviderTarget} should be {hex(target)}\033[0m')
return self
def dump_binary_str(self):