MCPcopy Index your code
hub / github.com/djg/verilated-rs

github.com/djg/verilated-rs @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
123 symbols 199 edges 12 files 43 documented · 35%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

verilated - Verilator Porcelain for Rust

A build dependency for running verilator to generate Rust bindings to Verilog code.

Motivation

Usage

# Cargo.toml
[build-dependencies]
verilator = { version = "0.1", features = ["gen", "module"] }
// 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

#![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::<Top>::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 or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (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.

Core symbols most depended-on inside this repo

file
called by 10
verilator/src/gen.rs
list_contains_name
called by 5
verilator/src/module.rs
fail
called by 4
verilator/src/gen.rs
getenv_unwrap
called by 3
verilator/src/gen.rs
fail
called by 2
verilated/build.rs
target
called by 2
verilator/src/module.rs
is_public
called by 2
verilator/src/module.rs
verilator_version
called by 2
verilator/src/lib.rs

Shape

Function 78
Method 33
Class 8
Enum 4

Languages

Rust69%
C++31%

Modules by API surface

verilator/src/module.rs30 symbols
verilated/src/verilated_shim.cpp27 symbols
verilator/src/gen.rs22 symbols
verilated/src/verilatedvcdc_shim.cpp11 symbols
verilated/src/vcd.rs11 symbols
verilated/src/api.rs11 symbols
verilator/src/lib.rs4 symbols
verilated/build.rs3 symbols
example/src/main.rs2 symbols
verilated-module/src/lib.rs1 symbols
example/build.rs1 symbols

For agents

$ claude mcp add verilated-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact