A value change dump parser for the Rust programming language.
The goal for this project is to parse VCD files into a similar data structure as yaml-cpp does for YAML files, create understandable data structure representations of a VCD file, and provide clear error messages if parsing fails.
Value change dump is a file format specifying how a digital waveform appears. It's mainly used for digital waveform viewers, among other electronic design automation (EDA) tools. You can read more about it on it's Wikipedia article.
The below file example is a simplified version of the file on the
VCD Wikipedia article.
Given this file named example.vcd
with the contents:
```
$date August 9th, 2020 $end
$version 1.0 $end
$comment This is an example $end
$timescale 1 ps $end
$scope module top $end
$var wire 8 # data $end
$upscope $end
$enddefinitions $end
$dumpvars
bxxxxxxxx #
$end
b10000001 #
b10101010 # ```
This file can be parsed with the load_from_file()
method:
```rust extern crate vcdrust; use vcdrust::{loadfromfile, types::timescale::{TimeScale, TimeUnit}};
fn main() { let vcd = loadfromfile("example.vcd").unwrap(); asserteq!(vcd.date, "August 9th, 2020"); // Date asserteq!(vcd.version, "1.0"); // Version asserteq!(vcd.comments, vec!["This is an example"]); // Comments as a vector asserteq!(vcd.timescale, TimeScale::init(1, TimeUnit::PS)); // Custom type for timescale // ...among other data structures } ```
Likewise, the string representation of a VCD file can be parsed with the load_from_string()
method:
```rust extern crate vcdrust; use vcdrust::{loadfromstring, vcd::VCD};
fn parsevcdstring() -> VCD { let vcdstring = "$date August 9th, 2020 $end..."; // etc. return loadfromstring(vcdstring).unwrap(); } ```