In reply to skyhome0911:
//data size will be 8 . wherever the strobe is selected use mask, otherwise set to zero .
class packet;
rand bit [63:0] address;
rand bit [7:0] strobe;
rand bit [7:0] data[8];
bit valid;
bit [15:0] mask = 'hff ;
constraint c1 {
foreach(strobe[i]){
if(strobe[i])
data[i] == ((address & (mask << i*8)) >> i*8); // shift left to use the lower byte assignment
else
data[i] == 0 ;
}
}
endclass`