Sending a stream from pynq to struct in HLS of different data types

Hallo all,

As the title informs, I have a struct of 256-bit wide (8 32-bit values) in HLS. The struct has 2 dummy values that are not used because its width needs to be a power of 2. I want to use one of those fields but with a different data type.
Here is a simplified HLS version of it:

struct data_t {
	float B1_real, B1_imag, gx, gy, gz, Rxy2;
        int cn;
	float dummy;
. . .
hls::stream<hls::axis<data_t, 0, 0, 0>> someStream;

In PYNQ, I need to instantiate a pynq buffer and send the data (I’m using the DMAs in SG mode btw, which I devoloped a mini python library to talk to the registers, if anyone is interested, i can share it with you guys). so lets assume i want to use the DMA in simple mode for clarity:

buffer = allocate(shape=(100, 8), dtype='float32')


Now this code above does achieve the required functionality as the 7th element of the pynq buffer has to be of type “int”.

Is there a way to achieve this?! I tried converting what i want to send to hex from the float representation. i. e. if i want to send all ones, then simply all elements are going to be 1.0 represented as float values, except the 7th element in each row. That element would be 1.4013e-45, because it translates to 0x01 (which is a 1 in int). But this approach doesn’t work because of floating points precision.

Thank for the help in advance!

If there are no systematic way to achieve this, I think we should develop one or else aggregating structs of different type would not be beneficial at all!


Hi @Yousef_Alnaser,

You can try creating your on datatype


Thanks a lot. worked fine.
Also, I tried converting the floats to hex and send the data as uin32. Also, worked!

1 Like