Skip to content
Snippets Groups Projects
Commit 60e19abd authored by Vipin Thomas's avatar Vipin Thomas
Browse files

Update pixel_original.cpp

parent fe38f908
No related branches found
No related tags found
No related merge requests found
#include "pixel.hpp" #include "pixel.hpp"
static int count_streams = 0; static int count_streams = 0;
static long long charIn=0; static long long charIn=0;
static long long final_char=0; static long long final_char=0;
int addNum=0; int addNum=0;
void pixel(ap_int<32> selector, void pixel(ap_int<32> selector,
ap_int<32> position1, ap_int<32> position1,
ap_int<32> position2, ap_int<32> position2,
...@@ -12,61 +12,60 @@ ...@@ -12,61 +12,60 @@
ap_int<32> ascii, ap_int<32> ascii,
stream &din, stream &din,
stream &dout stream &dout
) { ) {
#pragma HLS INTERFACE ap_ctrl_none port=return
#pragma HLS INTERFACE s_axilite port=selector #pragma HLS INTERFACE s_axilite port=selector
#pragma HLS INTERFACE s_axilite port=position1 #pragma HLS INTERFACE s_axilite port=position1
#pragma HLS INTERFACE s_axilite port=position2 #pragma HLS INTERFACE s_axilite port=position2
#pragma HLS INTERFACE s_axilite port=stream_count #pragma HLS INTERFACE s_axilite port=stream_count
#pragma HLS INTERFACE s_axilite port=ascii #pragma HLS INTERFACE s_axilite port=ascii
#pragma HLS INTERFACE axis port=din #pragma HLS INTERFACE axis port=din
#pragma HLS INTERFACE axis port=dout #pragma HLS INTERFACE axis port=dout
pkt_t pkt=din.read(); pkt_t pkt=din.read();
switch(selector) switch(selector)
{ {
case 0: case 0:
if (count_streams == 0){ if (count_streams == 0){
charIn=convert(ascii); charIn=convert(ascii);
final_char=0; final_char=0;
} }
if((count_streams >= 3 * (position1 - 1)) && (count_streams < 3 * (position2) - 1)){ if((count_streams >= 3 * (position1 - 1)) && (count_streams < 3 * (position2) - 1)){
addNum=0; addNum=0;
if(charIn!=0){ if(charIn!=0){
addNum=charIn%10; addNum=charIn%10;
charIn=(int)charIn/10; charIn=(int)charIn/10;
} }
if(pkt.data % 2 == 0 && addNum == 1){ if(pkt.data % 2 == 0 && addNum == 1){
pkt.data += 1; pkt.data += 1;
}else if(pkt.data % 2 != 0 && addNum == 0){ }else if(pkt.data % 2 != 0 && addNum == 0){
pkt.data -= 1; pkt.data -= 1;
} }
} }
break; break;
case 1: case 1:
if((count_streams >= 3 * (position1 - 1)) && (count_streams < 3 * (position2)-1)){ if((count_streams >= 3 * (position1 - 1)) && (count_streams < 3 * (position2)-1)){
decrypt(pkt.data); decrypt(pkt.data);
} }
break; break;
default: default:
break; break;
} }
count_streams++; count_streams++;
if (count_streams == stream_count){ if (count_streams == stream_count){
count_streams = 0; count_streams = 0;
charIn=0; charIn=0;
...@@ -76,13 +75,13 @@ ...@@ -76,13 +75,13 @@
ascii= convertBinInt(final_char); ascii= convertBinInt(final_char);
final_char=0; final_char=0;
} }
} }
dout.write(pkt); dout.write(pkt);
} }
long long convert(int n) { long long convert(int n) {
long long bin = 0; long long bin = 0;
int rem, i = 1, step = 1; int rem, i = 1, step = 1;
...@@ -94,7 +93,7 @@ ...@@ -94,7 +93,7 @@
} }
return bin; return bin;
} }
void decrypt(int data) { void decrypt(int data) {
int bit; int bit;
if(data % 2 == 0){ if(data % 2 == 0){
...@@ -103,7 +102,7 @@ ...@@ -103,7 +102,7 @@
bit=1; bit=1;
} }
final_char= final_char*10+bit; final_char= final_char*10+bit;
} }
int convertBinInt(long long n) { int convertBinInt(long long n) {
...@@ -117,5 +116,4 @@ ...@@ -117,5 +116,4 @@
} }
return dec; return dec;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment