X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsoc%2Fsimple%2Ftest%2Ftest_runner.py;h=a8898bf5caaefdae9b03fbd891e6c8b4de6c4519;hb=36188c1a34d3b377d0561bc9c5da41a48ddaa7f4;hp=cb4ca4589719d3fb09a214dd2e1cc15711f0c4cd;hpb=3fa7ba28c3ff08833bc75effcacff579eba26d92;p=soc.git diff --git a/src/soc/simple/test/test_runner.py b/src/soc/simple/test/test_runner.py index cb4ca458..a8898bf5 100644 --- a/src/soc/simple/test/test_runner.py +++ b/src/soc/simple/test/test_runner.py @@ -3,9 +3,11 @@ related bugs: * https://bugs.libre-soc.org/show_bug.cgi?id=363 + * https://bugs.libre-soc.org/show_bug.cgi?id=686#c51 """ from nmigen import Module, Signal, Cat, ClockSignal from nmigen.hdl.xfrm import ResetInserter +from copy import copy # NOTE: to use cxxsim, export NMIGEN_SIM_MODE=cxxsim from the shell # Also, check out the cxxsim nmigen branch, and latest yosys from git @@ -25,14 +27,15 @@ from soc.regfile.regfiles import StateRegs from soc.simple.issuer import TestIssuerInternal from soc.config.test.test_loadstore import TestMemPspec -from soc.simple.test.test_core import (setup_regs, check_regs, +from soc.simple.test.test_core import (setup_regs, check_regs, check_mem, wait_for_busy_clear, wait_for_busy_hi) -from soc.fu.compunits.test.test_compunit import (setup_test_memory, +from soc.fu.compunits.test.test_compunit import (setup_tst_memory, check_sim_memory) from soc.debug.dmi import DBGCore, DBGCtrl, DBGStat from nmutil.util import wrap from soc.experiment.test.test_mmu_dcache import wb_get +from openpower.test.state import TestState, StateRunner def setup_i_memory(imem, startaddr, instructions): @@ -121,21 +124,170 @@ def get_dmi(dmi, addr): return data +def run_hdl_state(dut, test, issuer, pc_i, svstate_i, instructions): + """run_hdl_state - runs a TestIssuer nmigen HDL simulation + """ + + imem = issuer.imem._get_memory() + core = issuer.core + dmi = issuer.dbg.dmi + pdecode2 = issuer.pdecode2 + l0 = core.l0 + hdl_states = [] + + # establish the TestIssuer context (mem, regs etc) + + pc = 0 # start address + counter = 0 # test to pause/start + + yield from setup_i_memory(imem, pc, instructions) + yield from setup_tst_memory(l0, test.mem) + yield from setup_regs(pdecode2, core, test) + + # set PC and SVSTATE + yield pc_i.eq(pc) + yield issuer.pc_i.ok.eq(1) + + # copy initial SVSTATE + initial_svstate = copy(test.svstate) + if isinstance(initial_svstate, int): + initial_svstate = SVP64State(initial_svstate) + yield svstate_i.eq(initial_svstate.value) + yield issuer.svstate_i.ok.eq(1) + yield + + print("instructions", instructions) + + # run the loop of the instructions on the current test + index = (yield issuer.cur_state.pc) // 4 + while index < len(instructions): + ins, code = instructions[index] + + print("hdl instr: 0x{:X}".format(ins & 0xffffffff)) + print(index, code) + + if counter == 0: + # start the core + yield + yield from set_dmi(dmi, DBGCore.CTRL, + 1<= len(instructions): + print ("index over, send dmi stop") + # stop at end + yield from set_dmi(dmi, DBGCore.CTRL, + 1<= len(instructions): - print ("index over, send dmi stop") - # stop at end - yield from set_dmi(dmi, DBGCore.CTRL, - 1<>>expected_data<<<) - # stop at end - yield from set_dmi(dmi, DBGCore.CTRL, 1<