- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
-------------- 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;
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is because of the strong typing in VHDL.
The int_array type in the function_list package is not the same type as the one you declared in the "main" entity. Hence the missmatch when you call the sum function, as data is int_array, while the function wants work.function_list.int_array The fix here is to remove the type declaration from the main file. You dont need it as it is already declared in the included function_list package. note: VHDL 2008 includes the integer_vector type that is an array of integers.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Tricky.
It get it now. Just one more question regarding to "integer_vector": - How to use / which package do I have to include so that I can use this "integer_vector" type ? Since it gives no suggestion for this type when I'm typing. I tried to search for answer but couldn't find. Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First of all, integer_vector requires that you use VHDL 2008. Quartus does not have full 2008 support unless you use Quartus Pro 17+, so it may not be supported.
integer_vector is part of the std.standard package that is included in all VHDL files by default, so no package inclusion is necessary.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page