Randomization Query

Hi, I have a question regarding a randomization i am trying to modify.
The current code i have which works is as below:

      if (max_sleep_cycles <= 200) max_sleep_cycles = $urandom_range(50,200);
      
      std::randomize(sleep_cycles) with {
        if(do_intr_abort_exit) sleep_cycles <= 60000;
        sleep_cycles  dist {
         [10:20000]       :/ 5,
         [20001:60000]     :/ 11,
         [60001:130000]    :/ 14,
         [150001:200000]    :/ 60
        };
        sleep_cycles <= max_sleep_cycles;
      };

I am trying to add some modifications to it, below is my modified code:

     if (max_sleep_cycles <= 200) max_sleep_cycles = $urandom_range(50,200);
      
      std::randomize(sleep_cycles) with {
        if(do_intr_abort_exit) 
          sleep_cycles <= 60000;
        else
          if(sleep_sync == 1'b1) 
          sleep_cycles  dist {
           [150001:170000]    :/ 45,
           [170001:200000]    :/ 45
          };
          else
          sleep_cycles  dist {
           [10:20000]       :/ 5,
           [20001:60000]     :/ 11,
           [60001:130000]    :/ 14,
           [150001:200000]    :/ 60
          };
        sleep_cycles <= max_sleep_cycles;
      };

With my modification, i am getting the below error
integer max_sleep_cycles = 69841;
bit[0:0] do_intr_abort_exit = 1’h0;
bit[0:0] sleep_sync = 1’h1;
rand integer sleep_cycles; // rand_mode = ON

constraint WITH_CONSTRAINT // (from this) (constraint_mode = ON)
{
((!do_intr_abort_exit) && (sleep_sync == 1’h1)) → (sleep_cycles dist {[150001:170000] :/ 45, [170001:200000] :/ 45});
(sleep_cycles <= max_sleep_cycles);
}

Iam not sure what i am doing wrong, can someone tell where i am going wrong and how to resolve it

Thanks,
Sid

In reply to sid1406:

Please use code tags making your code easier to read. I have added them for you.

It would also help to show a complete example, especially all the variable declarations and their values when the call to randomize is made.

But it’s seems your conflict is you have a constraint {sleep_cycles <= max_sleep_cycles} and you have randomized max_sleep_cycles to be a value between 50 and 200, and you have another constraint where sleep_cycles had to be in the range 150001 to 200000.

In reply to dave_59:

Hi Dave,

Yeah i understand that the at first i have the max_sleep_cycles to be a value between 50 and 200. What i don’t understand is that, how come the code which works is fine with it.

*In reply to sid1406:*i

Explain to us why you think the code that is working should not work. It would really help to see a complete reproducible example.