mux

Multiplexes the data, i.e. can be used to select which part of the input data to forward to output.

mux(ctrl: Uint, *din) → Union:

Uses the value received at the ctrl input to select from which input interface the data should be forwarded to the output. din is a tuple of interfaces, and the data recieved on ctrl input is used as an index to select the interface to forward.

ctrl = drv(t=Uint[2], seq=[0, 1, 2, 0, 1, 2])
a = drv(t=Uint[4], seq=[10, 11])
b = drv(t=Uint[5], seq=[20, 21])
c = drv(t=Uint[6], seq=[30, 31])

mux(ctrl, a, b, c) \
    | check(ref=[(10, 0), (20, 1), (30, 2), (11, 0), (21, 1), (31, 2)])
mux(ctrl: Uint, din: Tuple) → Union:

Uses the value received at the ctrl input to select which part of the Tuple received at the din input should be forwarded to the output. The data recieved at the ctrl input is used as an index to select which field of the Tuple to forward.

ctrl = drv(t=Uint[2], seq=[0, 1, 2])

drv(t=Tuple[Uint[4], Uint[5], Uint[6]], seq=[(10, 20, 30), (11, 21, 31), (12, 22, 32)]) \
    | mux(ctrl) \
    | check(ref=[(10, 0), (21, 1), (32, 2)])