Verilator rules.
Bazel rules for Verilator
Setup
bazel_dep(name = "rules_verilog", version = "{version}")
register_toolchain(
# Define a custom toolchain or use the `rules_verilog` provided toolchain.
"@rules_verilog//verilator/toolchain",
)
Rules
Aspects
verilator_cc_library
load("@rules_verilog//verilator:defs.bzl", "verilator_cc_library")
verilator_cc_library(name, data, linkopts, module)
Compiles a Verilog module to a C++ library using Verilator.
This rule uses an aspect to compile each Verilog module in the dependency tree to C++ object files using Verilator's hierarchical compilation mode, then links them all together into a single static library.
Example:
verilog_library(
name = "my_module",
srcs = ["my_module.sv"],
)
verilator_cc_library(
name = "my_module_cc",
module = ":my_module",
)
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| data | Data used at runtime by the library | List of labels | optional | [] |
| linkopts | List of additional C++ linker flags | List of strings | optional | [] |
| module | The top level Verilog module target to compile with Verilator. | Label | required |
verilator_lint_test
load("@rules_verilog//verilator:defs.bzl", "verilator_lint_test")
verilator_lint_test(name, module)
Test rule that runs Verilator lint on a Verilog module.
This rule runs Verilator in lint-only mode on the specified module and all its transitive dependencies. The test passes if linting succeeds.
Example: verilog_library( name = "my_module", srcs = ["my_module.sv"], )
verilator_lint_test(
name = "my_module_lint_test",
module = ":my_module",
)
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| module | The Verilog module to lint. | Label | required |
verilator_toolchain
load("@rules_verilog//verilator:defs.bzl", "verilator_toolchain")
verilator_toolchain(name, deps, copts, libverilator, linkopts, verilator, vopts)
Define a Verilator toolchain.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | Global Verilator dependencies to link into downstream targets. | List of labels | optional | [] |
| copts | Extra compiler flags to pass when compiling Verilator outputs. | List of strings | optional | [] |
| libverilator | The Verilator library. | Label | required | |
| linkopts | Extra linker flags to pass when linking Verilator outputs. | List of strings | optional | [] |
| verilator | The Verilator binary. | Label | required | |
| vopts | Extra flags to pass to Verilate actions. | List of strings | optional | [] |
verilator_lint_aspect
load("@rules_verilog//verilator:defs.bzl", "verilator_lint_aspect")
verilator_lint_aspect()
Aspect for linting Verilog modules with Verilator.
ASPECT ATTRIBUTES
ATTRIBUTES