async def serialize(din: Tuple[{ 'data': Any, 'active': Uint }]) -> Queue['din["data"][0]']: async with din as (data, active): for i, last in qrange(active): yield data[i], last
async def parallelize(din, *, t) -> b't': data = t() for i, last in qrange(len(t)): async with din as val: data[i] = val await clk() yield data
async def replicate(din: Tuple[{ 'length': Uint, 'val': Any }]) -> Queue['din["val"]']: """Replicates the input data. The ``length`` field of the :class:`Tuple` input type specifies the number of times the ``value`` field needs to be reproduced. Returns: A :class:`Queue` type where each element is equal to the ``value`` input field and the `eot` signalizes the last replicated element. """ async with din as (length, value): for i, last in qrange(length): yield (value, last)
async def test() -> Queue[Uint[3]]: for i, last in qrange(4): yield i, last
async def serialize_plain(din) -> Queue['din[0]']: i = Uint[bitw(len(din.dtype) - 1)](0) async with din as val: for i, last in qrange(len(din.dtype)): yield val[i], last