cirosantilli / vcdvcd

Python Verilog value change dump (VCD) parser library + the nifty vcdcat VCD command line pretty printer.
Other
56 stars 22 forks source link

TypeError: '<' not supported between instances of 'int' and 'str' #11

Closed leonardt closed 4 years ago

leonardt commented 4 years ago

Hi there, thanks for you great work on this package.

After upgrading to 2.0.0 I'm seeing a regression where some old code that used to work is now producing this error:

Traceback (most recent call last):
  File "test.py", line 7, in <module>
    tvs = next(iter(vcd.get_data().values()))["tv"]
  File ".../lib/python3.8/site-packages/vcdvcd/vcdvcd.py", line 267, in __getitem__
    left = bisect.bisect_left(self.tv, (time, ''))
TypeError: '<' not supported between instances of 'int' and 'str'

Here's the steps to reproduce:

# test.py
from vcdvcd import VCDVCD

vcd = VCDVCD("SimpleALU.vcd", signals=["TOP.CLK"])
# One elem dict, we can grab the first element
tvs = next(iter(vcd.get_data().values()))["tv"]
assert tvs == [(0, '0'), (5, '1'), (10, '0')]

vcd file (need to remove .txt, just added so I can upload to GH Issues) SimpleALU.vcd.txt

cirosantilli commented 4 years ago

Lenny, thanks for the ticket.

I've tested it like this, and it seems to work:

from vcdvcd import VCDVCD

vcd = VCDVCD("SimpleALU.vcd", signals=["TOP.CLK"])
tvs = vcd["TOP.CLK"].tv
assert tvs == [(0, '0'), (5, '1'), (10, '0')]

can you check that it meets your needs?

I broke the API a bit (thus major version bump ;-)) but hopefully things are a bit saner now.

I've also added a bit more explicit info at https://github.com/cirosantilli/vcdvcd/tree/85ecead53c4673a32bc9603d227613b42efae118#api-usage now.

leonardt commented 4 years ago

yes, that works and is a much cleaner API, nice work, thanks!