Vhdl package file




















One issue to be aware of is that std. To allow for this, include the package file: ieee. This example uses a 1-bit full-adder at the lowest level. The next highest level creates what is known as a ripple-carry adder. The test bench creates stimulus for the ripple-carry adder to exercise the logic and store the results to a file. In order to compile this code correctly, all three source files need to be in the same directory and compiled into Library Work.

See the Modelsim tutorial for beginners for detail. The body section contains the actual implementation of the functions and procedures.

If you've used C before, the declaration section is similar to a. Packages in combination with libraries are an excellent way that VHDL allows the digital designer to organize his or her code. By grouping functionality that belongs together, designs make much more sense and are leaner. They also allow you to write code that is reusable. You might find one particular package file being used again and again throughout your designs if it has some useful functions or constants.

It is preferable to put all of your component definitions in a single package file, rather than copy and pasting them everywhere the component is instantiated. This way, if the port map changes, only the package file and the actual instantiations need to be updated.

Constants and types that appear repeatedly throughout your code should likely be grouped together in a package file. At least those are restrictions imposed by the Altera software. The main drawback of this simple package arrangement is that the package s can only be accessed by the designer s who are using the same working directory.

When multiple designers work on a project, it is desirable for each of them to have their own working directory and have access to a common user library. This is shown in the following example.

Assuming the common user library is "usrlib01" the "01" is to emphasize the fact that there my be several user libraries , the directory structure may be as follows. There are four main differences with the previous, simpler, Altera-based , example:. There now must be a library statement identifying the package library. A complete example is given below, including the commands needed for the library pointer setup. This example is a little more elaborate than the previous one as it shows the use of multiple components, which is more typical of a large design.

We'll use a structural or hierarchical approach in the VHDL code, i. The design requires a source file for the circuit, a package file, a package name, a pointer to the package, a working directory and a user library. It is possible to use the same name for some of these items, but here we'll use all different ones to make it clearer what is what. A list of the various constituents is shown on the next page. It doesn't matter in which order cct. Note that it is desirable to list the directory where the package is located in the comment section, since it doesn't appear in the code itself.

Note also, that in the code there is no mention of a component. One of them is: "Undefined identifier" with myand2 highlighted in the source code. It does mapping though and the RTL view is as shown below:. This l ooks OK, because it's just like the schematic shown on page 1. However, keep in mind that the source code by itself contains enough information to draw an entity.

What you cannot see is that the blocks are empty. Now re-instate the user library statements and compile cct. This time the compiler will give several errors, one of them being:. However, you would get the same message if the file did exist but it hadn't been added to the project or no pointer had been defined. There are several things worth noting. One; the "use ieee On the other hand, the "library ieee For easy of reading and documentation purposes, it may be repeated, however.

The way Synplicty handles packages is the way it is intended in the language.



0コメント

  • 1000 / 1000