ModelSim Tutorial

ModelSim Tutorial

-

English
8 Pages
Read
Download
Downloading requires you to have access to the YouScribe library
Learn all about the services we offer

Description

GEGETTITTING STANG STARTERTED WITH ModeTH ModellSSiimm GEGETTITTING STANG STARTERTETH ModeTH ModellSSiimm AN Introduction Reza Nekovei Electrical Engineering and Computer Science Department Texas A&M University-Kingsville Introduction: The following handout demonstrates how to create and simulate a new VHDL project using Altera ModelSim 5.8e. ModelSim is used to simulate and verify the functionality of VHDL code as part of Quartus II design flow shown below: 1ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ I. Starting ModelSim 1. Start ModelSim from start menu or Windows shortcut icon: Start Programs ModelSim ModelSim 2. Upon running ModelSim, you will see the Welcome to ModelSim 5.8e dialog (Figure 1). If the dialog does not show up, you can display it by selecting Help Welcome Menu from the Main window. Figure 1: “Welcome to ModelSim 5.8e” dialog II. Create a New Project The first thing to do is to create a project. Project set-up eases the interaction with ModelSim and is useful for organizing files and simulation settings. 1. Create a new project by clicking on Jumpstart on the Welcome to ModelSim dialog, and then on Create a Project. You can also create a new project without the help of the dialog window by selecting: File New Project from the Main window. 2ÆÆÆÆÆÆÆÆÆÆÆÆ 2. A “Create Project” window pops up (Figure 2). Select a suitable name for your project; set the Project ...

Subjects

Informations

Published by
Reads 112
Language English
Report a problem
GETTING STARTED WITH ModelSimAN Introduction Reza Nekovei Electrical Engineering and Computer Science Department Texas A&M University-Kingsville Introduction: The following handout demonstrates how to create and simulate a new VHDL project using Altera ModelSim 5.8e. ModelSim is used to simulate and verify the functionality of VHDL code as part of Quartus II design flow shown below:
1
I. Starting ModelSim 1. Start ModelSim from start menu or Windows shortcut icon: StartÆProgramsÆModelSimÆModelSim 2. Upon running ModelSim, you will see theWelcome to ModelSim 5.8e dialog(Figure 1). If the dialog does not show up, you can display it by selectingHelpÆWelcome Menufrom the Main window.
Figure 1: “Welcome to ModelSim 5.8e” dialog II. Create a New Project The first thing to do is to create a project. Project set-up eases the interaction with ModelSim and is useful for organizing files and simulation settings. 1. Create a new project by clicking onJumpstarton the Welcome to ModelSim dialog, and then onCreate a Project.You can also create a new project without the help of the dialog window by selecting:FileÆNewÆProjectfrom the Main window.
2
2. A “Create Project” window pops up (Figure 2). Select a suitable name for your project; set the Project Location to the directory you are going to use for this project as shown in figure 2, and leave the Default Library Name to work.
Figure 2: “Create Project” dialog3. If the selected folder does not exist, it will get created and then anAdd items to the Project dialog will pop out (Figure 3).
Figure 3: “Add items to the Project” dialog There are two ways to put files into the project: Creating new VHDL files (using the editor) and then adding them to the project Adding already existing files to the project III.Creating a new VHDL File1. Create a new source file in VHDL editor by selecting:FileÆNewÆSourceÆVHDLfrom the Main menu. A blank VHDL editor will appear. Type in your new VHDL code here. In this example a simple XOR is used (figure 4).
3
Figure 4: “VHDL Editor” dialog 2. Save the file and add it to your project by selectingFileÆSavefrom the editor menu. However, before saving the file, remove the last semicolon to help us demonstrate debugging in the following section. IV.Adding Existing Files to the Project1. SelectFileÆAdd to ProjectÆExisting File. An “add file to Project” dialog pops up. Select the file that you want to add to the project. Also, make sure that you select VHDL from “the Add file as type” menu.
Figure 5: “Add file to Project” window
4
2. You should now see the file that you have just added in the workspace section of ModelSim’s Main window. V.Compiling / Debugging1. SelectCompileÆCompile All. 2. The compilation result is shown on the main window. A red message indicates that there is an error in our code. Steps 3 through 7 will illustrate how to correct this error.
Figure 6: “The error is indicated in red on the main window” 3. Double-click on the error (shown in Red) on the main window. This will open a new window that describes the nature of the error. In our case the error message is as follows:
4. Double-click on the Error message. The source window will open pointing to the line with the error. 5.Correct the above error by adding the semicolon. Next, save, and recompile the file. Repeat steps 1-5 until the code compiles with no errors (green check mark by the file).
5
VI.Simulating the DesignThis section covers the basics for simulating a design using ModelSim. 1. Click on the Library tab of the main window and then click on the (+) sign next to the work library. You should see the name of the entity of the code that we have just compiled “xor_ent” (Figure 7).
 Library  Tab
Figure 7: ModelSim’s Main Window, Library view 2. Double-click on xor_ent to load the file. This should open a third tab “sim” in the main window. 3. Now selectviewÆAll Windowsfrom the main window to open all ModelSim windows. 4. Locate the signals window and select the signals that you want to monitor for simulation purposes. For this tutorial, select all signals as shown below.
Figure 8: “The Signals Window”
6
5. Drag the above signals using the left button of the mouse into the wave window. You can also use:addÆwaveÆSelected signals. 6. Do the same as in step 5 with the list window (i.e. drag selected signals into the list window, or useaddÆlistÆSelected signals).
7. We are now ready to simulate our design. For this purpose, we will need to type in simulation commands on the main window of the simulator. Refer to the ModelSim documentation for some useful commands. 8. On the main window setxstimulus by entering:-repeat 20 nsforce x 0 0 ns, 1 10 ns .Also set input y using-repeat 40 ns .force y 0 0 ns, 1 10 ns This statements force an input signal on xto take the value of 0 at 0ns, 1 at 10 ns and to repeat the forcing of these values every 20 ns. Similarly input stimulus is set for signaly.
Figure 9: “Input the commands to the simulator as shown above” 9. Next, enterrun 80 nson the main window. This will run the simulation for 80 ns. You can see the changes in the both the wave and list windows.
7
10. Now, select the wave window, and click on “zoom full” (Figure 10). Your simulation should look as follows. Zoom full
Figure 10: “the Wave window” Note that the output's first 5 ns (red line) is of type “U” from std_logic, and the remaining of the output signal is delayed by 5 ns (right shifted). The list window confirms with the above waveform. Printing the outputs for your laboratory report: Printing the list window: 1. In order to print the list window, selectFileÆwrite listÆTabularfrom the list window and then save it as simulation.lst 2. Start Notepad and open the file that you saved above. You can then proceed to printing it. Printing the wave window: Printing from the wave window is simple as you only need to select:FileÆPrintfrom the wave window. However, make sure that your printed waveform can be read (Numbers may be printed too small if you try to print a long simulation waveform to one page).
8