Skip to content

Commit 046b8bf

Browse files
committedNov 27, 2016
drtio: fix transmit datapath with transceiver width > max packet width
1 parent b2450c7 commit 046b8bf

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed
 

Diff for: ‎artiq/gateware/drtio/rt_packets.py

+24-12
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __init__(self, frame, data, plm):
140140
self.packet_buffer = Signal(max(layout_len(l)
141141
for l in plm.layouts.values()))
142142
w_in_packet = len(self.packet_buffer)//ws
143-
self.packet_last_n = Signal(max=w_in_packet)
143+
self.packet_last_n = Signal(max=max(w_in_packet, 2))
144144
self.packet_stb = Signal()
145145
self.packet_last = Signal()
146146

@@ -149,18 +149,30 @@ def __init__(self, frame, data, plm):
149149

150150
# # #
151151

152-
packet_buffer_count = Signal(max=w_in_packet)
153-
self.comb += self.packet_last.eq(packet_buffer_count == self.packet_last_n)
152+
self.sync += frame.eq(0)
153+
154+
if w_in_packet > 1:
155+
packet_buffer_count = Signal(max=w_in_packet)
156+
self.comb += self.packet_last.eq(packet_buffer_count == self.packet_last_n)
157+
self.sync += [
158+
packet_buffer_count.eq(0),
159+
If(self.packet_stb,
160+
frame.eq(1),
161+
Case(packet_buffer_count,
162+
{i: data.eq(self.packet_buffer[i*ws:(i+1)*ws])
163+
for i in range(w_in_packet)}),
164+
packet_buffer_count.eq(packet_buffer_count + 1)
165+
)
166+
]
167+
else:
168+
self.comb += self.packet_last.eq(1)
169+
self.sync += \
170+
If(self.packet_stb,
171+
frame.eq(1),
172+
data.eq(self.packet_buffer)
173+
)
174+
154175
self.sync += [
155-
frame.eq(0),
156-
packet_buffer_count.eq(0),
157-
If(self.packet_stb,
158-
frame.eq(1),
159-
Case(packet_buffer_count,
160-
{i: data.eq(self.packet_buffer[i*ws:(i+1)*ws])
161-
for i in range(w_in_packet)}),
162-
packet_buffer_count.eq(packet_buffer_count + 1)
163-
),
164176
If(self.raw_stb,
165177
frame.eq(1),
166178
data.eq(self.raw_data)

0 commit comments

Comments
 (0)
Please sign in to comment.