Hi,
I am using xillybus ip core to communicate data between linux running on PS of zedboard with the ipcore on PL.Basically,I want to convert an image into grayscale.As a prototype I am sending a 4*12(48 elements) matrix from linux to PL and after performing averaging of every three pixels per row I get a grayscale value which is read back into a 4*4(16 elements) matrix.Now the problem is the code I use for averaging the pixels does not give correct values.The first column is correct but the rest of the columns are zero.
I extended the HLS demo code that comes with xillybus to write my code for averaging every three elements row wise.I suspect there is either something wrong with the way I am using floating point operations or the way I am reading or writing might be faulty.
Please, have a look at my HLS code and guide me.
#include <math.h>
#include <stdint.h>
#include "xilly_debug.h"
#include "ap_cint.h"
#include "ap_utils.h"
float rgb2gray(float r, float g, float b) {
float gray = (r + g + b)/3;
return gray;
}
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
float x1, x2, x3;
uint8_t res;
uint32_t i;
float y1;
for (i = 1; i <= 16 ;i++)
{
// Handle input data
x1 = *in++;
x2 = *in++;
x3 = *in++;
// Run the calculations
y1 = rgb2gray(x1, x2 ,x3);
res = uint8_t(y1);
// Handle output data
*out++ = res;
}
}