Hello,
I try to use a static function inside a constraint but I see the following error:
*xmsim: F,NWINFUNC (./testbench.sv,31|30): A new() was called by a function in a constraint. The unique id of the failed randomize call is 0.
My code from below can be run here:
class static utils#(type T=int);
static function bit exist(T q[$], T item);
foreach(q[i])
if(q[i] == item)
return 1;
return 0;
endfunction
endclass
class test;
rand int aux;
endclass
module tb;
int q[$] = {1};
string str[$] = {"hello"};
test t1;
initial begin
$display(utils#(int)::exist(q,0));
$display(utils#(int)::exist(q,1));
$display(utils#(string)::exist(str,"hello"));
$display("*****TEST CLASS*****");
t1 = new();
void'(t1.randomize with {
aux == utils#(int)::exist(q,1);
});
$display("t1.aux=%0d",t1.aux);
#10;
$finish(0);
end
endmodule
Please let me know if it’s possible to use a static function inside a constraint.
Thank you,
Eduard.