In reply to ChyavanPhadke:
If you are only concerned about the new randomized value not being equal to only the previous value, then you can use the constraint "a != const'(a)". If you want to exclude multiple previous values, you will want to create a dynamic array and add the generated value to the array in the post_randomize() method.
class transaction;
rand bit a;
rand bit b;
rand bit c;
constraint a_non_repeating { a != const'(a); }; // New value of 'a' != previous value
function new();
endfunction
function void print();
$display("Values are a: %0d b: %0d c: %0d", a,b,c);
endfunction
endclass
module testbench();
transaction txn;
initial begin
txn = new();
repeat (20) begin
if (!txn.randomize()) $display("Randomization failure!");
else txn.print();
end
end
endmodule