About cyclic randomlike the randc of SystemVerilog

Why OSVVM™? Forums OSVVM About cyclic randomlike the randc of SystemVerilog

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #309


    Can the cyclic random like the randc of SystemVerilog be described in OS-VVM?
    I think that I describe it by using the function coverage and RandCovPoint method.
    Is this idea correct?

    best regards,

    Ian Gibbins


    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:

    1. Create n-element array A (let’s say that it is indexed 0 to n-1)
    2. Fill array A with desired numbers ordered from minimal to maximal
    3. Create for loop with counter i and value range n-1 downto 1
    4. Within the loop you have to generate random number j from the range 0 to i and
    5. Swap A(i) with A(j) and go to the next loop iteration
    6. Initialize randc counter r to 0
    7. For each randc call return A(r) and increment r
    8. 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.

    Your Admin

    Jim Lewis

    Hi Kuri,

    For practical sized randc values, functional coverage plus RandCovPoint can do the same thing that randc does.   If your coverage goals are larger than 1, then you will want to use thresholding.  See the Coverage Package Users Guide in the distribution for details.  

    When using cross coverage, functional coverage plus RandCovPoint plus thresholding applies the principle of randc to each bin.  In fact, by changing the threshold percentage, you can either generate each bin one time before generating others or set the coverage goals higher and only randomize a bin that is within the specified percentage of the minimum coverage percentage.




    Hi Jerry-san and Jim-san

    Thank you for your advice.
    I understood this.

    Best regards,


Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.