Hi everyone, I am pretty much new in SV. I am trying write a constraint, based on strobe and valid bit, particular bits of address bits will be valid and printed. But as I understand in SV Queues, we can’t assigning in queue unless we define it. How can we achieve the intention which I mentioned here in code?
class packet;
bit [63:0] address;
bit [7:0] strobe;
bit [7:0] data[$];
bit valid;
constraint c1 {
if (strobe==0 && valid==1)
data = address[7:0];
else if (strobe==1 && valid==1)
data = address[15:8];
else if (strobe==2 && valid==1)
data = address[23:16];
else if (strobe==3 && valid==1)
data = address[24:30];
else if (strobe==4 && valid==1)
data = address[38:31];
else if (strobe==5 && valid==1)
data = address[39:47];
else if (strobe==6 && valid==1)
data = address[48:55];
else if (strobe==7 && valid==1)
data = address[56:63];
else; }
endclass`
module TB;
packet pkt;
pkt = new();
initial begin
address = 'h1234_45678_9ABC_DEF10;
strobe = 1;
valid =1;
$display("Address:%0h, Strobe:%0h, Valid:%0d, VALID_DATA:%0h", address, strobe, valid, pkt.data[]);
end
endmodule
Thanks and Regards,