From 1429bf1d4b0f07c756f242a14271a59cca206347 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 26 May 2021 14:22:45 +0100 Subject: [PATCH] add ldst PortInterface misalign unit test (underway) --- .../experiment/test/test_ldst_pi_misalign.py | 164 ++++++++++++++++++ src/soc/litex/florent | 2 +- 2 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 src/soc/experiment/test/test_ldst_pi_misalign.py diff --git a/src/soc/experiment/test/test_ldst_pi_misalign.py b/src/soc/experiment/test/test_ldst_pi_misalign.py new file mode 100644 index 00000000..df679977 --- /dev/null +++ b/src/soc/experiment/test/test_ldst_pi_misalign.py @@ -0,0 +1,164 @@ +"""MMU PortInterface Test + +quite basic, goes directly to the MMU to assert signals (does not +yet use PortInterface) +""" + +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 + +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 + + 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<