Example Code

Calculate the average of 2^N Points on FPGA

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW FPGA Module
  • LabVIEW

Code and Documents

Attachment

Overview

This example demonstrates how to calculate the average for 2^N input points on a FPGA. 

 

Description

This VI computes the average of 2^N 64-bit integer (I64) numbers and outputs the result. When the result is computed, Output Valid? is set to 'True'. For example, if N = 5, this VI will average 2^5=32 64-bit integer numbers, return the result and set Output Valid? as 'True'.

A Reset boolean is also provided to reset the FPGA VI. When Reset is set as True, all feedback nodes are set to '0', Average is set to '0' and Output Valid? is kept at 'False'.

The VI is built to accept the largest data representation available on a FPGA (I64). If you want to average numbers which don’t need the largest data representation, like I8, I16 and so on, modify the data representation inside the averager to a smaller data representation. This will save space on the FPGA and speed up the compilation process.

 

Requirements

 Software

  • LabVIEW Base Development System 2012 (or compatible)
  • LabVIEW FPGA Module 2012 (or compatible)

 Hardware

  • No hardware is necessary to use this example VI

 

Steps to Implement or Execute Code

  1. Download and open the attached ZIP-file
  2. Open the project and follow the instructions inside the [Main] Point Averager.VI

 

Additional Information or References

 

[MAIN] Point Average - Front Panel.png

 

Point Average - Block Diagram.png

 

Note
Keep in mind, that the averager can roll over without notification if you try to average to many points or if the input values are to big.

 

**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.