Skip to content

Commit

Permalink
[build] add build script
Browse files Browse the repository at this point in the history
  • Loading branch information
Clo91eaf committed Apr 29, 2024
1 parent d240fda commit 418dc33
Show file tree
Hide file tree
Showing 6 changed files with 2,185 additions and 40,151 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "verilator"]
path = verilator
[submodule "dependencies/verilated-rs"]
path = dependencies/verilated-rs
url = [email protected]:Anillc/verilated-rs.git
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ edition = "2021"
build = "build.rs"

[dependencies]
verilated = { path = "./verilator/verilated" }
verilated-module = { path = "./verilator/verilated-module" }
verilated = { path = "./dependencies/verilated-rs/verilated" }
verilated-module = { path = "./dependencies/verilated-rs/verilated-module" }
clap = { version = "4.3.11", features = ["derive"] }
anyhow = "1.0.80"

[build-dependencies]
verilator = { path = "./verilator/verilator", features = ["gen", "module"] }
verilator = { path = "./dependencies/verilated-rs/verilator", features = ["gen", "module"] }
25 changes: 9 additions & 16 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,13 @@ fn main() {

// Generate CPP from Verilog
let mut verilator = Verilator::default();

let dir = Path::new("myCPU");
let files: Vec<_> = fs::read_dir(dir)
.expect("Directory not found")
.filter_map(|entry| entry.ok().and_then(|e| e.path().to_str().map(|s| String::from(s))))
.collect();

println!("Files: {:?}", files);

verilator.with_coverage(true).with_trace(true);

for file in &files {
verilator.file_with_standard(file, Standard::Verilog2005);
}

verilator.file(out_dir.join("mycpu_top.cpp")).build("mycpu_top");
verilator
.with_coverage(true)
.with_trace(true)
.no_warn("fatal")
.no_warn("WIDTHTRUNC")
.file_with_standard("dependencies/rtl/PuaCpu.v", Standard::SystemVerilog2012)
.file_with_standard("dependencies/rtl/top.v", Standard::SystemVerilog2012)
.file(out_dir.join("top.cpp"))
.build("top");
}
Loading

0 comments on commit 418dc33

Please sign in to comment.