From: Tobias Platen Date: Mon, 15 Nov 2021 18:48:05 +0000 (+0100) Subject: add test_loadstore1.py X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a45806c8196cc726097491a7b4618efb53c73eaa;p=soc.git add test_loadstore1.py --- diff --git a/src/soc/experiment/test/test_loadstore1.py b/src/soc/experiment/test/test_loadstore1.py new file mode 100644 index 00000000..6871109a --- /dev/null +++ b/src/soc/experiment/test/test_loadstore1.py @@ -0,0 +1,156 @@ +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 +from nmigen.sim 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 soc.experiment.test import pagetables + +from nmigen.compat.sim import run_simulation + +stop = 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<