ModelSim Tutorial

  1. Before you can use ModelSim, our simulation tool, you must create a work directory. Type qhlib work to create this directory and set it as your current work directory. QuickHDL will store the files it creates in this directory.
  2. Type qvhcom -93 count.vhdl to compile the sample counter for simulation.
  3. Type qhsim & to start ModelSim. You will see a window like Figure 3-2.

    Figure 3-2: ModelSim Startup Window
  4. Select Design->Load Design from the menu. You will see a window like Figure 3-3.

    Figure 3-3: Load Design Window
  5. There are several ways to tell ModelSim what to do. You can attempt to navigate the menus to set forces, clocks, and displays. You can type commands in manually at the VSIM prompt. You can list these commands in a "do" file and run this file in "batch" mode. We believe this final option is the best way to proceed. The following is a sample do file that sets up a simulation for the counter you entered above.

    Listing 1: Sample Do File
    # Clear previous forces and wave window
    restart -force -nowave
    # Insert signals in wave display window
    add wave -logic slowclk
    add wave -logic rstn
    add wave -logic count
    # 40 MHz clock on signal slowclk (0 at 0ns, 1 at 12ns, repeat at 25)
    force -deposit slowclk 0 0, 1 12 -r 25
    # Initially reset the system, then set rstn inactive at time 25
    force -deposit rstn 0 0, 1 25
    # Force the value 0 (hex) onto the bus slowcount at time 0
    force -deposit slowcount 16#00000 0
    # Force the value 3B (hex) onto the bus value at time 0
    force -deposit value 16#3B 0
    # Execute the simulation for 250 ns
    run 250

  6. Type in the do file in Listing 1 and save it as count.do.
  7. Type do count.do at the VSIM prompt. The resulting waveform will appear as in Figure 3-4.

    Figure 3-4: Waveform display
  8. You can generate Postscript output from the wave window for inclusion in your reports. Do this by clicking File->Print Postscript... in the Wave window. The Write Postscript window will look like the Figure 3-5. Make sure to click the File name radio button, and specify a filename for your Postscript output. You should also select an appropriate Time Range. For our current output, selecting the Full Range is reasonable.

    Figure 3-5: Write Postscript


Last updated 1/16/2004 3:15:31 PM