Optimizing Memory Usage of Array Constants

You can optimize your FPGA application by specifying how LabVIEW implements array constants in memory. The default implementation for new array constants is Auto, which means that the compiler decides whether to implement an array constant in block memory, look-up tables, or flip-flops based on specific coding patterns.

If you have difficulty compiling FPGA VIs with the Auto setting, instead choose a Block Memory or Look-Up Tables implementation for array constants. Consider choosing a block memory implementation for array constants unless you need the advantages of a different type of memory. Block memory does not consume FPGA resources and tends to compile at a high clock rate relative to other types of memory.

An array constant created in another context, such as on the development computer, is automatically set to Auto when opened in an FPGA VI. An array constant created in an FPGA VI maintains the selected memory implementation when moved into another context.

Restrictions for Implementing Array Constants in Block Memory or Look-Up Tables

To ensure you can implement an array constant in either block memory or look-up tables, you must meet the following criteria:

  • You cannot wire an array constant to a top-level indicator. However you can separate the Replace Array Subset function from the Index Array function in a separate subVI.
  • If you place an array constant in a single-cycle Timed Loop, you can include in the loop only one Replace Array Subset function and only one Index Array function. For each of these functions, you can access only a single index address in one loop iteration and you cannot resize the function or include multiple value writes/reads.
  • For block memory implementations in a single-cycle Timed Loop, you must meet the following additional criteria:
    • You must pass an array constant through a Feedback Node that you configure to globally initialize when the VI compiles or loads and to ignore initialization if the FPGA VI resets. To globally initialize a Feedback Node, right-click the initializer terminal and select Globally Initialize»Initialize On Compile Or Load. To configure the Feedback Node to ignore initialization, place a checkmark in the Ignore FPGA reset method checkbox on the FPGA Implementation page of the Feedback Node Properties dialog box.
    • You must place Feedback Nodes after read and write operations.
  • For look-up table implementations within a single-cycle Timed Loop, you must also wire an array constant to a shift register or a Feedback Node.
Note If an array constant does not meet these requirements, LabVIEW reverts to the flip-flop implementation or returns an error.

Coding Patterns for Array Constant Memory Implementations

Use the following FPGA VI patterns to help you ensure that an array constant uses the memory type that you selected. Conversely, if an FPGA VI does not compile, use the patterns below to help you determine why it failed.

Note The Feedback Nodes in the following FPGA VIs include a yellow exclamation point, indicating that they will not be asynchronously reset, may contain bad data after a reset, and are not reset between top level VI executions. Block memory and look-up tables do not support asynchronously resetting state within Feedback Nodes.

Coding Examples of Array Constants in Single-Cycle Timed Loops

None

Block Memory Implementations

You can implement an array constant in block memory if your coding patterns resemble the following examples.

RAM Pattern

In the following coding pattern, notice that a Feedback Node appears after the read performed by Index Array and after the write performed by Replace Array Subset. This pattern compiles because it satisfies the requirement of only one read and one write with the required Feedback Nodes.

ROM Pattern

In the following coding pattern, notice that a Feedback Node is required after the read performed by Index Array.

Look-Up Table Implementations

You can implement an array constant in look-up tables if your coding patterns resemble the following examples.

RAM Pattern

In the following coding pattern, notice that a Feedback Node is not required after the read performed by Index Array when placed in a single-cycle Timed Loop. Also notice that the required Feedback Node is wired to the array constant.

ROM Pattern

In the following coding pattern, notice that a Feedback Node is not required after the read performed by Index Array.

Coding Examples of Array Constants outside of Single-Cycle Timed Loops

If your code resembles the following patterns, you can implement an array constant in either block memory or look-up tables.

RAM Pattern

The following coding pattern allows only one write performed by Replace Array Subset, followed by one read performed by Index Array.

ROM Pattern

The following coding pattern allows unlimited reads performed by Index Array and requires no Feedback Node.