Add number of mismatches exit code to cachesim scripts

This commit is contained in:
Jordan Carlin 2024-08-11 11:02:23 -07:00
parent e48d577545
commit e6ddebde72
No known key found for this signature in database
2 changed files with 20 additions and 8 deletions

View file

@ -192,7 +192,7 @@ class Cache:
return self.__str__()
if __name__ == "__main__":
def main():
parser = argparse.ArgumentParser(description="Simulates a L1 cache.")
parser.add_argument('numlines', type=int, help="The number of lines per way (a power of 2)", metavar="L")
parser.add_argument('numways', type=int, help="The number of ways (a power of 2)", metavar='W')
@ -206,7 +206,7 @@ if __name__ == "__main__":
args = parser.parse_args()
cache = Cache(args.numlines, args.numways, args.addrlen, args.taglen)
extfile = os.path.expanduser(args.file)
nofails = True
mismatches = 0
if args.perf:
hits = 0
@ -268,7 +268,7 @@ if __name__ == "__main__":
if not result == lninfo[2]:
print("Result mismatch at address", lninfo[0]+ ". Wally:", lninfo[2]+", Sim:", result)
nofails = False
mismatches += 1
if args.dist:
percent_loads = str(round(100*loads/totalops))
percent_stores = str(round(100*stores/totalops))
@ -279,5 +279,9 @@ if __name__ == "__main__":
ratio = round(hits/misses,3)
print("There were", hits, "hits and", misses, "misses. The hit/miss ratio was", str(ratio)+".")
if nofails:
print("SUCCESS! There were no mismatches between Wally and the sim.")
if mismatches == 0:
print("SUCCESS! There were no mismatches between Wally and the sim.")
return mismatches
if __name__ == '__main__':
exit(main())