Loading Arrays into Xillybus

Questions and discussions about the Xillybus IP core and drivers

Loading Arrays into Xillybus

Postby Guest »

I'm working on a pretty simple function for HLS, to take in data as it comes in and multiply the value by a corresponding value in an array, and send the result back to the processor. For some reason, 0 is the only value retrieved from my Array, whick I checked using hexprint. I srunk the array to experiment with it, but the full size is 283x696. Is there any reason why zero would be the only thing out? Is it not being initialized properly?

Code: Select all
//6/22/15 The previous version worked, but the output was a bit weird;
   //After talking to V, a potential reason for this is the cf factor being greater than 1.
   //Going to change the value to 2.0, and see if the answeres line up this time.
   //Also going to take out some of the "potentially" useless code in the function,
   //before the first line of main execution

#include <math.h>
#include <stdint.h>
#include "xilly_debug.h"
//#include "coeff.h"

#define IMAGE_WIDTH  696
#define TOTAL_BANDS  520

#define SKIPBYTES  896
#define SKIPCOUNT  448      // (896/2)
// When creating data cube, it is helpful to discard unneeded bands.
#define SHORTEST_BAND_TO_INCLUDE  171        // Must be between 1 and 519
#define SHORTEST_SKIPCOUNT        119016      // (171*696*2/2)
#define LONGEST_BAND_TO_INCLUDE   453        // Must be between 2 and 520, greater than SHORTEST_BAND_TO_INCLUDE
#define LONGEST_SKIPCOUNT         46632      // (67*696*2/2)
#define PROCESSCOUNT           196968         // (283*696*2/2)
// BANDS = LONGEST_BAND_TO_INCLUDE - SHORTEST_BAND_TO_INCLUDE + 1;
#define BANDS 283

#define RADIANCE_SCALING_FACTOR  100
int m = 0;
int n = 0;

int cf[4]={2,2,2,2];


uint16_t radCorr(uint16_t unCorrPixel){


   uint16_t corrPixel; //Holder for the corrected pixel value
    uint16_t x2;
    float a2, b2;
   int c2;


      a2 = (float) unCorrPixel;// * cf_mn;//L0R
      c2 = cf[0];
      xilly_hexprint(c2, 1);
      xilly_puts("\n");
      b2 = a2 * c2* RADIANCE_SCALING_FACTOR;
      corrPixel = *((uint16_t *) &b2);  // Convert float to uint16_t

    return corrPixel;
   
   //IF this works like inner array tester, then 2.0 should be the multiplier ad infinitum.

}

void xillybus_wrapper(int *in, int *out) {
#pragma AP interface ap_fifo port=in
#pragma AP interface ap_fifo port=out
#pragma AP interface ap_ctrl_none port=return

    uint32_t a1;
   uint16_t x1;
   uint16_t y1;

    xilly_puts("Hello, world\n");

// Handle input data
    a1 = *in++;
    x1 = *((uint16_t *) &a1);  // Convert uint32_t to uint16_t

    // Run the calculations
    y1 = radCorr(x1);

   // Handle output data
    *out++ = y1;
}
Guest
 

Re: Loading Arrays into Xillybus

Postby support »

Hello,

Your question is about HLS, and not so much on Xillybus, so I'd suggest turning to Xilinx' forums on this topic.

The line that initializes cf[4] ends with a square bracket instead of a curly one, but I suppose it's a typo when submitting the question, and not in the original code.

This way or another, it's a matter of how HLS treats initialized variables, and I'm not familiar with that topic. Maybe the docs can help.

I would try defining cf[] as a static const int -- maybe that will convince the compiler. Just an idea.

Regards,
Eli
support
 
Posts: 802
Joined:

Re: Loading Arrays into Xillybus

Postby Guest »

Thank you for the tip. I'll try the forums, and the constant solution as well.
Guest
 


Return to Xillybus