Пример #1
0
class ModuleTests(unittest.TestCase):
    def setUp(self):
        self.cycles = 100
        self.m = Module()

    def tearDown(self):
        pass

    def depth(self):
        return len(self.m.cells)

    def width(self):
        return len(self.m.cells[0])

    def createGridAndTieCell0Input(self,
                                   inWidth,
                                   outWidth,
                                   gridWidth,
                                   d,
                                   v=False):
        self.m.createGrid(inWidth, outWidth, gridWidth, d)
        self.m.tieCell0([v])

    def gatesPruned(self, inWidth, outWidth, gridWidth, depth, flops):
        self.createGridAndTieCell0Input(inWidth, outWidth, gridWidth, depth,
                                        True)
        self.m.setNumFlops(flops)
        self.m.randomizeGates()

        for i in range(self.cycles):
            a = []
            for i in range(inWidth):
                a.append(random.getrandbits(1))

            self.m.driveInputs(a)
            self.m.clk()
            self.m.sampleOutputs()

        return self.m.outputsFixed() or self.m.moduleHasFixedCells()