02-23-2011 06:38 PM
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.
02-23-2011 07:08 PM
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
02-24-2011 01:19 AM
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
02-24-2011 08:03 AM
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.
02-24-2011 08:25 AM
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.
02-24-2011 09:01 AM
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:
Al