Пример #1
0
    def test_fullFill_randomized(self):
        u = self.u
        N = 2 * 16 - 1
        m = DenseMemory(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 * 10 * Time.ns)

        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)
Пример #2
0
    def test_fullFill_randomized(self):
        u = self.u
        N = 2 * 16 - 1
        m = DenseMemory(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 * 10 * Time.ns)

        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)
Пример #3
0
    def test_3x128(self):
        u = self.u
        m = DenseMemory(self.DATA_WIDTH, u.clk, wDatapumpIntf=u.wDatapump)
        N = 128
        _mask = mask(self.DATA_WIDTH // 8)
        data = [[self._rand.getrandbits(self.DATA_WIDTH) for _ in range(N)]
                for _ in range(self.DRIVER_CNT)]

        dataAddress = [m.malloc(N * self.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) * self.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, self.DATA_WIDTH // 8, N)
            self.assertValSequenceEqual(inMem, data[i], "driver:%d" % i)