can any one help me passing an array to a function using verilog.
module x;
integer x1;
function func (ref integer a[]);
$display ("%p", a);
endfunction
initial begin
integer a [];
a = {1,2,3,4,5};
x1=func(a);
end
endmodule
Error-[SE] Syntax error
Following verilog source has syntax error :
“design.sv”, 46: token is ‘integer’
function func1 (ref integer a);
In reply to sambasiva:
Function with ref arguments shall be automatic - your function inside module is static by default.
thank you for educating on this. Learning is always a never-ending action.
module x;
integer x1;
function automatic func (ref integer a);
$display (“%p”, a);
endfunction
initial begin
integer a [];
a = {1,2,3,4,5};
x1=func(a);
end
In reply to Srini @ CVCblr.com:
thank you but it didn’t helped me
module x;
integer x1;
function automatic func1 (ref integer a);
$display (“%p”, a);
endfunction
initial begin
integer a ;
a = {1,2,3,4,5};
x1=func1(a);
end
endmodule
Error-[SE] Syntax error
Following verilog source has syntax error :
“design.sv”, 45: token is ‘integer’
function automatic func1 (ref integer a);
This seems to be simulator issue. It works for me.