Hi all ,
A while ago there was a thread related to int’() cast within with() clause ( unable to find it now ) .
It was related to int’() cast inside with() clause of sum().
I tried the following codes ::
// CODE 1
class WITH_CLAUSE1() ;
rand int a , b ;
rand bit [30:0] A[2] ;
constraint ADDITION {
A[0] == a ; A[1] == b ; // [X]
a + b == ( 32'd2**32 - 2 ) ;
}
endclass
With CODE 1 , I see Output :: '{a:'h7FFFFFFF, b:‘h7FFFFFFF, A:’{'h7FFFFFFF, 'h7FFFFFFF}}
With above , MSb of A[0] and A[1] is 0 , since both a and b are Sized to 32-bits with MSb as 0.
// CODE 2
class WITH_CLAUSE2() ;
rand bit [30:0] a[2] ;
constraint WITH {
a.sum() with ( int'( item ) ) == ( 32'd2**32 - 2 ) ;
}
endclass
This has failure on some simulator whereas on some simulator I see both a[0] and a[1] as 'h7FFFFFFF.
Similar to Code1 above , shouldn’t the elements a[0] and a[1] in Code2 both have MSb as 0 ??
Here’s my Question :: [Q1] Is there a difference between Code 1 and Code 2 above ?