In reply to ben@SystemVerilog.us:
Sorry, I just uploaded a hint of what I wanted to do, not the functional code itself.
I did something similar to solve the problem. I just wondered if there were an alternative without using auxiliary code.
Anyway, your solution is working fine, so thank you!