예제 #1
0
파일: table.py 프로젝트: rbarzic/pyeda
 def iter_ones(self):
     n = q = 0
     while n < self.cardinality:
         byte = self.data[q]
         if byte & 0x55:
             r = 0
             while r < 8 and n < self.cardinality:
                 output = (byte >> r) & self.MASK
                 if output & 1:
                     yield boolfunc.num2point(n, self.inputs)
                 r += self.WIDTH
                 n += 1
         else:
             n += 8
         q += 1
예제 #2
0
파일: table.py 프로젝트: rbarzic/pyeda
 def satisfy_one(self):
     n = q = 0
     while n < self.cardinality:
         byte = self.data[q]
         if byte & 0x55:
             r = 0
             while r < 8 and n < self.cardinality:
                 output = (byte >> r) & self.MASK
                 if output & 1:
                     return boolfunc.num2point(n, self.inputs)
                 r += self.WIDTH
                 n += 1
         else:
             n += 8
         q += 1
     return None
예제 #3
0
파일: table.py 프로젝트: rbarzic/pyeda
    def _iter_restrict(self, point):
        inputs = list(self.inputs)
        unmapped = dict()
        for i, v in enumerate(self.inputs):
            if v in point:
                inputs[i] = point[v]
            else:
                unmapped[v] = i

        vs = sorted(unmapped.keys())
        for n in range(1 << len(vs)):
            for v, val in boolfunc.num2point(n, vs).items():
                inputs[unmapped[v]] = val
            index = sum((val << i) for i, val in enumerate(inputs))
            q, r = divmod(index * self.WIDTH, 8)
            yield (self.data[q] >> r) & self.MASK