X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsoc%2Fexperiment%2Ftest%2Ftest_ldst_pi.py;h=aa3087c6f9c449edd17c75f266dfaceb58466380;hb=acd1da7b3604e36deba6be59226eeeaacd0ccf60;hp=290cbf5e081138d922a497efd52f500775d5e304;hpb=0d66f902ae1c9a67de8f042f6f10f4520eb3538e;p=soc.git diff --git a/src/soc/experiment/test/test_ldst_pi.py b/src/soc/experiment/test/test_ldst_pi.py index 290cbf5e..aa3087c6 100644 --- a/src/soc/experiment/test/test_ldst_pi.py +++ b/src/soc/experiment/test/test_ldst_pi.py @@ -28,37 +28,16 @@ from nmigen.compat.sim import run_simulation stop = False -def wb_get(wb): +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 - def b(x): - return int.from_bytes(x.to_bytes(8, byteorder='little'), - byteorder='big', signed=False) - - mem = {0x10000: # PARTITION_TABLE_2 - # PATB_GR=1 PRTB=0x1000 PRTS=0xb - b(0x800000000100000b), - - 0x30000: # RADIX_ROOT_PTE - # V = 1 L = 0 NLB = 0x400 NLS = 9 - b(0x8000000000040009), - - 0x40000: # RADIX_SECOND_LEVEL - # V = 1 L = 1 SW = 0 RPN = 0 - # R = 1 C = 1 ATT = 0 EAA 0x7 - b(0xc000000000000187), - - 0x1000000: # PROCESS_TABLE_3 - # RTS1 = 0x2 RPDB = 0x300 RTS2 = 0x5 RPDS = 13 - b(0x40000000000300ad), - - # data to return - 0x1000: 0xdeadbeef01234567 - } - while not stop: while True: # wait for dc_valid if stop: @@ -72,19 +51,38 @@ def wb_get(wb): if addr not in mem: print (" WB LOOKUP NO entry @ %x, returning zero" % (addr)) - data = mem.get(addr, 0) - yield wb.dat_r.eq(data) - print (" DCACHE get %x data %x" % (addr, data)) + # 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<