From f4e27ffcb67cba8c90f40241c2e254fec28f5ca8 Mon Sep 17 00:00:00 2001 From: Yehowshua Immanuel Date: Fri, 2 Sep 2022 17:00:14 -0400 Subject: [PATCH] - improve to-do list in README - move code that exercises searching for values at specific time within signals from src/vcd/parse.rs to sr/vcd/main.rs - make necessary struct and enum fields public as well as possibly the structs and enums themselves --- README.md | 14 ++++++++++---- src/main.rs | 25 ++++++++++++++++++++++--- src/vcd.rs | 2 +- src/vcd/parse.rs | 16 ---------------- src/vcd/signal.rs | 6 +++--- src/vcd/types.rs | 6 +++--- 6 files changed, 39 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 55d7f90..14111b6 100644 --- a/README.md +++ b/README.md @@ -68,14 +68,20 @@ Here's a command to test on a malformed VCD: # TODO ## Features and Other - - [ ] add timeline value scanner code - - [ ] test against large waveform directly within SpinalHDL + - [ ] add documenting comments + - [ ] add lz4 compression support and compare memory perf before and after + - [ ] add string support for timeline value scanner + - [ ] test against large waveforms from the + [verilog-vcd-parser](https://github.com/ben-marshall/verilog-vcd-parser) + tool - [ ] (a bit of work) consolidate error messages in validation phase + - [ ] once the access patterns of the GUI frontend are well understood, + create specific functions and restrict as many types to private + as possible - [ ] be explicit with imports, remove exports as possible once FastWave is known to be fairly stable. - - [ ] do a read through all the code - - make contents of src/types.rs public as necessary. - [ ] Print out git commit or release number. + - [ ] do a read through all the code - look for uneeded code - [ ] Take a look at GTKWave parser to compare efficiency. - [ ] Move part of the performance section to another markdown file. diff --git a/src/main.rs b/src/main.rs index 2f82089..97bc5c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,9 @@ use std::fs::File; pub mod test; pub mod vcd; -use vcd::parse_vcd; +use vcd::*; + +use num::BigUint; #[derive(Parser)] struct Cli { @@ -20,12 +22,29 @@ fn main() -> std::io::Result<()> { let now = Instant::now(); let file = File::open(&args.path)?; - parse_vcd(file).unwrap(); + let vcd = parse_vcd(file).unwrap(); let elapsed = now.elapsed(); println!("Elapsed: {:.2?}", elapsed); - // std::thread::sleep(std::time::Duration::from_secs(10)); + // the following is really only for test-vcd-files/icarus/CPU.vcd + // at the moment + if args.path.as_os_str().to_str().unwrap() == "test-vcd-files/icarus/CPU.vcd" { + let signal = &vcd.all_signals[51]; + let name = match signal { + Signal::Data { name, .. } => name, + _ => "ERROR", + }; + let val = signal + .query_num_val_on_tmln( + BigUint::from(4687u32), + &vcd.tmstmps_encoded_as_u8s, + &vcd.all_signals, + ) + .unwrap(); + dbg!(format!("{val:#X}")); + dbg!(name); + } Ok(()) } diff --git a/src/vcd.rs b/src/vcd.rs index b245601..029b934 100644 --- a/src/vcd.rs +++ b/src/vcd.rs @@ -8,7 +8,7 @@ mod parse; pub use parse::*; mod signal; -use signal::*; +pub use signal::*; mod utilities; use utilities::*; diff --git a/src/vcd/parse.rs b/src/vcd/parse.rs index 5260604..c7a500d 100644 --- a/src/vcd/parse.rs +++ b/src/vcd/parse.rs @@ -39,20 +39,6 @@ pub fn parse_vcd(file: File) -> Result { parse_scopes(&mut word_gen, &mut vcd, &mut signal_map)?; parse_events(&mut word_gen, &mut vcd, &mut signal_map)?; - let signal = vcd.try_dereference_alias(signal_map.get("Q").unwrap())?; - let name = match signal { - Signal::Data { name, .. } => name, - _ => "ERROR", - }; - let val = signal - .query_num_val_on_tmln( - BigUint::from(4687u32), - &vcd.tmstmps_encoded_as_u8s, - &vcd.all_signals, - ) - .unwrap(); - dbg!(format!("{val:#X}")); - dbg!(name); Ok(vcd) } @@ -93,8 +79,6 @@ mod tests { dbg!(file_name); vcd.unwrap(); } - - // assert!(vcd.is_ok()); } } } diff --git a/src/vcd/signal.rs b/src/vcd/signal.rs index 5582182..7cc91cc 100644 --- a/src/vcd/signal.rs +++ b/src/vcd/signal.rs @@ -7,7 +7,7 @@ use num::{BigUint, Zero}; pub struct LsbIdxOfTmstmpValOnTmln(pub(super) u32); #[derive(Debug)] -pub(super) enum SigType { +pub enum SigType { Integer, Parameter, Real, @@ -25,7 +25,7 @@ pub(super) enum TimelineQueryResults { } #[derive(Debug)] -pub(super) enum Signal { +pub enum Signal { Data { name: String, sig_type: SigType, @@ -69,7 +69,7 @@ pub(super) enum Signal { } #[derive(Debug)] -pub(super) enum SignalErrors { +pub enum SignalErrors { PreTimeline { desired_time: BigUint, timeline_start_time: BigUint, diff --git a/src/vcd/types.rs b/src/vcd/types.rs index 6a48e4d..edfc79b 100644 --- a/src/vcd/types.rs +++ b/src/vcd/types.rs @@ -24,10 +24,10 @@ pub(super) struct Metadata { // We do a lot of arena allocation in this codebase. #[derive(Debug, Copy, Clone)] -pub(super) struct ScopeIdx(pub(super) usize); +pub struct ScopeIdx(pub(super) usize); #[derive(Debug, Copy, Clone, PartialEq)] -pub(super) struct SignalIdx(pub(super) usize); +pub struct SignalIdx(pub(super) usize); #[derive(Debug)] pub(super) struct Scope { @@ -54,7 +54,7 @@ pub struct VCD { // keep track of all timestamp values, a given signal only needs to keep // track of the timestamps at which the given signal value changes. pub tmstmps_encoded_as_u8s: Vec, - pub(super) all_signals: Vec, + pub all_signals: Vec, pub(super) all_scopes: Vec, pub(super) root_scopes: Vec, }