Skip to main content

Pattern generator

This chapter focuses on the functions and notions related to the building of logic patterns with SP1000G series devices.

To use a pattern generator script with an SP1000G series device, one must follow those steps:

  • Add your script in Pattern Generator section,
  • Then, you have to click on Start Generate and Capture,
  • ScanaStudio executes the script that builds the pattern, sends pattern data to the SP1000G device, which will generate the pattern and capture logic signals while generating.

A simple pattern generator script will carry the main tasks below:

  • Build a pattern, defining the logic levels and sequences on all channels of interest
  • define the number of time the pattern must be repeated
  • send the pattern to the device and start generation
  • wait for pattern generation de be done.

As you will discover in this chapter, pattern generator scripts may get more sophisticated if this is needed to achieve required goals (e.g. generating long patterns)

Signal generation functions

To generate patterns with SP1000G device, one have two options:

  • Use the legacy signal builder functions. (not recommended for SP1000G pattern generation), those functions are builder_add_samples(), builder_add_cycle() and builder_add_cycles() and are detailed in the signal builder chapter.
  • Use dedicated pattern generator functions that extends the capabilities of the SP1000G pattern generation (recommended method).

The latter (dedicated pattern generator functions) are described in detail later in this chapter. These dedicated functions are particularly aimed at application that need to generate test pattern, like *.STILL files, *.WGL file, *.VCD file or other vendor specific formats. One of the most common use of that mode is for semiconductor testing ATE systems. That being said, it can be adapted to any

Note

signal builder functions used within SP1000G pattern generation context are deprecated as of January 2025. We recommend only using dedicated pattern generator functions found in that document when working with SP1000G devices.

Chunk memory structure

While SP1000G can stream captured data to the host computer, it is not able to stream data the other way around, from the host computer to the device. In order to generate logic signals, first the data need to be transferred from the host computer to the device's internal memory.

A chunk is defined in this context as a certain amount of logic transitions that are loaded into SP1000G's internal memory and can be generated once, a predetermined number of times, or in an infinite loop (until the STOP button is pressed in ScanaStudio).

A chunk has a maximum size, thus, if the amound of data that needs to be generated exceeds that maximum size, it needs to be splitted into several chunks.

There is no need to completely fill a chunk before starting another chunk. However, the generation of a previous chunk needs to be done before a new chunk can be loaded. That also means that there will always be a non-deterministic delay between two chunks.

It's important to understant the way generator data may be split into chunks to be able to design the generated script in a way that makes the most out of each chunk and alleviates any limitations that may be caused by this.

Entry point functions

If you want to write a script which is able to build and generate logic pattern with an SP1000G series device, your script must have these three entry point functions defined.

function on_draw_gui_pattern_generator()
{
// Function called when ScanaStudio needs to display the GUI
}

function on_eval_gui_pattern_generator()
{
// Function to evaluate (and validate) the choices set by the user in the GUI
}

function on_pattern_generate()
{
// Function to build the signals you want to generate
}

Function on_draw_gui_pattern_generator()

Description : This entry point function is launched when you add the script in Pattern Generator section. It will display a GUI, an interface which can be used (for example) :

  • To configure parameters you want to take into account for the signals generation (like letting the user configure which channels on which the signals should be generated).
  • To show information to user.

This entry point function is optional ; you don't have to write between the braces if you don't need it.

Context : Pattern generator

Function on_eval_gui_pattern_generator()

Description : This entry point function is used to evaluate if the GUI configuration (the choices made by the user in the GUI) is valid. The approach is often to:

  • Retrieve the values entered by the user in the GUI,
  • Test if this value is valid,
  • Then a display of an error message if this value doesn't correspond to criteria you defined.

This entry point function is optional.

Context : Pattern generator

Entry point function on_pattern_generate()

Description : This is the entry point function which is called when the user clicks on "start capture and generate". It's purpose should be the build the logic pattern, load it into the device and start generation.

Context : Pattern generator

Configuring channels

For each channel you want to use as a generator, you have to set three parameters :

ScanaStudio.builder_set_out_voltage(channel_index, voltage_in_mV) ; //Voltage of the output
ScanaStudio.builder_set_idle_state(channel_index, idle_state) ; //Idle state of the output
ScanaStudio.builder_set_io(channel_index, output_type) ; //Type of the output

ScanaStudio.builder_set_out_voltage(channel_index, voltage_in_mV)

Description : This function allows you to set the voltage of the output for a channel.

