Constraint for 32 bit addr to be different than prev addr by 2 bits

In reply to dave_59:

Hi Dave,

I tried the pre_randomize method instead const. I observed that prev_addr initializes to 0. So if I want the addr to be between certain range say [200:800] constraint fails.


  rand int addr;
  int prev_addr;
  
  function void pre_randomize();
    prev_addr = addr;
  endfunction
  
  constraint c1{
    addr inside{[200:800]};
    addr == prev_addr +4;
  }