)
)
header_offset_multiplier = 1 if header_words == 1 else 2
- self.sync += If(source.valid & source.ready, sink_d.eq(sink))
+ self.sync += If(sink.ready, sink_d.eq(sink))
fsm.act("UNALIGNED-DATA-COPY",
- source.valid.eq(sink_d.valid),
+ source.valid.eq(sink.valid | sink_d.last),
source.last.eq(sink_d.last),
If(fsm_from_idle,
source.data[:max(header_leftover*8, 1)].eq(sr[min(header_offset_multiplier*data_width, len(sr)-1):])
source.data[header_leftover*8:].eq(sink.data),
If(source.valid & source.ready,
sink.ready.eq(1),
- If(sink.valid, NextValue(fsm_from_idle, 0)),
+ NextValue(fsm_from_idle, 0),
If(source.last,
NextState("IDLE")
)
datas = [prng.randrange(2**dw) for _ in range(prng.randrange(2**7))]
packets.append(Packet(header, datas))
- def generator(dut):
+ def generator(dut, valid_rand=50):
# Send packets
for packet in packets:
yield dut.sink.field_8b.eq(packet.header["field_8b"])
yield
while (yield dut.sink.ready) == 0:
yield
- dut.sink.valid.eq(0)
+ yield dut.sink.valid.eq(0)
+ yield dut.sink.last.eq(0)
+ while prng.randrange(100) < valid_rand:
+ yield
def checker(dut):
dut.header_errors = 0