system verilog - systemverilog return dynamic array from function -
i trying return dynamic array function, did dome job dont know how dynamic, mean without declare "data_len" helping,
module test1(); typedef integer dyn_arr[]; function dyn_arr get_register_name(); int data_len = 3; get_register_name = new [data_len] ; get_register_name[0] = 5; get_register_name[1] = 2; endfunction dyn_arr my_q; initial begin my_q = get_register_name(); $display("%d",my_q[1]); $display("%d",my_q[0]); end endmodule
you can pass dynamic array reference in function purpose.
here sample code it.
module tp(); integer a[]; initial begin return_x(a); $display("a - %p", a); end endmodule function automatic void return_x(ref integer x[]); x = new [3]; x = '{3,3,3}; endfunction // output - // - '{3, 3, 3}
Comments
Post a Comment