Previous

Simulating with Script Files

In the “In-Depth Tutorial - Functional Simulation” chapter, you simulated by applying various types of stimulus including keyboard stimulus, formulae, and by using the internal binary counter. In this chapter, you use a script file to simulate the design.

Script files contain commands to stimulate inputs, display signals, and advance the simulation. You enter your commands in the script file and then press one button to run the entire simulation. Script files in Foundation support Viewlogic-style commands, as well as other Foundation-specific commands. The Simulator Online Help provides a full list and description of all the supported commands.

Creating Script Files - Script Wizard and Script Editor

The Script Editor is a text editor that you use to enter, edit, and view script files, as well as actually run the simulation. You may either create a script file from scratch, use an existing one, or create one with the help of the Script Wizard, an interactive tool which helps you create script files for simulation. In this section, you use the Script Wizard to create a complete script file to simulate the Watch design and then view the script file and run the simulation from the Script Editor.

  1. To invoke the Script Editor, select Tools Script Editor from the pulldown menus within the Simulator. A dialog box prompts you to select a script file.

  2. Choose Use Script Wizard to invoke the Script Wizard.

  3. Follow the instructions in the Wizard to advance to the Initialization page.

  4. On the Initialization page, select the following options.

  5. Click Next to advance to the Vectors page.

    Vectors provide a more convenient way to use buses in the script file. By defining vectors, you can more easily refer to these buses in the rest of the script file. You can also create vectors out of any group of signals, regardless of whether they are a bus in the original design.

    In this step, you define vectors for the three output buses, ONESOUT[6:0], TENSOUT[6:0], and TENTHSOUT[9:0]. For simplicity, name these vectors ONES, TENS and TENTHS, respectively.

  6. Click the New button. This adds a new vector to the vector list entitled Vector_Name_1 by default. Type TENS in the place of Vector_Name_1 to rename it.

  7. Click the Browse... button. This displays a Component Selection window which contains all of the signals in the design. On the right-hand side, scroll down to find the TENOUTS6..0 7-bit bus. Select this bus, and then click OK. By doing this, you have assigned the seven bits of the TENSOUT bus to the newly created TENS vector.

    Figure 8.2 Script Wizard Component Selection

    The seven bits of the TENSOUT bus are listed as components in the newly created TENS vector.

  8. With the TENS vector selected, click the Radix pulldown menu to change the radix of the vector to Binary. This determines how the vector is displayed in the simulator.

  9. Repeat Steps 6 through 8 to create vectors called ONES and TENTHS for both the ONESOUT[6:0] and TENTHSOUT[9:0] buses, respectively.

    Figure 8.3 Script Wizard Vectors

  10. Click the Next button to advance to the Stimulators page.

    Stimulators define the action of the inputs in the design. There are several different commands that can be used to define input stimulus. You will use three different methods in this tutorial. For a complete description of all available commands, refer to the online help.

  11. To select the first signal to stimulate, click the Browse... button.

  12. In the Component Selection window, scroll down the signal list on the right-hand side, and locate the CLK signal if using the schematic design or CLKINT if using the HDL design. Select it and click OK.

  13. See the CLK (or CLKINT) signal listed in the Simulators and Watched Signals list. Click the CLK signal and the Stimulator Type field now becomes active. Use the pulldown menu in the Stimulator Type field to select Clock.

  14. In the Value field, set the pattern of the clock. By typing 0 1 (delimited by a space) in the value field, you define the clock as having a pattern of low for one simulation step (previously defined as 10ns), then high for one simulation step. This pattern repeats indefinitely to produce the clock signal.

    Figure 8.4 Clock Stimulus

  15. Repeat Steps 12 and 13 to add the STRTSTOP signal to the Stimulated signals list.


  16. With the STRTSTOP signal selected in the Stimulated Signals list, set the Stimulator Type to Aldec Waveform.

  17. In the Value field, type the following:

    H50L30H500L30H500L30H3000

    Similar to the Custom Formula you created in the Functional Simulation section, this waveform means high for 50ns, then low for 30ns, then high for 500ns, and so on. This waveform will define a stimulus pattern for the STRTSTOP input signal.

  18. Repeat Steps 12 through 13 to add the RESET signal to the Stimulated Signals list.

  19. With the RESET signal selected in the Stimulated Signals list, set the Stimulator Type to be Waveform.

  20. In the value field type the following.

    @0=0 6500=1 400=0

    This means “at 0ns the signal is 0, 650ns later the signal is high, 40ns later the signal is low.” Note that the units of this measurement are tenths of nanoseconds. This waveform provides a reset pulse to reset the stopwatch during the simulation.

  21. The Stimulators page also allows you to select signals which you wish to “watch” in a printed output file. Since you will be setting a printed output file in the next section of the Wizard, you will add more signals to this list so that they may be watched.

    Repeat Steps 12 and 13 to add the TENS, ONES, and TENTHS vectors to the Stimulated and Watched Signals list. Be sure that you add the vectors and not the buses.

    Figure 8.5 Selecting Vectors to Watch

  22. Because the TENS, ONES, and TENTHS vectors are outputs, they should not have stimulus assigned to them. Select each of these vectors individually and set the Stimulator Type to be None.

  23. You should now see six signals listed in the window. Select them all by performing a shift-click and then click the Toggle Watch button. This changes the watch status of all of them from No to Yes.

    Figure 8.6 Signals' Stimulus

  24. Click Next to advance to the Breakpoints and Simulation page.

  25. Breakpoints allow you to monitor the simulation for some output response. You can specify how the simulator will notify you when the output response is detected.

    On the Breakpoints and Simulation page, click the Browse... button to choose the first signal to set a breakpoint on.

  26. In the Component Selection window, choose the ONES vector from the signal list and click OK.

  27. You should now see the ONES vector listed in the Defined Breakpoints list. Highlight ONES, and then from the Condition pulldown menu, select Low State. This defines the condition which must be present on the ONES vector for the breakpoint to occur.

  28. In the Action field, type the following:

    print > tim_out.txt

    This tells the simulator to write out an output report called tim_out.txt whenever the breakpoint condition is met.

  29. Set the Simulation Command to Cycle, and the Simulation Value to 400. This tells the simulator to run for 400 clock cycles.

    Figure 8.7 Breakpoints and Simulation

  30. Click Finish. You can now view your completed script file in the Script Editor.

