Flows and tools
A flow owns the shape of one kind of work: which steps exist, how they connect, and what the result means. A tool, through its plugin, knows one tool: how to invoke it and how to read what it wrote. They meet at a capability, a trait with tool-neutral requests, so a flow never names a tool. A flow names roles, each needing a capability, and config binds a tool to each role.
Switching Xcelium for Verilator in TestRIG, or adding a linter, changes a value in a design’s config and nothing in the flow.
Every tool comes from a plugin: a WebAssembly component doris embeds, or loads from a site’s plugin directory. What this page says of a tool, its plugin does.
Tools
Every tool implements one trait:
#![allow(unused)]
fn main() {
pub trait Tool: Send + Sync {
/// The name config binds it by, and results record.
fn name(&self) -> &str;
/// Find the tool and report its version, for cache keys and results.
fn probe(&self, env: &ToolEnv) -> Result<ToolVersion>;
/// Host variables that change the tool's results, and so are part of
/// the cache key.
fn key_env(&self) -> &[String] {
&[]
}
/// The hash of the plugin the tool comes from, part of the cache key.
fn plugin(&self) -> Option<&str> {
None
}
}
}
probeis how a tool is identified. It reports the tool’s version, which is part of the cache key of every step that uses the tool, and is written to the job’s result file. It is given aToolEnv, which can run a command and read a variable on the host. AToolEnvruns each command once and remembers what it printed, because a tool does not change while doris runs.key_envnames the host variables that change the tool’s results. A tool is given the whole host environment, but only these are keyed: each one’s name and its value, or that it is not set. Verilator as a simulator namesUVM_HOME, the UVM library it compiles. No other tool names one.pluginnames the plugin that knows how to run the tool, by its hash, which is keyed too: a new plugin is a miss. A helper program has none.- A helper program is a tool too. A step also runs programs that are no capability’s tool, such as
cabal,ghcandgcc. Each is atools::program: a name and the arguments that make it print its version.
Capabilities
| Capability | Tools | Used by |
|---|---|---|
| Simulator | Xcelium, Verilator | TestRIG |
| Reference model | Sail, as the CHERI RISC-V model | TestRIG |
| Coverage reporter | IMC for Xcelium, and doris’s own for Verilator | TestRIG |
| Linter | Verilator, Verible, slang, AscentLint | Lint |
| Source manager | FuseSoC | Every flow |
| CDC checker | Meridian CDC | CDC |
| RDC checker | Meridian RDC | RDC |
These are the plugins built into doris. A plugin in a site’s plugin directory adds its tool to the capabilities it exports.
Each capability is a trait of its own, and a subtrait of Tool. The linter’s is the simplest:
#![allow(unused)]
fn main() {
pub trait Linter: Tool {
/// The file list the linter reads.
fn backend(&self) -> sources::FilelistFormat;
fn lint(&self, req: &LintRequest) -> Result<LintPlan>;
/// The log files in the lint step's directory that `parse` reads.
fn logs(&self) -> Vec<String>;
/// What the linter reported, from the content of its logs.
fn parse(&self, log: &str) -> Result<Vec<LintMessage>>;
}
}
- Requests are tool-neutral. A
LintRequestorSimBuildcarries the filelist, the top module and typed options. Nothing in it is a tool flag. ASimBuildalso carries the defines, the values of the top module’s parameters, DPI sources, and whether UVM, coverage and waves are wanted. Each simulator turns them into its own arguments. - A capability returns a small plan, not a step. It holds an invocation and what the flow needs to know about it, such as where the snapshot is, or which exit codes mean the linter finished. The flow decides where the invocation goes. In most steps it is the command. In TestRIG’s run step the simulator’s is a service.
- Results are tool-neutral too. Every linter’s
parsereturnsLintMessages, so the result file and the report are the same whichever linter ran. ALintPlancarries a judge of those messages, which the lint step is given as a judge on parsed results. - A tool that provides two capabilities is one plugin that exports both. Verilator is a linter and a simulator in one plugin. Both have the name
verilatorand share onetools.verilatortable of options.
The source manager is a capability, but not a role. Every flow resolves a design’s sources the same way, with the filelist and flatten steps that tools::sources::steps builds from the plan of the fusesoc plugin. Config binds no tool to it: the flows always use FuseSoC. Its knowledge of FuseSoC’s files is in its plugin, like any other tool’s, so its hash is in the key of both steps.
Features
A simulator says what it supports, as Simulator::features: functional coverage, waves, DPI and UVM. A flow checks the build request against it when it plans a job. A job that needs a feature its simulator lacks fails in doris plan, before anything runs:
job `testrig/core@bare` needs functional coverage from its simulator, and `bare` has none
Xcelium and Verilator both have every feature, so no config can fail this check today.
Simulators and coverage reporters
A coverage reporter reads the databases of its own vendor’s simulators and no others. So a simulator says which format its runs write, as Simulator::coverage_format, and a reporter says which it reads, as CoverageReporter::reads. There are two formats: Cadence’s, which Xcelium writes and IMC reads, and Verilator’s, which doris’s own reporter reads.
The flow checks the pair when it plans a job that collects coverage. A binding that pairs IMC with Verilator is an error:
job `testrig/core@verilator` pairs simulator `verilator` with coverage reporter `imc`: `verilator` writes Verilator coverage databases, and `imc` only reads Cadence ones
The reporter’s role is optional. With none bound, a job gets the reporter that reads its simulator’s databases, so a config rarely names one. A flow can say a design’s jobs don’t use a role at all, with Flow::uses(role, cfg): TestRIG uses coverage only when dut.coverage.functional is set, so the reporters bound to it give no jobs of their own otherwise.
Flows, roles and bindings
#![allow(unused)]
fn main() {
pub trait Flow {
type Config: DeserializeOwned;
type Job: Job;
/// The name the command line and the project file's `tool` table use.
fn name(&self) -> &'static str;
/// What the flow needs tools for, the main role first.
fn roles(&self) -> &'static [Role];
/// Whether a design's jobs use `role` at all.
fn uses(&self, role: &Role, cfg: &Self::Config) -> bool {
true
}
/// The job of `design` with `tools` bound to the flow's roles.
fn plan(&self, repo: &Repo, design: &Design, cfg: &Self::Config, tools: &Bindings)
-> Result<Self::Job>;
}
}
A role is one thing a flow needs a tool for: a name, the capability the tool must have, and whether the role is optional. A flow’s first role is its main role.
| Flow | Role | Capability | Optional |
|---|---|---|---|
| Lint | linter | Linter | No |
| CDC | checker | CDC checker | No |
| RDC | checker | RDC checker | No |
| TestRIG | dut | Simulator | No. The main role |
| TestRIG | reference | Reference model | No |
| TestRIG | coverage | Coverage reporter | Yes. Left out, a job gets the reporter that reads its simulator’s data |
Bindings is one tool bound to each role: the tools of one job. plan takes them and returns that job. A value of the flow holds what one run asks of it, such as TestRIG’s seed.
flows::plan_jobs is the driver every flow shares. It works out the tools bound to each role, makes every combination, keeps those --tool asks for, and calls plan for each.
The command line is still a fixed list of flows that main.rs matches on. Each flow has a plan function of its own shape that the match calls, and that function calls plan_jobs. What the flows share beyond that is the Job trait: an ID, a design, the steps, a way to cut them short for --until, and a way to write the result file.
Choosing tools
A flow config binds tools to roles in its tool table: a role’s name, and a tool’s name or a list of names.
tool: {
dut: [
xcelium
verilator
]
reference: sail
}
- The project file gives the defaults. Its
tooltable has a role table for each flow, such astool.lint.linter. A flow config’s binding for a role replaces the default for that role, whole. A role that neither binds is an error, unless it is optional. - Several tools for any role give a job for each combination. The job’s ID ends
@TOOLwith the main role’s tool. Another role adds+TOOLwhen it has several:testrig/core@xcelium+imc. A role with one tool says nothing about which job it is, so it is not in the ID. - Names are checked when config loads. An unknown flow in the project file, a role the flow does not have, a tool without the role’s capability, and a tool named twice for one role are each an error that
doris validatereports.
Options a neutral request can’t express go in a typed table under tools.<name> in the flow config, read only by the jobs that tool is bound in. Every tool has one, except doris’s own coverage reporter, which has no options. A table is keyed by tool and then by step:
tools: {
verilator: {
build: {
args: [
-Wno-fatal
]
}
run: {
args: [
+UVM_VERBOSITY=UVM_LOW
]
}
}
}
Options are keyed by step because one tool can be used in two steps, with different arguments in each: xrun builds and runs, and Sail’s model step runs make where its run step runs the emulator. A tools.<name> table for a tool that can fill no role of the flow is an error. Most of a linter’s options still come from the FuseSoC core’s lint target (see Lint).
Invocations
An invocation is one program and everything doris must do to start it. It is all a plugin hands back, so a plugin never starts a process and never sees the machine.
| Field | Meaning |
|---|---|
program, args | The command. An argument is text, a named port or the thread count, the last two filled in when the step starts |
env | Variables set for the program, on top of the whole host environment |
cwd | The working directory. Default: the step’s directory |
stage | Work done just before the program starts: make a directory, make a symlink, or copy a source tree |
needs | Programs the command runs itself, such as the compiler a Makefile calls. Checked on PATH like program |
host_env | Variables worked out on the host when the program starts, such as a library path. The request is keyed, not the answer |
tools | The tools the invocation uses. The version each one’s probe reports is keyed, and so is each variable of its key_env |
resources | What the program holds from a resource pool while it runs, such as one xcelium licence. Not keyed |
threads | The CPU threads the program uses: a count, one by default, or every thread of the pool. An argument can stand for the count it is given. Not keyed |
prechecks | Conditions the program needs of the machine, checked before any step of the run starts, such as a variable being set. Not keyed |
Planning never runs a command or reads the environment. Anything that depends on the machine is declared: a host_env variable, a port, or a tool whose version is wanted. The executor answers when the step starts, and the cache asks each tool’s probe when it works out a step’s key. This is what makes a plan repeatable and a cache key the same on every machine.
A probe that fails still gives a key. The version is then unknown, keyed like any other. A missing program is caught by the check before the run, not by the probe.
A command is a program and an argument list. It is built from typed values and run without a shell. A step that needs a pipeline asks for a shell in so many words: Invocation::shell(script) is bash -c SCRIPT. No flow has one.
Where tool knowledge lives
Everything about running a tool is in doris, not in the project’s repo:
| Tool knowledge | In doris |
|---|---|
| The order of a flow’s stages | Steps returned by the flow’s plan |
| Command and options | Built by the tool’s capability methods from typed requests |
| Environment passed to the tool | Set by the plugin in its invocation |
| Report parsing | The capability’s parse function, in Rust |
| Pass and fail | The flow’s judge, working on parsed results |
| Tool special cases | Each tool is its own plugin behind a capability |
A project provides designs and options, and doris provides tools. A project depends on no other repo for tool definitions.
Not built
Tool capabilities in the roadmap has what is designed here and not built: a command line that works on any Flow, a published schema for each flow’s config, options checked against the steps a tool is used in, tool scripts, and the capabilities of the planned flows. Adding tools and flows says how to add to what is here.