Most modern HDL simulators, including our simx simulator, compile HDL source files into one or compiled libraries (referred to as symbolic libraries in the Verilog Language Reference Manual). By default, sources files will be compiled into a compiled library with the symbolic name of work, unless a different destination library is specified via the --work <destination_library_name> compiler option.
Once an HDL file has been compiled into a compiled library , the modules defined in that source file can be re-used across multiple designs without needing to recompile this source file again. For most users, this increase in compilation speed is the biggest advantage of using a compiler that supports compiled libraries. For example, if many of your simulations re-use primitives from the library source files of an FPGA/ASIC vendor, these files only need to be compiled once with compiled library support.
Cells and Snapshots
A compiled library contains cells and snapshots. Cells represent the definitions for objects such as modules and User-Defined Primitives (UDPs) that are created when source files are compiled into a library. Snapshots are created during simulation elaboration and represent a fully built “simulation” that can be executed.
Within a library, cell and snapshot names must be unique and any attempt to compile a cell into a library that already contains a cell of that name will cause the original cell to be overwritten. However, cells and snapshots of the same name can exist in different libraries.
Cell Instance Resolution During Compilation and Elaboration
When module instances are instantiated inside a user source file, the module definitions for these instances must be found by searching through your symbolic libraries during either the compilation or elaboration phase. The compiler and elaborator search for matching module definitions in the following order:
1.First, the current destination library is searched. The destination library is the compiled library to which all cells currently being compiled are being stored. The --work libname option can be used to set the destination library. If this option is not set, the default library known as work will be used as the destination library. 2.Next, any source code libraries are searched. The location and search order for source code libraries is specified using one or more -y options. For more information about using these libraries, see Section 2.9 Source Code Libraries. Source code libraries represent an older Verilog technology for storing frequently used module definitions in source code form rather than in a compiled form, so we recommend using compiled libraries instead. Compiled libraries are faster than source code libraries as the modules only need to be compiled once with any given version of the simulator. 3.Finally, any compiled libraries are searched. Use one or more -L options to specify the symbolic names of compiled libraries to be searched. The compiler/elaborator will map these symbolic names to the actual physical location of the compiled library using the library mappings specified in the scd.lib file. The compiled libraries will be searched in the order they are specified using the -L option (with the special exception of the destination library, which as previously stated, is always searched first). |
Creating and Viewing Compiled Libraries using BugHunter
•Under the Simulated Models folder, right click on the Compiled Libraries folder and choose Edit Compiled Libraries from the context menu to open the Compiled Libraries dialog where you can view the contents of existing compiled libraries referenced by the project and add new libraries. •To view an existing library not referenced by the project or to create a new library, press the Add Library button to open another dialog and fill in the library's symbolic name and the physical path of the library. •To delete a library, select the library and press the Remove Library button. •You can also use the simxlib command-line tool to create and delete compiled libraries. See Section 5.13 Simxlib: Compiled Library Utility for more details. |
Naming and Running Snapshots (Built Simulations) Using BugHunter
•To name a snapshot, press the Project Simulation Properties button on the button bar to open a dialog of the same name. •In the Snapshot box, type in the name of the snapshot or pass it as a compiler command-line option. If no snapshot name is specified, then the name of the first top-level module will be used as the default snapshot name. |
•When you press the yellow Build button, a snapshot is created and stored in the destination library. •When you press any of the green Run buttons, the named snapshot will loaded from the destination library and run. •You can tell which snapshot was built or ran by looking at Notes in the simulation.log file. The image below shows that simulator loaded and ran a simulation snapshot called "bob2" from the library called "work". |
Populating a Compiled Library
When simx compiles source code files, the compiled models are stored to the current destination library specified using the --work option. If no --work option is passed to simx, it will store the compiled models in a default library called work.