What is wrong with the following code. Am I not supposed to use randomize method outside the class?
module top;
typedef struct {
bit [3:0] a;
bit [3:0] b;
} x_struct;
class c1;
rand x_struct x_st;
endclass
initial begin
c1 c1_inst;
c1_inst = new;
void'( randomize(c1_inst));
end
endmodule
The compiler throws error randomize method call failed.
dave_59
December 14, 2018, 4:09am
2
In reply to verif_learner :
There’s nothing wrong with your code other than being unconventional. Why you not call c1_inst.randomize()?.
Works for me in 3 different simulators.
In reply to dave_59 :
This is a tool support issue. I got error message saying “rand unpacked structs are not currently supported; use “-svrnc rand_struct” to enable their use.” with simvision.
And simulation went through with this command.
irun test_rand.sv -svrnc rand_struct
In reply to MayurKubavat :
thanks