Probes

Probes are used to see what data is consumed or emitted by a specific port or shared model element.

They are useful model elements when searching for bugs or simply understanding what a model instance or module does during simulation runs. Probes are recognized in the Tree View by the probe icon shown here. A probe reads data from a model element and displays the information in one of the following ways:

Online Display
A resizeable white display with a thin black border is placed close to the model element on which the probe is placed.
File
The output data is written to a text file.
Tcl Variable
The data is defined as a Tcl variable.

Probes are capable of reading information from input/output ports, Memories and Events. The information displays or is printed to a file when the value of the information on the appropriate model element changes.

Probes can only be placed on or deleted from model elements before or after a simulation run while MLDesigner is in simulation mode.

Port Probes

The probe is triggered every time data is written to or read from a port. Numbered ports of special primitives are handled as normal ports. Probes do not differentiate between multi ports and single ports. All ports represented by the multi port deliver data to the probe. The probe cannot determine which port delivered which data.

Probes on Memories and Events

Probes on Memories and Events are triggered when data is written to the shared model element. The Dump primitive in the Probes library is designed to handle data of type anytype and can be used for reading from Memories and Events. The data is placed on the input port of the probe.

Probes on Dynamic Instances

The mechanism for placing probes within modules that are dynamic instances is the same as that used for placing breakpoints. As explained previously the dynamic instance does not exist when the probe is placed and must therefore be defined as a supposed probe on a model instance that will be dynamically created at some stage in the future. The difference is that only one probe can be placed on a given port whereas numerous breakpoints can be defined for a port. Breakpoints can also be placed on a model instance whereas the placement of probes is restricted to ports and shared model elements.

Probe Properties

The Probe Properties window is visible when a probe is selected in the Model Editor window while MLDesigner is in simulation mode. The probe properties are listed and explained in the following table.

Property name

Function

Probe

Defines the type of Probe primitive to use. Default is the Dump primitive. Other types of probes are:

  • FloatingMean
  • Maximum
  • Mean Value
  • Minimum

Source Model

Instance from which to sample data.

Display

Yes/No: Defines whether the probe is a display which is visible in the Model Editor window during simulation.

File

Yes/No: Defines whether the data should be saved to a file or not.

File Path

Opens a dialog where it is possible to select or create a file to write the data to. The data is printed to the file as text. Data is separated by white spaces and a newline for each new element. The data is overwritten with each simulation run or with each iteration.

Workspace

Yes/No: Whether the data should be written to a Tcl variable or not.

Workspace Variable

Name of a Tcl variable to print the data to. The variable is overwritten with each triggering.

Control Type

Time/Trigger: Defines whether the probe must write data after a certain simulation interval or after a certain number of triggerings.

Start Time

The time to start reading data from the model element if Control Type is set to Time.

Stop Time

The time to stop reading data from the model element if Control Type is set to Time.

Ignore Count

The number of triggerings to ignore before reading data from the selected model element if the Control Type is set to Trigger.

Trigger Count

The number of triggerings to read data from the selected model element if the Control Type is set to Trigger.

Probe Primitives

The probe primitives define the algorithm used to analyze data samples. The primitives have an input and an output port. Data samples are collected on the input port. Additional parameters can be defined for probe primitives. Additional ports, Memories, Events or Resources may NOT be defined.

Probes are not specific to a particular domain and can be used in all simulations.

Create user defined probes

The procedure for creating user defined probes is similar to the one for creating a new primitive. Open the Create New Model dialog. Select Probe as Type of Model. Give the probe an appropriate name and save it in a library. A probe primitive with one input port and one output port is now open in the Model Editor window.

Open the source code of the new primitive. The three methods init(), trigger() and finish() must be defined. These methods are briefly explained here:

Method

Description

void init()

Is called when a probe is instantiated or when a simulation is started. There is no data on the port but the parameter is initialized.

trigger()

Typically reads data from the input, analyzes the data and puts the result on the output.

finish()

Is called when the simulation is complete or when the probe is deleted.

The DataNew flag

The programmer must ensure that the DataNew flag for a port is set to true when a probe places data on an output port in the finish method. The following example demonstrates a Sum probe that collects all values and passes them on once they have all been received.

defprobe
{
  name        { Sum }

  input
  {
    name { Input }
    type { anytype }
  }

  output
  {
    name { Output }
    type { float }
    num  { 0 }
  }

  protected
  {
    double sum;
  }

  init
  {
    sum = 0.0;
  }

  trigger
  {
    sum += double(Input%0); // accumulate
  }

  finish
  {
    Output.setPort(FLOATTYPE, 1); // put one value of float at the end
    Output%0 = sum;
    Output.setDataNewFlag(true); // set the flag!
  }
}