FPGA Center



PACKAGE

Package is a unit for grouping declarations for use in different designs.

PACKAGE DECLARATION

package package_name is
     package_declaration
end package package_name;

EXAMPLE 1:

library Packages;
use
Packages.MUX_FUN.all;
architecture
Behavioral of MUX is
................
end architecture MUX;

In this example all declarations in Mux_Fun package located in Packages library can be used Behavioral architecture od MUX ntity.

EXAMPLE 2:

library IEEE;
use
IEEE.STD_LOGIC_1164.all;
package
MUX_FUN is
constant latency : Integer;
type
MUX_in is array (INTEGER range<>) of BIT_VECTOR (0 to 7);
type
state is (IDLE,STOP,START );
subtype
MUX_address is POSITIVE;
function
Adress_E (IN1 : MUX_in) return MUX_address;
end MUX_FUN;

Since MUX_FUN package contains a function declatarion and a deferred constant, a package body should be defined for this package.

PACKAGE BODY

Subprograms are declared and values of deferred constants defined in this section.

package body package_name is
     package body_declaration
     subprogram body_declarations
     deferred constatnt_declarrations
end package body package_name;

EXAMPLE 3:

library IEEE;
use
IEEE.STD_LOGIC_1164.all;

package MUX_FUN is
     constant latency : Integer;
      type
MUX_in is array (INTEGER range<>) of BIT_VECTOR (0 to 7);
      type
state is (IDLE,DUR,BASLA );
      subtype
MUX_address is POSITIVE;
      function
Adress_E (IN1 : MUX_in) return MUX_address;
end MUX_FUN;
 
package body MUX_FUN is
  constant latency : Integer := 13;
  function Adress_E (IN1 : MUX_in) return MUX_address is  
      begin
          ............
      end;   
end package body MUX_FUN;

In this example package declaration takes place first, then package body does. Both has the same name.

 

                                                                                                           

    

                                                                                                                                    

 

                                                                                                                                                                                                                                                                   

Home | Fpga | VHDL | VHDL Dictionary | Digital Design | Simulation | PCB | Examples | Contact Us
Copyright © 2010 - 2013 FPGAcenter. All Rights Reserved.