Hi

I want to pass a signal with a defined typedef into a function, however I got this error:

* 10476: type identifier "data" does nto agree with its usage as "int_array" type.*

10559: actual formal parameter "data" must be a signal

and I couldn't find an answer for it. My code is as followed.

Code:

-------------- Sub function ---------------------
package function_list is
--* typedef
type int_array is array (integer range <>) of integer;
--* functions
function sum(signal data: int_array(0 to 9)) return integer;
end function_list;
package body function_list is
function sum(signal data: int_array(0 to 9)) return integer is
variable sum_val: integer range 0 to 255 :=0;
begin
for i in 0 to 9 loop
sum_val:= sum_val + data(i);
end loop;
return sum_val;
end sum;
end function_list;
--------------- Main file --------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
use work.function_list.all;
architecture rtl of main is
type int_array is array (integer range <>) of integer;
signal data: int_array(0 to 9);
begin
sum_process: process(sum_flag,clk)
variable sum_val: integer range 0 to 255;
begin
if rising_edge(clk) then
if sum_flag = '1' then
sum_val:= sum(data);
end if;
end if;
end process;
end rtl;

## Bookmarks