Hi all ,
I am trying the following Code , but for some reason it doesn’t even Compile .
// Sample 1
class A # ( int A , B = A ) ; // In case 2nd Argument isn't Given
rand int unsigned Arr [A]**;
typedef int unsigned q_return [$:(A*B)-1] ; // TO Return Unpacked Array ( Queue ) from a Function
constraint UNIQ {
foreach(Arr[A,B])
{
.... // Some Logic When Unique Constraint Should be Applicable
unique { Entire_Block( A , B , Arr ) } ; // Calling a Function in Unique Constraint
}
}
function q_return Entire_Block ( input int a , b , input int unsigned Arr[A][B] ) ;
.. // Some Logic Used when I want Values to be Pushed
Entire_Block.push_back(..)
endfunction
endclass
I get the Following Message ::
Simulator 1 => Error :: Invalid argument ‘Entire_Block(this,Row,Col,this.Arr)’ specified for ‘unique’ constraint
Simulator 2 => Error :: Non-constant expression .
The following expression should be a constant.
Expression: ((Row * Col) - 1) // [b]Points to typedef Statement**
[Q1] Is there a Restriction on Calling Functions inside Unique Constraint ?
A Unique Constraint does accept a Queue , Unpacked Array inside it . My Code returns the Queue instead of Explicitly Mentioning it
I then try the following Code
// Sample 2
class A # ( int A , B = A ) ; // In case 2nd Argument isn't Given
rand int unsigned Arr [A]**;
rand int unsigned q[$:(A*A)-1][$:(B*B)-1] ;
typedef int unsigned Unpkd_return [0:(B*B)-1] ; // TO Return Unpacked Array from a Function
constraint UNIQ {
foreach(Arr[A,B])
{
.... // Some Logic When Constraint Should be Applicable
q[A] == Entire_Block( A , B , Arr ) ; // Shows Error Here !!
}
}
function Unpkd_return Entire_Block ( input int a , b , input int unsigned Arr[A][B] ) ;
int Index ;
// Some Logic Used when I want Values to be Written
for ( int i = 0 ; i < A ; i ++ )
begin
for ( int j = 0 ; j < B ; j ++ )
begin
Entire_Block[Index] = (Arr[a+i][b+j]);
Index++;
end
end
endfunction
endclass
I get the Following Message ::
Simulator 1 :: Illegal non-integral expression in random constraint.
Simulator 2 => Error :: Non-constant expression .
The following expression should be a constant.
Expression: ((Row * Col) - 1) // [b]Points to typedef “Unpkd_return” Statement**
[Q2] Is the Statement " q[A] == Entire_Block( A , B , Arr ) " incorrect ?
Regards ,
AGIS