From: Tobias Platen Date: Sun, 11 Jul 2021 15:37:22 +0000 (+0200) Subject: add test_dcbz_pi.py (skeleton only) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fb00d02206b0ef0331d511e43fea891648eeb255;p=soc.git add test_dcbz_pi.py (skeleton only) --- diff --git a/src/soc/experiment/test/test_dcbz_pi.py b/src/soc/experiment/test/test_dcbz_pi.py new file mode 100644 index 00000000..a49d95da --- /dev/null +++ b/src/soc/experiment/test/test_dcbz_pi.py @@ -0,0 +1,166 @@ +"""DCache PortInterface Test + starting as a copy to test_ldst_pi.py +""" + +from nmigen import (C, Module, Signal, Elaboratable, Mux, Cat, Repl, Signal) +from nmigen.cli import main +from nmigen.cli import rtlil +from nmutil.mask import Mask, masked +from nmutil.util import Display +from random import randint, seed + +if True: + from nmigen.back.pysim import Simulator, Delay, Settle +else: + from nmigen.sim.cxxsim import Simulator, Delay, Settle +from nmutil.util import wrap + +from soc.config.test.test_pi2ls import pi_ld, pi_st, pi_ldst +from soc.config.test.test_loadstore import TestMemPspec +from soc.config.loadstore import ConfigMemoryPortInterface + +from soc.fu.ldst.loadstore import LoadStore1 +from soc.experiment.mmu import MMU + +from nmigen.compat.sim import run_simulation + + +stop = False + +def b(x): # byte-reverse function + return int.from_bytes(x.to_bytes(8, byteorder='little'), + byteorder='big', signed=False) + +def wb_get(wb, mem): + """simulator process for getting memory load requests + """ + + global stop + assert(stop==False) + + while not stop: + while True: # wait for dc_valid + if stop: + return + cyc = yield (wb.cyc) + stb = yield (wb.stb) + if cyc and stb: + break + yield + addr = (yield wb.adr) << 3 + if addr not in mem: + print (" WB LOOKUP NO entry @ %x, returning zero" % (addr)) + + # read or write? + we = (yield wb.we) + if we: + store = (yield wb.dat_w) + sel = (yield wb.sel) + data = mem.get(addr, 0) + # note we assume 8-bit sel, here + res = 0 + for i in range(8): + mask = 0xff << (i*8) + if sel & (1<