SystemRDL rules.
Bazel rules for SystemRDL
Setup
bazel_dep(name = "rules_verilog", version = "{version}")
register_toolchain(
# Define a custom toolchain or use the `rules_verilog` provided toolchain.
"@rules_verilog//system_rdl/toolchain",
)
Rules
Providers
system_rdl_library
load("@rules_verilog//system_rdl:defs.bzl", "system_rdl_library")
system_rdl_library(name, deps, srcs, exporter_args, root)
A SystemRDL library.
Outputs of these rules are generally extracted via a filegroup.
load("@rules_verilog//system_rdl:system_rdl_library.bzl", "system_rdl_library")
system_rdl_library(
name = "atxmega_spi",
srcs = ["atxmega_spi.rdl"],
exporter_args = {
"regblock": [
"--cpuif",
"axi4-lite-flat",
],
},
)
filegroup(
name = "atxmega_spi.sv",
srcs = ["atxmega_spi"],
output_group = "system_rdl_regblock",
)
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | Additional system_rdl_library dependencies. | List of labels | optional | [] |
| srcs | Source files which define the entire SystemRDL dag. | List of labels | required | |
| exporter_args | A mapping of exporter names to arguments. | Dictionary: String -> List of strings | optional | {} |
| root | The top source file of the SystemRDL library. | Label | optional | None |
system_rdl_toolchain
load("@rules_verilog//system_rdl:defs.bzl", "system_rdl_toolchain")
system_rdl_toolchain(name, exporter_args, exporters, peakrdl, peakrdl_config)
A SystemRDL toolchain.
Plugins:
Additional exporters
are supported via a combination of the peakrdl and peakrdl_config attributes.
load("@rules_venv//python:py_library.bzl", "py_library")
load("//system_rdl:system_rdl_toolchain.bzl", "system_rdl_toolchain")
py_library(
name = "peakrdl_toml",
srcs = ["peakrdl_toml.py"],
deps = [
"@pip_deps//peakrdl",
"@pip_deps//tomli",
],
)
PLUGINS = [
":peakrdl_toml
]
py_library(
name = "peakrdl",
deps = [
"@pip_deps//peakrdl",
] + PLUGINS,
)
system_rdl_toolchain(
name = "system_rdl_toolchain",
peakrdl = ":peakrdl",
peakrdl_config = "peakrdl.toml",
exporters = {
"html": "_html",
"regblock": ".sv",
"toml": ".toml",
},
)
toolchain(
name = "toolchain",
toolchain = ":system_rdl_toolchain",
toolchain_type = "@rules_verilog//system_rdl:toolchain_type",
visibility = ["//visibility:public"],
)
peakrdl.toml:
# https://peakrdl.readthedocs.io/en/latest/configuring.html
[peakrdl]
# The import path should be the repo realtive import path of the plugin.
plugins.exporters.toml = "tools.system_rdl.peakrdl_toml:TomlExporter"
Now with the toolchain configured. all system_rdl_library targets built
in the same configuration as the registered toolchain will have an additional
output group system_rdl_toml that is the output of the custom exporter.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| exporter_args | A pair of exporters keys to a list of default exporter args to apply to all rules. | Dictionary: String -> List of strings | optional | {} |
| exporters | A mapping of exporters to expected output file formats. | Dictionary: String -> String | optional | {"html": "_html", "regblock": ".sv"} |
| peakrdl | The python library for the peakrdl package. | Label | optional | None |
| peakrdl_config | The peakrdl config file. | Label | required |
verilog_system_rdl_library
load("@rules_verilog//system_rdl:defs.bzl", "verilog_system_rdl_library")
verilog_system_rdl_library(name, lib)
A rule which extracts a verilog_library from a system_rdl_library.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| lib | The system_rdl_library to extract Verilog from. | Label | required |
SystemRdlInfo
load("@rules_verilog//system_rdl:defs.bzl", "SystemRdlInfo")
SystemRdlInfo(root, srcs)
Info for SystemRDL targets.
FIELDS