Interleaving elements

In reply to rahulcodesinverilog:

Is your final sequence fixed to “0 1 0 2”. If yes, on what basis are you fixing it?
If my_q = {200,50,100,150}; i.e, when mod_rate[i] will be {4, 1, 2, 3}, what will be your expectation on output? It makes more sense not to have fixed order and let the order be random given the number of times for each port (Unless the specification fixes it for some reason). Specify more inputs, and the expected outputs for each input to get needed help.

And, what is the reason for choosing HCF way to decide the weights? Is it not the same 100:50:50:0 in that order (for 0, 1, 2, 3 ports)? i.e., 2:1:1:0. If that is the case, code can be simplified instead of using HCF calculation.