Table Of Contents

Static Array Indexing in Optimized FPGA VIs

Last Modified: March 30, 2016

Use static array indexing so the compiler can make optimizations to your code and get the best performance possible for your Optimized FPGA VI.

There are two methods you can use to index an array:

  • Dynamic array indexing—Dynamic code produces values that the compiler cannot determine at compile time. An example of dynamic code is the value in a control. Other parts of an application can change the value of the control at run time, which means the compiler cannot determine what the value of the control is at compile time. When you index arrays using dynamic values, called dynamic array indexing, the compiler can only make limited optimizations.
  • Static array indexing—Static code produces values that the compiler can determine at compile time. An example of static code is the value in a constant. When you index arrays using static values, called static array indexing, the compiler makes behind-the-scenes optimizations that improve the performance of the Optimized FPGA VI.

Examples

The following image shows an example of dynamic array indexing. In the example, the Optimized FPGA VI offsets the index by 0 when the even call control is True and by 6 when the control is False. Because the compiler cannot determine the value of the control at compile time, it makes only limited optimizations. As a result, the throughput of the Optimized FPGA VI suffers.

By identifying recurring patterns in the code, you can make the control value static at compile time and improve the performance of the code. If you assume the control is True on even calls and False on odd calls, you can rewrite the code as shown in the following image.

In the rewritten code, the compiler determines the value for the array indexing logic at compile time. It makes more optimizations, and the throughput of the Optimized FPGA VI is higher.


Recently Viewed Topics