From c0d245c0e5445ed20d9b9eb4e224cef61102a7af Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Wed, 6 Sep 2023 12:53:38 +0200 Subject: [PATCH 1/4] Update README with more information about surfer --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 105415f..18f1415 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ Copyright - Yehowshua Immanuel # Status -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 +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 ) # A High performance, VCD Parser written in Rust -- 2.47.1 From 73332179ee387bdb341f4d9f0ba6d71d8bb10709 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Wed, 6 Sep 2023 13:02:02 +0200 Subject: [PATCH 2/4] Replace deprecated method --- src/vcd/parse/metadata.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vcd/parse/metadata.rs b/src/vcd/parse/metadata.rs index b908403..126a334 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, TimeZone}; +use chrono::prelude::{DateTime, Utc}; 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 = Utc.datetime_from_str(full_date.as_str(), "%a %b %e %T %Y"); + let full_date = DateTime::parse_from_str(full_date.as_str(), "%a %b %e %T %Y"); if full_date.is_ok() { - return Ok(full_date.unwrap()); + return Ok(full_date.unwrap().into()); } Err(format!( -- 2.47.1 From 03705f263d554ce1ba5c4b5a650c821b5e8438d5 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Wed, 13 Sep 2023 14:18:18 +0200 Subject: [PATCH 3/4] Allow comments in scope (fix typo) --- src/vcd/parse/scopes.rs | 2 +- tests/files.rs | 7 +- tests/vcd-files/scope_with_comment.vcd | 296 +++++++++++++++++++++++++ 3 files changed, 301 insertions(+), 4 deletions(-) create mode 100644 tests/vcd-files/scope_with_comment.vcd diff --git a/src/vcd/parse/scopes.rs b/src/vcd/parse/scopes.rs index c60deda..6a0f28c 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/tests/files.rs b/tests/files.rs index f5d2ac3..7832a85 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; 30] = [ +pub const FILES : [&str; 31] = [ "./tests/vcd-files/aldec/SPI_Write.vcd", "./tests/vcd-files/ghdl/alu.vcd", "./tests/vcd-files/ghdl/idea.vcd", @@ -36,7 +36,8 @@ pub const FILES : [&str; 30] = [ "./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/xilinx_isim/test2x2_regex22_string1.vcd", + "./tests/vcd-files/scope_with_comment.vcd", ]; pub const GOOD_DATE_FILES : [&str; 24] = [ @@ -73,4 +74,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 new file mode 100644 index 0000000..cf17910 --- /dev/null +++ b/tests/vcd-files/scope_with_comment.vcd @@ -0,0 +1,296 @@ +$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* -- 2.47.1 From a7537206e2ede4173b5ed637dbf0c701ed42f933 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Wed, 20 Sep 2023 14:50:16 +0200 Subject: [PATCH 4/4] Add support for VHDL std_ulogic --- src/vcd/parse/events.rs | 8 ++++++-- src/vcd/utilities.rs | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) 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/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)), } } -- 2.47.1