Transcription

ModelSim-Altera Software Simulation User GuideModelSim-Altera Software SimulationUser Guide101 Innovation DriveSan Jose, CA 95134www.altera.comUG-01102-2.0Document last updated for Altera Complete Design Suite version:Document publication date:12.1January 2013

2013 Altera Corporation. All rights reserved. ALTERA, ARRIA, CYCLONE, HARDCOPY, MAX, MEGACORE, NIOS, QUARTUS and STRATIX are Reg. U.S. Pat.& Tm. Off. and/or trademarks of Altera Corporation in the U.S. and other countries. All other trademarks and service marks are the property of their respectiveholders as described at www.altera.com/common/legal.html. Altera warrants performance of its semiconductor products to current specifications in accordancewith Altera’s standard warranty, but reserves the right to make changes to any products and services at any time without notice. Altera assumes no responsibility orliability arising out of the application or use of any information, product, or service described herein except as expressly agreed to in writing by Altera. Alteracustomers are advised to obtain the latest version of device specifications before relying on any published information and before placing orders for products orservices.ModelSim-Altera Software Simulation User GuideJanuary 2013 Altera Corporation

Simulating with the ModelSim-AlteraSoftwareThis user guide describes simulation using the ModelSim-Altera Starter Edition orModelSim-Altera Edition software.The Quartus II software supports HDL design simulation at register transfer (RTL)and gate levels in various industry-standard simulators. You can use the Quartus IINativeLink feature to integrate your EDA simulator within the Quartus II design flowand streamline simulation processing steps.For more tool-specific guidelines, refer to Aldec Active-HDL and Riviera-PRO Support,Synopsys VCS and VCS MX Support, Cadence Incisive Enterprise Simulator Support, orMentor Graphics ModelSim and QuestaSim Support in the Quartus II Handbook.PrerequisitesThis user guide assumes you have a working knowledge of the following subjects: Verilog HDL, SystemVerilog, or VHDL hardware description languages Subjects covered in the Quartus II software “Getting Started Tutorial”Starting the ModelSim-Altera Software with the Quartus II SoftwareTo start the ModelSim-Altera software, follow these steps:1. Unzip the provided Quartus II design example project counter.zip.2. Start the Quartus II software and open the design example Quartus II project filecounter.qpf.Setting Up EDA Tool OptionsYou can specify where your third-party EDA simulators are installed with the EDAtool options settings in the Quartus II software. These settings enable you to startthird-party EDA simulators from the Quartus II software.The ModelSim-Altera toolpath is automatically added during Quartus II installation.Setting Up the SimulationTo set up the Model-Sim Altera simulation environment, follow these steps:1. On the Tools menu, click Options and specify the location of your simulatorexecutable file on the EDA Tool Options page.2. On the Assignments menu, click Settings.3. In the Settings dialog box, under EDA Tool Settings, select Simulation. TheSimulation page appears. (Figure 1–1).January 2013Altera CorporationModelSim-Altera Software Simulation User Guide

1–2Simulating with the ModelSim-Altera SoftwareRunning ModelSim-Altera from the Quartus II SoftwareFigure 1–1. Simulation Page (Settings Dialog Box)1. In the Tool name list, select ModelSim-Altera. Ensure that Run gate-levelsimulation automatically after compilation box is turned off.2. Under EDA Netlist Writer settings, in the Format for output netlist list, selectVerilog HDL. Ensure that the Map illegal HDL characters, Enable glitchfiltering, and Generate Value Change Dump (VCD) file script boxes are turnedoff.3. Under NativeLink settings, select None.f For more information about the Quartus II NativeLink feature, refer to the SimulatingAltera Designs chapter in volume 3 of the Quartus II Handbook.Running ModelSim-Altera from the Quartus II SoftwareTo generate the ModelSim-Altera automation script (.do file), start the ModelSimAltera software, and then compile the design files, follow these steps:1. On the Processing menu, point to Start, and then click Start Analysis &Elaboration.ModelSim-Altera Software Simulation User GuideJanuary 2013Altera Corporation

