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.
Was trying the above code using the latest edatools, I observe that 2 of 3 tools now treat the code as legal
(1) Does 1800-2023 make any new mention about scope of std::randomize ?
Section 18.2 of 1800-2023 says
The scope randomize function behaves exactly the same as a class randomize method except that it operates on the variables of the current scope instead of class member variables
(2) So why is hierarchical referencing discussed in thread illegal for class randomize method whereas it’s legal for std::randomize ?
(3) In a module is the prefix std:: when calling the randomize function optional ?