Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/djg/verilated-rs
Verilator Porcelain
https://github.com/djg/verilated-rs
Last synced: 8 days ago
JSON representation
Verilator Porcelain
- Host: GitHub
- URL: https://github.com/djg/verilated-rs
- Owner: djg
- License: apache-2.0
- Created: 2018-03-15T06:26:55.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-11-07T18:25:43.000Z (about 1 year ago)
- Last Synced: 2024-11-01T05:26:02.177Z (15 days ago)
- Language: Rust
- Size: 122 KB
- Stars: 37
- Watchers: 3
- Forks: 15
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# verilated - Verilator Porcelain for Rust
A build dependency for running `verilator` to generate Rust bindings to Verilog code.
## Motivation
## Usage
```toml
# Cargo.toml
[build-dependencies]
verilator = { version = "0.1", features = ["gen", "module"] }
``````rust
// build.rs
extern crate verilator;use verilator::gen::Verilator;
use verilator::module::ModuleGenerator;fn main() {
...
// Generate CPP shim from Rust
ModuleGenerator::new().generate("src/main.rs");
...
// Generate CPP from Verilog, ...
Verilator::new()
.file("rtl/top.v");
// ... and from ModuleGenerator output ...
.file("top.cpp")
// ... compile and link into crate.
.build("top");
}
```## Example
```rust
#![feature(proc_macro)]extern crate verilated;
extern crate verilated_module;
use verilated_module::module;
use verilated::test_bench::TestBench;#[module(top)]
pub struct Top {
#[port(clock)] pub clk_i: bool,
#[port(reset)] pub rst_i: bool,
#[port(output)] pub count_o: [bool; 4],
}fn main() {
let mut tb = TestBench::::init(|core, tick_count| {
if tick_count > 10 {
return false;
}println!("{}: count_o = {}", tick_count, core.count_o());
true
});while !tb.done() {
tb.tick();
}
}
```## License
This project is licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
http://opensource.org/licenses/MIT)at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in verilated-rs by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.