Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17268 Discussions

Question about component and packag

Altera_Forum
Honored Contributor II
1,051 Views

Hello, I am new to VHDL. I have a question about using a component in the package body which is defined in package head. But there is error about the port map in the package body. Could anyone help me on this? Thanks. 

the code is something like following: 

 

library ieee; use ieee.std_logic_1164.all; use work. comparator.all; package func_pkg is function compare (a, b: in std_logic_vector(3 downto 0)) return std_logic_vector(3 downto 0); component comparator port( in_a: in std_logic_vector(3 downto 0); in_b: in std_logic_vector(3 downto 0); alb: out std_logic ); end component; end package; package body func_pkg is function compare (a, b: in std_logic_vector(3 downto 0)) return std_logic_vector(3 downto 0) is variable result : std_logic_vector(3 downto 0); variable sig_l : std_logic; begin cmp: comparator port map (in_a => a, in_b => b, alb => sig_l); if (sig_l = '1') then result := a; else resutl := b; end if; end function; end package body; 

 

where comparator is the component which input a, b and return 1 if a<b.
0 Kudos
0 Replies
Reply