Simulating with the ModelSim-Altera SoftwareCreating Stimulus Waveforms1–32. On the Tools menu, point to Run Simulation Tool and then click RTL Simulation.The Quartus II software starts the ModelSim-Altera simulator. You can ignoreerror or warning messages about the tcounter.v file. In the next section you createstimulus waveforms and export the waveforms into tcounter.v testbench file.Creating Stimulus WaveformsThis section guides you in adding signals to the Wave window, creating the clockwaveform, and creating the reset waveform.Adding Signals to the Wave WindowTo add signals to the Wave window, follow these steps:1. In the ModelSim-Altera GUI, expand Work in the Library window, and thenright-click counter.2. Click Create Wave (Figure 1–2).Three signals (clk, reset, and count) from the counter design example are added inthe Wave window, where you can create stimulus waveforms for each signal tosimulate the design. In this example, you will create stimulus waveforms for theclk and reset signals. The count signal is not needed and can be deleted.Figure 1–2. Create Wave on the Shortcut Menu3. Right-click the count signal in the Wave window, and then click Delete.January 2013Altera CorporationModelSim-Altera Software Simulation User Guide

1–4Simulating with the ModelSim-Altera SoftwareCreating Stimulus WaveformsCreating the Clock Waveform1. Right-click the clk signal in the waveform, point to Edit, and then clickcreate/modify. The Create Pattern Wizard appears (Figure 1–3).Figure 1–3. Create Pattern Wizard2. Under Patterns, select Clock.3. For Start Time, enter 0, for End Time, enter 5000, and for Time Unit, enter ns.4. Click Next.5. For Clock Period, enter 100, for Time Unit enter ns, and for Duty Cycle, enter 50.6. Click Finish.Creating the Reset Waveform1. Right-click the reset signal in the waveform, point to Edit, and then clickcreate/modify.2. In the Create Pattern Wizard, under Patterns, select Constant.3. For Start Time, enter 0, for End Time, enter 5000, and for Time Unit, enter ns.4. Click Next.5. Enter St0 (Strong 0) for Value.6. Click Finish.f For more information, refer to Chapter 13, Generating Stimulus with Waveform Editor inthe ModelSim User’s Manual. In the ModelSim-Altera software, on the Help menu,point to PDF Documentation, and then click User’s Manual.Modifying Stimulus WaveformsTo modify stimulus waveforms, follow these steps:1. Click in the waveform window to enable the Wave menu.2. On the Wave menu, point to Mouse Mode and then click Edit Mode. Make surethe Wave window is activated. To activate it, click in the Wave window.ModelSim-Altera Software Simulation User GuideJanuary 2013Altera Corporation

Simulating with the ModelSim-Altera SoftwareCreating Stimulus Waveforms1–53. Select the reset signal from 0 ns to approximately 120 ns. The selection does notneed to be exact (Figure 1–4).Figure 1–4. Inverted Waveform for reset Signal4. On the Wave menu, point to Wave Editor, and then click Invert. The Edit Invertdialog box appears (Figure 1–5).Figure 1–5. Edit Invert Dialog Box5. For Start Time, enter 0, for End Time, enter 120, and for Time Unit, enter ns.January 2013Altera CorporationModelSim-Altera Software Simulation User Guide

1–6Simulating with the ModelSim-Altera SoftwareExporting Created Stimulus Waveforms as an HDL Testbench6. Click OK to invert the waveform. Figure 1–6 shows the inverted waveform.Figure 1–6. Inverted Waveform for reset Signal (0–120 ns)Starting SimulationTo start the simulation, follow these steps:1. Expand the Work library, right-click counter and click Simulate.2. Drag the count signal from the Objects window to the Wave window.3. In the Transcript window, type the command run –all r.After you type the run -all command, the example counter design is simulated withthe created stimulus waveforms for the clk and reset signals. The clk signal is acontinuous clock waveform. The reset signal is asserted for the first 120 ns. When thereset signal is deasserted after 120 ns, the counter begins to increment, once on eachrising edge of clk.The output signal count produces the simulated waveform, in theWave window, adjacent to the stimulus waveforms.Exporting Created Stimulus Waveforms as an HDL TestbenchAn HDL testbench file is typically written in the same hardware description languageas your design, and interacts with your design as an instantiated module. An HDLtestbench file is conceptually similar to a waveform like the one created in “CreatingStimulus Waveforms” on page 1–3, but because it is written in HDL, it is able toaccommodate more complexity and flexibility than a graphical waveform.ModelSim-Altera Software Simulation User GuideJanuary 2013Altera Corporation

