def test_fullFill_randomized(self): u = self.u N = 2 * 16 - 1 m = AxiDpSimRam(self.DATA_WIDTH, u.clk, wDatapumpIntf=u.wDatapump) ITEM_SIZE = self.DATA_WIDTH // 8 MAGIC = 88 self.randomize(u.items) self.randomize(u.wDatapump.w) self.randomize(u.wDatapump.req) self.randomize(u.wDatapump.ack) BASE = m.malloc(ITEM_SIZE * N) u.baseAddr._ag.dout.append(BASE) u.items._ag.data.extend([MAGIC + i for i in range(N)]) self.runSim(200 * CLK_PERIOD) self.assertEmpty(u.items._ag.data) self.assertEmpty(u.wDatapump.ack._ag.data) BASE_INDX = BASE // ITEM_SIZE for i in range(N): self.assertEqual(m.data[BASE_INDX + i], MAGIC + i) self.assertValEqual(self.u.uploaded._ag.data[-1], N)
def test_3x128(self): u = self.u m = AxiDpSimRam(u.DATA_WIDTH, u.clk, wDatapumpIntf=u.wDatapump) N = 128 _mask = mask(u.DATA_WIDTH // 8) data = [[self._rand.getrandbits(u.DATA_WIDTH) for _ in range(N)] for _ in range(self.DRIVER_CNT)] dataAddress = [ m.malloc(N * u.DATA_WIDTH // 8) for _ in range(self.DRIVER_CNT) ] for di, _data in enumerate(data): req = u.drivers[di].req._ag wIn = u.drivers[di].w._ag dataIt = iter(_data) addr = dataAddress[di] end = False while True: frameSize = self._rand.getrandbits(4) + 1 frame = [] try: for _ in range(frameSize): frame.append(next(dataIt)) except StopIteration: end = True if frame: req.data.append(mkReq(addr, len(frame) - 1)) wIn.data.extend([(d, _mask, i == len(frame) - 1) for i, d in enumerate(frame)]) addr += len(frame) * u.DATA_WIDTH // 8 if end: break ra = self.randomize for d in u.drivers: ra(d.req) ra(d.w) ra(d.ack) ra(u.wDatapump.req) ra(u.wDatapump.w) ra(u.wDatapump.ack) self.runSim(self.DRIVER_CNT * N * 50 * Time.ns) for i, baseAddr in enumerate(dataAddress): inMem = m.getArray(baseAddr, u.DATA_WIDTH // 8, N) self.assertValSequenceEqual(inMem, data[i], f"driver:{i:d}")