Professional Documents
Culture Documents
Component, Package, Function & Procedure
Component, Package, Function & Procedure
COMPONENT component_name IS
PORT (
port_name : signal_mode signal_type;
port_name : signal_mode signal_type;
...);
END COMPONENT;
COMPONENT instantiation:
1
Lecture 4: Component, Package, Function & Procedure Dr. Fadhil Sahib Al-Moussawi
2
Lecture 4: Component, Package, Function & Procedure Dr. Fadhil Sahib Al-Moussawi
BEGIN
U1: inverter PORT MAP (b, w);
U2: nand_2 PORT MAP (a, b, x);
U3: nand_3 PORT MAP (w, c, d, y);
END structural;
----------------------------------------------------------------
3
Lecture 4: Component, Package, Function & Procedure Dr. Fadhil Sahib Al-Moussawi
2. PACKAGE
Its syntax is presented below.
PACKAGE package_name IS
(declarations)
END package_name;
4
Lecture 4: Component, Package, Function & Procedure Dr. Fadhil Sahib Al-Moussawi
5
Lecture 4: Component, Package, Function & Procedure Dr. Fadhil Sahib Al-Moussawi
ENTITY project IS
PORT ( a, b, c, d: IN STD_LOGIC;
x, y: OUT STD_LOGIC);
END project;
6
Lecture 4: Component, Package, Function & Procedure Dr. Fadhil Sahib Al-Moussawi
3. FUNCTION
7
Lecture 4: Component, Package, Function & Procedure Dr. Fadhil Sahib Al-Moussawi
END my_package;
----------------------------------------------
8
Lecture 4: Component, Package, Function & Procedure Dr. Fadhil Sahib Al-Moussawi
4. PROCEDURE
A PROCEDURE is very similar to a FUNCTION and has the same basic
purposes. However, a procedure can return more than one value.
9
Lecture 4: Component, Package, Function & Procedure Dr. Fadhil Sahib Al-Moussawi
ENTITY min_max IS
GENERIC (limit : INTEGER := 255);
PORT ( ena: IN BIT;
inp1, inp2: IN INTEGER RANGE 0 TO limit;
min_out, max_out: OUT INTEGER RANGE 0 TO limit);
END min_max;
ARCHITECTURE my_architecture OF min_max IS
10
Lecture 4: Component, Package, Function & Procedure Dr. Fadhil Sahib Al-Moussawi
BEGIN
PROCESS (ena)
BEGIN
IF (ena='1') THEN sort (inp1, inp2, min_out, max_out); -- CALL PROCEDURE
END IF;
END PROCESS;
END my_architecture;
----------------------------------------------------------------
The simulation results is shown.
11
Lecture 4: Component, Package, Function & Procedure Dr. Fadhil Sahib Al-Moussawi
12