From c5213803b82fd4d348c90fefff2a62eeb4c814d2 Mon Sep 17 00:00:00 2001 From: klehman Date: Sat, 25 Sep 2021 08:16:18 -0400 Subject: [PATCH] start of HDLRunner --- src/soc/simple/test/test_runner.py | 44 +++++++++++++++++------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/soc/simple/test/test_runner.py b/src/soc/simple/test/test_runner.py index 615413f5..a8898bf5 100644 --- a/src/soc/simple/test/test_runner.py +++ b/src/soc/simple/test/test_runner.py @@ -262,6 +262,18 @@ class SimRunner(StateRunner): m.submodules.simdec2 = simdec2 # pain in the neck +class HDLRunner(StateRunner): + def __init__(self, dut, m, pspec): + self.dut = dut + #hard_reset = Signal(reset_less=True) + self.issuer = TestIssuerInternal(pspec) + # use DMI RESET command instead, this does actually work though + #issuer = ResetInserter({'coresync': hard_reset, + # 'sync': hard_reset})(issuer) + m.submodules.issuer = self.issuer + self.dmi = self.issuer.dbg.dmi + + class TestRunner(FHDLTestCase): def __init__(self, tst_data, microwatt_mmu=False, rom=None, svp64=True, run_hdl=True, run_sim=True): @@ -301,14 +313,7 @@ class TestRunner(FHDLTestCase): # StateRunner.setup_for_test() if self.run_hdl: - - #hard_reset = Signal(reset_less=True) - issuer = TestIssuerInternal(pspec) - # use DMI RESET command instead, this does actually work though - #issuer = ResetInserter({'coresync': hard_reset, - # 'sync': hard_reset})(issuer) - m.submodules.issuer = issuer - dmi = issuer.dbg.dmi + hdlrun = HDLRunner(self, m, pspec) if self.run_sim: simrun = SimRunner(self, m, pspec) @@ -318,11 +323,12 @@ class TestRunner(FHDLTestCase): comb += intclk.eq(ClockSignal()) if self.run_hdl: + pc_i = Signal(32) svstate_i = Signal(64) - comb += issuer.pc_i.data.eq(pc_i) - comb += issuer.svstate_i.data.eq(svstate_i) + comb += hdlrun.issuer.pc_i.data.eq(pc_i) + comb += hdlrun.issuer.svstate_i.data.eq(svstate_i) # nmigen Simulation - everything runs around this, so it # still has to be created. @@ -336,7 +342,7 @@ class TestRunner(FHDLTestCase): if self.run_hdl: # start in stopped - yield from set_dmi(dmi, DBGCore.CTRL, 1<>>expected_data<<<) # get CR - cr = yield from get_dmi(dmi, DBGCore.CR) + cr = yield from get_dmi(hdlrun.dmi, DBGCore.CR) print("after test %s cr value %x" % (test.name, cr)) # get XER - xer = yield from get_dmi(dmi, DBGCore.XER) + xer = yield from get_dmi(hdlrun.dmi, DBGCore.XER) print("after test %s XER value %x" % (test.name, xer)) # test of dmi reg get for int_reg in range(32): - yield from set_dmi(dmi, DBGCore.GSPR_IDX, int_reg) - value = yield from get_dmi(dmi, DBGCore.GSPR_DATA) + yield from set_dmi(hdlrun.dmi, DBGCore.GSPR_IDX, int_reg) + value = yield from get_dmi(hdlrun.dmi, DBGCore.GSPR_DATA) print("after test %s reg %2d value %x" % (test.name, int_reg, value)) # pull a reset - yield from set_dmi(dmi, DBGCore.CTRL, 1<