Transcription

ModelSim TutorialSoftware Version 6.4a 1991-2008 Mentor Graphics CorporationAll rights reserved.This document contains information that is proprietary to Mentor Graphics Corporation. The original recipient of thisdocument may duplicate this document in whole or in part for internal business purposes only, provided that this entirenotice appears in all copies. In duplicating any part of this document, the recipient agrees to make every reasonableeffort to prevent the unauthorized use and distribution of the proprietary information.

This document is for information and instruction purposes. Mentor Graphics reserves the right to makechanges in specifications and other information contained in this publication without prior notice, and thereader should, in all cases, consult Mentor Graphics to determine whether any changes have beenmade.The terms and conditions governing the sale and licensing of Mentor Graphics products are set forth inwritten agreements between Mentor Graphics and its customers. No representation or other affirmationof fact contained in this publication shall be deemed to be a warranty or give rise to any liability of MentorGraphics whatsoever.MENTOR GRAPHICS MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS MATERIALINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ANDFITNESS FOR A PARTICULAR PURPOSE.MENTOR GRAPHICS SHALL NOT BE LIABLE FOR ANY INCIDENTAL, INDIRECT, SPECIAL, ORCONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING BUT NOT LIMITED TO LOST PROFITS)ARISING OUT OF OR RELATED TO THIS PUBLICATION OR THE INFORMATION CONTAINED IN IT,EVEN IF MENTOR GRAPHICS CORPORATION HAS BEEN ADVISED OF THE POSSIBILITY OFSUCH DAMAGES.RESTRICTED RIGHTS LEGEND 03/97U.S. Government Restricted Rights. The SOFTWARE and documentation have been developed entirelyat private expense and are commercial computer software provided with restricted rights. Use,duplication or disclosure by the U.S. Government or a U.S. Government subcontractor is subject to therestrictions set forth in the license agreement provided with the software pursuant to DFARS 227.72023(a) or as set forth in subparagraph (c)(1) and (2) of the Commercial Computer Software - RestrictedRights clause at FAR 52.227-19, as applicable.Contractor/manufacturer is:Mentor Graphics Corporation8005 S.W. Boeckman Road, Wilsonville, Oregon 97070-7777.Telephone: 503.685.7000Toll-Free Telephone: 800.592.2210Website: www.mentor.comTRADEMARKS: The trademarks, logos and service marks ("Marks") used herein are the property ofMentor Graphics Corporation or other third parties. No one is permitted to use these Marks without theprior written consent of Mentor Graphics or the respective third-party owner. The use herein of a thirdparty Mark is not an attempt to indicate Mentor Graphics as a source of a product, but is intended toindicate a product from, or associated with, a particular third party. A current list of Mentor Graphics’trademarks may be viewed at: www.mentor.com/terms conditions/trademarks.cfm.

Table of ContentsChapter 1Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Assumptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Before you Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Example Designs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9999Chapter 2Conceptual Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Basic Simulation Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Project Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Multiple Library Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Debugging Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1111121314Chapter 3Basic Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Create the Working Design Library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Run the Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Set Breakpoints and Step through the Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Navigating the Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1516202225Chapter 4Projects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Create a New Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Add Objects to the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Changing Compile Order (VHDL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Compile the Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Load the Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Organizing Projects with Folders. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Add Folders. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Moving Files to Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Simulation Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31313234353637373939Chapter 5Working With Multiple Libraries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Creating the Resource Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Creating the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Linking to the Resource Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Linking in Verilog. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Linking in VHDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Permanently Mapping VHDL Resource Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43434546484951ModelSim Tutorial, v6.4a3

Table of ContentsChapter 6Analyzing Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Loading a Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Add Objects to the Wave Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Zooming the Waveform Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Using Cursors in the Wave Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Working with a Single Cursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Working with Multiple Cursors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53545455565658Chapter 7Viewing And Initializing Memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .View a Memory and its Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Navigate Within the Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Export Memory Data to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Initialize a Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Interactive Debugging Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .616265676972Chapter 8Automating Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Creating a Simple DO File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Running in Command-Line Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Using Tcl with the Simulator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77777881IndexEnd-User License Agreement4ModelSim Tutorial, v6.4a

List of Examples5ModelSim Tutorial, v6.4a

List of FiguresFigure 2-1. Basic Simulation Flow - Overview Lab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 2-2. Project Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 2-3. Multiple Library Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-1. Basic Simulation Flow - Simulation Lab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-2. The Create a New Library Dialog. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-3. work Library in the Workspace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-4. Compile Source Files Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-5. Verilog Modules Compiled into work Library . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-6. Loading Design with Start Simulation Dialog . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-7. Workspace sim Tab Displays Design Hierarchy . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-8. Object Pane Displays Design Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-9. Using the Popup Menu to Add Signals to Wave Window . . . . . . . . . . . . . . . . .Figure 3-10. Waves Drawn in Wave Window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-11. Setting Breakpoint in Source Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-12. Setting Restart Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-13. Blue Arrow Indicates Where Simulation Stopped. . . . . . . . . . . . . . . . . . . . . . .Figure 3-14. Values Shown in Objects Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-15. Parameter Name and Value in Source Examine Window . . . . . . . . . . . . . . . .Figure 3-16. The Main Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-17. Window/Pane Control Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-18. zooming in on Workspace Pane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 3-19. Panes Rearranged in Main Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-1. Create Project Dialog - Project Lab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-2. Adding New Items to a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-3. Add file to Project Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-4. Newly Added Project Files Display a “?” for Status . . . . . . . . . . . . . . . . . . . . .Figure 4-5. Compile Order Dialog. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-6. Library Tab with Expanded Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-7. Structure Tab for a Loaded Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-8. Adding New Folder to Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-9. A Folder Within a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-10. Creating Subfolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-11. A folder with a Sub-folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-12. Changing File Location via the Project Compiler Settings Dialog. . . . . . . . . .Figure 4-13. Simulation Configuration Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-14. A Simulation Configuration in the Project Tab . . . . . . . . . . . . . . . . . . . . . . . .Figure 4-15. Transcript Shows Options for Simulation Configurations . . . . . . . . . . . . . . . .Figure 5-1. Creating New Resource Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 5-2. Compiling into the Resource Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Figure 5-3. Verilog Simulation Error Reported in Main Window. . . . . . . . . . . . . . . . . . . . 33343536363738383839404141444547ModelSim Tutorial, v6.4a

L