Pattern generator
This chapter focuses on the functions and notions related to the building of logic patterns with SP1000G series device.
To use a pattern geneartor 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 patern 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 interrest
- 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
It’s important to understand that the Pattern Generator scripting feature is a superset of the signal builder scripting feature. Which means that within the Pattern generator context, you have access to all signal builder related functions (but not vice versa).
In this chapter, we’ll mainly focus on the features and additions specific to the pattern generator. Please refer to the signal builder scripting documentation if you need more details about the functions used to build logic signals.
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
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 pannel, then the first chuck will not start generating until the device trigger condition occures.
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
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 proactice) 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