The Simulator (Tutorial)

This section explains how to verify the counter using the built-in simulator.

Set up the simulator

Before simulation can start, the schematic needs to be compiled. Moreover, it is necessary to set up a few simulation parameters. In particular, since the project can contain many schematics, it is necessary to specify which schematic to simulate.

Simulate with the simulator view

When the simulation has started, the simulator view appears under a new tab in the same area as the schematic editor. The simulator view is divided into two main areas: the signal area to the left shows the names and the current values of the signals, and the graph area to the right shows the simulated data graphically. As the simulation progresses, the graphs will be plotted towards the right. By default, the graphs are shown individually in rows aligned with their names, but the graphs can also be shown in full size in the graph area by clicking the Joint View toolbar button.

Counter simulation

Force a signal

Individual signal values can be forced to any value during the simulation by clicking in the Value or the Force column. For boolean signals, the value will switch between 0 and 1 when clicked, while for other types, a box appears where a new value can be entered. Forcing is removed by right-clicking the value and choosing Unforce in the context menu that appears.

Move the cursor to examine simulation results

The cursor is a vertical line that is always present in the graph area, by default at the right end of the graphs. However, the cursor can be moved by clicking in the graph area or by pressing Ctrl-Left arrow or Ctrl-Right arrow. The values shown in the signal area always reflect the values at the cursor's position.

View values in the schematic

Simulated signal values can also be viewed in the schematic right by the corresponding connections. As with the signal area, the schematics reflect the values of the cursor, even if the cursor is not explicitly visible.

Set up a testbench

A common way to perform simulation is to set up a testbench where input data is fed automatically into the model. In RTflow, this can be done by using the model as a block in another schematic and connecting this block to a signal generator.

The above procedure exemplifies how models can be structured into a hierarchy of schematics. A typical model has a top-level schematic containing the model's inputs and outputs and a number of connected user-defined blocks. These blocks have been defined in schematics that may again contain other user-defined blocks. The definition of a block can be opened by double-clicking it, and one can return to the parent schematic by clicking the Pop Context toolbar button in the schematic editor.

Simulate with the testbench

Since the simulator is now set up to simulate the Counter schematic, it is necessary to change this setting to simulate the Testbench schematic and restart the simulator.