-- VHDL code position: p218_ex8_6_axamp
-- Note : This is code for explaining "OVERLOADED FUNCTION" of VHDL
-- Debug : no debug
---------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.all;
PACKAGE packexp IS
FUNCTION max ( a, b : IN STD_LOGIC_VECTOR )
RETURN STD_LOGIC_VECTOR;
FUNCTION max ( a, b : IN BIT_VECTOR )
RETURN BIT_VECTOR;
FUNCTION max ( a, b : IN INTEGER )
RETURN INTEGER;
END;
PACKAGE BODY packexp IS
FUNCTION max ( a, b : IN STD_LOGIC_VECTOR )
RETURN STD_LOGIC_VECTOR IS
BEGIN
IF a > b THEN RETURN a; ELSE RETURN b;
END IF;
END FUNCTION max;
FUNCTION max ( a, b : IN BIT_VECTOR )
RETURN BIT_VECTOR IS
BEGIN
IF a > b THEN RETURN a; ELSE RETURN b;
END IF;
END FUNCTION max;
FUNCTION max ( a, b : IN INTEGER )
RETURN INTEGER IS
BEGIN
IF a > b THEN RETURN a; ELSE RETURN b;
END IF;
END FUNCTION max;
END BODY packexp ;
-------------------------------------------------------------------
--
--
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE WORK.packexp.all;
ENTITY axamp IS
PORT
(
a1, b1 : IN STD_LOGIC_VECTOR ( 3 DOWNTO 0 );
a2, b2 : IN BIT_VECTOR ( 4 DOWNTO 0 );
a1, b1 : IN INTEGER RANGE 0 TO 15;
c1 : OUT STD_LOGIC_VECTOR ( 3 DOWNTO 0 );
c2 : OUT BIT_VECTOR ( 4 DOWNTO 0 );
c3 : OUT INTEGER RANGE 0 TO 15
);
END axamp;
ARCHITECTURE behav OF axamp IS
BEGIN
out1 <= max (dat1, dat2);
PROCESS ( dat2, dat4 )
BEGIN
c1 <= max ( a1, b1 );
c2 <= max ( a2, b2 );
c3 <= max ( a3, b3 );
END PROCESS;
END ARCHITECTURE behav;