Skip to content

Commit

Permalink
[profiler] handle /TestBench/profData hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
FanShupei committed Sep 15, 2024
1 parent 6bb9f60 commit ca69f94
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 0 deletions.
251 changes: 251 additions & 0 deletions profiler/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions profiler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "profiler"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.87"
clap = { version = "4.5.17", features = ["derive"] }
vcd = "0.7.0"
36 changes: 36 additions & 0 deletions profiler/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use std::{fs::File, io::BufReader, path::PathBuf};

use anyhow::anyhow;
use clap::Parser;
use vcd::ScopeItem;

#[derive(Parser)]
struct Cli {
input_vcd: PathBuf,
}

fn main() -> anyhow::Result<()> {
let cli = Cli::parse();

let input = File::open(cli.input_vcd)?;

let mut input = vcd::Parser::new(BufReader::new(input));
let header = input.parse_header()?;

let prof_data = header
.find_scope(&["TestBench", "profData"])
.ok_or_else(|| anyhow!("can not find scope /TestBench/profData"))?;

for item in &prof_data.items {
match item {
ScopeItem::Var(var) => {
let name = &var.reference;
let width = var.size;
println!("- {name} : bit({width})");
}
_ => {}
}
}

Ok(())
}

0 comments on commit ca69f94

Please sign in to comment.