Previous

Performing Functional Simulation

You perform functional simulation before design implementation to verify that the schematic that you have designed is logically correct. All components in the Calc design, even the non-schematic LogiBLOX module, have built-in simulation models so little pre-processing is necessary. However, every top-level design in Mentor Graphics must have a simulation viewpoint before you can use it in QuickSim. The viewpoint describes how a design should be interpreted, including what components in the design are primitives, as well as how components within the design hierarchy should be modeled.

Using Pld_dve

You use the PLD Design Viewpoint Editor to generate a design viewpoint to tell QuickSim how to interpret certain Xilinx-specific design properties. Follow these steps to generate a viewpoint with pld_dve.

  1. Select the calc design object from the appropriate directory in the Navigator window.

  2. Invoke pld_dve on the design by selecting Right Mouse Button Open pld_dve.

    A dialog box appears. Note that the component name, Calc, is entered automatically with a fully qualified path.

    Figure 9.53 Invoking Pld_dve for Functional Simulation

  3. Select the appropriate PLD Technology from the listing, e.g., XC4000E, as shown in the figure above. (Leave other options set to their defaults, as shown in the figure.)

  4. Click OK to execute the pld_dve script.

  5. Once pld_dve completes, dismiss the shell window in which it executed.

Invoking Pld_quicksim

Invoke pld_quicksim for functional simulation on the Calc design using the following method:

  1. Select the Calc design object in the Navigator window.

  2. Invoke pld_quicksim on the design by selecting Right Mouse Button Open pld_quicksim.

    A dialog box appears. Note that the component name, Calc, is entered automatically with a fully qualified path.

    Figure 9.54 Invoking Pld_quicksim for Functional Simulation

  3. Under Select desired mode, select NO Cross-Probing (Front-end).

    This runs pld_quicksim in functional simulation mode, which uses information from the original schematic (as opposed to a timing netlist generated by the Xilinx software) to model the design.

  4. Click OK to start QuickSim II.

Viewing the Calc Schematic

When QuickSim starts, no windows are open. In this section, you open a window and view the top-level schematic for the Calc design. Displaying the schematic is convenient for viewing back-annotation during the simulation.

  1. To open a window containing the Calc schematic, select OPEN SHEET from the palette.

    This automatically opens the top-level sheet for Calc.

  2. Move the window to the upper left corner of the QuickSim window.

    Figure 9.55 Top-Level Calc Schematic

Selecting Nets for Simulation

There are several ways to select the signals that you would like to monitor. One way is to select the Right Mouse Button Add Traces Specified command, then type in the nets you want to view in simulation. Another way is to select the nets on the schematic. To select the signals, you may need to zoom and pan using the scroll bars or using strokes.

To select the nets on the schematic follow these steps:

  1. Using the F8 key, zoom in on the area pictured in the following figure.

  2. Position the cursor on the net labeled CLK, and press the left mouse button.

    The net appears highlighted, as in the figure below. Whenever any portion of a net is selected in QuickSim, the entire net appears highlighted. You can select additional nets using the same procedure. If you make a mistake, click the left mouse button a second time on the net or object to unselect it.

    Figure 9.56 Selecting the CLK Net for Display in Trace Window

  3. Use the left mouse button to select the following nets: STACKEN, PUSH.

  4. Using the Shift-F8 key, view the entire schematic.

  5. Select the net labeled EXEC (output of the DEBOUNCE component) with the left mouse button.

    One of the advantages of labeling all nets is now clear. When you select an unlabeled net for simulation display, note that a default name is used for the net, such as N$14. This name is not very useful for debugging, especially since making changes to the schematic may cause renumbering of net names.

  6. You can also add buses to your list of signals to be monitored. Use the left mouse button to select the buses labeled ALUVAL(3:0) and STACKOUT(3:0).

  7. Press the blue TRACE button in the palette to add all selected signals to the Trace window.

Opening Trace and List Windows

To view the waveforms of the selected signals, you must open a QuickSim Trace window.

To open a Trace window, perform these steps.

  1. Select the blue button labeled TRACE in the palette with the left mouse button.

    A Trace window appears displaying the waveforms selected on the schematic.

  2. If necessary resize the Trace window to see all the signals at once. Otherwise, move the cursor into the Trace window and use the PageUp and PageDown keys to scroll through the signals in the window.

    Note that all the signals in the Trace window are highlighted. Every window opened in QuickSim is dynamically linked to the others. The selection of a net on the schematic sheet, for example, is also reflected in the Trace window, and in any other window that is open. This is useful, for example, if a setup violation occurs. The instance name in the error message text is highlighted, and the related component on the schematic page also appears highlighted.

    Figure 9.57 Trace Window

It is sometimes useful to obtain tabular output using a List window. A List window displays signal values and highlights the points at which a given signal value changes.

