def send_result( addr: Queue[Tuple[Uint['w_scale'], Tuple['y_scaled', 'x_scaled']], 1], res: Queue[Uint[1], 1]): demux_ctrl = res | yield_zeros_and_eot maybe_send = czip(addr, demux_ctrl) | Queue[Union[Unit, addr.dtype[0]], 1] detected_addr = maybe_send | filt(fixsel=1) interrupt = maybe_send[1] | yield_on_one_uint return detected_addr, interrupt
def when_single(cond, din, *, f): return ccat(din, cond) | Union | filt(fixsel=1) | f
def when_some(din: Maybe) -> b'din.dtype': return din | filt(fixsel=1)