LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fixed Point in a U32 DMA FIFO

Hi Folks,

Here's a fun challenge:

I have an FPGA VI that reads a lot of analog inputs and converts them to scaled, fixed point numbers...  The trouble is that I have a lot of channels, and putting an array of fixed point numbers on the front panel is expensive.  Can someone think of a really smart way to encode signed 64,32 fixed point as an array of U32 numbers?

So far, I'm guessing that I can use the rotate with carry functions and maybe some boolean logic, but I haven't figured it out yet.  Any ideas?

Thanks in advance,

Jim


0 Kudos
Message 1 of 11
(7,938 Views)

Hey Jim,

I do the following when trying to pass fixed point data over DMA

How Can I Transfer My Fixed-Point Data to My Host Using a DMA FIFO?

Not sure if this is the final answer but it may be a place to start.

Bassett

Message 2 of 11
(7,934 Views)
Thanks as usual Bassett,

You've been very helpful throughout this project I've been working on.  The document wasn't exactly an answer, but it did point me in the right direction.  I've decided to change my fixed point representation down to 32,16 since the 64 bit representation seemed like overkill.  I hadn't thought of using the number to boolean array function, which apparently does work on fixed point numbers (I got that idea from the document, even though the document didn't use the FXP type explicitly). 

Converting FXP 32,16 directly to and from U32 resulted in some ugly data loss, but changing the FXP to a boolean array, and then to a U32 worked perfectly.  (Hint - this conversion would be super helpful in the "To U32" function if it's feasible)  I've attached a picture, since it pretty much clears up the methodology.  If anyone ever has to encode a 64 bit FXP number into U32 numbers, there has to be a way, but I think I'll save that one for another time.

Thanks again,

Jim
Message 3 of 11
(7,920 Views)

Glad it helped.  I sometimes use the following to split 64,32 into a U32 Array.

Bassett

Message 4 of 11
(7,913 Views)
Oops... I guess the document does cover fixed point explicitly.  I needed to read it more closely.  (My apologies - it's a bad habit of mine)  I'm using a slightly different host conversion method, but that method would work, too.
0 Kudos
Message 5 of 11
(7,908 Views)
That last VI you posted is exactly what I was looking for!  The number to boolean array function was the missing piece when I was trying to figure it out.

Thanks so much.

Jim
0 Kudos
Message 6 of 11
(7,904 Views)
Bassett,

Is there any way that you could put that document back up?  I was going to revisit it today, but I get a message that says I'm not authorized to view it.

"You are not authorized to view this document"


Thanks,

Jim

@Bassett Hound wrote:

Hey Jim,

I do the following when trying to pass fixed point data over DMA

How Can I Transfer My Fixed-Point Data to My Host Using a DMA FIFO?

Not sure if this is the final answer but it may be a place to start.

Bassett





0 Kudos
Message 7 of 11
(7,868 Views)
Hi Jim,
 
I believe one of the Applications Engineers is updating that document today.  I've asked him to publish it as soon as they are done so it should be up shortly.
 
Let me know if you can't find it in the future.
 
Thanks,
 
Bassett
0 Kudos
Message 8 of 11
(7,860 Views)
Hi Jim,
 
I did update the KB yesterday and it should be back on the web soon, but for quick reference here are the changes that were made.  The important part is that the conversion VIs in the KB are not needed, since all you need to do is right click on the boolean array to number and select it's properties, then change the output type to fixed point along with the settings for the fixed point number.  Let me know if you have any questions on this.
 
As of LabVIEW 8.5, the DMA FIFO only supports the unsigned 32-bit data type.  If the fixed-point number is passed directly to the FIFO, the fractional portion will be truncated when the number is coerced to an unsigned integer. In order to preserve the fractional part of the data, type cast the fixed-point number as an unsigned 32-bit integer that can be written to the DMA.

To do this, you will need to pass the binary representation of the fixed-point number over the DMA FIFO and convert this set of bits on the host.  The steps below detail the method to pass a fixed-point number to the host using a DMA FIFO.

FPGA Conversion

  1. Convert the fixed-point number to an array of booleans using the Number to Boolean Array VI.
  2. Convert this array of booleans to a numeric using the Boolean Array to Numeric VI.
  3. Wire the output of the Boolean Array to Numeric to the Element input of the FIFO Write VI.

Host Conversion

  1. On the host side, read a number of elements from the DMA FIFO.
  2. Convert each element one at a time to an array of booleans using the Numeric to Boolean Array VI, inside of an auto-indexed for loop.
  3. Place a Boolean Array to Numeric VI inside of the for loop and wire the boolean array to the input.
  4. Right click on the Boolean Array to Numeric VI and select Properties.  Change the representation to fixed-point and fill in the Fixed-Point Configuration according to the properties of the fixed point data type on the FPGA. 
  5. Wire the fixed point data type out of the for loop into an auto-indexed terminal.


Note: It is required to know the settings of the fixed-point data on the
FPGA in order to convert the number on the host. 

Once the fixed point data is converted, you can use the numeric conversion VIs to convert the data to any representation that is needed on the host.

Note: It is necessary to use the Binary Array to Number and override the output type under the properties of the VI.  Using just the Binary Array to Number and then the To FXP VIs will also truncate the fractional part of the data.

Message Edited by Coal Man on 10-17-2007 11:45 AM

Brian Coalson

Software Engineer
National Instruments
Download All
Message 9 of 11
(7,859 Views)
Brian and Bassett,

Many thanks to you both.  I hadn't realized that the document was being modified, but the newer method is even better.  (Certainly faster to code)  I hadn't realized that you could change the output representation of the "Boolean Array to Number" function.  You learn something new every day.

Jim
0 Kudos
Message 10 of 11
(7,847 Views)