class sample;
rand int i;
rand bit [2:0] array [10];
//constraint array_size {array.size() == 10;}
function bit [2:0] a [10] (int i);
for (i=0;i<=4;i++)
begin
a[i] = i;
$display("a[%0d] = %0d",i,a[i]);
end
for (i=9;i>=6;i--)
begin
a[i] = i;
$display("a[%0d] = %0d",i,a[i]);
end
endfunction
constraint elements {array == a(i);}
endclass
module arrayfunc;
initial
begin
sample s = new;
s.randomize();
end
endmodule
There’s a syntax error and I’m trying to print first 5 elements incrementing and nxt five in decreasing order using functional constraints.