Hi all,
I was trying to generate this sequence by using constraint → 021346578. This is my code -
module test;
class generate_pattern;
rand int array[];
int j=0,k=0,num1 = 0,num2 = 2;
constraint size{array.size == 9;}
constraint condition{foreach(array[i])
array[i]==func(i);}
function int func (int i);
if(!(i%2))
begin
func = num1;
if(j==0)
begin
num1++;
j++;
end
else
begin
j = 0;
num1+=3;
end
end
else
begin
func = num2;
if(k==0)
begin
num2++;
k++;
end
else
begin
num2+=3;
k=0;
end
end
endfunction
function void post_randomize();
$display("%0p",array);
endfunction
endclass
generate_pattern pkt = new;
initial
begin
assert(pkt.randomize());
end
endmodule
- This should have given the required output. But it’s giving the following error message .
Error-[CSTR-UMC] Constraint: unsupported method call
testbench.sv, 176
test, “this.func(i)”
Method generate_pattern::func contains a construct not supported in
constraint functions: driving a non-local variable ‘num1’ at line 185 of
testbench.sv.
Rewrite the method to avoid unsupported constructs.
Error-[CSTR-UMC] Constraint: unsupported method call
testbench.sv, 176
test, “this.func(i)”
Method generate_pattern::func contains a construct not supported in
constraint functions: driving a non-local variable ‘j’ at line 186 of
testbench.sv.
Rewrite the method to avoid unsupported constructs.
Error-[CSTR-UMC] Constraint: unsupported method call
testbench.sv, 176
test, “this.func(i)”
Method generate_pattern::func contains a construct not supported in
constraint functions: driving a non-local variable ‘j’ at line 190 of
testbench.sv.
Rewrite the method to avoid unsupported constructs.
Error-[CSTR-UMC] Constraint: unsupported method call
testbench.sv, 176
test, “this.func(i)”
Method generate_pattern::func contains a construct not supported in
constraint functions: driving a non-local variable ‘num1’ at line 191 of
testbench.sv.
Rewrite the method to avoid unsupported constructs.
Error-[CSTR-UMC] Constraint: unsupported method call
testbench.sv, 176
test, “this.func(i)”
Method generate_pattern::func contains a construct not supported in
constraint functions: driving a non-local variable ‘num2’ at line 202 of
testbench.sv.
Rewrite the method to avoid unsupported constructs.
Error-[CSTR-UMC] Constraint: unsupported method call
testbench.sv, 176
test, “this.func(i)”
Method generate_pattern::func contains a construct not supported in
constraint functions: driving a non-local variable ‘k’ at line 203 of
testbench.sv.
Rewrite the method to avoid unsupported constructs.
Error-[CSTR-UMC] Constraint: unsupported method call
testbench.sv, 176
test, “this.func(i)”
Method generate_pattern::func contains a construct not supported in
constraint functions: driving a non-local variable ‘num2’ at line 207 of
testbench.sv.
Rewrite the method to avoid unsupported constructs.
Error-[CSTR-UMC] Constraint: unsupported method call
testbench.sv, 176
test, “this.func(i)”
Method generate_pattern::func contains a construct not supported in
constraint functions: driving a non-local variable ‘k’ at line 208 of
testbench.sv.
Rewrite the method to avoid unsupported constructs.