LabVIEW FPGA Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
nanocyte

Allow smaller integer representations of enums

Status: New

I love using enums because they can often make discrete options much clearer. Example:

enum clarity.PNG

But, at least as of 2017, the below code is going to use fewer resources and propagate faster because LabVIEW is going to use an 8 bit register above instead of the two bits below. 

 

My solution is to allow smaller integer representations of enums (I'd use a U2 in the above case).

 

Ideally the user wouldn't even have to specify the integer size, it could just calculate the minimum at edit time and show the user what it is.

5 Comments
Manzolli
Active Participant

If someone from NI assures that this will save some slices it will get my kudo.

André Manzolli

Mechanical Engineer
Certified LabVIEW Developer - CLD
LabVIEW Champion
Curitiba - PR - Brazil
nanocyte
Active Participant

Here's the usage test I ran to evaluate the performance benefit of the above:

https://forums.ni.com/t5/Example-Program-Drafts/Comparing-FPGA-resource-usage-of-bool-vs-enum/ta-p/3...

Intaris
Proven Zealot
LabViewTinkerer
Member

I think, this is rather a matter of the compiler. This should be part of automatic code optimization. 

nanocyte
Active Participant

Yeah, that's what I was getting at with my "ideally statement". I just find it annoying to have to mentally keep track of all these compiler optimizations. I'd rather it could tell you about an optimization, for example, in the context help window it could tell you what size it's calculating.