示例#1
0
    def test_translate10xRandomized(self):
        u = self.u
        N = 10
        # self.randomize(u.rDatapump.req)
        self.randomize(u.rDatapump.r)
        self.randomize(u.virtIn)
        self.randomize(u.physOut)

        m = DenseMemory(self.DATA_WIDTH, u.clk, rDatapumpIntf=u.rDatapump)
        virt = u.virtIn._ag.data
        virt.extend([NOP for _ in range(N)])

        expected = []
        for i in range(N):
            lvl2pgtData = [int(2 ** 12) * i2 if i + 1 == i2 else -1
                           for i2 in range(self.LVL2_PAGE_TABLE_ITEMS)]
            lvl2pgt = m.calloc(self.LVL2_PAGE_TABLE_ITEMS,
                               4,
                               initValues=lvl2pgtData)

            u.lvl1Table._ag.requests.append((WRITE, i, lvl2pgt))
            v = self.buildVirtAddr(i, i + 1, i + 1)
            virt.append(v)
            expected.append(int(2 ** 12) * (i + 1) + i + 1)

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

        self.assertValSequenceEqual(u.physOut._ag.data, expected)
        self.assertValEqual(u.segfault._ag.data[-1], 0)
示例#2
0
    def _test_s0(self, u):
        DW = 64
        N = 3
        self.prepareUnit(u)

        m = DenseMemory(DW, u.clk, u.rDatapump)

        # init expectedFieldValues
        expectedFieldValues = {}
        for f in s0.fields:
            if f.name is not None:
                expectedFieldValues[f.name] = []

        for _ in range(N):
            d = s0RandVal(self)
            for name, val in d.items():
                expectedFieldValues[name].append(val)

            asFrame = list(iterBits(s0.fromPy(d),
                                    bitsInOne=DW,
                                    skipPadding=False,
                                    fillup=True))
            addr = m.calloc(len(asFrame), DW // 8, initValues=asFrame)
            u.get._ag.data.append(addr)

        self.runSim(500 * Time.ns)

        for f in s0.fields:
            if f.name is not None:
                expected = expectedFieldValues[f.name]
                got = u.dataOut._fieldsToInterfaces[f]._ag.data
                self.assertValSequenceEqual(got, expected)
示例#3
0
    def _test_s0(self, u):
        DW = 64
        N = 3
        self.prepareUnit(u)

        m = DenseMemory(DW, u.clk, u.rDatapump)

        # init expectedFieldValues
        expectedFieldValues = {}
        for f in s0.fields:
            if f.name is not None:
                expectedFieldValues[f.name] = []

        for _ in range(N):
            d = s0RandVal(self)
            for name, val in d.items():
                expectedFieldValues[name].append(val)

            asFrame = list(
                iterBits(s0.fromPy(d),
                         bitsInOne=DW,
                         skipPadding=False,
                         fillup=True))
            addr = m.calloc(len(asFrame), DW // 8, initValues=asFrame)
            u.get._ag.data.append(addr)

        self.runSim(500 * Time.ns)

        for f in s0.fields:
            if f.name is not None:
                expected = expectedFieldValues[f.name]
                got = u.dataOut._fieldsToInterfaces[f]._ag.data
                self.assertValSequenceEqual(got, expected)
示例#4
0
    def test_randomized2(self):
        u = self.u
        m = DenseMemory(self.DATA_WIDTH, u.clk, u.rDatapump)
        N = 17

        for d in u.drivers:
            self.randomize(d.req)
            self.randomize(d.r)
        self.randomize(u.rDatapump.req)
        self.randomize(u.rDatapump.r)
        _mask = mask(self.DATA_WIDTH // 8)

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

                d.req._ag.data.append((_id, addr, size - 1, 0))

                for i2, v in enumerate(values):
                    data = (_id, v, _mask, int(i2 == size - 1))
                    expected[_id].append(data)

        self.runSim(self.DRIVERS_CNT * N * 200 * Time.ns)

        for expect, driver in zip(expected, u.drivers):
            self.assertValSequenceEqual(driver.r._ag.data, expect)
示例#5
0
    def test_randomized2(self):
        u = self.u
        m = DenseMemory(self.DATA_WIDTH, u.clk, u.rDatapump)
        N = 17

        for d in u.drivers:
            self.randomize(d.req)
            self.randomize(d.r)
        self.randomize(u.rDatapump.req)
        self.randomize(u.rDatapump.r)
        _mask = mask(self.DATA_WIDTH // 8)

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

                d.req._ag.data.append((_id, addr, size - 1, 0))

                for i2, v in enumerate(values):
                    data = (_id, v, _mask, int(i2 == size - 1))
                    expected[_id].append(data)

        self.runSim(self.DRIVERS_CNT * N * 200 * Time.ns)

        for expect, driver in zip(expected, u.drivers):
            self.assertValSequenceEqual(driver.r._ag.data, expect)
示例#6
0
    def test_get(self):
        u = self.u
        MAGIC = 99
        N = self.ITEMS
        t = 10 + N

        m = DenseMemory(self.DATA_WIDTH, u.clk, rDatapumpIntf=u.rDatapump)
        base = m.calloc(self.ITEMS,
                        self.ITEM_WIDTH // 8,
                        initValues=[MAGIC + i for i in range(N)])
        u.base._ag.data.append(base)
        u.index._ag.data.extend([i for i in range(N)])

        self.runSim(t * 10 * Time.ns)

        self.assertValSequenceEqual(u.item._ag.data,
                                    [MAGIC + i for i in range(N)])
示例#7
0
    def test_lvl2_fault(self):
        u = self.u
        MAGIC = 45

        m = DenseMemory(self.DATA_WIDTH, u.clk, rDatapumpIntf=u.rDatapump)

        lvl2pgt = m.calloc(self.LVL2_PAGE_TABLE_ITEMS, 4,
                           initValues=[-1 for _ in range(self.LVL2_PAGE_TABLE_ITEMS)])

        u.lvl1Table._ag.requests.append((WRITE, MAGIC, lvl2pgt))

        va = self.buildVirtAddr(MAGIC, 0, 0)
        # wait for lvl1Table storage init
        u.virtIn._ag.data.extend([NOP, NOP, va])

        self.runSim(100 * Time.ns)

        self.assertEmpty(u.physOut._ag.data)
        self.assertValEqual(u.segfault._ag.data[-1], 1)
示例#8
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)