Help about if statement in constraint block

In reply to Vinay Jain:

Hi Vinay,

Thanks for the reply.

Anyway, I think I know what causes the problem. When the method this.pkt.randomize() occurs and it generates a cmd with a value of 1’b1, the data did not concatenate and just randomly generated… And then when I override it with this.pkt.cmd = 1’b0, I mistakenly concluded that the actual randomly generated value of cmd is 1’b0.

Anyway, I have already solved the problem. I just added the code below to override data during read operation.


// Set the item
this.pkt.randomize();
this.pkt.cmd     = 1'b0;
this.pkt.data    = {this.pkt.td, this.pkt.addr_inc, this.pkt.num_rd};
this.pkt.crc_key = crc({this.pkt.cmd, this.pkt.addr, this.pkt.data},
                         `GEN_POL);