New parser #2
27
src/main.rs
27
src/main.rs
|
@ -13,33 +13,8 @@ struct Cli {
|
|||
fn main() -> std::io::Result<()> {
|
||||
let args = Cli::parse();
|
||||
|
||||
let file = File::open(&args.path)?;
|
||||
// dbg!(take_while("01234hello", digit));
|
||||
|
||||
// dbg!(["hello", "goodbye", "myworld"].contains(&"myworlde"));
|
||||
// let mut word_gen = WordReader::new(file);
|
||||
// let mut word_count = 0;
|
||||
|
||||
// while word_gen.next_word().is_some() {
|
||||
// word_count += 1;
|
||||
// }
|
||||
// dbg!(word_count);
|
||||
|
||||
// let word1 = "hello world";
|
||||
// let word2 = "hello planet";
|
||||
// dbg!(&word1[0..6].len());
|
||||
let file = File::open(&args.path)?;
|
||||
parse_vcd(file);
|
||||
|
||||
// tag("my oh my");
|
||||
|
||||
|
||||
// loop {
|
||||
// let word = word_gen.next_word();
|
||||
// if word.is_none() {break};
|
||||
|
||||
// dbg!(word.unwrap());
|
||||
// }
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -284,6 +284,7 @@ fn parse_timescale(word_reader : &mut WordReader) -> Result<(Option<u32>, Timesc
|
|||
if residual == "" {
|
||||
let (word, cursor) = word_reader.next_word().ok_or(&err_msg)?;
|
||||
let unit = match word {
|
||||
"fs" => {Ok(Timescale::fs)}
|
||||
"ps" => {Ok(Timescale::ps)}
|
||||
"ns" => {Ok(Timescale::ns)}
|
||||
"us" => {Ok(Timescale::us)}
|
||||
|
@ -437,3 +438,56 @@ pub fn parse_vcd(file : File) {
|
|||
let header = parse_metadata(&mut word_gen).unwrap();
|
||||
dbg!(header);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::fs::File;
|
||||
#[test]
|
||||
fn headers() {
|
||||
let files = vec![
|
||||
"./test-vcd-files/aldec/SPI_Write.vcd",
|
||||
"./test-vcd-files/ghdl/alu.vcd",
|
||||
"./test-vcd-files/ghdl/idea.vcd",
|
||||
"./test-vcd-files/ghdl/pcpu.vcd",
|
||||
"./test-vcd-files/gtkwave-analyzer/perm_current.vcd",
|
||||
"./test-vcd-files/icarus/CPU.vcd",
|
||||
"./test-vcd-files/icarus/rv32_soc_TB.vcd",
|
||||
"./test-vcd-files/icarus/test1.vcd",
|
||||
"./test-vcd-files/model-sim/CPU_Design.msim.vcd",
|
||||
"./test-vcd-files/model-sim/clkdiv2n_tb.vcd",
|
||||
"./test-vcd-files/my-hdl/Simple_Memory.vcd",
|
||||
"./test-vcd-files/my-hdl/sigmoid_tb.vcd",
|
||||
"./test-vcd-files/my-hdl/top.vcd",
|
||||
// "./test-vcd-files/ncsim/ffdiv_32bit_tb.vcd",
|
||||
// "./test-vcd-files/quartus/mipsHardware.vcd",
|
||||
// "./test-vcd-files/quartus/wave_registradores.vcd",
|
||||
"./test-vcd-files/questa-sim/dump.vcd",
|
||||
"./test-vcd-files/questa-sim/test.vcd",
|
||||
"./test-vcd-files/riviera-pro/dump.vcd",
|
||||
// "./test-vcd-files/systemc/waveform.vcd",
|
||||
// "./test-vcd-files/treadle/GCD.vcd",
|
||||
"./test-vcd-files/vcs/Apb_slave_uvm_new.vcd",
|
||||
"./test-vcd-files/vcs/datapath_log.vcd",
|
||||
"./test-vcd-files/vcs/processor.vcd",
|
||||
"./test-vcd-files/verilator/swerv1.vcd",
|
||||
"./test-vcd-files/verilator/vlt_dump.vcd",
|
||||
// "./test-vcd-files/vivado/iladata.vcd",
|
||||
"./test-vcd-files/xilinx_isim/test.vcd",
|
||||
"./test-vcd-files/xilinx_isim/test1.vcd",
|
||||
"./test-vcd-files/xilinx_isim/test2x2_regex22_string1.vcd"
|
||||
];
|
||||
|
||||
for file in files {
|
||||
let metadata = parse_metadata(
|
||||
&mut WordReader::new(
|
||||
File::open(file)
|
||||
.unwrap()
|
||||
)
|
||||
);
|
||||
assert!(metadata.is_ok());
|
||||
assert!(metadata.unwrap().date.is_some());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ use num::BigInt;
|
|||
pub(super) struct Version(pub String);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) enum Timescale {ps, ns, us, ms, s, unit}
|
||||
pub(super) enum Timescale {fs, ps, ns, us, ms, s, unit}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct Metadata {
|
||||
|
|
Loading…
Reference in a new issue