def check_regs(dut, sim, core, test, code):
- # int regs
- # TODO, split this out into "core-register-getter" function
- intregs = []
- for i in range(32):
- if core.regs.int.unary:
- rval = yield core.regs.int.regs[i].reg
- else:
- rval = yield core.regs.int.memory._array[i]
- intregs.append(rval)
- print("core int regs", list(map(hex, intregs)))
- # TODO, split this out into "sim-register-getter" function
- simregs = []
- for i in range(32):
- simregs.append(sim.gpr[i].asint())
- print("sim int regs", list(map(hex, simregs)))
+ # Get regs and compare
+ intregs = get_core_hdl_regs(dut, sim, core, test, code)
+ simregs = get_sim_regs(dut, sim, core, test, code)
+ compare_core_sim_regs(dut,simregs,intregs,code)
- # TODO, split this out into "compare-sim-regs-against-core-regs" function
- for i in range(32):
- simregval = simregs[i]
- dut.assertEqual(simregval, intregs[i],
- "int reg %d not equal %s. got %x expected %x" % \
- (i, repr(code), simregval, intregs[i]))
# TODO: exactly the same thing as above, except with CRs
# TODO: exactly the same thing with SPRs (later)
+def get_core_hdl_regs(dut, sim, core, test, code):
+ # int regs
+ # TODO, split this out into "core-register-getter" function
+ intregs = []
+ for i in range(32):
+ if core.regs.int.unary:
+ rval = yield core.regs.int.regs[i].reg
+ else:
+ rval = yield core.regs.int.memory._array[i]
+ intregs.append(rval)
+ print("core int regs", list(map(hex, intregs)))
+ return intregs
+
+def get_sim_regs(dut, sim, core, test, code):
+ # int regs
+ # TODO, split this out into "core-register-getter" function
+ simregs = []
+ for i in range(32):
+ simregval = sim.gpr[i].asint()
+ simregs.append(simregval)
+ print("sim int regs", list(map(hex, simregs)))
+ return simregs
+
+def compare_core_sim_regs(dut,regsim,regcore, code):
+ for i, (regsim, regcore) in enumerate(zip(regsim, regcore)):
+ dut.assertEqual(regsim, regcore,
+ "int reg %d not equal %s. got %x expected %x" % \
+ (i, repr(code), regsim, regcore))
def wait_for_busy_hi(cu):
while True: