Help about if statement in constraint block

In reply to Vinay Jain:

This is a big debate. Although it may seam easier to use ‘randomize with’, it does not always scale to the ‘OOP’ way of doing things because it becomes difficult to extend procedural code. If you really want packets of a particular cmd, you should extend the packet class with the additional constraints

class packet_cmd0 extends packet;
`uvm_object_utils(packet_cmd0;
constraint cmd0 {cmd == 0;}
endclass

Then create this class instead of the packet class.