Search code examples
rangecoverspecmane

Specman coverage: Is there a way to define ranges using variable?


I have comp_value that gets values between 1 .. 100. In addition I have an input variable period (of the same range). I need to cover 2 ranges of comp_values: [1..period] and [period+1 .. 100]. Something like this:

cover some_event_e is {
        item period using no_collect;
        item comp_val using no_collect,
            ranges = {
                range([1..period], "Smaller_than_period");
                range([period+1..100], "Bigger_than_period");
            };
    };

(The code causes compilation error since no variable can be written inside range). Is there a way to collect the coverage? Thank you for your help.


Solution

  • Ranges must be constant.

    But if I understood your intent correctly, you can define new items like

    cover some_event_e is {
      item smaller_or_equal_than_period: bool = (comp_val in [1..period]) using 
        ignore = (not smaller_or_equal_than_period);
      item greater_than_period: bool = (comp_val in [(min(100,period+1)..100]) using
        ignore = (not greater_than_period); 
    };
    

    Assuming period is always in [1..100].