Rajan
Rajan

Reputation: 1

coverage for array with a fixed value of each element

I have a 1D array of 512 elements, which is 8 bit wide. I want the coverage to hit 100% only when a specific unique value is present in each of these 512 elements. For eg, let say we had only 4 elements, so I want the coverage to be 100% only when say 1st element is 0x1, 2nd is 0x2, 3rd is 0x3 and 4th is 0x4.

I am confused on how to achieve this.

I am new to this, haven’t tried anything yet. Wanted some direction on how to achieve this.

Upvotes: -1

Views: 68

Answers (1)

dave_59
dave_59

Reputation: 42673

You can always create a function that returns true for whatever condition you want to cover, and make a cover directive or coverpoint sample calling that function

  bit [7:0] array[];
  bit clk;   
  function bit is_unique(bit [7:0] arg[]);
    foreach(array[i])
      foreach(arg[j])
        if (i!=j && arg[i] == arg[j]) return 0;
    return 1;
  endfunction

  cover property (@(posedge clk) is_unique(array));

Upvotes: 0

Related Questions