soc/interconnect/packet: connect error/last_be only present on both sink and source
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 15 Nov 2019 13:57:31 +0000 (14:57 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 15 Nov 2019 13:57:31 +0000 (14:57 +0100)
litex/soc/interconnect/packet.py

index a9a98130df82049b914c964b76ad94bcf0a2ea69..28663d3a2e65dc75ef9c1351b71e71b433391e3c 100644 (file)
@@ -262,11 +262,11 @@ class Packetizer(Module):
         )
 
         # Error ------------------------------------------------------------------------------------
-        if hasattr(sink, "error"):
+        if hasattr(sink, "error") and hasattr(source, "error"):
             self.comb += source.error.eq(sink.error)
 
         # Last BE ----------------------------------------------------------------------------------
-        if hasattr(sink, "last_be"):
+        if hasattr(sink, "last_be") and hasattr(source, "last_be"):
             rotate_by = header.length%bytes_per_clk
             x = [sink.last_be[(i + rotate_by)%bytes_per_clk] for i in range(bytes_per_clk)]
             self.comb += source.last_be.eq(Cat(*x))
@@ -375,11 +375,11 @@ class Depacketizer(Module):
         )
 
         # Error ------------------------------------------------------------------------------------
-        if hasattr(sink, "error"):
+        if hasattr(sink, "error") and hasattr(source, "error"):
             self.comb += source.error.eq(sink.error)
 
         # Last BE ----------------------------------------------------------------------------------
-        if hasattr(sink, "last_be"):
+        if hasattr(sink, "last_be") and hasattr(source, "last_be"):
             x = [sink.last_be[(i - (bytes_per_clk - header_leftover))%bytes_per_clk]
                 for i in range(bytes_per_clk)]
             self.comb += source.last_be.eq(Cat(*x))