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

Lack of support for fractional timescales #24

Closed Lampus closed 2 months ago

Lampus commented 3 years ago

I have VCD file dumped from Cadence Simvision viewer with less than femtosecond timescale:

$comment
TOOL:   simvision(64)   19.03-s012
$end

$date
    Jun 22, 2021 11:14:06
$end

$timescale
    0.001fs
$end

$scope module tb_top $end

Parsing of this file is failed with next error:

Error: Magnitude of timescale must be one of 1, 10, or 100.
Current magnitude is: 0

Used workaround:

...
magnitude = Decimal(re.findall(r"\d+(\.\d+)?|$", timescale)[0])
                if magnitude not in [Decimal('0.001'), 1, 10, 100]:
...
samimia-swks commented 2 months ago

I see the same issue. @cirosantilli can you please apply this fix?

samimia-swks commented 2 months ago

@cirosantilli to clarify, you already removed the error, but the problem is that this regex magnitude = Decimal(re.findall(r"\d+|$", timescale)[0]) fails to parse 0.001fs as 0.001. It results in magnitude = 0 instead.

What @Lampus suggested, i.e. Decimal(re.findall(r"\d+(\.\d+)?|$", timescale)[0]) seems to work

cirosantilli commented 2 months ago

Fixed and released on v2.3.6, let me know if any issues remain with this.