Viewing the Script File with the Script Editor

The Script Editor is very similar to the HDL Editor. Commands are color-coded, with simulation command keywords highlighted in red and comments in green for easy reading and debugging.

The Script Editor also provides a Macro Assistant that is very similar to the Language Assistant which you saw earlier in the HDL Editor.

  1. From within the Script Editor, select Tools Macro Assistant to invoke the Macro Assistant.

    The Macro Assistant provides templates and help for the various script file commands. Browse through the various templates to see what is available.

    Figure 8.8 Macro Assistant

  2. Close the Macro Assistant by clicking the X in the upper-right corner of the window.

  3. Save the script file that was created by the Script Wizard by selecting File Save. Be sure that the file is being saved into the current Foundation project directory (that is, C:\FNDTN\ACTIVE\PROJECTS\watch_proj_name). Name the script file watchtim.cmd.

  4. Look through the script file to see what the Script Wizard created.

Running the Simulation from the Script Editor

  1. You can execute the simulation directly from the Script Editor. To do this, select Execute Go.

    A log of the executed commands appears at the bottom of the Script Editor, including messages indicating when breakpoints were encountered.

  2. To view the simulation results in the Waveform Viewer, move the Script Editor window and bring the Waveform Viewer window to the front of your view. Inspect the simulation results to make sure they are accurate.

You should now see that this is indeed performing a timing simulation based on actual delays in the placed and routed design. If you zoom in to get a closer view of the waveforms, you will see that there is a delay from the rising edge of the clock to the transitions or the counter outputs.

Figure 8.9 Timing Simulation Waveforms


NOTE

For the HDL design, the Tenths output bus will be inverted: 1110111111 instead of 0001000000. You are looking at the signals after the inverters in the HDL design instead of before the inverters as in the schematic.


For more detailed information related to actual path delays and system performance requirements, you can use the Xilinx Timing Analyzer to do Static Timing Analysis. Refer to the DynaText document Timing Analyzer Reference/User Guide for details.

Viewing the Printed Output File

As previously mentioned, you set a breakpoint action to write to a printed output file called tim_out.txt. This file is a text file that is viewable in any text editor. You can use the Script Editor or any other text editor to view this file.

To view this file from the Script Editor, select File Open from the Script Editor and set the File Type filter to *.*. Locate the file tim_out.txt, and click Open.

This file is a printed output file in the form of a state table, showing the states of all the “watched” signals at the times at which breakpoints were encountered. The times of the five breakpoints should match the times listed in the log console area of the Script Editor when the simulation was originally run. You should still be able to see the console messages to verify this.

Closing the Simulator

When you are satisfied with the results of the simulation, you may close the Script Editor and the Simulator.

Next