async def zip_cat(*din) -> b'zip_type(din)': id_max_lvl, max_lvl = max(enumerate(din), key=lambda p: p[1].dtype.lvl if typeof(p[1].dtype, Queue) else 0) async with gather(*din) as dout: yield (din_data_cat_value(dout), dout[id_max_lvl].eot)
async def match_timing(*din) -> b'din': if any(not d.empty() for d in din): all_valid = all(not d.empty() for d in din) sim_assert(all_valid, f'not all inputs valid at the same time') async with gather(*din) as data: yield data await clk()
async def cart_cat(*din) -> b'cart_type(din)': async with gather(*din) as data: dout_data = [] dout_eot = Unit() for d in data: if isinstance(d, Queue): dout_data.append(d.data) dout_eot = d.eot @ dout_eot else: dout_data.append(d) yield (dout_data, dout_eot)
async def ccat(*din) -> b'Tuple[din]': """Short for concatenate, combines multiple interfaces into a single interface whose type is a :class:`Tuple` of the input interface types. One output data is formed by combining one data from each of the inputs:: din0 = Intf(Uint[8]) din1 = Intf(Uint[16]) >>> ccat(din0, din1) Intf(Tuple[Uint[8], Uint[16]]) """ async with gather(*din) as dout: yield dout
async def cart_cat(*din, order=None) -> b'cart_type(din, order)': if order is None: order = range(len(din)) async with gather(*din) as data: dout_data = [] dout_eot = Unit() for o in order: d = data[o] # for d in data: if isinstance(d, Queue): dout_data.append(d.data) dout_eot = dout_eot @ d.eot else: dout_data.append(d) yield (dout_data, dout_eot)
async def fixp_arith(x: Fixpnumber, y: Fixpnumber) -> Ufixp[6, 9]: async with gather(x, y) as data: yield (data[0] + data[1]) + (data[0] + data[1])
async def add_real_part_module(x: TComplex, y: TComplex) -> b'x[0]': res: x.dtype[0] + y.dtype[0] async with gather(x, y) as data: res = add_real_part_func(data[0], data[1]) yield code(res, x.dtype[0])