This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CHAPTER 9 Packagesand Libraries This chapter explains packages and how compiled design units are stored in design libraries. It explains how the contents of design units stored in different libraries may be shared by several design units. A package provides a convenient mechanism to store and share declarations that are common across many design units. A package is represented by 1 . a package declaration, and optionally, 2. a package body. 9.1 Package Declaration A package declaration contains a set of declarations that may possibly be shared by many design units. It defines the interface to the package, that is, it defines items that can be made visible to other design units, for example, a function declaration. A package body, in contrast, contains the hidden details of a package, for example, a function body. The syntax of a package declaration is package package-name is package-item-declarations "> These may be:- subprogram declarations ~ type declarations- subtype declarations- constant declarations- signal declarations- file declarations- alias declarations- component declarations- attribute declarations- attribute specifications- disconnection specifications- use clauses end [ package-name ] ; An example of a package declaration is given next. package SYNTH_PACK is constant LOW2HIGH: TIME := 20ns: type ALU_OP is (ADD, SUB, MUL, DIV, EQL); attribute PIPELINE: BOOLEAN; type MVL is ('U', '0', '1', 'Z'); type MVL_VECTOR is array (NATURAL range <>) of MVL; subtype MY_ALU_OP is ALU_OP range ADD to DIV; component NAND2 port (A, B: in MVL; C: out MVL); end component; end SYNTH_PACK; Items declared in a package declaration can be accessed by other design units by using the library and use context clauses. The set of common declarations may also include function and procedure declarations and deferred constant declarations. In this case, the behavior of the subprograms and the values of the deferred constants are specified in a separate design unit called the package body. Since the previous package example did not contain any subprogram declarations and deferred constant declarations, a package body was not necessary. Consider the following package declaration. use WORK.SYNTH_PACK. all: package PROGRAM_PACK is constant PROP_DELAY: TIME; -A deferred constant. function "and" (L, R: MVL) return MVL; procedure LOAD (signal ARRAY_NAME: inout MVL_VECTOR; START_BIT, STOP_BIT, INT_VALUE: in INTEGER); end PROGRAM_PACK; In this case, a package body is required. 9.2 Package Body 78 A package body primarily contains the behavior of the subprograms and the values of the deferred constants declared in a package declaration. It may contain other declarations as well, as shown by the following syntax of a package body....
View Full Document
This note was uploaded on 08/24/2011 for the course ECE 231 taught by Professor Damodar during the Spring '10 term at IIT Kanpur.
- Spring '10