tb: Fix incorrect valid in send_recovered_bits

At the end of the bitstream, we might not have enough bits for valid=2.
If we don't change it to valid=1, instead of marking an X as valid.

Fixes: d351291 ("Initial commit")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
This commit is contained in:
Sean Anderson 2022-08-24 12:18:39 -04:00
parent 6800b85a85
commit 15ae994ad6
1 changed files with 3 additions and 1 deletions

View File

@ -90,11 +90,11 @@ class saw_valid:
return self.last return self.last
async def send_recovered_bits(clk, data, valid, bits, valids): async def send_recovered_bits(clk, data, valid, bits, valids):
bits = iter(bits)
await FallingEdge(clk) await FallingEdge(clk)
try: try:
while True: while True:
v = valids() v = valids()
valid.value = v
if v == 0: if v == 0:
d = 'XX' d = 'XX'
elif v == 1: elif v == 1:
@ -105,8 +105,10 @@ async def send_recovered_bits(clk, data, valid, bits, valids):
second = next(bits) second = next(bits)
except StopIteration: except StopIteration:
second = 'X' second = 'X'
v = 1
d = (first, second) d = (first, second)
data.value = LogicArray(d) data.value = LogicArray(d)
valid.value = v
await FallingEdge(clk) await FallingEdge(clk)
except StopIteration: except StopIteration:
pass pass