// DMA2axis2st.cpp
// 2019/06/07 by marsee
//
#include <ap_int.h>
#include <hls_stream.h>
#include <ap_axi_sdata.h>
int DMA2axis(volatile ap_int<32> *in, int sel, int x_size, int y_size,
hls::stream<ap_axis<32,1,1,1> >& outs0, hls::stream<ap_axis<32,1,1,1> >& outs1){
#pragma HLS INTERFACE s_axilite port=y_size
#pragma HLS INTERFACE s_axilite port=x_size
#pragma HLS INTERFACE s_axilite port=sel
#pragma HLS INTERFACE s_axilite port=return
#pragma HLS INTERFACE axis register both port=outs0
#pragma HLS INTERFACE axis register both port=outs1
#pragma HLS INTERFACE m_axi depth=480000 port=in offset=slave
ap_axis<32,1,1,1> out_val;
for(int y=0; y<y_size; y++){
#pragma HLS LOOP_TRIPCOUNT min=600 max=600 avg=600
for(int x=0; x<x_size; x++){
#pragma HLS LOOP_TRIPCOUNT min=800 max=800 avg=800
#pragma HLS PIPELINE II=1
out_val.data = in[y*x_size+x];
if(x==0 && y==0)
out_val.user = 1;
else
out_val.user = 0;
if(x == x_size-1)
out_val.last = 1;
else
out_val.last = 0;
if(sel == 0)
outs0 << out_val;
else
outs1 << out_val;
}
}
return(0);
}
// DMA2axis2st_tb.cpp
// 2019/06/07 by marsee
//
#include <iostream>
#include "hls_opencv.h"
#include "bmp_data.h"
#define Y_SIZE 600
#define X_SIZE 800
char OUTPUT_BMP_FILE0[] = "test0.bmp";
char OUTPUT_BMP_FILE1[] = "test1.bmp";
int DMA2axis(volatile ap_int<32> *in, int sel, int x_size, int y_size,
hls::stream<ap_axis<32,1,1,1> >& outs0, hls::stream<ap_axis<32,1,1,1> >& outs1);
int main(){
hls::stream<ap_axis<32,1,1,1> > outs0;
hls::stream<ap_axis<32,1,1,1> > outs1;
ap_axis<32,1,1,1> axisp;
ap_int<32> *rd_bmp;
if((rd_bmp =(ap_int<32> *)malloc(sizeof(ap_int<32>) * (X_SIZE * Y_SIZE))) == NULL){
fprintf(stderr, "Can't allocate rd_bmp memory\n");
exit(1);
}
for(int y=0; y<Y_SIZE; y++){
for(int x=0; x<X_SIZE; x++){
rd_bmp[y*X_SIZE+x] = (int)(bmp_file_array[y][x][0]) | ((int)(bmp_file_array[y][x][1])<<8) | ((int)(bmp_file_array[y][x][2]) <<16);
}
}
DMA2axis(rd_bmp, 0, X_SIZE, Y_SIZE, outs0, outs1);
cv::Mat img(Y_SIZE, X_SIZE, CV_8UC3);
cv::Mat_<cv::Vec3b> dst_vec3b = cv::Mat_<cv::Vec3b>(img);
for (int y=0; y<Y_SIZE; y++){
for (int x=0; x<X_SIZE; x++){
outs0 >> axisp;
cv::Vec3b pixel;
pixel[0] = axisp.data & 0xff; // blue
pixel[1] = (axisp.data >> 8) & 0xff; // green
pixel[2] = (axisp.data >> 16) & 0xff; // red
dst_vec3b(y,x) = pixel;
}
}
cv::imwrite(OUTPUT_BMP_FILE0, img);
DMA2axis(rd_bmp, 1, X_SIZE, Y_SIZE, outs0, outs1);
for (int y=0; y<Y_SIZE; y++){
for (int x=0; x<X_SIZE; x++){
outs1 >> axisp;
cv::Vec3b pixel;
pixel[0] = axisp.data & 0xff; // blue
pixel[1] = (axisp.data >> 8) & 0xff; // green
pixel[2] = (axisp.data >> 16) & 0xff; // red
dst_vec3b(y,x) = pixel;
}
}
cv::imwrite(OUTPUT_BMP_FILE1, img);
return(0);
}
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | - |