LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Variable size array output from dynamic dispatch class method on FPGA

Solved!
Go to solution

I have a Parent class on the FPGA that will serve as a template/framework for future code that will be developed. I had planned on creating a child class and overriding a couple methods. The child class constant would be dropped on the block diagram so the compiler wouldn't have any trouble figuring out which method (parent's or child's) should be used (i.e. the parent's method will never actually be used and won't be compiled with the main code). The output of one of the methods is an array. This array will have a different size depending on the application. I defined the array size as variable. In the child method, there is no question about the size of the array so the compiler should be able to figure it out. However, when I try to compile, I get an error about the array size. I can't figure out any way around it. Any thought would be greatly appreciated! 

Thanks, Patrick

 

Test.png

0 Kudos
Message 1 of 9
(3,288 Views)
Solution
Accepted by topic author patrickpollock

The issue involves the use of the unitialized shift register. On the first iteration of the loop, the value coming out of the shift register is the default value for the data type which for an array is an empty array (zero size). Therefore, unless you wire an empty array to the right shift register, the array size cannot be statically inferred by the compiler.

 

To fix this, you need to feed in an initial value for the array. Here I just used the same array function, but if you need to have a separate method that just returns a default array or the size of the array that will work as well.

 

fix.png

 

Message 2 of 9
(3,273 Views)

Deleted....

 

was not aware you can use LVOOP on FPGA 

0 Kudos
Message 3 of 9
(3,272 Views)

Dragis, Thanks. That makes sense. I missed that because I usually use fixed-size arrays which can have uninitialized shift registers. Glad that the problem is not with the dynamic dispatch part. Thanks for the help.

0 Kudos
Message 4 of 9
(3,249 Views)

Yeah, the fixed-size uninitialized shift registers is a bug but due to the amount of code that relies on it it has never been fixed. It throws some people off that have an algorithm that works on the host but then when they move to FPGA and change their types to fixed-size arrays it doesn't function the same way anymore.

0 Kudos
Message 5 of 9
(3,236 Views)

Wait what? Smiley Surprised

 

Can we use dynamic dispatch VIs on FPGA?  Really?  I was completely unaware of this.  Obviously the dependencies need to be constant and known at compile time but...... This would have saved me a lot of headaches in the last few months.

 

Since which LV version is this supported?

0 Kudos
Message 6 of 9
(3,082 Views)

Dynamic dispatch has been supported since LabVIEW FPGA 2009, but the compiler was refactored to make processing classes better, faster, and to support a few more use cases in 2012 so I would suggest using 2012 or higher if you are going to extensively use LabVIEW classes on FPGA. 

 

Like you mentioned, the compiler must (for now) be able to determine a single dynamic dispatch method to be called at run-time. This generally means each code path must resolve to a single (possibly derived) class at compile-time.

0 Kudos
Message 7 of 9
(3,070 Views)

Why didn't I know this!

 

I was hoping this would be supported some time int he future and here we are, it's already supported...... I have been jumping thorugh hoops implementing groups of static objects on FPGA since I just -assumed- this did not work.  I thought I heard from someone that DD didn't work on FPGA but that probably meant non-clear child methods (like multiplexing different classes on a wire).

 

Take away from this:

 

Cool!

0 Kudos
Message 8 of 9
(3,067 Views)

I'm glad to here you will start using the feature ; )

 

You all might be interested in this idea as well: http://forums.ni.com/t5/LabVIEW-FPGA-Idea-Exchange/Run-Time-Dynamic-Dispatch-Support/idi-p/2896184.

0 Kudos
Message 9 of 9
(3,062 Views)