class packet;
bit [7:0] a;
rand bit [7:0] b;
bit [7:0] c;
bit [7:0]j;
foreach(b[i])
c[i] == 2**i;
endclass
module inline_constr;
initial begin
packet pkt;
int i;
pkt = new();
//pkt.b = 8'b10010000;
//pkt.j=8'h00;
//pkt.add();
//repeat(10) begin
//pkt.randomize();
foreach(pkt.c[i])
$display("Value of b = %0d",pkt.c);
//end
end
endmodule
Its throws following error
SystemVerilog keyword ‘foreach’ is not expected to be used in this context.
In class, is it not possible to use foreach and i see error while assigning variables with class on = sign.
Could you comment on this.