LRM 18.12 says ::
The scope randomize function, std::randomize() , enables users to randomize data in the current
scope without the need to define a class or instantiate a class object
But the LRM isn’t clear if an object with random properties can be used as argument to it
Example ::
class seq ;
rand bit [1:0] b ;
bit [1:0] a ;
endclass
seq obj ;
initial begin
obj = new();
if ( std::randomize(obj.a) with { obj.a == 3 ; } ) // Valid ??
begin
$display("Success with a == %0d",obj.a);
end
else
begin
$display("Fails");
end
if ( std::randomize(obj.b) with { obj.b == 2 ; } ) // Valid ??
begin
$display("Success with b == %0d",obj.b);
end
else
begin
$display("Fails");
end
end
I see warning message on some Simulators ::
Warning: (vopt-2961) Argument #1 for std::randomize() function is non-LRM compliant.
While some throw Compilation Error ::
**if ( std::randomize(obj.a) with { obj.a == 3 ; } )
xmvlog: *E,RNDRARG : The argument to class or scope randomize must be a simple identifier of integral type.
**
[Q] Is this a violation based on LRM ??