The quick answer is: you cannot do it in a quick and easy manner. You have to do some manual coding to get the required results. Let me explain quickly why:
- implementation of randc is memory hungry: for k-bit number you want to randomize you need at least n=2k element array to store permutations,
- algorithm for selecting sequences is time consuming and uses resources in very uneven manner.
Here is an outline of the algorithm:
- Create n-element array A (let’s say that it is indexed 0 to n-1)
- Fill array A with desired numbers ordered from minimal to maximal
- Create for loop with counter i and value range n-1 downto 1
- Within the loop you have to generate random number j from the range 0 to i and
- Swap A(i) with A(j) and go to the next loop iteration
- Initialize randc counter r to 0
- For each randc call return A(r) and increment r
- When r reaches n, jump to step 3.
As you see, flexible implementation of this algorithm requires smart decisions to balance memory usage and execution speed. We will investigate further, but for now I recommend creating fixed implementation suited to your particular needs.
One more thing, SV implementation of randc that meets LRM requirements cannot be really random! I will post explanation in the blog section soon.