diff --git a/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py b/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py index be9b51e6a7b1b3e255cd2ee8baf10937b95f8665..6ed4df512725eebd14fd0df80040d82b802e48ad 100644 --- a/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py +++ b/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py @@ -41,6 +41,9 @@ class StreamingFCLayer_Batch(HLSCustomOp): "binaryXnorMode": ("i", False, 0), # no-activation mode (produce accumulators) "noActivation": ("i", False, 0), + # input and output FIFO depths + "inFIFODepth": ("i", False, 0), + "outFIFODepth": ("i", False, 0), } my_attrs.update(super().get_nodeattr_types()) return my_attrs @@ -99,6 +102,7 @@ class StreamingFCLayer_Batch(HLSCustomOp): info_messages.append('Attribute backend should be set to "fpgadataflow"') # verify that all necessary attributes exist + # TODO collect automatically from get_nodeattr_types try: self.get_nodeattr("code_gen_dir_npysim") self.get_nodeattr("executable_path") @@ -161,6 +165,7 @@ class StreamingFCLayer_Batch(HLSCustomOp): Y. Umuroglu, M. Leeser and K. Vissers - 12. Sep 2018 """ + # TODO add in/out FIFO contributions P = self.get_nodeattr("PE") Q = self.get_nodeattr("SIMD") wdt = self.get_weight_datatype() @@ -178,6 +183,7 @@ class StreamingFCLayer_Batch(HLSCustomOp): Y. Umuroglu, M. Leeser and K. Vissers - 12. Sep 2018 """ + # TODO add in/out FIFO contributions P = self.get_nodeattr("PE") Q = self.get_nodeattr("SIMD") wdt = self.get_weight_datatype() @@ -642,6 +648,17 @@ class StreamingFCLayer_Batch(HLSCustomOp): def pragmas(self): self.code_gen_dict["$PRAGMAS$"] = ["#pragma HLS INTERFACE axis port=in0"] self.code_gen_dict["$PRAGMAS$"].append("#pragma HLS INTERFACE axis port=out") + in_fifo_depth = self.get_nodeattr("inFIFODepth") + out_fifo_depth = self.get_nodeattr("outFIFODepth") + # insert depth pragmas only if specified + if in_fifo_depth != 0: + self.code_gen_dict["$PRAGMAS$"].append( + "#pragma HLS stream depth=%d variable=in0" % in_fifo_depth + ) + if out_fifo_depth != 0: + self.code_gen_dict["$PRAGMAS$"].append( + "#pragma HLS stream depth=%d variable=out" % out_fifo_depth + ) self.code_gen_dict["$PRAGMAS$"].append( "#pragma HLS INTERFACE ap_ctrl_none port=return" )