Testing with a Mentor Graphics® ModelSim® Tcl/Tk .do File

Overview

This section describes how to generate a Mentor Graphics® ModelSim® Tcl/Tk .do file test bench, and use the Mentor Graphics ModelSim simulator to test and verify your filter design.

Generating the Filter HDL Code and Test Bench .do File

Use the Filter Design HDL Coder™ GUI or command line interface to generate the HDL code for your filter design and test bench. The GUI generates a Mentor Graphics ModelSim .do file test bench if you select the ModelSim .do file option in the Test bench settings pane of the Generate HDL dialog box. You can specify a number of other test bench customizations, as described in Customizing the Test Bench.

The following figure shows settings for generating the filter and test bench files MyFilter.vhd and MyFilter_tb.do. The dialog box also specifies that the generated files are to be placed in the default target directory hdlsrc under the current working directory.

After you click Generate, the coder displays progress information similar to the following in the MATLAB® Command Window:

### Starting VHDL code generation process for filter: Myfilter
### Generating: d:\work\MyPlayArea\hdlsrc\Myfilter.vhd
### Starting generation of Myfilter VHDL entity
### Starting generation of Myfilter VHDL architecture
### HDL latency is 2 samples
### Successful completion of VHDL code generation process for filter: Myfilter

### Starting generation of ModelSim .do file Test Bench
### Generating input stimulus
### Done generating input stimulus; length 3429 samples.
### Generating ModelSim .do file MyFilter_tb in: hdlsrc
### Done generating ModelSim .do file test bench.

If you use the command line interface, you must

Also, consider using the function generatetbstimulus to return the test bench stimulus to the workspace.

For details on the property name and property value pairs that you can specify with the generatehdl and generatetb functions for customizing the output, see Properties Reference.

Starting the Mentor Graphics® ModelSim® Simulator

After you generate your filter and test bench HDL files, start the Mentor Graphics ModelSim simulator. A screen display similar to the following appears.

After starting the simulator, set the current directory to the directory that contains your generated filter and test bench files.

Compiling the Generated Filter File

Using your choice HDL compiler, compile the generated filter HDL file. The test bench .do file looks for your compiled HDL elements in a design library named work. The design library stores the compiled HDL components. If the design library work does not exist, you can create it by setting the current directory to hdlsrc and then issuing the command vlib work. Once the library exists, you can use the Mentor Graphics ModelSimcompiler to compile the filter's HDL file.

The following Mentor Graphics ModelSim command sequence changes the current directory to hdlsrc, creates the design library work, and compiles filter VHDL code.

cd hdlsrc
vlib work
vcom MyFilter.vhd

The following screen display shows this command sequence and informational messages displayed during compilation.

Execute the .do File

After your filter's HDL file is compiled, execute the generated test bench .do file. The .do file

  1. Loads the compiled filter for simulation.

  2. Opens a wave window and populates it with filter signals.

  3. Applies stimulus to filter signals with force commands.

  4. Compares filter output to expected results.

You can execute the .do file by using the Mentor Graphics ModelSim do command or the Tcl source command. The following figure shows how to use the do command.

The test bench .do script displays the simulation results in a wave window that appears as follows.

As your test bench simulation runs, watch for error messages. If any error messages appear, you must interpret them as they pertain to your filter design and the code generation options you applied. For example, a number of HDL customization options allow you to specify settings that can produce numeric results that differ from those produced by the original filter object. Expected and actual results are compared. If they differ, an error message similar to the following is returned:

Error in filter test: Expected xxxxxxxx Actual xxxxxxxx

You must determine whether the actual results are expected based on the customizations you specified when generating the filter HDL code.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS