diff --git a/README.md b/README.md index 18f1415..105415f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ Copyright - Yehowshua Immanuel # Status -July 25 2023: Haven't worked on this in a while. It seems the Zoq is now pushing forward on this codebase. -Check out his frontend here: https://app.surfer-project.org/ (code at https://gitlab.com/surfer-proj/surfer ) +July 25 2022: Haven't worked on this in a while. It seems the Zoq is now pushing forward on this codebase. +Check out his frontend here: https://gitlab.com/TheZoq2/surfer # A High performance, VCD Parser written in Rust diff --git a/src/vcd/parse/events.rs b/src/vcd/parse/events.rs index 2246d15..1a75e73 100644 --- a/src/vcd/parse/events.rs +++ b/src/vcd/parse/events.rs @@ -96,7 +96,11 @@ pub(super) fn parse_events<'a, R: std::io::Read>( Err( BinaryParserErrTypes::XValue | BinaryParserErrTypes::ZValue - | BinaryParserErrTypes::UValue, + | BinaryParserErrTypes::UValue + | BinaryParserErrTypes::WValue + | BinaryParserErrTypes::HValue + | BinaryParserErrTypes::DashValue + | BinaryParserErrTypes::LValue, ) => { store_as_string = true; value_string = binary_value.to_string(); @@ -408,7 +412,7 @@ pub(super) fn parse_events<'a, R: std::io::Read>( } // // other one bit cases - "x" | "X" | "z" | "Z" | "u" | "U" => { + "x" | "X" | "z" | "Z" | "u" | "U" | "h" | "H" | "l" | "L" | "w" | "W" | "-" => { let val = word.to_string(); // lokup signal idx let hash = &word[1..]; diff --git a/src/vcd/parse/metadata.rs b/src/vcd/parse/metadata.rs index 126a334..b908403 100644 --- a/src/vcd/parse/metadata.rs +++ b/src/vcd/parse/metadata.rs @@ -2,7 +2,7 @@ // This program is distributed under both the GPLV3 license // and the YEHOWSHUA license, both of which can be found at // the root of the folder containing the sources for this program. -use chrono::prelude::{DateTime, Utc}; +use chrono::prelude::{DateTime, Utc, TimeZone}; use itertools::Itertools; use super::super::reader::{Cursor, WordReader, next_word}; @@ -133,9 +133,9 @@ pub(super) fn parse_date( // unfortunately, the minutes, seconds, and hour could occur in an // unexpected order let full_date = format!("{day} {month} {date} {hh}:{mm}:{ss} {year}"); - let full_date = DateTime::parse_from_str(full_date.as_str(), "%a %b %e %T %Y"); + let full_date = Utc.datetime_from_str(full_date.as_str(), "%a %b %e %T %Y"); if full_date.is_ok() { - return Ok(full_date.unwrap().into()); + return Ok(full_date.unwrap()); } Err(format!( diff --git a/src/vcd/parse/scopes.rs b/src/vcd/parse/scopes.rs index 6a0f28c..c60deda 100644 --- a/src/vcd/parse/scopes.rs +++ b/src/vcd/parse/scopes.rs @@ -386,7 +386,7 @@ pub(super) fn parse_scopes<'a, R: std::io::Read>( ident(word_reader, "$end")?; break; } - "$comment" => { + "comment" => { // although we don't store comments, we still need to advance the // word_reader cursor to the end of the comment loop { diff --git a/src/vcd/utilities.rs b/src/vcd/utilities.rs index 3fb5122..0f3e246 100644 --- a/src/vcd/utilities.rs +++ b/src/vcd/utilities.rs @@ -7,6 +7,10 @@ pub(super) enum BinaryParserErrTypes { XValue, ZValue, UValue, + HValue, + LValue, + DashValue, + WValue, OtherValue(char), TooLong, } @@ -39,6 +43,10 @@ fn base2_str_to_byte(word: &[u8]) -> Result { b'x' | b'X' => return Err(BinaryParserErrTypes::XValue), b'z' | b'Z' => return Err(BinaryParserErrTypes::ZValue), b'u' | b'U' => return Err(BinaryParserErrTypes::UValue), + b'l' | b'L' => return Err(BinaryParserErrTypes::LValue), + b'h' | b'H' => return Err(BinaryParserErrTypes::HValue), + b'w' | b'W' => return Err(BinaryParserErrTypes::WValue), + b'-' => return Err(BinaryParserErrTypes::DashValue), _ => return Err(BinaryParserErrTypes::OtherValue(*chr as char)), } } diff --git a/tests/files.rs b/tests/files.rs index 7832a85..f5d2ac3 100644 --- a/tests/files.rs +++ b/tests/files.rs @@ -5,7 +5,7 @@ // TODO: we should eventually be able to only test on just // the files const -pub const FILES : [&str; 31] = [ +pub const FILES : [&str; 30] = [ "./tests/vcd-files/aldec/SPI_Write.vcd", "./tests/vcd-files/ghdl/alu.vcd", "./tests/vcd-files/ghdl/idea.vcd", @@ -36,8 +36,7 @@ pub const FILES : [&str; 31] = [ "./tests/vcd-files/xilinx_isim/test.vcd", "./tests/vcd-files/xilinx_isim/test1.vcd", // TODO : add signal ignore list to handle bitwidth mismatches - "./tests/vcd-files/xilinx_isim/test2x2_regex22_string1.vcd", - "./tests/vcd-files/scope_with_comment.vcd", + "./tests/vcd-files/xilinx_isim/test2x2_regex22_string1.vcd" ]; pub const GOOD_DATE_FILES : [&str; 24] = [ @@ -74,4 +73,4 @@ pub const BAD_DATE_FILES : [&str; 6] = [ "./test-vcd-files/systemc/waveform.vcd", "./test-vcd-files/treadle/GCD.vcd", "./test-vcd-files/vivado/iladata.vcd", -]; +]; \ No newline at end of file diff --git a/tests/vcd-files/scope_with_comment.vcd b/tests/vcd-files/scope_with_comment.vcd deleted file mode 100644 index cf17910..0000000 --- a/tests/vcd-files/scope_with_comment.vcd +++ /dev/null @@ -1,296 +0,0 @@ -$date - Sat Dec 26 15:33:14 2020 -$end -$version - ModelSim Version 10.5b -$end -$timescale - 1ns -$end - -$scope module clkdiv2n_tb $end -$comment foo $end -$var reg 1 ! clk $end -$var reg 1 " reset $end -$var wire 1 # clk_out $end - -$scope module t1 $end -$var parameter 32 $ WIDTH $end -$var parameter 32 % N $end -$var wire 1 & clk $end -$var wire 1 ' reset $end -$var wire 1 # clk_out $end -$var reg 3 ( r_reg [2:0] $end -$var wire 1 ) r_nxt [2] $end -$var wire 1 * r_nxt [1] $end -$var wire 1 + r_nxt [0] $end -$var reg 1 , clk_track $end -$upscope $end -$comment foo $end -$upscope $end -$comment foo $end -$enddefinitions $end -#0 -$comment foo $end -$dumpvars -0! -x" -bx ( -x, -b11 $ -b110 % -x# -x+ -x* -x) -x' -0& -$end -#5 -1" -1' -b0 ( -0, -1+ -0* -0) -0# -#10 -1! -1& -#15 -0" -0' -#20 -0! -0& -#30 -1! -1& -b1 ( -0+ -1* -#40 -0! -0& -#50 -1! -1& -b10 ( -1+ -#60 -0! -0& -#70 -1! -1& -b11 ( -0+ -0* -1) -#80 -0! -0& -#90 -1! -1& -b100 ( -1+ -#100 -0! -0& -#110 -1! -1& -b101 ( -0+ -1* -#120 -0! -0& -#130 -1! -1& -b0 ( -1, -1+ -0* -0) -1# -#140 -0! -0& -#150 -1! -1& -b1 ( -0+ -1* -#160 -0! -0& -#170 -1! -1& -b10 ( -1+ -#180 -0! -0& -#190 -1! -1& -b11 ( -0+ -0* -1) -#200 -0! -0& -#210 -1! -1& -b100 ( -1+ -#220 -0! -0& -#230 -1! -1& -b101 ( -0+ -1* -#240 -0! -0& -#250 -1! -1& -b0 ( -0, -1+ -0* -0) -0# -#260 -0! -0& -#270 -1! -1& -b1 ( -0+ -1* -#280 -0! -0& -#290 -1! -1& -b10 ( -1+ -#300 -0! -0& -#310 -1! -1& -b11 ( -0+ -0* -1) -#320 -0! -0& -#330 -1! -1& -b100 ( -1+ -#340 -0! -0& -#350 -1! -1& -b101 ( -0+ -1* -#360 -0! -0& -#370 -1! -1& -b0 ( -1, -1+ -0* -0) -1# -#380 -0! -0& -#390 -1! -1& -b1 ( -0+ -1* -#400 -0! -0& -#410 -1! -1& -b10 ( -1+ -#420 -0! -0& -#430 -1! -1& -b11 ( -0+ -0* -1) -#440 -0! -0& -#450 -1! -1& -b100 ( -1+ -#460 -0! -0& -#470 -1! -1& -b101 ( -0+ -1* -#480 -0! -0& -#490 -1! -1& -b0 ( -0, -1+ -0* -0) -0# -#500 -0! -0& -#510 -1! -1& -b1 ( -0+ -1*