05-10-2021 08:01 AM
Is there a method to get the Fixed-Point configuration (i.e. Sign, Word length, Integer Word length) details of an input?
I am using High-Throughput Natural Log VI from High-throughput Math Palette of Labview FPGA. This VI has limitation that it accepts inputs only in with integer word length = 0.
So in order to get the Logarithm of a number it needs to be broken in the following way:
x = 2^k * M
Thus ln(x) = kln(2) + ln(M)
where x is the input, 2^k > x and M is the mantissa
Example: For 7.25 = 2^3 + 0.90625
Thus ln(7.25) = 3ln(2) + ln(0.90625) = approx. 1.981
The problem is, the method of finding k and M is heavily dependent on word length and integer word length. In my code I have multiple logarithmic operations with different fxp configuration. I wanted to design the block of code in way that it is reusable and can be re-used for any fxp configuration, for which I will need know the fxp configuration of the input.
Is there any other way to do this efficiently?
05-10-2021 03:52 PM
Are you able to make use of this vi.lib VI ?
\vi.lib\Utility\Data Type\Get Fixed-Point Information.vi
Or does running on FPGA preclude its use? Sorry, all my relevant experience is with Windows targets.
Dave
05-10-2021 04:06 PM
Here's another alternative, in case the vi.lib library VI isn't available on an FPGA target. No guarantee the attached will work, either, and it's an old "hidden gem", so beware its use in critical code.
Unpublished FXP node for encoding
Good luck!
Dave
05-11-2021 12:52 AM
Thank you for the suggestion however Get FXP Information.vi is not supported in Labview FPGA. I also realized another issue. In the subVIs that I write the FXP configuration of the control cannot change, thus making my approach invalid. Any suggestion on that?
05-11-2021 09:29 AM
I'm curious to know if you also tried the hidden node I placed in the snippet - can you place that on the BD of a VI targeted to FPGA?
I read more of your interests in your other thread here but I'm unclear if you're needing to make a compile-time or a run-time decision based off of a particular FXP's representation. So, no other suggestions from me other than if you can write your code as a malleable VI (*.vim). The type assertion primitive requires FXPs to match completely (width, integer width, sign, and OF flag), I had to check. Between that, and perhaps the primitives for casting FXPs to/from integers, you could write adaptive code?
Sorry, I'm out of my field of direct experience here (though I have used FXPs to solve some programming problems where Windows was the target - when interpreting data structures sent to/from another device flattened for serialized transfer).
Dave
05-11-2021 09:47 AM
No, I was unable to find the hidden node you placed in the snippet. I am trying to make compile time decision to begin with and improvise further. Thank you very for your help Dave.
05-11-2021 09:55 AM
You drag the snippet onto a block diagram and LV should place the node. The code is hidden in the image as metadata that a compatible version of LabVIEW should be able to interpret.
I did it that way since the node is not on any published palette.
Dave