2424# Arg 17: batch size (log)
2525# Arg 18: in block size (log)
2626# Arg 19: out block size (log)
27- # Arg 20: uop buffer size in B (log)
28- # Arg 21: inp buffer size in B (log)
29- # Arg 22: wgt buffer size in B (log)
30- # Arg 23: acc buffer size in B (log)
31- # Arg 24: out buffer size in B (log)
32-
33- if { [llength $argv ] eq 26 } {
27+ # Arg 20: bus width in b (log)
28+ # Arg 21: uop buffer size in B (log)
29+ # Arg 22: inp buffer size in B (log)
30+ # Arg 23: wgt buffer size in B (log)
31+ # Arg 24: acc buffer size in B (log)
32+ # Arg 25: out buffer size in B (log)
33+
34+ if { [llength $argv ] eq 27 } {
3435 set target [lindex $argv 2]
3536 set src_dir [lindex $argv 3]
3637 set sim_dir [lindex $argv 4]
@@ -50,43 +51,24 @@ if { [llength $argv] eq 26 } {
5051 set batch [lindex $argv 18]
5152 set block_in [lindex $argv 19]
5253 set block_out [lindex $argv 20]
53- set uop_buff_size [lindex $argv 21]
54- set inp_buff_size [lindex $argv 22]
55- set wgt_buff_size [lindex $argv 23]
56- set acc_buff_size [lindex $argv 24]
57- set out_buff_size [lindex $argv 25]
54+ set bus_width [lindex $argv 21]
55+ set uop_buff_size [lindex $argv 22]
56+ set inp_buff_size [lindex $argv 23]
57+ set wgt_buff_size [lindex $argv 24]
58+ set acc_buff_size [lindex $argv 25]
59+ set out_buff_size [lindex $argv 26]
5860} else {
59- set target " pynq"
60- set src_dir " ../src"
61- set sim_dir " ../sim"
62- set test_dir " ../../src/test"
63- set include_dir " ../../include"
64- set mode " all"
65- set debug " False"
66- set alu_ena " True"
67- set mul_ena " True"
68- set target_period 8
69- set target_gemm_ii 10
70- set target_alu_ii 16
71- set inp_width 3
72- set wgt_width 3
73- set acc_width 5
74- set out_width 3
75- set batch 1
76- set block_in 4
77- set block_out 4
78- set uop_buff_size 15
79- set inp_buff_size 15
80- set wgt_buff_size 15
81- set acc_buff_size 17
82- set out_buff_size 15
61+ puts " Not enough arguments provided!"
8362 exit
8463}
8564
65+ puts " about to start doing some stuff"
66+
67+
8668# Initializes the HLS design and sets HLS pragmas for memory partitioning.
8769# This is necessary because of a Vivado restriction that doesn't allow for
8870# buses wider than 1024 bits.
89- proc init_design {target per g_ii a_ii inp_width wgt_width out_width acc_width batch block_in block_out alu_ena} {
71+ proc init_design {target per g_ii a_ii bus_width inp_width wgt_width out_width acc_width batch block_in block_out alu_ena} {
9072
9173 # Set device number
9274 if {$target ==" pynq" } {
@@ -95,28 +77,25 @@ proc init_design {target per g_ii a_ii inp_width wgt_width out_width acc_width b
9577 set_part {xczu3eg-sbva484-1-e}
9678 } elseif {$target ==" zcu102" } {
9779 set_part {xczu9eg-ffvb1156-2-e}
80+ } elseif {$target ==" f1" } {
81+ set_part {xcvu9p-flgb2104-2-i}
82+ # config_interface -m_axi_addr64
9883 }
9984
10085 # Max bus width (supported by Vivado)
10186 set max_width 1024
10287
103- # Set axi width (TODO derive from top level config)
104- if {$target ==" pynq" } {
105- set axi_width 64
106- } elseif {$target ==" ultra96" } {
107- set axi_width 128
108- } elseif {$target ==" zcu102" } {
109- set axi_width 128
110- }
88+ # Set axi width
89+ set axi_width [expr {1 << $bus_width }]
11190
11291 # Set the clock frequency
11392 create_clock -period $per -name default
11493
11594 # Set pipeline directive
116- set_directive_pipeline -II $g_ii " compute /READ_GEMM_UOP"
95+ set_directive_pipeline -II $g_ii " gemm /READ_GEMM_UOP"
11796
11897 if {$alu_ena ==" True" } {
119- set_directive_pipeline -II $a_ii " compute /READ_ALU_UOP"
98+ set_directive_pipeline -II $a_ii " alu /READ_ALU_UOP"
12099 }
121100
122101 # Set input partition factor to (INP_VECTOR_WIDTH*BATCH/(1024*g_ii)
@@ -174,7 +153,8 @@ set cflags "-I $include_dir -I $src_dir -I $test_dir \
174153 -DVTA_LOG_BATCH=$batch -DVTA_LOG_BLOCK_OUT=$block_out -DVTA_LOG_BLOCK_IN=$block_in \
175154 -DVTA_LOG_UOP_BUFF_SIZE=$uop_buff_size -DVTA_LOG_INP_BUFF_SIZE=$inp_buff_size \
176155 -DVTA_LOG_WGT_BUFF_SIZE=$wgt_buff_size -DVTA_LOG_ACC_BUFF_SIZE=$acc_buff_size \
177- -DVTA_LOG_OUT_BUFF_SIZE=$out_buff_size "
156+ -DVTA_LOG_OUT_BUFF_SIZE=$out_buff_size -DVTA_LOG_BUS_WIDTH=$bus_width \
157+ -DVTA_GEMM_II=$target_gemm_ii "
178158if {$debug ==" True" } {
179159 append cflags " -DVTA_DEBUG=1"
180160}
@@ -185,6 +165,7 @@ if {$mul_ena=="True"} {
185165 append cflags " -DMUL_EN"
186166}
187167
168+
188169# HLS behavioral sim
189170if {$mode ==" all" || $mode ==" sim" } {
190171 open_project vta_sim
@@ -193,7 +174,7 @@ if {$mode=="all" || $mode=="sim"} {
193174 add_files -tb $sim_dir /vta_test.cc -cflags $cflags
194175 add_files -tb $test_dir /test_lib.cc -cflags $cflags
195176 open_solution " solution0"
196- init_design $target $target_period $target_gemm_ii $target_alu_ii $inp_width $wgt_width $out_width $acc_width $batch $block_in $block_out $alu_ena
177+ init_design $target $target_period $target_gemm_ii $target_alu_ii $bus_width $ inp_width $wgt_width $out_width $acc_width $batch $block_in $block_out $alu_ena
197178 csim_design -clean
198179 close_project
199180}
@@ -204,7 +185,7 @@ if {$mode=="all" || $mode=="skip_sim" || $mode=="fetch"} {
204185 set_top fetch
205186 add_files $src_dir /vta.cc -cflags $cflags
206187 open_solution " solution0"
207- init_design $target $target_period $target_gemm_ii $target_alu_ii $inp_width $wgt_width $out_width $acc_width $batch $block_in $block_out $alu_ena
188+ init_design $target $target_period $target_gemm_ii $target_alu_ii $bus_width $ inp_width $wgt_width $out_width $acc_width $batch $block_in $block_out $alu_ena
208189 csynth_design
209190 if {$mode ==" all" || $mode ==" skip_sim" } {
210191 export_design -format ip_catalog
@@ -218,7 +199,7 @@ if {$mode=="all" || $mode=="skip_sim" || $mode=="load"} {
218199 set_top load
219200 add_files $src_dir /vta.cc -cflags $cflags
220201 open_solution " solution0"
221- init_design $target $target_period $target_gemm_ii $target_alu_ii $inp_width $wgt_width $out_width $acc_width $batch $block_in $block_out $alu_ena
202+ init_design $target $target_period $target_gemm_ii $target_alu_ii $bus_width $ inp_width $wgt_width $out_width $acc_width $batch $block_in $block_out $alu_ena
222203 csynth_design
223204 if {$mode ==" all" || $mode ==" skip_sim" } {
224205 export_design -format ip_catalog
@@ -232,7 +213,7 @@ if {$mode=="all" || $mode=="skip_sim" || $mode=="compute"} {
232213 set_top compute
233214 add_files $src_dir /vta.cc -cflags $cflags
234215 open_solution " solution0"
235- init_design $target $target_period $target_gemm_ii $target_alu_ii $inp_width $wgt_width $out_width $acc_width $batch $block_in $block_out $alu_ena
216+ init_design $target $target_period $target_gemm_ii $target_alu_ii $bus_width $ inp_width $wgt_width $out_width $acc_width $batch $block_in $block_out $alu_ena
236217 csynth_design
237218 if {$mode ==" all" || $mode ==" skip_sim" } {
238219 export_design -format ip_catalog
@@ -246,7 +227,7 @@ if {$mode=="all" || $mode=="skip_sim" || $mode=="store"} {
246227 set_top store
247228 add_files $src_dir /vta.cc -cflags $cflags
248229 open_solution " solution0"
249- init_design $target $target_period $target_gemm_ii $target_alu_ii $inp_width $wgt_width $out_width $acc_width $batch $block_in $block_out $alu_ena
230+ init_design $target $target_period $target_gemm_ii $target_alu_ii $bus_width $ inp_width $wgt_width $out_width $acc_width $batch $block_in $block_out $alu_ena
250231 csynth_design
251232 if {$mode ==" all" || $mode ==" skip_sim" } {
252233 export_design -format ip_catalog
0 commit comments