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

Update pixel.cpp

parent 7682ffe8
No related branches found
No related tags found
No related merge requests found
......@@ -9,52 +9,81 @@ using namespace std;
typedef ap_axis<32,0,0,0> pkt_t;
static int count_streams = 0;
static long long charIn=0;
static long long final_char=0;
int addNum=0;
long long toAscii(int number);
long long convert(int n);
int convertBinInt(long long n);
void decrypt(int data);
void pixel(char key,
void pixel(ap_int<32> selector,
ap_int<32> position1,
ap_int<32> position2,
ap_int<32> stream_count,
ap_int<32> ascii,
ap_int<32> &ascii,
hls::stream< pkt_t > &din,
hls::stream< pkt_t > &dout
) {
#pragma HLS INTERFACE ap_ctrl_none port=return
#pragma HLS INTERFACE s_axilite port=key
#pragma HLS INTERFACE s_axilite port=selector
#pragma HLS INTERFACE s_axilite port=position1
#pragma HLS INTERFACE s_axilite port=position2
#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=dout
pkt_t pkt=din.read();
if (count_streams == 0){
charIn=toAscii(ascii);
}
pkt_t pkt=din.read();
if((count_streams >= 3 * (position1 - 1)) && (count_streams < 3 * (position2))&& (charIn!=0)){
switch(selector)
{
case 0:
if (count_streams == 0){
charIn=convert(ascii);
}
addNum=charIn%10;
charIn=(int)charIn/10;
if((count_streams >= 3 * (position1 - 1)) && (count_streams < 3 * (position2) - 1)){
addNum=0;
if(charIn!=0){
addNum=charIn%10;
charIn=(int)charIn/10;
}
pkt.data = convertBinInt((convert(pkt.data)/10)*10+addNum)
// pkt.data-=addNum;
if(pkt.data % 2 == 0 && addNum == 1){
pkt.data += 1;
}else if(pkt.data % 2 != 0 && addNum == 0){
pkt.data -= 1;
}
}
}
break;
case 1:
if((count_streams >= 3 * (position1 - 1)) && (count_streams < 3 * (position2))){
decrypt(pkt.data);
}
break;
default:
break;
}
count_streams++;
if (count_streams == stream_count){
count_streams = 0;
charIn=0;
addNum=0;
if(selector == 1){
ascii= convertBinInt(final_char);
}
}
......@@ -74,10 +103,15 @@ long long convert(int n) {
return bin;
}
void decrypt(int data) {
int bit;
if(data % 2 == 0){
bit = 0;
}else if(data % 2 != 0){
bit=1;
}
final_char= final_char*10+bit;
long long toAscii(int c) {
long long bin = convert(c);
return bin;
}
int convertBinInt(long long n) {
......@@ -90,3 +124,5 @@ int convertBinInt(long long n) {
}
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