To open a List window, perform these steps.

  1. Since the desired signals are already selected, select the blue LIST button in the palette with the left mouse button.

    The list window appears, with the signal names at the bottom. The caret (`^') is an arrow pointing up to indicate the correct column for each signal.

  2. Move the List window to the upper right-hand corner of the screen next to the Schematic window.

    Figure 9.58 List Window

Adding Traces Manually

In the Calc design, inputs are entered via a set of eight switches, SWITCH(7:0). The lower seven switches (SWITCH(6:0)) define the opcode. The left-most switch (SWITCH(7)) is the execute switch. When SWITCH(7) is toggled, the selected opcode on SWITCH(6:0) is executed. It is useful to view SWITCH(6:0) and SWITCH(7) separately in the Trace window.

Add these two traces to the Trace window as follows:

  1. To add traces manually, the Stimulus Palette must be active. Click on the red STIMULUS button in the palette. The icons in the palette change.

  2. Press the F2 key to unselect everything.

  3. Select the Trace window with the left mouse button.

  4. Choose Right Mouse Button Add Traces Specified.

  5. In the dialog box that appears, select the Named Signals button with the left mouse button.

  6. Fill in the dialog box as shown in the figure below.

  7. Select OK or press Return.

    The bus SWITCH(6:0) and the signal SWITCH(7) are added to the Trace window.

    Figure 9.59 Adding Traces Manually

Assigning Values to the Clock

Define a clock for the circuit as follows:

  1. Make sure that the Trace window is active (border appears blue). If not, select the window using the left mouse button.

  2. Press the F2 key to unselect everything, then select the CLK net in the Trace window using the left mouse button.

  3. Select ADD CLOCK in the palette.

  4. Fill in the dialog box that appears as shown in the following figure.

    Figure 9.60 Adding a Clock Waveform

    The dialog box selections give the clock a 100 ns period and a 50 percent duty cycle. At zero ns, the clock begins with a value of zero. The Absolute option indicates that the times are absolute, and not relative to the state of the simulator. For example, if you had already been simulating, the state of the simulator may not be at zero nanoseconds. If Absolute is selected, the times entered in the dialog box are referenced from time zero. If Absolute is not selected, the times entered in the dialog box are added to the present time in the simulation.

    Selecting a Fixed Force type indicates that the signal is driven as if it were connected directly to VCC or GND. If Wired were selected, the signal would be driven as if it were connected to a pull-up or pull-down resistor. A Charge Force type represents a default charge on a floating signal. Wired values are overridden by Fixed values, and Charge values are overridden by both. In general, for Xilinx designs always use a force type of Fixed unless it is a bidirectional input, in which case a Wired force type should be used.

  5. Press return or select OK to add the force to CLK.

Asserting Global Set/Reset (without STARTUP)


NOTE

This section applies to designs in which the STARTUP module has not been instantiated. If you have an XC4000 family or XC5200 design that has the STARTUP module in it, go to the “Asserting Global Set/Reset (with STARTUP)” section.


In every simulation, the first node you must assert is the global-reset signal. This signal does not exist on your schematic, but does exist in the device. This dedicated net is connected to every asynchronous reset pin on every flip-flop (including IOB flip-flops) in an FPGA or CPLD. The net is named differently and has a particular polarity depending on the device family used as shown in the following table.

Table 9_3 Net Names for the Global Set/Reset Signal

Device Family
Net Name
Polarity
XC3000
//globalresetb
Active Low
XC4000
//globalsetreset
Active High
XC5200
//globalreset
Active High
XC7000
//prld
Active High
XC9000
//prld
Active High

In each case, the global-reset net name is preceded by two forward slashes, indicating that the net is a global signal in QuickSim. The global-reset signal is part of the simulation models; you must toggle it at the beginning of every simulation. If you do not pulse globalresetb low, all flip-flop outputs are unknown at all times during your simulation.

In the following example, you set //prld, the XC9000 global-reset signal, high at time 0 and low at 100 ns:

  1. With the Trace window selected, press the blue Unselect All button in the palette with the left mouse button.

  2. Select the Add Force icon in the palette with the left mouse button.

    The Force Multiple Values dialog box appears.

  3. Since a signal is not selected, the Signal name field is empty. Fill in the dialog box as shown in the following figure. The signal is to be forced low (asserted) at time zero and high at time 100ns.

    Figure 9.61 Forcing the Global-Reset Signal (XC9000)

For other families, assert the appropriate signal with the appropriate polarity. For example, in the XC3000 family, the global-reset signal is //globalresetb, which must be forced low at time 0, and so on.

Asserting Global Set/Reset (with STARTUP)


NOTE

This section applies to designs in which the STARTUP module has been instantiated. If you have a design without a STARTUP module instantiated, follow the instructions in the “Asserting Global Set/Reset (without STARTUP)” section.


The global-reset signal must be forced at the beginning of all XC4000 family and XC5200 simulations. It is an active-High signal that sets or resets all flip-flops in the chip. Whether a flip-flop is set or reset depends on whether it is an FDP or an FDC flip-flop, or on the value of the flip-flop's INIT attribute. The default configuration for all flip-flops is to function as a reset flip-flop.

Unlike other families, the global-reset signal in the XC4000 family and XC5200 family is not hard-wired to a package pin, and need not appear on one at all. If you want access to the global-reset net from an external pin, place the STARTUP component in your schematic and attach an IPAD and IBUF to the GSR pin for XC4000 family designs, or to the GR pin for XC5200 family designs. This pad becomes an active-High Global Set Reset signal in XC4000 family devices and an active-High Global Reset signal in XC5200 family devices. You can also use an internally generated signal to drive the GSR or GR pin of the STARTUP component. There is also an active-High Global Three State signal (GTS) that you can access in the same way. See the XACT Libraries Guide for more information on the STARTUP symbol.

Since an external signal is connected to the global-reset net via the STARTUP symbol, you must pulse this external signal to activate global reset as opposed to the internal global-reset signal (explained in the “Asserting Global Set/Reset (without STARTUP)” section.

  1. With the Trace window selected, press the blue Unselect All button in the palette with the left mouse button.

  2. Select the Add Force icon in the palette with the left mouse button.

    A dialog box appears.

  3. Normally, the net name //globalsetreset (XC4000) or //globalreset (XC5200) would be added as the signal name. (The two leading forward slashes would indicate that this is a global signal.) However, since you have included the STARTUP symbol in this design, you must instead pulse whatever signal is driving the GSR pin on the STARTUP module. In this case, pulse the NOTGBLRESET signal.

  4. Fill in the dialog box as shown in the following figure. The NOTGBLRESET signal is to be forced low (asserted) at time zero and high at 100ns. Note that, because of the inverter in the path from NOTGBLRESET to GSR or GR, this series of forces is equivalent to pulsing globalsetreset or globalreset high.

    Figure 9.62 Forcing Globalsetreset via Notgblreset (XC4000E)

Design Description

The Calc design is a simple four-bit processor with a stack. The CONTROL module interprets the switch input and drives the control lines of the ALU and STACK components. The ALU performs functions between an internal register and either the top of the stack or data read in from the external switches. Outputs include ALUVAL(3:0), the current contents of the internal register, and STACKOUT(3:0), the top value in the stack.

For a more detailed description of the Calc design, see the “Design Description” section.

Simulating the Circuit

You are now ready to force the inputs to known values and simulate.

  1. Press the blue Unselect All button in the palette.

  2. Select the Add Force button in the palette with the left mouse button.

  3. Fill in the dialog box as shown in the figure below.

    All numbers entered are interpreted as hex. This sets opcode (SWITCH(6:0)) to perform the following actions:

    00: ADD 0h to register value (should produce a zero).
    61: LOAD register with 1h.
    0D: ADD Dh to register value (1 + D should produce F).
    7B: PUSH register value to stack (top of stack=F).
    50: CLEAR register value.

    Figure 9.63 Forcing Values to SWITCH(6:0)

For these commands to be executed, you must provide stimulus to SWITCH(7), the execute switch. Perform the following actions to force SWITCH(7) correctly:

  1. Press the blue Unselect All button in the palette.

  2. Select the SWITCH(7) signal from the Trace window. It may be necessary to use the PageDown key to scroll through the list of signals in the Trace window.

  3. Select the red WF EDITOR button from the top of the Palette. The icons in the palette change.

  4. Select the icon labeled EDIT WAVEFORM.

    A new trace appears labeled forces@@/SWITCH(7). While the SWITCH(7) trace represents the value of SWITCH(7) up to the present time in simulation, the trace forces@@/SWITCH(7) represents all values that will ever be forced on the signal. During simulation, this waveform can be edited to modify future values of SWITCH(7).

A blue line appears extending from SWITCH(7) to indicate that it has not been given a value. First, force SWITCH(7) to a known value at time zero as follows:

  1. Select the ADD icon in the palette.

  2. Move the cursor into the Trace window.

    A red vertical line appears under the cursor. The numbers in the grey box reflect the value and time that are pointed to as the cursor is moved.

  3. Move the cursor close to the beginning of forces@@/SWITCH(7), as shown in the figure below, and then press the left mouse button.

    This indicates that you want to change the value from the nearest left edge (in this case, time zero is considered an edge) to the next right edge. Since the signal makes no transitions, you can assign the same value to the entire length of the signal.

  4. Type a `1' in the value field of the small dialog box and click OK.

    This indicates that you want to change the signal value between the two nearest edges to a one. The entire length of the signal changes color from dark blue to light blue, and the line moves up, indicating it will be driven to a one.

    Figure 9.64 Forcing SWITCH(7) to Initial Value

  5. Press the Escape key to end the Add Event operation.

Now that SWITCH(7) has been given an initial value, you must define when transitions occur on the signal as follows:

  1. Select the TOGGLE icon from the palette.

  2. Move the cursor to the Trace window.

    A red vertical line appears with numbers indicating the value and time of the signal at the position beneath the cursor.

  3. Move the cursor to the forces@@/SWITCH(7) signal at time 700ns and press the mouse button, as shown in the figure below.

    A high to low transition is added to the force waveform at time 700 ns.

    Figure 9.65 Adding the First Toggle to SWITCH(7)


    NOTE

    It is sometimes difficult to position the cursor at exactly the right value if you are zoomed in too close. If you zoom out, the numbers get rounded to the nearest 1.0 ns, making it easy to place the edges correctly. Use the stroke 753 to zoom out. If you still cannot place the edges exactly, err to the left of the desired location. If you make a mistake, select the CUT icon in the palette and click the left mouse button on the incorrectly placed edge. The edge disappears. Then, select TOGGLE to continue adding edges.


  4. Without moving the cursor, use the right arrow key to scroll the window forward in time. Each press of the right arrow key advances the window (and, consequently, the position under the cursor) by 50 ns. Add toggles at times 900, 1200, 1400, 1800, 2000, 2300, 2500, 2800, and 3000 ns. The waveform then appears as in the figure below. Press Shift-F8 to view the entire waveform.

  5. Press Escape to end the TOGGLE command

    Figure 9.66 SWITCH(7) Force Waveform

    Now that your inputs and clock are defined, you are ready to run the simulation.

  6. Type run 3400 at any location in the QuickSim window, then press return.

    A window automatically appears containing the text. The results should look similar to those in the following figure.

    Figure 9.67 Output from Simulation (XC4000E design)

Saving the Results

If you were to exit QuickSim now, you would lose your waveform data. You can save the waveform information in a waveform database. To view the waveforms at a later time, you can use the File Load Waveform DB command found in the menu bar.

  1. Select the red STIMULUS button from the palette.

  2. Select the SAVE WDB icon from the palette.

    The Save Waveform DB dialog box appears.

  3. Fill in the Save Waveform DB dialog box as shown in the following figure.

    This saves your results to the WaveForm Database, simrun1. This database is created in the directory specified by the $MGC_WD environment variable.

  4. Press return or click OK.

    Figure 9.68 Saving Results

It may be useful to save the stimulus so that it can be run again. To do this perform the following steps:

  1. Press the red STIMULUS button in the palette.

  2. Select the SAVE WDB icon from the palette.

    The Save Waveform DB dialog box appears.

  3. Fill in the Save Waveform DB dialog box as shown in the figure below.

    This saves the stimulus to the file, forces1. As with simrun1, this file is created in the directory specified by $MGC_WD.

  4. Press return or click OK to save the forces.

    Figure 9.69 Saving Forces

After saving the results, reset the simulator to time zero as follows:

  1. Press the blue RESET button in the palette.

  2. In the dialog box that appears, select the State button so that it highlights, and deselect any highlighted buttons.

    This forces the simulator to reset without saving.

  3. Press return or choose OK.

    The Trace window results disappear, while the forces waveform remains.

Using the Transcript

In addition to saving the results and forces, you can also save the actual transcript for the QuickSim session. Every mouse click and key press is recorded. This is sometimes useful for making macros to perform complicated, repetitive tasks. The saved transcript can then be replayed using the MGC Transcript Replay command found in the menu bar. Save the transcript as follows:

  1. Select the MGC Transcript Show Transcript command from the menu bar.

    A text window appears. In this text window are AMPLE commands. AMPLE (Advanced Multi-Purpose Language) is a C-like programming language used by all of the Mentor Graphics tools.

  2. Select Right Mouse Button Export.

  3. In the dialog box that appears, type the file name transcript.out in the text field of the dialog box.

    This saves the transcript to that file.

    It is usually necessary to edit the transcript to make it useful. For example, if this transcript were re-run on the Calc design, it would setup the simulation, run, save the results, reset the simulator, and open a transcript window. Perhaps all you want it to do is setup and run the simulation. You would then have to delete the other commands from the transcript file before re-running it. For example, the $show_transcript(); command at the end of the transcript file could be deleted to keep the transcript window from appearing. You would probably also want to delete the $set_active_window(“Transcript”); command as well if you did this. For more information on AMPLE, refer to the appropriate Mentor Graphics documentation.

  4. Select File Quit to exit QuickSim.

Next