-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_benchmarks.py
46 lines (41 loc) · 1.72 KB
/
run_benchmarks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from pymtl3 import *
from src.cl.ramp_core import RampCore
from src.common.consts import MEM_SIZE
from src.fl.util import get_mem
def scalar_multiply(niter):
# test unconditional jump without worrying about register renaming
dut = RampCore(data=get_mem("tests/input_files/test_scalar_multiply.bin", MEM_SIZE), memory_size=MEM_SIZE)
dut.apply(DefaultPassGroup(linetrace=False, vcdwave="vcd/test_ramp_core_scalar_multiply"))
dut.sim_reset()
# running program, until it is finished
idx_reg = dut.decode.register_rename.map_table[0x8]
val_reg = dut.decode.register_rename.map_table[0x6]
c = 0
c_bp = 0
try:
while dut.register_file.regs[idx_reg] < niter*4:
# print("cycle:", c,
# "prd:", dut.register_file.regs[idx_reg],
# "val:", dut.register_file.regs[val_reg].uint(),
# end = "\r")
print(c, [x.uint() for x in dut.register_file.regs])
idx_reg = dut.decode.register_rename.map_table[0x8]
val_reg = dut.decode.register_rename.map_table[0x6]
dut.sim_tick()
if dut.fetch_stage.pc < 0x28:
c_bp += 1
c += 1
except:
# while not input("continue: \r"):
# dut.sim_tick()
# checking results
for i in range(niter):
try:
assert dut.memory_unit.dram.mem[i] == i * 10
except AssertionError:
print([x.uint() for x in dut.memory_unit.dram.mem])
print(c)
assert dut.memory_unit.dram.mem[i] == i * 10
print(f"\n\ntotal cycles: {c}\n branch prediction cycles: {c_bp}\n iterations: {niter}")
if __name__ == "__main__":
scalar_multiply(1024)