ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FPGA - how to set array to zero

I use a signal filtering subVI applied on a fixed size array. Depending on cRIO configuration, I use different fixed size array.

 

The thing is that I need to initialize filters with zeros. As maximum effectiveness in resources usage is required, I want to know how to get the fixed size array and set it to zero with most efficient way. Ideas that come to my mind:

 

Multiply by zero

Bit shift right 32 times (datatype I32)

Size of fixed size array is constant -> wiring "array size" output to initialize array (not working, size of fixed size array is not considered constant)

0 Kudos
Message 1 of 7
(4,966 Views)

Or maybe subtract array from itself

0 Kudos
Message 2 of 7
(4,947 Views)

Another idea: xor the array with itself.

I doubt there will be a significant performance difference between initialization methods. If the compiler recognizes the pattern, it should optimize it to a constant.

0 Kudos
Message 3 of 7
(4,935 Views)

Hi,

 

use a memory item in the FPGA: here you can define intial values…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(4,931 Views)

Do you need this during run-time or only at startup?

0 Kudos
Message 5 of 7
(4,916 Views)

I did some testing and both multiplication by zero and subtracting the array from itself works in a single-cycle timed loop. This means you can do the initialization in the timeframe of one click.

0 Kudos
Message 6 of 7
(4,896 Views)

Or just create a constant and use a select primitive.

0 Kudos
Message 7 of 7
(4,887 Views)