From: Luke Kenneth Casson Leighton Date: Wed, 22 Sep 2021 19:18:53 +0000 (+0100) Subject: split out HDL from Simulator into separate functions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cd2850274b3d0bf5f6ba5e011764681bcab2bb10;p=soc.git split out HDL from Simulator into separate functions --- diff --git a/src/soc/simple/test/test_runner.py b/src/soc/simple/test/test_runner.py index 20318a37..a25b4426 100644 --- a/src/soc/simple/test/test_runner.py +++ b/src/soc/simple/test/test_runner.py @@ -7,6 +7,7 @@ related bugs: """ 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 @@ -123,6 +124,135 @@ 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<