With in system verilog not giving expected output

Hi, This might be a very stupid question but my ‘q’ queue is coming out as empty with the following code. What am i missing? , also why is it that array locator methods such as max,min,unique,find give out a queue?

module tb;
int idx;
int q[$];
int d = '{9,1,8,7,2,4};
initial begin
q = d.find with (idx >3);
$display(“%p”,q);
q = d.find with (idx == 4);
$display(“%p”,q);
end
endmodule

In reply to yr:



Assuming your are expecting the queue values not the index.

module tb;
int idx;
int q[$];
int d[] = '{9,1,8,7,2,4};
initial begin
  q = d.find(idx) with (idx >3);
$display("%p",q);
  q = d.find(idx) with (idx == 4);
$display("%p",q);
end
endmodule

or if you want this


module tb;
int idx;
int q[$];
int d[] = '{9,1,8,7,2,4};
initial begin
  q = d.find(item) with (item.index >3);
$display("%p",q);
  q = d.find(item) with (item.index == 4);
$display("%p",q);
end
endmodule

In reply to rag123:

got that. I thought the variable is automatically declared.