Skip to content

Commit 93bb8db

Browse files
committed
Added sample code
1 parent 319de86 commit 93bb8db

File tree

7 files changed

+144
-12
lines changed

7 files changed

+144
-12
lines changed

example_projects/vitis_hls_test_prj_template_v2/run_hls.tcl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
# Create a project
77
open_project prj -reset
88
add_files src/hls_operator.cpp
9-
add_files -tb src/hls_operator_tb.cpp
9+
add_files -tb src/hls_operator_tb.cpp -cflags "-Wno-unknown-pragmas" -csimflags "-Wno-unknown-pragmas"
1010
set_top hls_operator
1111

1212
# Create a solution
1313
open_solution -reset sol1 -flow_target vitis
1414
set_part {xcvu9p-flga2104-2-i}
1515
create_clock -period 5 -name default
1616

17+
#source "./prj/sol1/directives.tcl"
18+
1719
#csim_design
1820
csynth_design
1921
#cosim_design

example_projects/vitis_hls_test_prj_template_v2/src/hls_operator.cpp

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,75 @@
66
#include "ap_int.h"
77
#include "hls_stream.h"
88

9+
//#include "hls_operator.h"
10+
11+
12+
//==================================================================================================
13+
void stream_splitter(
14+
hls::stream<int> &is,
15+
hls::stream<int> &os1,
16+
hls::stream<int> &os2
17+
){
18+
19+
//#pragma HLS INLINE
20+
21+
int data;
22+
data = is.read();
23+
24+
os1.write( data );
25+
os2.write( data );
26+
}
27+
28+
//==================================================================================================
29+
void func_1(
30+
hls::stream<int> &is,
31+
hls::stream<int> &os
32+
){
33+
34+
//#pragma HLS INLINE
35+
36+
const int st_k = 5;
37+
38+
os.write( is.read() + st_k );
39+
}
40+
41+
42+
//==================================================================================================
43+
void func_2(
44+
hls::stream<int> &is,
45+
hls::stream<int> &os
46+
){
47+
48+
//#pragma HLS INLINE
49+
50+
static int st_k;
51+
52+
os.write( is.read() + st_k );
53+
54+
if( st_k < 4 ){
55+
st_k++;
56+
} else {
57+
st_k = 0;
58+
}
59+
}
60+
61+
62+
//==================================================================================================
63+
void func_3(
64+
hls::stream<int> &is,
65+
hls::stream<int> &os
66+
){
67+
68+
//#pragma HLS INLINE
69+
70+
//#pragma HLS DATAFLOW disable_start_propagation
71+
//#pragma HLS INTERFACE mode=ap_ctrl_none port=return
72+
73+
os.write( is.read() / 13 );
74+
}
75+
76+
77+
//==================================================================================================
978
void hls_operator(
1079
hls::stream<int> &a,
1180
hls::stream<int> &b,
@@ -16,12 +85,33 @@ void hls_operator(
1685
#pragma HLS DATAFLOW disable_start_propagation
1786
#pragma HLS INTERFACE mode=ap_ctrl_none port=return
1887

88+
//#pragma HLS PIPELINE
89+
1990
#pragma HLS INTERFACE port=a ap_fifo
20-
#pragma HLS INTERFACE port=b axis
91+
#pragma HLS INTERFACE port=b ap_fifo
2192
#pragma HLS INTERFACE port=c ap_fifo
22-
#pragma HLS INTERFACE port=d axis
93+
#pragma HLS INTERFACE port=d ap_fifo
94+
95+
96+
hls::stream<int> a1;
97+
hls::stream<int> a2;
98+
stream_splitter(a, a1, a2);
99+
100+
101+
// first branch (short)
102+
hls::stream<int> fa_os;
103+
func_1( a1, fa_os );
104+
105+
106+
// second branch (long)
107+
hls::stream<int> fb_os;
108+
func_2( a2, fb_os );
109+
110+
hls::stream<int> fc_os;
111+
func_3( fb_os, fc_os );
112+
113+
114+
b.write( fa_os.read() + fc_os.read() );
23115

24-
c.write( a.read() + b.read() );
25-
d.write( a.read() - b.read() );
26116
}
27117

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
void stream_splitter(
3+
hls::stream<int> &is,
4+
hls::stream<int> &os1
5+
hls::stream<int> &os2
6+
);
7+
8+
void func_1(
9+
hls::stream<int> &is,
10+
hls::stream<int> &os
11+
);
12+
13+
void func_2(
14+
hls::stream<int> &is,
15+
hls::stream<int> &os
16+
);
17+
18+
void func_3(
19+
hls::stream<int> &is,
20+
hls::stream<int> &os
21+
);

example_projects/vitis_hls_test_prj_template_v2/vitis_hls_csynth.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
rm -rf ./prj/sol1/syn
1313
rm -rf ./prj/sol1/impl
1414

15-
vitis_hls -f run_hls.tcl
15+
if (vitis_hls -f run_hls.tcl | grep --color -P "ERROR:|") ; then
1616

17-
# open top Verilog
18-
subl ./prj/sol1/syn/verilog/hls_operator.v
17+
# open top Verilog
18+
subl ./prj/sol1/syn/verilog/hls_operator.v
1919

20-
# open main report
21-
subl ./prj/sol1/syn/report/csynth.rpt
20+
# open main report
21+
subl ./prj/sol1/syn/report/csynth.rpt
22+
subl ./prj/sol1/syn/report/hls_operator_csynth.rpt
23+
fi
2224

example_projects/vitis_hls_test_prj_template_v2/vitis_hls_impl.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@ if [ ! -d "./prj" ]; then
1212
source vitis_hls_csynth.sh
1313
fi
1414

15-
vitis_hls -eval 'export_design -flow impl -rtl verilog -format ip_catalog'
15+
if (vitis_hls -eval 'export_design -flow impl -rtl verilog -format ip_catalog' | grep --color -P "ERROR:|") ; then
16+
17+
# open top Verilog
18+
subl ./prj/sol1/syn/verilog/hls_operator.v
19+
20+
# open main report
21+
subl ./prj/sol1/impl/report/verilog/hls_operator_export.rpt
22+
subl ./prj/sol1/impl/report/verilog/export_syn.rpt
23+
subl ./prj/sol1/impl/report/verilog/export_impl.rpt
24+
fi
1625

example_projects/vitis_hls_test_prj_template_v2/vitis_hls_syn.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,13 @@ if [ ! -d "./prj" ]; then
1212
source vitis_hls_csynth.sh
1313
fi
1414

15-
vitis_hls -eval 'export_design -flow syn -rtl verilog -format ip_catalog'
15+
if (vitis_hls -eval 'export_design -flow syn -rtl verilog -format ip_catalog' | grep --color -P "ERROR:|") ; then
16+
17+
# open top Verilog
18+
subl ./prj/sol1/syn/verilog/hls_operator.v
19+
20+
# open main report
21+
subl ./prj/sol1/impl/report/verilog/hls_operator_export.rpt
22+
subl ./prj/sol1/impl/report/verilog/export_syn.rpt
23+
fi
1624

example_projects/скрипт компилирует до тех пор, пока не сойдутся тайминги.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)