diff --git a/src/finn/transformation/fpgadataflow/create_stitched_ip.py b/src/finn/transformation/fpgadataflow/create_stitched_ip.py index 52e4e88b409766f0764d3ce7666dbf1971713575..8e2c69bad4b0a6749c605bea9ee21d6408c904c0 100644 --- a/src/finn/transformation/fpgadataflow/create_stitched_ip.py +++ b/src/finn/transformation/fpgadataflow/create_stitched_ip.py @@ -310,6 +310,14 @@ class CreateStitchedIP(Transformation): behavior. It is strongly recommended to insert FIFOs prior to calling CreateStitchedIP.""" ) + if model.graph.node[0].op_type == "StreamingFIFO": + firstfifo = getCustomOp(model.graph.node[0]) + if firstfifo.get_nodeattr("impl_style") == "vivado": + warnings.warn( + """First FIFO has impl_style=vivado, which may cause + simulation glitches (e.g. dropping the first input sample + after reset).""" + ) for node in model.graph.node: # ensure that all nodes are fpgadataflow, and that IPs are generated assert is_fpgadataflow_node( diff --git a/src/finn/transformation/fpgadataflow/insert_fifo.py b/src/finn/transformation/fpgadataflow/insert_fifo.py index 50da9cdf1666c21f99a66e1d27e134b914738cb1..bfeee95e9bbd2a3a3f7c6eb0a4c7e74d30f76228 100644 --- a/src/finn/transformation/fpgadataflow/insert_fifo.py +++ b/src/finn/transformation/fpgadataflow/insert_fifo.py @@ -209,13 +209,9 @@ class InsertFIFO(Transformation): graph.value_info.append(fifo_output_tensor) model.set_tensor_datatype(fifo_output_tensor.name, dtype) - if ( - self.max_qsrl_depth is None - or fifo_depth <= self.max_qsrl_depth - ): - impl_style = "rtl" - else: - impl_style = "vivado" + # only use rtl-style FIFOs to avoid simulation bug + # (top-level IOs should not have impl_style=vivado) + impl_style = "rtl" fifo_node = oh.make_node( "StreamingFIFO", @@ -271,13 +267,9 @@ class InsertFIFO(Transformation): graph.value_info.append(fifo_input_tensor) model.set_tensor_datatype(fifo_input_tensor.name, dtype) - if ( - self.max_qsrl_depth is None - or fifo_depth <= self.max_qsrl_depth - ): - impl_style = "rtl" - else: - impl_style = "vivado" + # only use rtl-style FIFOs to avoid simulation bug + # (top-level IOs should not have impl_style=vivado) + impl_style = "rtl" fifo_node = oh.make_node( "StreamingFIFO", diff --git a/src/finn/transformation/fpgadataflow/set_fifo_depths.py b/src/finn/transformation/fpgadataflow/set_fifo_depths.py index 2619557edfb92059f0ac0d824f7e9c289b282612..35e7b9e6c929587d00038650742edb5dcb922130 100644 --- a/src/finn/transformation/fpgadataflow/set_fifo_depths.py +++ b/src/finn/transformation/fpgadataflow/set_fifo_depths.py @@ -412,8 +412,13 @@ class InsertAndSetFIFODepths(Transformation): node_inst = getCustomOp(node) node_inst.set_nodeattr("depth", depth) node_inst.set_nodeattr("depth_monitor", 0) + # exception for top-level IO FIFOs which cause a bug in simulation + # (top-level IOs should not have impl_style=vivado) + toplevel_in = node.input[0] in [x.name for x in model.graph.input] + toplevel_out = node.output[0] in [x.name for x in model.graph.output] + toplevel_style_exception = toplevel_in or toplevel_out # Set FIFO implementation/ram styles - if depth > self.max_qsrl_depth: + if (depth > self.max_qsrl_depth) and (not toplevel_style_exception): node_inst.set_nodeattr("impl_style", "vivado") node_inst.set_nodeattr("ram_style", self.vivado_ram_style) else: