cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sharpmddr
Contributor
Contributor
1,265 Views
Registered: ‎05-10-2018

How to print Stream data out ?

I am a new one to using the vivado HLS. I want to figure out the process of data transfer between PL and PS memory. I refer to an example on GitHub(https://github.com/lbielich/PLDataMoveSDSoC), but it only has printing process of memory address. I just want to use the assignment data to verify this process. I added the print function of the data value to this case, but when I print the output data(the value of “sofifo”), the output stream data are all zero. Replace the statement printf("sofifo[0] = %llx \r\n", (long long) sofifo[0]) with std::cout << " sofifo[0] = " << sofifo[0] << std::endl, the output value is still zero. I want to get the data value which are stored on the sofifo pointer. How can I get the correct value for printout this program? Thank you!!

 

#include <iostream>

#include <sds_lib.h>

#include <stdio.h>

#include <unistd.h>

#include <queue>

#include <fstream>

#include <unistd.h>

#include <stdint.h>

 

using namespace std;

 

#define BUF_SIZE (1024*8)

#define PL_DDR_ADDR 0x80000000

 

void stream_dma_pl( ap_uint<64> *din, ap_uint<64> *doutmig, int num_elements)

{            

     for(int i = 0; i < num_elements; i++)

     {

       #pragma HLS pipeline

       doutmig[i] = din[i];

     }

}

 

 

void dma_pl_to_ps(ap_uint<128> *src, ap_uint<128> *dest, unsigned int length)

{

       for(int i = 0; i < length; i++)

{

#pragma HLS pipeline

       *dest++ = *src++;

       }

}

 

void psddr_2_stream( ap_uint<64> *din, ap_uint<64> *dout, int num_elements)

{

   for(int i = 0; i < num_elements; i++)

   {

     #pragma HLS pipeline

      dout[i] = din[i];

   }

}

 

 

int main(int argc, char **argv)

{

 

              //PL Buffers

              unsigned long long* plddr_buf = (unsigned long long*)sds_mmap((void *)(PL_DDR_ADDR ), BUF_SIZE, NULL);

              //Input Stream Sources

              ap_uint<64> *fifo = (ap_uint<64> *)sds_alloc(BUF_SIZE);

              //Output Stream Sink

              ap_uint<64> *sofifo = (ap_uint<64> *)sds_alloc(BUF_SIZE);

              //PS Contiguous Buffers

              ap_uint<128> * psddr_buf3 = (ap_uint<128> *)sds_alloc(BUF_SIZE);

 

              for(unsigned i = 0; i < 32; i++) //Initial input Stream Sources

              {

                 fifo[i] = i;

             }

 

              stream_dma_pl( fifo, (ap_uint<64> *)plddr_buf, BUF_SIZE/8);

 

              std::cout << " fifo[0] = " << fifo[0] << std::endl;

              std::cout << " fifo[1] = " << fifo[1] << std::endl;

              std::cout << " fifo[2] = " << fifo[2] << std::endl;

              printf("plddr_buf[0] = %llx \r\n", plddr_buf[0]);

              printf("plddr_buf[1] = %llx \r\n", plddr_buf[1]);

              printf("plddr_buf[2] = %llx \r\n", plddr_buf[2]);

 

 

              dma_pl_to_ps((ap_uint<128> *)plddr_buf, (ap_uint<128> *)psddr_buf3, BUF_SIZE/16);

              //Creates an output stream from received input

              psddr_2_stream((ap_uint<64> *)psddr_buf3, sofifo, BUF_SIZE/8);

 

              printf("psddr_buf3[0] = %llx \r\n", (long long) psddr_buf3[0]);

              printf("psddr_buf3[1] = %llx \r\n", (long long) (psddr_buf3[0]>>64));

 

              printf("sofifo[0] = %llx \r\n", (long long) sofifo[0]);

              printf("sofifo[1] = %llx \r\n", (long long) sofifo[1]);

}

 

The result is:

fifo[0] = 0

fifo[1] = 1

fifo[2] = 2

plddr_buf[0] = 5ccb2f07a

plddr_buf[1] = 5ccb2f07b

plddr_buf[2] = 5ccb2f07c

psddr_buf3[0] = 5ccb2f07a

psddr_buf3[0] = 5ccb2f07b

sofifo[0] = 0

sofifo[1] = 0

0 Kudos
2 Replies
nmoeller
Xilinx Employee
Xilinx Employee
1,238 Views
Registered: ‎09-05-2018

Hey @sharpmddr,

Could you try using the ap_uint class's member function to_uint64()? Example:

 std::cout << " sofifo[0] = " << sofifo[0].to_uint64() << std::endl

Please let me know if that helps.

 

Nicholas Moellers

Xilinx Adaptive Computing Tools
0 Kudos
sharpmddr
Contributor
Contributor
1,207 Views
Registered: ‎05-10-2018

Unfortunately, the output of this statement is still zero.

0 Kudos