Beispiel #1
0
 def visit_queue(self, data, dtype):
     for d, eot in quiter(data):
         if type(d) == dtype:
             yield d
         else:
             for ret in self.visit(d, dtype.sub()):
                 if dtype.lvl == 1:
                     yield (ret, Uint[1](eot))
                 else:
                     yield (ret[0], eot @ ret[1])
Beispiel #2
0
 def visit_queue(self, dtype, field=None, data=None):
     self.sample(dtype, field, data)
     field = self.set_field_prefix(field)
     for (i, d), eot in quiter(enumerate(data)):
         for ret in self.visit(dtype.sub(), f'{field}data', data=d):
             if dtype.lvl == 1:
                 self.sample(Uint[1], 'eot', data=eot)
                 yield (ret, Uint[1](eot))
             else:
                 self.sample(
                     dtype.eot,
                     'eot',
                     data=(int(ret[1]) + (eot << ret[1].width)))
                 yield (
                     ret[0],
                     Uint[ret[1].width + 1](ret[1]) + (eot << ret[1].width))
Beispiel #3
0
    def AssignValue(self, node):
        if not isinstance(node.val, ir.GenNext):
            return super().AssignValue(node)

        gen_id = node.val.val
        if gen_id.name not in self.generators:
            func_call = gen_id.obj.func

            if not const_func_args(func_call.args.values(), func_call.kwds):
                raise Ununfoldable()

            args = tuple(node.val for node in func_call.args.values())

            vals = exhaust(func_call.func, args)

            self.generators[gen_id.name] = {'vals': quiter(vals)}

        next_val, last = next(self.generators[gen_id.name]['vals'])

        self.forwarded[node.target.name] = ir.ResExpr(next_val)
        self.generators[gen_id.name]['last'] = ir.ResExpr(last)

        return None
Beispiel #4
0
    def ExprStatement(self, node):
        if not isinstance(node.expr, (ir.GenAck, ir.GenInit)):
            return super().ExprStatement(node)

        if isinstance(node.expr, ir.GenAck):
            if node.expr.val in self.generators:
                return None

        if isinstance(node.expr, ir.GenInit):
            gen_id = node.expr.val
            func_call = gen_id.obj.func

            if not const_func_args(func_call.args.values(), func_call.kwds):
                raise SyntaxError(f'Only generator calls with constant arguments are supported')

            args = tuple(node.val for node in func_call.args.values())

            vals = exhaust(func_call.func, args)

            self.generators[gen_id.name] = {'vals': quiter(vals)}

            return None

        return node