modelsim simulation tutorial

3

Click here to load reader

Upload: gideontargrave7

Post on 17-Dec-2015

29 views

Category:

Documents


0 download

DESCRIPTION

sv

TRANSCRIPT

  • ECE 4242/5242 Department of Electrical and Computer Engineering

    Advanced Digital Design Methodology University of Colorado at Colorado Springs Fall Semester "Illuminate, Investigate, Innovate" Dr. Greg Tumbush, [email protected]

    ModelSim Simulation Tutorial Page 1 of 3 Version 1.7

    ModelSim/QuestSim Simulation Tutorial

    1. Start ModelSim or the fully featured QuestaSim. There are many ways to access these

    tools:

    a. Download student version (ModelSim only) from

    http://www.mentor.com/company/higher_ed/modelsim-student-edition

    b. PCs in EN229, EN230, and 136.

    c. Access through the windows server ClaaS. Instructions at

    http://www.uccs.edu/~gtumbush/misc/QuestaSim_ClaaS.pdf (once certificate errors

    are resolved). Until certificate errors are resolved access ClasS via

    https://claas1.uccs.edu/portal/webclient/index.html. Ignore certificate warnings. You

    will need to be connected to the UCCS Resources VPN (Voyager).

    d. Access through the linux server LATS1.

    i. From Windows 7 instructions at

    http://www.uccs.edu/~gtumbush/misc/accessing_lats1.pdf

    ii. From Windows 8 instructions at http://www.uccs.edu/~gtumbush/misc/LATS-

    HowToSetup.pdf

    iii. You will need to be connected to the UCCS Resources VPN (Voyager).

    2. Create a new project

    a. Create a directory called Add_half in your workspace using Windows Explorer

    (windows) or mkdir (Linux).

    b. Click on File->New->project

    c. In pop-up window fill in the Project Name field (ex: Add_half)

    d. Click on Browse to create the project in the desired location. (ex:

    Z:/Data/4242/Add_half)

    e. Click on OK

    3. Add files

    a. In Add items to the Project pop-up click on Add Exiting File or Create New File.

    Since Im creating Add_half from scratch Ill click on Create New File.

    b. Fill in the File Name field (ex Add_half) and in the Add file as type pull-down

    select verilog. The correct file extension will be added. Click on OK

    c. Click on Close

    4. In the Project tab of the main modelsim window double click on Add_half.v. The file will

    open in an editor. If you wish undock the editing window by clicking on . in the editor

    window. Type in the following data:

  • ECE 4242/5242 Department of Electrical and Computer Engineering

    Advanced Digital Design Methodology University of Colorado at Colorado Springs Fall Semester "Engineering for the Future"

    ModelSim Simulation Tutorial Page 2 of 3 Version 1.7

    5. Click on File->Save in either the main modelsim window or the undocked editor window.

    6. In main modelsim window click on Compile->Compile All. In the transcript window you

    should see Compile of Add_half.v was successful. If not fix any syntax errors.

    7. Simulate

    a. In the Transcript window type vsim novopt Add_half. In the transcript

    window you should see # Loading work.Add_half

    b. In the main modelsim window Click on View->Wave

    c. In the Workspace window make sure the Sim tab is selected and click on

    Add_half. This will show you all the signals at the Add_half level of hierarchy in

    the Objects window.

    d. Select all the signals in the Objects window and drag them to the wave window.

    e. In the Transcript window type run 10ns

    f. In the wave window click on View->Zoom->Zoom Full if the wave window is

    undocked or type F. Note that your inputs are Z and outputs are X. This is

    because the inputs are not driven. The wave window can be undocked by

    clicking on the . button on the upper right hand side of the wave window.

    g. In the Transcript window type the following

    h. You should see signal a being driven to a 0, signal b being driven to a 1, and

    the expected output is c_out = 0 and sum = 1.

    8. To restart a simulation type in the Transcript window quit sim

    9. To quit modelsim click on File->Quit

    10. To open up an existing project do one of the following:

    a. Start Modelsim, click on File->Open, in the Open File dialog box select Project

    Files (*.mpf) in the Files of Type pull-down, select the project and click Open.

    b. Browse to the location you specified in step 2 and double click on the project.

    11. Notes:

    force a 0

    force b 1

    run 10ns

    // Definition of a half adder using primitives

    module Add_half (input a, b, output sum, c_out);

    xor (sum,a,b);

    and(c_out,a,b);

    endmodule

  • ECE 4242/5242 Department of Electrical and Computer Engineering

    Advanced Digital Design Methodology University of Colorado at Colorado Springs Fall Semester "Engineering for the Future"

    ModelSim Simulation Tutorial Page 3 of 3 Version 1.7

    a. You must add signals before running the simulation or else the simulator will not

    collect the data for you.

    b. If you recompile any code or add signals to the waveform and want to re-run

    type the following:

    i. quit sim

    ii. vsim novopt Add_half

    iii. add your signals

    iv. run