Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Modelsim: compiling into libraries

Hi all,

I've a few questions regarding Modelsim:

1) libraries contain the VHDL files or the result of the compilation of these files?

2) How can I compile a file in a directory by my choice, different from the work directory?

3) In a testbench, i saw this:

library work;

use work.lib_one.all;

use work.lib_two.all;

This means that in work directory there are subdirectories named lib_one, lib_two, and in those subdirectories there were compiled some VHDL files.

How can I create subdirectories of WORK and compile there VHDL files?

Thanks a lot for your answers.

12 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thank u for your answer,

    yes, i'm a little bit confused. :)

    So if I want to write:

    library work;

    use work.lib_one.all;

    how have I to map the library lib_one?

    Have I to map it into work library?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I think you might be getting a bit confused. In VHDL, you have packages, which are part of a library. The standard format is:

    library lib;

    use lib.package.all;

    The libraries do not have to be in any specific directory. The libraries just contain compiled code. Any code can go wherever you want to put it. But inside a library, local bits can be referenced via work (rather than specifying the library name). This allows the whole library to reference itself while you are free to call it whatever you want.

    So in modesim, the libaries are created with the vlib command:

    vlib some_library;

    Then to compile code into a specific library, you can specify which library is the work library for that file:

    vcom some_file.vhd -work some_library_path

    some_library should be the path of the working directory for some_library.

    If you already have a completly compiled library, you can use vmap to add a library to your work directory:

    vlib some_library

    vmap some_library some_library_path

    (some_library_path will usually end with /work, because locally the directory is /work)

    So basically, the answer to the questions is:

    1. The compilation of the files, but you can work locally in a library with the files in then use vmap from another directory.

    2. See above (use the -work option on vcom)

    3. you are confused. the work.lib_one.all has nothing to do with file paths. It is the libary paths of compiled code.