Skip to content

Commit 88168eb

Browse files
authored
Merge pull request #1414 from Xilinx/fix/fifo_hwcustomop
Accessing adjusted depth and impl style only when FIFO in RTL layer format
2 parents 66ace88 + 1a2cbd3 commit 88168eb

1 file changed

Lines changed: 58 additions & 10 deletions

File tree

src/finn/custom_op/fpgadataflow/streamingfifo.py

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,30 @@ def infer_node_datatype(self, model):
8585

8686
def get_verilog_top_module_intf_names(self):
8787
ret = super().get_verilog_top_module_intf_names()
88-
is_rtl = self.get_nodeattr("impl_style") == "rtl"
88+
try:
89+
is_rtl = self.get_nodeattr("impl_style") == "rtl"
90+
except AttributeError:
91+
raise Exception(
92+
self.onnx_node.name
93+
+ """ is still in hw abstraction format,
94+
Please run SpecializeLayers() before proceeding."""
95+
)
8996
is_depth_monitor = self.get_nodeattr("depth_monitor") == 1
9097
if is_rtl and is_depth_monitor:
9198
ret["ap_none"] = ["maxcount"]
9299
return ret
93100

94101
def get_normal_input_shape(self, ind=0):
95-
depth = self.get_adjusted_depth()
102+
try:
103+
depth = self.get_adjusted_depth()
104+
except AttributeError:
105+
depth = self.get_nodeattr("depth")
96106
assert depth >= 1, """Depth is too low"""
97-
if depth > 256 and self.get_nodeattr("impl_style") == "rtl":
107+
try:
108+
impl_style = self.get_nodeattr("impl_style") == "rtl"
109+
except AttributeError:
110+
impl_style = ""
111+
if depth > 256 and impl_style == "rtl":
98112
warnings.warn("Depth is high, set between 2 and 256 for efficient SRL implementation")
99113
return self.get_nodeattr("normal_shape")
100114

@@ -131,9 +145,20 @@ def execute_node(self, context, graph):
131145

132146
def bram_estimation(self):
133147
"""Calculates resource estimation for BRAM"""
134-
impl = self.get_nodeattr("impl_style")
148+
try:
149+
impl = self.get_nodeattr("impl_style") == "rtl"
150+
except AttributeError:
151+
raise Exception(
152+
self.onnx_node.name
153+
+ """ is still in hw abstraction format,
154+
Please run SpecializeLayers() before proceeding."""
155+
)
156+
135157
ram_type = self.get_nodeattr("ram_style")
136-
depth = self.get_adjusted_depth()
158+
try:
159+
depth = self.get_adjusted_depth()
160+
except AttributeError:
161+
depth = self.get_nodeattr("depth")
137162
W = self.get_instream_width()
138163

139164
if impl == "rtl" or (impl == "vivado" and ram_type != "block"):
@@ -156,9 +181,19 @@ def bram_estimation(self):
156181
def uram_estimation(self):
157182
"""Calculates resource estimation for URAM"""
158183

159-
impl = self.get_nodeattr("impl_style")
184+
try:
185+
impl = self.get_nodeattr("impl_style") == "rtl"
186+
except AttributeError:
187+
raise Exception(
188+
self.onnx_node.name
189+
+ """ is still in hw abstraction format,
190+
Please run SpecializeLayers() before proceeding."""
191+
)
160192
ram_type = self.get_nodeattr("ram_style")
161-
depth = self.get_adjusted_depth()
193+
try:
194+
depth = self.get_adjusted_depth()
195+
except AttributeError:
196+
depth = self.get_nodeattr("depth")
162197
W = self.get_instream_width()
163198

164199
if impl == "rtl" or (impl == "vivado" and ram_type != "ultra"):
@@ -168,7 +203,10 @@ def uram_estimation(self):
168203
return (math.ceil(depth / 4096)) * (math.ceil(W / 72))
169204

170205
def bram_efficiency_estimation(self):
171-
depth = self.get_adjusted_depth()
206+
try:
207+
depth = self.get_adjusted_depth()
208+
except AttributeError:
209+
depth = self.get_nodeattr("depth")
172210
W = self.get_instream_width()
173211
bram16_est = self.bram_estimation()
174212
if bram16_est == 0:
@@ -179,9 +217,19 @@ def bram_efficiency_estimation(self):
179217

180218
def lut_estimation(self):
181219
"""Calculates resource estimations for LUTs"""
182-
impl = self.get_nodeattr("impl_style")
220+
try:
221+
impl = self.get_nodeattr("impl_style") == "rtl"
222+
except AttributeError:
223+
raise Exception(
224+
self.onnx_node.name
225+
+ """ is still in hw abstraction format,
226+
Please run SpecializeLayers() before proceeding."""
227+
)
183228
ram_type = self.get_nodeattr("ram_style")
184-
depth = self.get_adjusted_depth()
229+
try:
230+
depth = self.get_adjusted_depth()
231+
except AttributeError:
232+
depth = self.get_nodeattr("depth")
185233
W = self.get_instream_width()
186234

187235
address_luts = 2 * math.ceil(math.log(depth, 2))

0 commit comments

Comments
 (0)