Esempio n. 1
0
    def test_fullFill_randomized3(self, N=None):
        u = self.u
        BASE = 0x1230
        MAGIC = 1
        if N is None:
            N = self.ITEMS + 10

        m = DenseMemory(self.DATA_WIDTH, u.clk, wDatapumpIntf=u.wDatapump)

        u.baseAddr._ag.dout.append(BASE)
        for i in range(N):
            u.items._ag.data.append(MAGIC + i)

        def enReq(s):
            u.wDatapump.req._ag.enable = False
            yield s.wait(32 * 10 * Time.ns)
            yield from self.simpleRandomizationProcess(u.wDatapump.req._ag)(s)

        self.procs.append(enReq)

        self.randomize(u.wDatapump.w)
        self.randomize(u.items)
        # self.randomize(u.req)
        self.randomize(u.wDatapump.ack)

        self.runSim(N * 40 * Time.ns)

        self.assertEmpty(u.items._ag.data)
        d = m.getArray(BASE, self.DATA_WIDTH // 8, self.ITEMS)

        expected = [i + MAGIC if i >= 10 else i + self.ITEMS + MAGIC for i in range(self.ITEMS)]

        self.assertValSequenceEqual(d, expected)
        self.assertValEqual(u.uploaded._ag.data[-1], N)
Esempio n. 2
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)
Esempio n. 3
0
    def test_randomized2(self):
        u = self.u
        m = DenseMemory(self.DATA_WIDTH, u.clk, wDatapumpIntf=u.wDatapump)
        N = 25
        _mask = mask(self.DATA_WIDTH // 8)

        for d in u.drivers:
            self.randomize(d.req)
            self.randomize(d.w)
            self.randomize(d.ack)

        self.randomize(u.wDatapump.req)
        self.randomize(u.wDatapump.w)
        self.randomize(u.wDatapump.ack)

        sectors = []
        framesCnt = [0 for _ in range(self.DRIVER_CNT)]
        for i in range(N):
            for _id, d in enumerate(u.drivers):
                size = self._rand.getrandbits(3) + 1
                magic = self._rand.getrandbits(16)
                addr = m.calloc(size, 8, initValues=[None for _ in range(size)])

                d.req._ag.data.append((_id, addr, size - 1, 0))
                for i in range(size):
                    data = (magic + i, _mask, int(i == size - 1))
                    d.w._ag.data.append(data)

                values = [i + magic for i in range(size)]
                sectors.append((_id, addr, values))
                framesCnt[_id] += 1

        self.runSim(self.DRIVER_CNT * N * 250 * Time.ns)

        for _id, d in enumerate(u.drivers):
            self.assertEmpty(d.req._ag.data)
            self.assertEmpty(d.w._ag.data)
            self.assertEqual(len(u.drivers[_id].ack._ag.data),
                              framesCnt[_id])

        for _id, addr, expected in sectors:
            v = m.getArray(addr, 8, len(expected))
            self.assertSequenceEqual(v, expected)
Esempio n. 4
0
    def test_randomized(self):
        u = self.u
        m = DenseMemory(self.DATA_WIDTH, u.clk, wDatapumpIntf=u.wDatapump)

        for d in u.drivers:
            self.randomize(d.req)
            self.randomize(d.w)
            self.randomize(d.ack)

        self.randomize(u.wDatapump.req)
        self.randomize(u.wDatapump.w)
        self.randomize(u.wDatapump.ack)

        sectors = []

        def prepare(driverIndex, addr, size, valBase=1, _id=1):
            driver = u.drivers[driverIndex]
            driver.req._ag.data.append((_id, addr, size - 1, 0))
            _mask = mask(self.DATA_WIDTH // 8)

            for i in range(size):
                d = (valBase + i, _mask, int(i == size - 1))

                driver.w._ag.data.append(d)
                u.wDatapump.ack._ag.data.append(driverIndex)

            sectors.append((addr, valBase, size))

        prepare(0, 0x1000, 3, 99, _id=0)
        prepare(0, 0x2000, 1, 100, _id=0)
        prepare(0, 0x3000, 16, 101)
        prepare(1, 0x4000, 3, 200, _id=1)
        prepare(1, 0x5000, 1, 201, _id=1)  # + prepare(1, 0x6000, 16, 202) #+ prepare(1, 0x7000, 16, 203)

        self.runSim(2000 * Time.ns)

        for addr, seed, size in sectors:
            expected = [seed + i for i in range(size)]
            self.assertValSequenceEqual(m.getArray(addr, 8, size), expected)
Esempio n. 5
0
    def test_fullFill_randomized3(self, N=None):
        u = self.u
        BASE = 0x1230
        MAGIC = 1
        if N is None:
            N = self.ITEMS + 10

        m = DenseMemory(self.DATA_WIDTH, u.clk, wDatapumpIntf=u.wDatapump)

        u.baseAddr._ag.dout.append(BASE)
        for i in range(N):
            u.items._ag.data.append(MAGIC + i)

        def enReq(s):
            u.wDatapump.req._ag.enable = False
            yield s.wait(32 * 10 * Time.ns)
            yield from self.simpleRandomizationProcess(u.wDatapump.req._ag)(s)

        self.procs.append(enReq)

        self.randomize(u.wDatapump.w)
        self.randomize(u.items)
        # self.randomize(u.req)
        self.randomize(u.wDatapump.ack)

        self.runSim(N * 40 * Time.ns)

        self.assertEmpty(u.items._ag.data)
        d = m.getArray(BASE, self.DATA_WIDTH // 8, self.ITEMS)

        expected = [
            i + MAGIC if i >= 10 else i + self.ITEMS + MAGIC
            for i in range(self.ITEMS)
        ]

        self.assertValSequenceEqual(d, expected)
        self.assertValEqual(u.uploaded._ag.data[-1], N)