Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
Does anyone know a method of dividing in labview FPGA without using the remainder and quotient function?

The normal divide function is not supported in labview FPGA and the quotient and remainder function introduces a constant delay.

I've tried ouputing the parameters and performing the division in the real time environment (where normal divide is supported) however this introduces a delay at high frequency due to jitter.

03-04-2005 06:27 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

The normal divide function is not supported in labview FPGA and the quotient and remainder function introduces a constant delay.

I've tried ouputing the parameters and performing the division in the real time environment (where normal divide is supported) however this introduces a delay at high frequency due to jitter.

Highlighted
Options
You can do the same thing as the remainder and quotient function by subtracting the two numbers in a while loop.

I'm not sure if this will be any better than the remainder and quotient function, but I can't think of any other way.

Ed

Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner

Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

03-04-2005 08:20 AM - edited 03-04-2005 08:20 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

I'm not sure if this will be any better than the remainder and quotient function, but I can't think of any other way.

Ed

Message Edited by Ed Dickens on 03-04-2005 08:21 AM

Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner

Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

Highlighted
Options
An efficient method to handle division or any kind of non-integer scaling is to use a Multiply and Scale by Power of 2 function. In addition by wrapping them in a Single Cycle Timed Loop in LabVIEW FPGA you will get optimal performance out of these functions.

The Scaling Constant and Shift value will determine the value by which you are multiplying your numerator. For example to divide by 2, set the Scaling constant to 1 and the Shift to -1. To divide by four set the Scaling constant to 1 and the Shift to -2.

You have to make sure that the result of the multiplication can still fit within the data type you are using. With the Saturation Multiply function you can multiply two 16-bit integers and be sure that the result will fit into a 32-bit integer. Of course if your result needs to be a 16- bit integer then the Scale by Power of 2 function needs to shift the product back into the 16-bit range. This method will not give you exact results for every scaling value, but it will give you very good approximations. The trick is to find the right combination of Scaling Constant and Shift value.

To divide by 10, you can use a Scaling constant of 102 and a shift of -10. In effect you are multiplying your numerator by 102 and then dividing by 1024. 102/1024 = 0.099609375 = 1/10.039

To find the right Scaling Constant and Shift value, it is often easiest to pick a suitably large Shift value and then calculate the corresponding Scaling Constant for your needs.

03-04-2005 04:52 PM - edited 03-04-2005 04:52 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

The Scaling Constant and Shift value will determine the value by which you are multiplying your numerator. For example to divide by 2, set the Scaling constant to 1 and the Shift to -1. To divide by four set the Scaling constant to 1 and the Shift to -2.

You have to make sure that the result of the multiplication can still fit within the data type you are using. With the Saturation Multiply function you can multiply two 16-bit integers and be sure that the result will fit into a 32-bit integer. Of course if your result needs to be a 16- bit integer then the Scale by Power of 2 function needs to shift the product back into the 16-bit range. This method will not give you exact results for every scaling value, but it will give you very good approximations. The trick is to find the right combination of Scaling Constant and Shift value.

To divide by 10, you can use a Scaling constant of 102 and a shift of -10. In effect you are multiplying your numerator by 102 and then dividing by 1024. 102/1024 = 0.099609375 = 1/10.039

To find the right Scaling Constant and Shift value, it is often easiest to pick a suitably large Shift value and then calculate the corresponding Scaling Constant for your needs.

Message Edited by Christian L on 03-04-2005 04:55 PM

Highlighted
Options

03-04-2005 05:07 PM - edited 03-04-2005 05:07 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

The attached VI shows a simple example on how to calculate the Scaling Constant and Shift value for my previous post. This code will be run as part of the host application in Windows or LabVIEW Realtime and assumes you will be using an I16 Numerator. It uses an I32 intermediate value to get the best result.

Message Edited by Christian L on 03-04-2005 05:10 PM

- Tags:
- FPGA_SCALE

Highlighted
Options
I see that the host VI is calculating the scaling factors automatically without the need of the user to enter the bit shift and multiplier. Can this be implemented onto the FPGA VI target?

03-20-2009 04:51 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Highlighted
Options

05-09-2018 04:04 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

can you tell the reason behind, "divide is not working in FPGA"?

Highlighted
Options

05-09-2018 04:22 AM - edited 05-09-2018 04:23 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Hi Shiva,

you are asking in a 13 years old thread: quite a lot has changed in this time…

Surely the Divide operation is supported in the FPGA, even with SGL data since several years. BUT: a division (most often) requires a lot of resources in the FPGA!

So the recommendation is: avoid division, when possible…

Best regards,

GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO

GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO

Highlighted
Options

05-09-2018 04:37 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

"a division (most often) requires a lot of resources in the FPGA!", still i couldn't get this gerd..

by the way, i'm new to the FPGA concepts..so, can you elaborate this thing (dividing in FGPA)?

Highlighted
Options

05-09-2018 04:53 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Hi Shiva,

in FPGA you can use most functions you also use in "standard" LabVIEW on "standard" computer.

THe difference is: in standard PC "heavy" computations need more time, but in the FPGA "heavy" operations consume more "fabric"/"space"/"resources".

Keep in mind: the FPGA is a piece of hardware providing a limited amount of "computational units" (aka resources), but those resources can execute all at the same speed (more or less)…

Best regards,

GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO

GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO