From ba280ff150695025390e0f039a3f6651090f2edb Mon Sep 17 00:00:00 2001 From: Vipin Thomas <vipin.thomas@stud.th-deg.de> Date: Sat, 5 Jun 2021 15:46:50 +0000 Subject: [PATCH] Update pixel2.cpp --- pixel2.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 pixel2.cpp diff --git a/pixel2.cpp b/pixel2.cpp new file mode 100644 index 0000000..91715df --- /dev/null +++ b/pixel2.cpp @@ -0,0 +1,56 @@ +#include <iostream> +#include <hls_stream.h> +#include <ap_axi_sdata.h> + +using namespace std; + +typedef ap_axis<32,0,0,0> pkt_t; +static int count = 0; +static int count_streams = 0; +static bool flag = false; +static int p_count = 3; + +void pixel( + ap_int<32> position, + ap_int<32> stream_count, + hls::stream< pkt_t > &din, + hls::stream< pkt_t > &dout +) { + #pragma HLS INTERFACE ap_ctrl_none port=return + #pragma HLS INTERFACE s_axilite port=position + #pragma HLS INTERFACE s_axilite port=stream_count + #pragma HLS INTERFACE axis port=din + #pragma HLS INTERFACE axis port=dout + + pkt_t pkt=din.read(); + count_streams++; + + + if(count == position || count == position+1 || count == position+2){ + pkt.data -= 1; + p_count--; + if(p_count==0){ + count = -1; + flag=true; + } + + } + + if(!flag){ + count++; + } + + if (count_streams == stream_count){ + count_streams = 0; + flag = false; + p_count=3; + count = 0; + } + + // pending: have to make count=0 when TLAST signal is active - for w not in the range of 0 to n(size of the array) + + + dout.write(pkt); + +} + -- GitLab