LOOP

Finally, the application provides a method to trace the Looping algorithm.  The looping algorithm is a recursive method used to set the switches of a Benes Network. The looping algorithm takes the initial permutation to set the outer switches, and generates the permutation to be realized by the two inner subnetworks. Each switch in the last stage receives one input from the upper subnetwork and one from the lower subnetwork; this will become apparent as we start tracing the algorithm.  

It is very simple to trace and understand the looping algorithm.  Let us trace the method with the (01234567, 01234567) permutation.  The initial state is shown, as we can see, the first stage outer switch automatically sends one of his inputs to the upper switch.  

 Now, click on the Next Iteration Button, which calls the next state of the switches.  In the following figure, it can be seen that the last stage outer switch followed the same process previously described. 

Invoking the next state shows the following, which shows once again that each outer switch (first and last stage switches) interchange its inputs with the upper and lower central switches (or subnetworks).

Invoking the next state will show a mirror image, which is the case for this permutation example.  However, the method is always the same, each outer switch sends one input to the upper subnetwork and the second input to the lower subnetwork.  Depending on the permutation being realized, the state of each individual outer switches may be changed to straight or exchange.  So far, all our outer switches have been set to straight. 

Let us continue the process for a few more traces. Now that we have completed the first two upper switches, the looping algorithm follows the same process for the next switch (namely inputs 2 & 3).  

 

The next iteration shows the same process being followed for the second switch in the last stage. 

After several calls to the algorithm, all outer switches are set as shown in the following figure.  As you can see, each switch has one input set to the upper subnetwork and the other input set to the outer subnetwork. 

Now the same method will be use to set the upper subnetwork.  But instead of worrying about the initial permutation (01234567, 01234567), we only need to worry about the permutation that the upper subnetwork needs to perform which is (0246, 0246).  The looping algorithm will set the switches in order to satisfy this permutation, without worrying about the settings of the lower subnetwork. The next figure shows the process of setting the upper subnetwork, which is essentially the same as setting the outer switches. 

The next iteration shows the exact same process followed previously, namely, the upper subnetwork has been set as a mirror image. 

After a few calls, the upper subnetwork gets set to satisfy the required permutation (0246, 0246). The same process will be employed to set the lower subnetwork but now to satisfy the permutation (1357, 1357)

Finally, after invoking the looping algorithm several times, the desired permutation is obtained (01234567, 01234567).  At this point, the looping algorithm has set the switches in all stages.