Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions verilator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@ license = "MIT/Apache-2.0"
repository = "https://github.com/djg/verilated-rs"
homepage = "https://github.com/djg/verilated-rs"
keywords = ["verilator", "verilog"]
categories = ["development-tools::build-utils","development-tools::ffi", "simulation"]
categories = [
"development-tools::build-utils",
"development-tools::ffi",
"simulation",
]
edition = "2021"

[dependencies]
cc = { version = "1.0", optional = true }
fnv = { version = "1.0", optional = true }
glob = "0.3.1"
regex = "1.4"
syn = { version = "0.13", features = ["extra-traits", "full", "visit"], optional = true }
syn = { version = "0.13", features = [
"extra-traits",
"full",
"visit",
], optional = true }

[features]
gen = ["cc"]
Expand Down
29 changes: 18 additions & 11 deletions verilator/src/gen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use verilator_version;
use cc;
use std::fs::read_dir;
use std::io::ErrorKind;
use std::path::{Path, PathBuf};
use std::process::Command;
Expand All @@ -25,7 +25,7 @@ pub struct Verilator {
module_directories: Vec<PathBuf>,
coverage: bool,
trace: bool,
optimized: bool,
optimized: bool,
suppress_warnings: Vec<String>,
}

Expand Down Expand Up @@ -136,9 +136,6 @@ impl Verilator {
let mut cmd = Command::new(verilator_exe.clone());
cmd.arg("--getenv").arg("VERILATOR_ROOT");

// Determine the Verilator version
let (verilator_major, verilator_minor) = verilator_version().unwrap();

println!("running: {:?}", cmd);
let root = match cmd.output() {
Ok(output) => PathBuf::from(String::from_utf8_lossy(&output.stdout).trim()),
Expand Down Expand Up @@ -251,12 +248,22 @@ impl Verilator {
cpp_cfg
.include(root.join("include"))
.include(root.join("include/vltstd"))
.include(&dst)
.file(dst.join(format!("V{}.cpp", top_module)))
.file(dst.join(format!("V{}__Syms.cpp", top_module)));

if verilator_major > 4 || verilator_minor >= 38 {
cpp_cfg.file(dst.join(format!("V{}__Slow.cpp", top_module)));
.include(&dst);

let all_files = read_dir(&dst).map_or(Vec::new(), |read_dir| read_dir.collect());

let extra_modules: Vec<_> = all_files
.iter()
.filter_map(|entry| match entry {
Ok(path) => Some(path.file_name().to_string_lossy().to_string()),
Err(_) => None,
})
.filter(|s| s.starts_with("V") && s.ends_with(".cpp"))
.filter(|s| !s.contains("__Trace.cpp") && !s.contains("__Trace__Slow.cpp"))
.collect();

for module in extra_modules {
cpp_cfg.file(dst.join(module));
}

for &(ref f, _) in &self.files {
Expand Down