Simulating with the ModelSim-Altera SoftwareExporting Created Stimulus Waveforms as an HDL Testbench1–7The stimulus waveforms you created for the simulation can be exported as a HDLtestbench file. You can then use the HDL testbench file to simulate your design againwithout manually recreating the stimulus waveforms.To export the stimulus waveform as an HDL testbench, perform the following steps:1. Click in the Wave window to ensure it is active.2. On the File menu, point to Export and then click Waveform. The ExportWaveform dialog box appears (Figure 1–7).Figure 1–7. Export Waveform Dialog Box3. In the Export Waveform dialog box, under Save As, select Verilog Testbench.4. For Start Time, enter 0, for End Time, enter 5000, and for Time Unit, enter ns.5. In the File Name box, type the name of your testbench or click the Browse button.6. Click OK.The testbench appears in the Quartus II project folder \simulation\modelsimfolder. You can use the testbench file for the simulation of your Quartus II design.January 2013Altera CorporationModelSim-Altera Software Simulation User Guide

1–8ModelSim-Altera Software Simulation User GuideSimulating with the ModelSim-Altera SoftwareExporting Created Stimulus Waveforms as an HDL TestbenchJanuary 2013Altera Corporation

Additional InformationThis section provides additional information about the document and Altera.Document Revision HistoryThe following table shows the revision history for this document.DateVersionChangesJanuary 20132.0Updated Linux and GUI information.June 20111.0Initial release.How to Contact AlteraTo locate the most up-to-date information about Altera products, refer to thefollowing table.Contact (1)Technical supportTechnical trainingProduct literatureContact itewww.altera.com/literatureNon-technical support (General)[email protected](Software Licensing)[email protected] to Table:(1) You can also contact your local Altera sales office or sales representative.Typographic ConventionsThe following table shows the typographic conventions this document uses.Visual CueMeaningBold Type with Initial CapitalLettersIndicate command names, dialog box titles, dialog box options, and other GUIlabels. For example, Save As dialog box. For GUI elements, capitalization matchesthe GUI.bold typeIndicates directory names, project names, disk drive names, file names, file nameextensions, software utility names, and GUI labels. For example, \qdesignsdirectory, D: drive, and chiptrip.gdf file.Italic Type with Initial Capital LettersIndicate document titles. For example, Stratix IV Design Guidelines.Indicates variables. For example, n 1.italic typeJanuary 2013Variable names are enclosed in angle brackets ( ). For example, file name and project name .pof file.Altera CorporationModelSim-Altera Software Simulation User Guide

Info–2Additional InformationAdditional InformationTypographic ConventionsVisual CueMeaningInitial Capital LettersIndicate keyboard keys and menu names. For example, the Delete key and theOptions menu.“Subheading Title”Quotation marks indicate references to sections within a document and titles ofQuartus II Help topics. For example, “Typographic Conventions.”Indicates signal, port, register, bit, block, and primitive names. For example, data1,tdi, and input. The suffix n denotes an active-low signal. For example, resetn.Courier typeIndicates command line commands and anything that must be typed exactly as itappears. For example, c:\qdesigns\tutorial\chiptrip.gdf.Also indicates sections of an actual file, such as a Report File, references to parts offiles (for example, the AHDL keyword SUBDESIGN), and logic function names (forexample, TRI).rAn angled arrow instructs you to press the Enter key.1., 2., 3., anda., b., c., and so onNumbered steps indicate a list of items when the sequence of the items is important,such as the steps listed in a procedure. Bullets indicate a list of items when the sequence of the items is not important. 1The hand points to information that requires special attention.hA question mark directs you to a software help system with related information.fThe feet direct you to another document or website with related information.cA caution calls attention to a condition or possible situation that can damage ordestroy the product or your work.wA warning calls attention to a condition or possible situation that can cause youinjury.The envelope links to the Email Subscription Management Center page of the Alterawebsite, where you can sign up to receive update notifications for Altera documents.ModelSim-Altera Software Simulation User GuideJanuary 2013 Altera Corporation