Hi all ,
I was trying if I could achieve a unique array without array.sum() / unique constraint .
So I tried the following ::
module UNIQ_via_inside ;
class Main ;
rand bit [2:0] b [] ;
constraint SIZE { b.size() == 5 ; }
constraint UNIQ {
foreach( b[ i ] )
{
if( i == 0 )
{
!( b[i] inside { b[ ( i+1) : ( b.size() - 1 ) ] } ) ;
}
else if ( i == ( b.size() - 1 ) )
{
!( b[i] inside { b[ 0: ( b.size() - 2 )] } ) ;
}
else
{
!( b[i] inside { b[0 : ( i - 1 ) ] , b[ ( i + 1 ) : ( b.size() - 1 ) ] } ) ;
}
}
}
endclass
Main m1 ;
initial begin
m1 = new() ;
repeat( 5 )
begin
if( m1.randomize() )
$display("Success with %0p " , m1.b);
else
$display(" FAILS ");
end
end
endmodule
This however doesn’t work due to Illegal Slice Compilation Error
Any suggestions ?