Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Embedded Acceleration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vipin Thomas
Embedded Acceleration
Commits
ccfcfc74
Commit
ccfcfc74
authored
3 years ago
by
Vipin Thomas
Browse files
Options
Downloads
Patches
Plain Diff
Update pixel_1.cpp, pixel.py files
parent
e76e2733
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pixel.py
+160
-0
160 additions, 0 deletions
pixel.py
with
160 additions
and
0 deletions
pixel.py
0 → 100644
+
160
−
0
View file @
ccfcfc74
#include <stdio.h>
#include <hls_stream.h>
#include <ap_axi_sdata.h>
#include<math.h>
#include <string.h>
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
;
static
int
decNum
=
0
;
static
int
decimalCounter
=
0
;
int
lastDecimalVal
;
long
long
convert
(
int
n
);
int
convertBinInt
(
long
long
n
);
void
decrypt
(
int
data
);
void
toAscii
(
char
*
c
);
int
getDecimal
(
int
n
);
void
pixel
(
ap_int
<
32
>
in_decimal
,
ap_int
<
32
>
selector
,
ap_int
<
32
>
position1
,
ap_int
<
32
>
position2
,
ap_int
<
32
>
stream_count
,
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=in_decimal
#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 axis port=din
#pragma HLS INTERFACE axis port=dout
pkt_t
pkt
=
din
.
read
();
//
toAscii
(
key
);
switch
(
selector
)
{
case
0
:
if
(
count_streams
==
0
){
final_char
=
0
;
decNum
=
in_decimal
;
}
//
123456321
if
((
count_streams
>=
3
*
(
position1
-
1
))
&&
(
count_streams
<
3
*
(
position2
)
-
1
)){
//
addNum
=
0
;
addNum
=
0
;
if
(
decimalCounter
%
8
==
0
){
lastDecimalVal
=
getDecimal
(
decNum
);
decNum
/=
1000
;
charIn
=
convert
(
lastDecimalVal
);
}
addNum
=
charIn
%
10
;
charIn
=
(
int
)
charIn
/
10
;
//
if
(
decNum
!=
0
){
//
pkt
.
data
+=
getDecimal
(
decNum
);
//
decNum
=
decNum
/
1000
;
//
}
if
(
pkt
.
data
%
2
==
0
&&
addNum
==
1
){
pkt
.
data
+=
1
;
}
else
if
(
pkt
.
data
%
2
!=
0
&&
addNum
==
0
){
pkt
.
data
-=
1
;
}
decimalCounter
++
;
}
break
;
case
1
:
if
((
count_streams
>=
3
*
(
position1
-
1
))
&&
(
count_streams
<
3
*
(
position2
)
-
1
)){
decrypt
(
pkt
.
data
);
}
break
;
default
:
break
;
}
count_streams
++
;
if
(
count_streams
==
stream_count
){
count_streams
=
0
;
charIn
=
0
;
addNum
=
0
;
ascii
=
0
;
if
(
selector
==
1
){
ascii
=
convertBinInt
(
final_char
);
final_char
=
0
;
}
}
dout
.
write
(
pkt
);
}
long
long
convert
(
int
n
)
{
long
long
bin
=
0
;
int
rem
,
i
=
1
,
step
=
1
;
while
(
n
!=
0
)
{
rem
=
n
%
2
;
n
/=
2
;
bin
+=
rem
*
i
;
i
*=
10
;
}
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
;
}
int
convertBinInt
(
long
long
n
)
{
int
dec
=
0
,
i
=
7
,
b
=
0
,
rem
=
0
;
while
(
n
!=
0
)
{
b
=
pow
(
10
,
i
);
rem
=
n
/
b
;
n
=
n
%
b
;
dec
+=
rem
*
pow
(
2
,
7
-
i
);
--
i
;
}
return
dec
;
}
int
getDecimal
(
int
n
)
{
int
num
=
0
;
num
=
n
%
1000
;
return
num
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment