• Debug Daily
  • Posts
  • (Solution) Constraint Challenge - Various Companies

(Solution) Constraint Challenge - Various Companies

Good morning debuggers!

Hope you enjoyed attempting yesterday’s question of the day.

The most concise solution to this question we found was provided by dave_59 on verification academy:

This clever use of const actually works to compare the old (pre_randomize) value of cur_val and new (post_randomize) value of cur_val without any need to track the previous value of cur_val seperate. This results in really clean and maintainable code, a major plus for any DV engineer. Try it out on EDA Playground!

class abc;
  rand bit [31:0] cur_val;
  constraint sel {
    $countones( const'(cur_val)^cur_val)==2;
  }
endclass

Reply

or to participate.