Previous

Adding Stimulus

To define the function of the input signals, you must add stimulus to your simulation. There are many ways to define stimulus with the Foundation Simulator. Some of these methods are listed below and are discussed in more detail in the sections to follow.

In this tutorial, you use the keyboard stimulus, custom formulae, internal binary counter, and script file. The script file method is used later in the tutorial when you are performing a timing simulation. All of these stimulator methods may be used in both functional and timing simulations.

Open the Stimulator Selection Window by clicking the Stimulator icon in the toolbar or by selecting Signal Add Stimulators...

figures/add_stim_icon.gif

The various components of this window are discussed in the following sections.

Figure 6.4 Stimulator Selector

Stimulating with the Internal Binary Counter

The Foundation Simulator includes an internal free-running 16-bit binary counter. You can use each of the 16 output bits of the counter as stimulators. These signals provide 50% duty cycle signals, each bit having half the frequency of the next least significant bit. These are useful when defining clock stimulus. You may define the frequency of the LSB of the counter (B0) and can therefore derive the frequencies of the other counter outputs.

These counter outputs are represented by the round yellow LEDs in the Stimulator Selection window. The row of red round LEDs below it represents the complement of the counter outputs. The B0 output (LSB) of the counter is the farthest LED to the right, and B15 (MSB) is all the way to the left.

In the Watch design, the system clock is generated by the internal oscillator in the XC4000E device. This is represented by the OSC4 component on the schematic. The OSC4 does not have a simulation model, and, thus, cannot be simulated. To simulate the system clock, you assign stimulus to the CLK signal in the simulator. You use the B0 stimulator signal to stimulate the CLK signal in the Watch design.

  1. In the Waveform Viewer, select the CLK (CLKINT for HDL designs) signal by clicking it.

  2. In the Stimulator Selection Window, click the B0 stimulator (the right-most yellow LED). You should now see a B0 next to the CLK signal in the Waveform Viewer indicating that the B0 stimulator is assigned to CLK.

  3. Select Options Preferences from the Simulator window. This opens the Preferences window. In the Simulation tab of this window, you can set the frequency of the B0 counter output.

  4. Set the B0 frequency to 10MHz. This is significantly faster than the actual speed of the system clock used in this design (15Hz), but this frequency is adequate for the purposes of this simulation.

    Figure 6.5 Simulator Preferences

  5. Press OK to close the Preferences window.

Stimulating with Keyboard Stimulators

You assign keyboard keys as stimulus for signals in your design with the keyboard in the Stimulator Selection window. After you assign this stimulus, the signal's value toggles between 1 and 0 whenever you press the corresponding key on your PC's keyboard. Additionally, you can assign a constant 1 or 0 to a signal using the 1 and 0 keys on the Stimulator Selector's keyboard.

Now assign the R keyboard stimulus to the RESET signal in the Watch design.

  1. Click and drag the R key on the keyboard in the Stimulator Selector onto the RESET signal name in the Waveform Viewer.

    You should now see an R next to the RESET signal in the Waveform Viewer, which indicates that this is the assigned stimulus.

  2. Press the R key on your PC keyboard a few times to see the state of the stimulus changing in the Waveform Viewer.

Stimulating with Custom Formulae

The 16 square LEDs in the Stimulator Selector represent Custom Formulae. You have the option to define each of these 16 formulae to any custom stimulus pattern you want.

Now create a custom formula and then assign that formula to the STRTSTOP signal in the Watch design.

  1. Click the Formula... button in the Stimulator Selection Window to bring up the Set Formulas window.


    NOTE

    There are two sections of the Set Formulas window: Clocks and Formulas. Any pattern that you specify for a Clock repeats forever. Any pattern that you specify for a Formula executes just once, and then holds the last specified value for the rest of the simulation.


  2. Double click on F0 in the Formulas section. The Edit Formula field at the bottom of the window should now be active.

  3. Type the following formula into the Edit Formula field:

    h100l20h2000l20h500l200h1000

    This formula means “High for 100ns, then Low for 20ns, then High for 2000ns, then Low for 20ns, etc...”. This defines the stimulus pattern which you assign to STRTSTOP.

  4. Click Accept. This assigns the formula you just entered to the F0 formula. You should now see it displayed next to the F0.

    Figure 6.6 Creating Formulas

  5. Click Close.

  6. Assign this newly created F0 formula to the STRTSTOP signal. Click the F0 LED in the Stimulator Selection box (the farthest square LED to the right) and drag it onto the STRTSTOP signal in the Waveform Viewer. You should now see an F0 next to the STRTSTOP signal indicating that the F0 formula has been assigned as stimulus for that signal. The F0 formula may now also be used for any other signals you want within this same project.

Other Sections of the Stimulator Selector

There are a few more sections of the Stimulator Selector that are not used in this tutorial, but are discussed briefly here. For complete documentation on these topics, refer to the Foundation Logic Simulator online help.

The Clocks section contains four custom clock signals. These custom clocks are defined in the Set Formulas window as mentioned above in the Custom Formula section. These custom clocks are useful for clocks with duty cycles other than 50%. You could not use the internal binary counter outputs for those types of clocks or for other repeating functions.

The EN, DS, CC, OV, and CS buttons pertain to the “mode” of the signal and stimulus. These modes control options, such as whether the stimulus is overridden by internally driven signals and whether the stimulus is enabled or disabled at a given time.

Finally, the Delete button deletes the stimulus from a selected signal. This function does not delete the signal from the waveform viewer. It merely deletes the stimulus associated with that signal.

Close the Stimulator Selection window by clicking Close.

Next