From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FPGA quick questions: High Throughput Division vs. Multiplication Implementation (rounding?)

Solved!
Go to solution

Hi all,

 

I'm trying to implement a simple routine where I divide a FXP by the number 7 in FPGA. I wanted to use the high throughput division but it seems to only round to the nearest integer although the output is capable of representing fractions. Alternatively, I could multiply my number by 1/7 using the high throughput multiplication and I get what I want. I'm not too familiar with FXP arithmetic. Without fully understanding the problem, I at least have a solution which is to use the multiplication. I'd just like to know a little more. Can anyone please shine some insight on why the division rounds even though it can handle fractions?

 

Thanks for your help

--
Jeffrey Lee
0 Kudos
Message 1 of 6
(3,599 Views)

Recreating your code on my machine, I got an appropriate fractional answer for the division (15.7109). I wonder if the configuration of your HTM node and/or the representation of your controls/indicators is set to something different? Can you attach a simple VI that demonstrates the problem? Here's my VI (saved in LabVIEW 2013) that works fine. I don't think it matters, but I'm running this VI in emulation mode under a cRIO-9074 target.

Message 2 of 6
(3,577 Views)

Either of these options should work assuming your value for "1/7" is sufficiently precise for the output type you need. The divide is configured with a less precise output than the multiply, if you change the output of both to match do you get the same (or closer) answer?

0 Kudos
Message 3 of 6
(3,568 Views)

Thanks for the suggestions. I recreated this and indeed was able to get the correct results! So what happened?

This may blow your minds, but there is something inherently wrong with my x/y indicator. I have it on "adapt to source". I created another supposedly identical indicator ("x/y 2") off the same wire and get the correct result with that indicator. This seems like some kind of bug but it worries me because I should have never run into it.

 

I've attached a screenshot of the code in action as well as the VI (i'm using 2011)

 

Thanks

--
Jeffrey Lee
0 Kudos
Message 4 of 6
(3,556 Views)
Solution
Accepted by topic author jblee

Somehow your original indicator got set to have 0 digits of precision for display formatting. This means the data is actually correct and there, but the textual format of the display to the screen rounds to integer.

 

precision.png

 

Any ideas how that setting got changed?

Message 5 of 6
(3,546 Views)

Thanks, so the adapt to source doesn't actually change my display format.

Got it!

--
Jeffrey Lee
0 Kudos
Message 6 of 6
(3,540 Views)