LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FPGA - the result of simple maths on constants isn't a constant!

Why can't I do simple maths on a constant and for the FPGA compiler to still see it as a constant?

If I replace the 99 constant with the output of the 100 constant -1 then the VI breaks and isn't able to see that the array size is 100.

I don't want to have to state the size of a buffer in multiple places.

FPGA constant.JPG

 

0 Kudos
Message 1 of 6
(2,439 Views)

I do not have any experience with FPGA, so this is based on general information.

 

Try moving the Decrement (y = x-1) function outside the loop.  First, that may make it look like a constant to the loop.  Second, why would you want to perform the subtraction every time the loop iterates when you expect the result to be the same every time? Only calculate once things which never change!

 

Does Replace Array Subset work in FPGA? If so, just replace element 0 rather than than the way you are doing it.  Then you do not need the decremented constant at all.

 

Lynn

FPGA Constant.png

0 Kudos
Message 2 of 6
(2,432 Views)

You are correct the decrement should have ben outside the loop - but it makes no difference to my problem in this case.

replace array subset works fine in FPGA - it's rotate array that doesn't which is why I'm doing it what looks like a slightly odd way!

Al

0 Kudos
Message 3 of 6
(2,416 Views)

Array in FPGA have to be fixed size and have to be defined in the beginning.

 

You are changing the size of the array by -1 then changing it again by +1 adding the bit at the front of the array.

 

I wanted to do the same thing, to create a FIFO for bits, but came up against the very same road block.

 My solution was to use Rotate with Carry functions.

I had 256 bits so I use 4 U64 to store the bits and rotated each new bit in and carried the bits other to the next U64.

You could use 2 U64 and just ignore the bits above 100.

 

This even worked inside a Single Cycle Time loop.

 

Omar
0 Kudos
Message 4 of 6
(2,389 Views)

Probably you could use the "Delete from Array" function instead of array subset. You don't need to wire any lenghts there since the default is to delete the last element, which is what you're doing.

 

0 Kudos
Message 5 of 6
(2,382 Views)

Thanks for the reply Omar - yes all my arrays are defined correctly as fixed. It's OK to change the size of arrays as long as the compiler knows what you intend. (it's just bit selection in the Xilinx chip after all!)

 

My original point was why can't I do simple maths that gives a  compile-time constant but the compiler doesn't think is a constant.

 

Thanks Dan that works fine:

Capture 2.JPG

 

Al

 

0 Kudos
Message 6 of 6
(2,369 Views)