from soc.experiment.dcache import DCache
from soc.experiment.icache import ICache
-from random import randint
+import random
stop = False
+def set_stop(newval):
+ global stop
+ stop = newval
+
+
def b(x):
return int.from_bytes(x.to_bytes(8, byteorder='little'),
byteorder='big', signed=False)
+
+
default_mem = { 0x10000: # PARTITION_TABLE_2
# PATB_GR=1 PRTB=0x1000 PRTS=0xb
b(0x800000000100000b),
"""simulator process for getting memory load requests
"""
- global stop
-
+ logfile = open("/tmp/wb_get.log","w")
- mem = mem
+ def log(msg):
+ logfile.write(msg+"\n")
+ print(msg)
+ global stop
while not stop:
while True: # wait for dc_valid
if stop:
+ log("stop")
return
cyc = yield (c.wb_out.cyc)
stb = yield (c.wb_out.stb)
yield
addr = (yield c.wb_out.adr) << 3
if addr not in mem:
- print (" %s LOOKUP FAIL %x" % (name, addr))
+ log("%s LOOKUP FAIL %x" % (name, addr))
stop = True
return
yield
data = mem[addr]
yield c.wb_in.dat.eq(data)
- print (" %s get %x data %x" % (name, addr, data))
+ log("%s get %x data %x" % (name, addr, data))
yield c.wb_in.ack.eq(1)
yield
yield c.wb_in.ack.eq(0)
+ yield
def icache_sim(dut, mem):
def test_icache():
# create a random set of addresses and "instructions" at those addresses
mem = {}
- for i in range(100):
- mem[randint(0, 1<<10)] = b(randint(0,1<<32))
+ # fail 'AssertionError: insn @1d8=0 expected 61928a6100000000'
+ #random.seed(41)
+ # fail infinite loop 'cache read adr: 24 data: 0'
+ random.seed(43)
+ for i in range(3):
+ mem[random.randint(0, 1<<10)] = b(random.randint(0,1<<32))
# set up module for simulation
m = Module()
if __name__ == '__main__':
test_mmu()
- test_icache_il()
+ #test_icache_il()
#test_icache()