notable restructuring

This commit is contained in:
Yehowshua Immanuel 2022-09-09 02:59:33 -04:00
parent 4c1af97760
commit 320b0d348d
43 changed files with 154 additions and 142 deletions

29
examples/parse_vcd.rs Normal file
View file

@ -0,0 +1,29 @@
use clap::Parser;
use std::fs::File;
use fastwave::*;
use num::{BigUint};
#[derive(Parser)]
struct Cli {
/// The path to the file to read
#[clap(parse(from_os_str))]
path: std::path::PathBuf,
}
fn main() -> std::io::Result<()> {
let args = Cli::parse();
use std::time::Instant;
let now = Instant::now();
let file = File::open(&args.path)?;
let vcd = parse_vcd(file).unwrap();
let elapsed = now.elapsed();
println!("Parsed VCD file {} : {:.2?}", &args.path.as_os_str().to_str().unwrap(), elapsed);
Ok(())
}

34
examples/vcd1.rs Normal file
View file

@ -0,0 +1,34 @@
use clap::Parser;
use std::fs::File;
use fastwave::*;
use num::{BigUint};
fn main() -> std::io::Result<()> {
use std::time::Instant;
let now = Instant::now();
let file_path = "tests/vcd-files/icarus/CPU.vcd";
let file = File::open(file_path).unwrap();
let vcd = parse_vcd(file).unwrap();
let elapsed = now.elapsed();
println!("Parsed VCD file {} : {:.2?}", file_path, elapsed);
// testbench -> CPU -> rs2_data[31:0] @ 4687s
let rs2_data_signal = &vcd.all_signals[51];
let name = rs2_data_signal.name();
let time = BigUint::from(4687u32);
let val = rs2_data_signal
.query_num_val_on_tmln(
&time,
&vcd.tmstmps_encoded_as_u8s,
&vcd.all_signals,
)
.unwrap();
println!("Signal `{name}` has value `{val}` at time `{time}`");
Ok(())
}

34
examples/vcd2.rs Normal file
View file

@ -0,0 +1,34 @@
use clap::Parser;
use std::fs::File;
use fastwave::*;
use num::{BigUint};
fn main() -> std::io::Result<()> {
use std::time::Instant;
let now = Instant::now();
let file_path = "tests/vcd-files/amaranth/up_counter.vcd";
let file = File::open(file_path)?;
let vcd = parse_vcd(file).unwrap();
let elapsed = now.elapsed();
println!("Parsed VCD file {} : {:.2?}", file_path, elapsed);
let state_signal = &vcd.all_signals[4];
let name = state_signal.name();
let time = BigUint::from(57760000u32);
let val = state_signal
.query_string_val_on_tmln(
&time,
&vcd.tmstmps_encoded_as_u8s,
&vcd.all_signals,
)
.unwrap();
println!("Signal `{name}` has value `{val}` at time `{time}`");
Ok(())
}