uart: COBS decoder working with both irritators
This commit is contained in:
parent
f47a415692
commit
0e22a8d563
|
|
@ -69,7 +69,7 @@ class COBSDecode(wiring.Component):
|
|||
|
||||
m.d.comb += [
|
||||
self.source.data.eq(fifo.r_data),
|
||||
self.source.valid.eq(fifo.r_rdy),
|
||||
self.source.valid.eq(fifo.r_rdy & (fsm.ongoing("IDLE") | (fifo.r_level > 1))),
|
||||
self.source.last.eq(fsm.ongoing("IDLE") & self.source.valid & (fifo.r_level == 1)),
|
||||
fifo.r_en.eq(self.source.valid & self.source.ready),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ async def test_cobs_decode_static(ctx):
|
|||
]
|
||||
|
||||
for data in testcases:
|
||||
await decode_and_compare(ctx, data, tx_irritate=False, rx_irritate=False)
|
||||
await decode_and_compare(ctx, data, tx_irritate=True, rx_irritate=True)
|
||||
|
||||
|
||||
async def decode(ctx, data, tx_irritate, rx_irritate):
|
||||
|
|
@ -54,11 +54,11 @@ async def decode(ctx, data, tx_irritate, rx_irritate):
|
|||
# Feed data to decoder
|
||||
tx_stall = random.randint(0, 1) if tx_irritate else False
|
||||
|
||||
if tx_done:
|
||||
if tx_done or tx_stall:
|
||||
ctx.set(cd.sink.data, 0)
|
||||
ctx.set(cd.sink.valid, 0)
|
||||
|
||||
elif not tx_stall:
|
||||
else:
|
||||
ctx.set(cd.sink.valid, 1)
|
||||
ctx.set(cd.sink.data, data[tx_index])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue