Skip to content

Commit

Permalink
refactoring and moving log computations to cpp compile side
Browse files Browse the repository at this point in the history
  • Loading branch information
lstasytis committed Sep 18, 2024
1 parent 8e297d1 commit 337dced
Show file tree
Hide file tree
Showing 4 changed files with 454 additions and 381 deletions.
16 changes: 1 addition & 15 deletions src/finn/custom_op/fpgadataflow/hls/iodma_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def docompute(self):
raise ValueError("Invalid IODMA direction, please set to in or out")
# define templates for instantiation
dma_inst_template = func + "<DataWidth1, NumBytes1>(%s, %s, numReps);"
dwc_inst_template = dwc_func + "<%d, %d, %d, %d, %d, %d, %d, %d>(%s, %s, numReps);"
dwc_inst_template = dwc_func + "<%d, %d, %d, %d, %d>(%s, %s, numReps);"
# do stream infrastructure and instantiations
intfw = self.get_nodeattr("intfWidth")
strmw = self.get_nodeattr("streamWidth")
Expand All @@ -257,10 +257,6 @@ def docompute(self):
if outWidth > inWidth:
totalIters += int(np.floor(outWidth / inWidth) + 1) - 1

NumInWordsLog = int(np.log2(numInWords) + 1)
NumOutWordsLog = int(np.log2(numOutWords) + 1)
BufferWidthLog = int(np.log2(inWidth + outWidth) + 1)

# AXI MM -> IODMA -> (DWCs) -> out
# DWCs depend on AXI MM and out interface width
if strmw == intfw:
Expand All @@ -281,9 +277,6 @@ def docompute(self):
outWidth,
numInWords,
numOutWords,
NumInWordsLog,
NumOutWordsLog,
BufferWidthLog,
totalIters,
"dma2dwc",
"out_" + self.hls_sname(),
Expand All @@ -301,10 +294,6 @@ def docompute(self):
if outWidth > inWidth:
totalIters += int(np.floor(outWidth / inWidth) + 1) - 1

NumInWordsLog = int(np.log2(numInWords) + 1)
NumOutWordsLog = int(np.log2(numOutWords) + 1)
BufferWidthLog = int(np.log2(inWidth + outWidth) + 1)

# in0 -> (DWCs) -> IODMA -> AXI MM
# DWCs depend on AXI MM and out interface width
if strmw == intfw:
Expand All @@ -324,9 +313,6 @@ def docompute(self):
outWidth,
numInWords,
numOutWords,
NumInWordsLog,
NumOutWordsLog,
BufferWidthLog,
totalIters,
"in0_" + self.hls_sname(),
"dwc2dma",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@


class StreamingDataWidthConverter_hls(StreamingDataWidthConverter, HLSBackend):
"""Class that corresponds to finn-hlslib StreamingDataWidthConverter_Batch
"""Class that corresponds to finn-hlslib StreamingDataWidthConverterGeneralized_Batch
function."""

def get_nodeattr_types(self):
Expand Down Expand Up @@ -77,18 +77,12 @@ def defines(self, var):
if outWidth > inWidth:
totalIters += int(np.floor(outWidth / inWidth) + 1) - 1

NumInWordsLog = int(np.log2(numInWords) + 1)
NumOutWordsLog = int(np.log2(numOutWords) + 1)
BufferWidthLog = int(np.log2(inWidth + outWidth) + 1)

self.code_gen_dict["$DEFINES$"] = [
"#define InWidth %d " % inWidth,
"#define OutWidth %d " % outWidth,
"#define NumInWords %d " % numInWords,
"#define NumOutWords %d " % numOutWords,
"#define NumInWordsLog %d " % NumInWordsLog,
"#define NumOutWordsLog %d " % NumOutWordsLog,
"#define BufferWidthLog %d " % BufferWidthLog,
"#define totalIters %d " % totalIters,
"#define numReps %d" % numReps,
]
Expand All @@ -109,11 +103,10 @@ def strm_decl(self):

def docompute(self):
# TODO continue with fxns below, they are copy-pasted
op = "StreamingDataWidthConverter_Batch"
op = "StreamingDataWidthConverterGeneralized_Batch"

self.code_gen_dict["$DOCOMPUTE$"] = [
"%s<InWidth, OutWidth, NumInWords,NumOutWords," % op
+ "NumInWordsLog, NumOutWordsLog, BufferWidthLog,"
+ " totalIters>(in0_%s, out_%s, numReps);" % (self.hls_sname(), self.hls_sname())
]

Expand Down
Loading

0 comments on commit 337dced

Please sign in to comment.