Concept Flow - Signal routing (Mux, Demux, Switch)
Input Signals
Single Combined Signal
Separated Signals
Selected Output Signal
Signal routing uses Mux to combine signals, Demux to split them, and Switch to select which signal passes through.
inputs = [1, 2, 3] muxed = inputs # Mux combines signals into one bus (list here) demuxed = muxed # Demux splits combined signal back (list here) switched = demuxed[1] # Switch selects signal based on control=1 print(switched)
| Step | Action | Input | Control | Output | Notes |
|---|---|---|---|---|---|
| 1 | Input signals ready | [1, 2, 3] | - | [1, 2, 3] | Initial separate signals |
| 2 | Mux combines signals | [1, 2, 3] | - | [1, 2, 3] combined | Signals combined into one bus |
| 3 | Demux splits signals | [1, 2, 3] combined | - | [1, 2, 3] | Combined signal split back |
| 4 | Switch selects signal | [1, 2, 3] | 1 | 2 | Control=1 selects second signal |
| 5 | End | - | - | 2 | Output is selected signal |
| Variable | Start | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|
| inputs | [1, 2, 3] | [1, 2, 3] | [1, 2, 3] | [1, 2, 3] | [1, 2, 3] |
| muxed | - | [1, 2, 3] combined | [1, 2, 3] combined | [1, 2, 3] combined | [1, 2, 3] combined |
| demuxed | - | - | [1, 2, 3] | [1, 2, 3] | [1, 2, 3] |
| switched | - | - | - | 2 | 2 |
Signal routing uses: - Mux: combines multiple signals into one bus - Demux: splits combined bus back to signals - Switch: routes one input to output based on control Control input in Switch selects which signal passes through Used to organize and select signals in Simulink models
Input1 = 3;
Input2 = 7;
Input3 = 5;
mux_out = Mux([Input1, Input2, Input3]);
demux_out = Demux(mux_out);
demux_out[1] (the second output of Demux)?Pass the test and this pattern moves unknown