Parameters :

  • channel_index : Index of the channel (0 Based, that is the first channel's index in 0).
  • voltage_in_mV : Voltage of the output, which depends on your use, and is expressed in milliVolts (mV).

Example :

If you want to initialize the first channel to 3300 mV, you can write :

ScanaStudio.builder_set_out_voltage(0, 3300) ;

Context : Pattern generator

ScanaStudio.builder_set_idle_state(channel_index, idle_state)

Description : The idle state for a channel is the logic level (1 our 0) that will be set for an output-configured channel before the chunk is started, in between two chunks, or after the last chunk generation is done.

Parameters :

  • channel_index : Index of the channel (0 Based, that is the first channel's index in 0).
  • idle_state : This value depends on your use, and is either 0 or 1.

Example :

If you want to initialize the idle state of the first channel to 1, you can write :

ScanaStudio.builder_set_idle_state(0, 1) ;

Context : Pattern generator

ScanaStudio.builder_set_io(channel_index, output_type)

Description : This function allows you to set the output type for a channel.

Parameters :

  • channel_index : Index of the channel (0 Based, that is the first channel's index in 0).
  • output_type : Depending on your use, the output type could be :
 ScanaStudio.io_type.push_pull;
ScanaStudio.io_type.open_drain_no_pull; //open drain, not pull up device
ScanaStudio.io_type.open_drain_pull_up; //open drain with a pull up device

If you're not sure which option to set, keep in mind that :

  • Push-pull output is best suited for communication interfaces that have single direction lines (e.g SPI, UART etc...).
  • Open drain is commonly used for bidirectional single line communication interfaces, where more than two devices are connected on the same line(e.g I2C, One-Wire etc.).

Example :

If you want to initialize the output type of the first channel to push-pull, you can write :

ScanaStudio.builder_set_io(0,  ScanaStudio.io_type.push_pull) ;

Context : Pattern generator

Dedicated pattern generation functions

The functions below are used to describe the signals to be physically generated on the probes. In other words, they are used to fill the chunks with the pattern to be generated, and the control the generation of that chunk by inserting loops or pauses.

Note

it's not possible to mix the functions below and the legacy signal builder functions (builder_add_samples(), builder_add_cycle() and builder_add_cycles()) in a same script execution.

ScanaStudio.builder_add_step(channel_data[], hold)

Description : Adds a logic level on all channels, for a duration of hold samples.

Parameters :

  • channel_data[] : An array of integers (0 or 1), have the same size as the number of channels of the device being used. This array describe the logic level on all channels. Only channels configured as output-capable will be affected.
  • hold : An integer describing the number of samples to hold the logic level described by channel_data[]

Example :

var ch_val = [];
for (var ch = 0; ch < ScanaStudio.get_device_channels_count(); ch++) {
ch_val.push(1);
}
ScanaStudio.builder_add_step(ch_val, 100); //Adds 100 samples

Context : Pattern generator

ScanaStudio.builder_loop_start(quint32 loop_count)

Description : This function allows a part of the pattern to be repeated for loop_count times. The part of the pattern to be repeated should be delimited by builder_loop_start() and builder_loop_end(). Please note that only 3 nested loop levels are allowed.

Parameters :

  • loop_count : The number of times the loop should be repeated. 0 means infinite loop. Maximum value should fit on 28 bits integer.

Example :

var ch_val = [];
for (var ch = 0; ch < ScanaStudio.get_device_channels_count(); ch++) {
ch_val.push(1);
}
ScanaStudio.builder_add_step(ch_val, 100); //Adds 100 samples

ScanaStudio.builder_loop_start(100);
ch_val[0] = 0;
ScanaStudio.builder_add_step(ch_val, 100);
ch_val[0] = 1;
ScanaStudio.builder_add_step(ch_val, 200);
ch_val[0] = 0;
ScanaStudio.builder_add_step(ch_val, 300);
ScanaStudio.builder_loop_end();

Context : Pattern generator

ScanaStudio.builder_loop_end()

Description : Used in conjunction with builder_loop_start() to repeat a parts of the pattern.

Context : Pattern generator

ScanaStudio.builder_get_loop_level()

Description : returns the current loop level (in case of several nested loops). 3 is the top level, meaning no any loop is currently "open". Returning 2 means currently one loop is started with builder_loop_start(), 1 means two nested loops are started, 0 means three nested loops are started an no more loops can be started before close one or more open loops with builder_loop_end().

Context : Pattern generator

ScanaStudio.builder_get_max_chunk_size()

Description : This function returns the maximum number of transitions that can be stored in a chunk. The maximum chunk size depends on hardware embedded memroy and device firmware version.

Context : Pattern generator

Controlling pattern generation

ScanaStudio.builder_start_chunk()

Description : This function sends a chunk to your device's memory and starts generating it. Please note, however, that if "wait for trigger" option box is ticked in ScanaStudio's GUI, in the Pattern Generator panel, then the first chuck will not start generating until the device trigger condition occurs.

Context : Pattern generator

ScanaStudio.builder_add_pause()

Description : Request the pattern to be paused, keeping all signals unchanged until resumed by the user

Example :

var ch_val = [];
for (var ch = 0; ch < ScanaStudio.get_device_channels_count(); ch++) {
ch_val.push(1);
}
ScanaStudio.builder_add_step(ch_val, 100); //Adds 100 samples
ch_val[0] = 0;
ScanaStudio.builder_add_step(ch_val, 100);
ScanaStudio.builder_add_pause() // <------ Pattern will pause here until resumed by the user.
ch_val[0] = 1;
ScanaStudio.builder_add_step(ch_val, 200);
ch_val[0] = 0;
ScanaStudio.builder_add_step(ch_val, 300);

Context : Pattern generator

ScanaStudio.builder_wait_done(timeout_ms)

Description : Once the chunk is sent using ScanaStudio.builder_start_chunk(), calling this function will return true or false, depending on whether or not the device has finished generating the chunk that is loaded in memory. It's important to wait for the device to return true before sending starting another chunk.

Note : Although it's not legal to start a new chunk while the previous one is still being generated, it's totally legal (and even considered good practice) to start building the next chunks right after calling ScanaStudio.builder_start_chunk(). Only the next call to ScanaStudio.builder_start_chunk() need to be delayed until ScanaStudio.builder_wait_done() return true

Parameters :

  • timeout_ms : maximum time to wait, expressed in milliseconds. Leave empty for infinite wait.

Context : Pattern generator