ekiwi / wellen

wellen: waveform datastructures in Rust. Fast VCD, FST and GHW parsing for waveform viewers.
BSD 3-Clause "New" or "Revised" License
35 stars 6 forks source link

Panic when trying to load (invalid) file with spaces between bit value and wire ID #18

Open andreasWallner opened 1 week ago

andreasWallner commented 1 week ago

Wellen panics when trying to load a (admittedly invalid) vcd file that contains spaces on single-bit lines in the file.

Reproduced with surfer using this vcd:

$version Generated manually $end
$timescale 1s $end

 $scope module logic $end
  $var wire  8 # data [7:0] $end
  $var wire  1 $ data_valid $end
 $upscope $end
$enddefinitions $end

#0
b00000011 #
1 $
#10
b11000011 #
#20
0 $
#30
b00111100 #
1 $
#40

which the panic:

thread '<unnamed>' panicked at /home/uhu01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wellen-0.9.14/src/vcd.rs:979:51:
called `Option::unwrap()` on a `None` value

I would expect an error message instead of the panic.

ekiwi commented 1 week ago

Thanks! I will try to figure out how to handle this more gracefully. Have you encountered this problem with any tool that produces VCDs? Does this load in GTKWave? I am trying to decide whether we should try to parse this, even if it is technically wrong, or if it is enough to just not crash and return an error instead.

andreasWallner commented 1 week ago

It was from a hand-written VCD that I typed up for testing Surfer... I don't think there is much reason to support this, gtkwave silently fails to load it

ekiwi commented 1 week ago

OK. Thanks! Sounds like the goal here is to return an error instead of crashing.

JabulaniNgcobo commented 21 hours ago

18