From e587eb23fb9c6e59284233ebf724a9c07e2d8c19 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 4 Dec 2021 17:59:24 +0000 Subject: [PATCH] add wb_get function for emulating wishbone interface --- src/openpower/test/wb_get.py | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/openpower/test/wb_get.py diff --git a/src/openpower/test/wb_get.py b/src/openpower/test/wb_get.py new file mode 100644 index 00000000..4d8a098e --- /dev/null +++ b/src/openpower/test/wb_get.py @@ -0,0 +1,52 @@ +"""useful function for emulating a wishbone interface +""" + +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<