← All exercises

Demux 4

easy

An input is routed to one of four outputs chosen by a select input (0 to 3).

What it teaches

Inverse of Mux 4 — the select value decides which one of four outputs follows the input while the rest stay 0. Reinforces that mux and demux are duals: the same per-value cases with the roles of input and output swapped.

Inputs and outputs

TagTypeDefaultDescription
In_ValueDINT42Value to route
In_SelectDINT0Selector switch; 0 = select Out_0, 1 = select Out_1, 2 = select Out_2, 3 = select Out_3
Out_0DINTFirst output value
Out_1DINTSecond output value
Out_2DINTThird output value
Out_3DINTFourth output value

Required behavior

  • When In_Select is 0, Out_0 equals In_Value while all other outputs are 0.
  • When In_Select is 1, Out_1 equals In_Value while all other outputs are 0.
  • When In_Select is 2, Out_2 equals In_Value while all other outputs are 0.
  • When In_Select is 3, Out_3 equals In_Value while all other outputs are 0.
  • When In_Select is outside the 0 to 3 range, all outputs are 0.