system_rdl_toolchain
Rules
system_rdl_toolchain
load("@rules_systemrdl//systemrdl:system_rdl_toolchain.bzl", "system_rdl_toolchain")
system_rdl_toolchain(name, exporter_args, exporter_dirs, exporter_files, 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("@rules_systemrdl//systemrdl: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",
exporter_files = {
"regblock": [
"sv={name}.sv",
"pkg={name}_pkg.sv",
],
"toml": [
"toml={name}.toml",
],
},
exporter_dirs = {
"html": [
"dir={name}_html",
],
},
)
toolchain(
name = "toolchain",
toolchain = ":system_rdl_toolchain",
toolchain_type = "@rules_systemrdl//systemrdl: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.
Describing exporter outputs
Each exporter is registered with a list of output descriptors of the form
<id>=<pattern>. Exporters that produce regular files go in
exporter_files; exporters that produce a directory go in exporter_dirs
(an exporter cannot be registered in both).
<id>is a stable identifier used to address this specific output from downstream consumers (e.g. thesystem_rdl_<exporter>_<id>output group, or theextractattribute onverilog_system_rdl_library/vhdl_system_rdl_library). Ids must be unique within an exporter and match[A-Za-z0-9_]+.<pattern>is the basename of the output. The literal token{name}is expanded to the target's resolved output name (target name, theoutput_nameattribute, or--rename). Patterns without{name}are fixed-name outputs the exporter always writes under that exact basename (e.g. a shared utility package emitted bypeakrdl regblock-vhdl --copy-utils-pkg).
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 | {} |
| exporter_dirs | A mapping of exporter name to a list of output descriptors <id>=<pattern> for exporters that produce a directory. See the rule's main documentation for the descriptor format. | Dictionary: String -> List of strings | optional | {"html": ["dir={name}_html"]} |
| exporter_files | A mapping of exporter name to a list of output descriptors <id>=<pattern> for exporters that produce regular files. See the rule's main documentation for the descriptor format. | Dictionary: String -> List of strings | optional | {"regblock": ["sv={name}.sv", "pkg={name}_pkg.sv"]} |
| peakrdl | The python library for the peakrdl package. | Label | optional | None |
| peakrdl_config | The peakrdl config file. | Label | required |