Skip to content

Commit

Permalink
Include all cpp files generated by verilator
Browse files Browse the repository at this point in the history
Fixes djg#9. Might not always work, but it does for the current example. Tested with verilator 4.222.
  • Loading branch information
cchalmers committed Aug 20, 2022
1 parent 7755bb7 commit 8918199
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions verilator/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::io::ErrorKind;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::{env, fs};
use verilator_version;

#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Standard {
Expand Down Expand Up @@ -137,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 @@ -252,12 +248,13 @@ 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)));
.include(&dst);

if verilator_major > 4 || verilator_minor >= 38 {
cpp_cfg.file(dst.join(format!("V{}__Slow.cpp", top_module)));
for entry in std::fs::read_dir(&dst).unwrap() {
let path = entry.unwrap().path();
if path.extension() == Some(std::ffi::OsStr::new("cpp")) {
cpp_cfg.file(path);
}
}

for &(ref f, _) in &self.files {
Expand All @@ -275,9 +272,7 @@ impl Verilator {

if self.trace {
cpp_cfg
.define("VM_TRACE", "1")
.file(dst.join(format!("V{}__Trace.cpp", top_module)))
.file(dst.join(format!("V{}__Trace__Slow.cpp", top_module)));
.define("VM_TRACE", "1");
}

cpp_cfg.compile(&format!("V{}__ALL", top_module));
Expand Down

0 comments on commit 8918199

Please sign in to comment.