interconnect/packet/Packetizer/Depacketizer: Avoid generating unaligned logic when aligned.
This commit is contained in:
parent
0a919e709f
commit
e0d5a7bff5
|
@ -170,6 +170,7 @@ class Packetizer(Module):
|
|||
bytes_per_clk = data_width//8
|
||||
header_words = (header.length*8)//data_width
|
||||
header_leftover = header.length%bytes_per_clk
|
||||
aligned = header_leftover == 0
|
||||
|
||||
# Signals.
|
||||
sr = Signal(header.length*8, reset_less=True)
|
||||
|
@ -208,11 +209,7 @@ class Packetizer(Module):
|
|||
sr_load.eq(1),
|
||||
NextValue(fsm_from_idle, 1),
|
||||
If(header_words == 1,
|
||||
If(header_leftover != 0,
|
||||
NextState("UNALIGNED-DATA-COPY")
|
||||
).Else(
|
||||
NextState("ALIGNED-DATA-COPY")
|
||||
)
|
||||
NextState("ALIGNED-DATA-COPY" if aligned else "UNALIGNED-DATA-COPY")
|
||||
).Else(
|
||||
NextState("HEADER-SEND")
|
||||
)
|
||||
|
@ -227,12 +224,8 @@ class Packetizer(Module):
|
|||
sr_shift.eq(1),
|
||||
If(count == (header_words - 1),
|
||||
sr_shift.eq(0),
|
||||
If(header_leftover,
|
||||
NextState("UNALIGNED-DATA-COPY"),
|
||||
NextState("ALIGNED-DATA-COPY" if aligned else "UNALIGNED-DATA-COPY"),
|
||||
NextValue(count, count + 1)
|
||||
).Else(
|
||||
NextState("ALIGNED-DATA-COPY")
|
||||
)
|
||||
).Else(
|
||||
NextValue(count, count + 1),
|
||||
)
|
||||
|
@ -251,6 +244,7 @@ class Packetizer(Module):
|
|||
)
|
||||
)
|
||||
)
|
||||
if not aligned:
|
||||
header_offset_multiplier = 1 if header_words == 1 else 2
|
||||
self.sync += If(source.ready, sink_d.eq(sink))
|
||||
fsm.act("UNALIGNED-DATA-COPY",
|
||||
|
@ -291,6 +285,7 @@ class Depacketizer(Module):
|
|||
bytes_per_clk = data_width//8
|
||||
header_words = (header.length*8)//data_width
|
||||
header_leftover = header.length%bytes_per_clk
|
||||
aligned = header_leftover == 0
|
||||
|
||||
# Signals.
|
||||
sr = Signal(header.length*8, reset_less=True)
|
||||
|
@ -320,11 +315,7 @@ class Depacketizer(Module):
|
|||
sr_shift.eq(1),
|
||||
NextValue(fsm_from_idle, 1),
|
||||
If(header_words == 1,
|
||||
If(header_leftover,
|
||||
NextState("UNALIGNED-DATA-COPY")
|
||||
).Else(
|
||||
NextState("ALIGNED-DATA-COPY")
|
||||
),
|
||||
NextState("ALIGNED-DATA-COPY" if aligned else "UNALIGNED-DATA-COPY"),
|
||||
).Else(
|
||||
NextState("HEADER-RECEIVE")
|
||||
)
|
||||
|
@ -336,15 +327,24 @@ class Depacketizer(Module):
|
|||
NextValue(count, count + 1),
|
||||
sr_shift.eq(1),
|
||||
If(count == (header_words - 1),
|
||||
If(header_leftover,
|
||||
NextState("ALIGNED-DATA-COPY" if aligned else "UNALIGNED-DATA-COPY"),
|
||||
NextValue(count, count + 1),
|
||||
NextState("UNALIGNED-DATA-COPY")
|
||||
).Else(
|
||||
NextState("ALIGNED-DATA-COPY")
|
||||
)
|
||||
)
|
||||
)
|
||||
fsm.act("ALIGNED-DATA-COPY",
|
||||
source.valid.eq(sink.valid | sink_d.last),
|
||||
source.last.eq(sink.last | sink_d.last),
|
||||
sink.ready.eq(source.ready),
|
||||
source.data.eq(sink.data),
|
||||
If(source.valid & source.ready,
|
||||
If(source.last,
|
||||
NextState("IDLE")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not aligned:
|
||||
self.sync += If(sink.valid & sink.ready, sink_d.eq(sink))
|
||||
fsm.act("UNALIGNED-DATA-COPY",
|
||||
source.valid.eq(sink.valid | sink_d.last),
|
||||
|
@ -366,17 +366,6 @@ class Depacketizer(Module):
|
|||
)
|
||||
)
|
||||
)
|
||||
fsm.act("ALIGNED-DATA-COPY",
|
||||
source.valid.eq(sink.valid | sink_d.last),
|
||||
source.last.eq(sink.last | sink_d.last),
|
||||
sink.ready.eq(source.ready),
|
||||
source.data.eq(sink.data),
|
||||
If(source.valid & source.ready,
|
||||
If(source.last,
|
||||
NextState("IDLE")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
# Error.
|
||||
if hasattr(sink, "error") and hasattr(source, "error"):
|
||||
|
|
Loading…
Reference in New Issue