DSP Builder for Intel® FPGAs (Advanced Blockset): Handbook

ID 683337
Date 7/15/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

14.6.6.6. Creating the Finite State Machine Configuration File

The DSP Builder m-script, substitutePlaceholderValues, allows you to insert parameter values into a .fsm configuration template file.
Figure 145. Example count_edges_template.fsm
# Counts N rising/falling edges
require version 23.3
inputs x
finish done
netlist
for n 0 < %NEDGES% : c
    transitions EdgeDetect
        state Initial
            if (~x) Low
            if (x) High
        state Low
            if (x) %RISING%
        state High
            if (~x) %FALLING%
    end
end

Procedure

  1. In the setup script for your DSP Builder model, create a cell array that defines the parameter values:
    Figure 146. Parameter ValuesThe parameter placeholder names do not have to be in the %NAME% format. They can be any arbitrary string. Adding a unique delimiter makes it easier to identify what is a parameter.
    parameterDefinitions = {
        {'%NEDGES%', 5 },
        {'%RISING%', 'Initial'},
        {'%FALLING%', 'Low'}};
    
  2. Generate the .fsm configuration file that the Finite State Machine block uses by calling the m-script:
    substitutePlaceholderValues(parameterDefinitions, 'count_edges_template.fsm', 'count_rising_edges.fsm');