cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor
212 Views
Registered: ‎03-07-2018

fixed to float

Hello, 

I am writing some fixed-point numbers to the DDR memory using memcpy in Vivado HLS. This HLS design is then exported to Vivado, where it is connected to microblaze,MIG 7 series block and UARTlite. Then in SDK I am trying to access those numbers from DDR memory which are being written by HLS IP using Xil_IN32 command. I am successfully able to print these fixed point numbers in hexadecimal format. Now, I want to convert these numbers in type 'float'. I am using following mentioned function from header file "ap_fixed.h" for the purpose:

var_name.to_float() 

And when I print these numbers in float, nothing is being printed in SDK terminal. What could be the reason? Can anyone suggest something?

HLS Code:

#include "ap_fixed.h"

typedef ap_fixed <32,15> fixed;

void fixed_pt1(volatile fixed * inpt)
{

#pragma HLS INTERFACE m_axi depth=5 port=inpt offset=direct

fixed data[5] = {1.0, 1.5, 2.48, 11.09, 1.369369369};

memcpy((fixed*)(inpt), data, 5*sizeof(fixed));

}

SDK Code:

#include "ap_fixed.h"

typedef ap_fixed <32,15> fixed;


int main()
{
fixed arr;
float temp;

u32 base = XPAR_MICROBLAZE_0_DCACHE_BASEADDR+0x00300000;

for (int i=0; i<5; i++){
 arr = (fixed)Xil_In32(base+4*i);
 temp = arr.to_float();
 printf("Data[%d] is %.11f\r\n", i, temp);
 }

return 0;
}

0 Kudos
2 Replies
Highlighted
Scholar
Scholar
185 Views
Registered: ‎03-28-2016

Re: fixed to float

@kritika117 

I could be wrong, but I don't think that you can use the "ap_fixed" data types in the SDK environment.  I think it's only for the the HLS environment.  Someone please correct me if I am wrong on this.

You might try something like:

float arr;
float temp;

...

for (int i=0; i<5; i++){
 arr = (float)Xil_In32(base+4*i);
 temp = arr>>17;

...

Ted Booth | Tech. Lead FPGA Design Engineer | DesignLinx Solutions
https://www.designlinxhs.com
0 Kudos
Highlighted
Contributor
Contributor
171 Views
Registered: ‎03-07-2018

Re: fixed to float

@tedbooth 

Thanks for replying.

But, I think we can use 'ap_fixed.h' header file in SDK. We just have to add the path of Vivado_hls include in C/C++ build settings.

0 Kudos