0
\$\begingroup\$

I have a class of sequence item with rand variables:

class my_seq_item extends uvm_sequence_item;
rand bit a, b, c, d;

I want to generate a random bit for 'd' only if 'b' and 'c' are 0. How do I write a constraint for this?

\$\endgroup\$
  • \$\begingroup\$ What should bit 'd' be otherwise? Or stay the same? \$\endgroup\$ – Oldfart Jul 4 '18 at 21:07
  • \$\begingroup\$ bit 'd' should be 0 otherwise. If b and c are 0, bit d should be 1 \$\endgroup\$ – pavan sp Jul 4 '18 at 21:54
2
\$\begingroup\$
constraint my_constraint { if (b==0 && c==0) d==1; else d==0;}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.