Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Code layout

This page maps the source tree and follows one doris run through it. Architecture explains the pieces and the rules they keep, and the API documentation has every type and function.

Modules

ModuleDoes
mainThe command line: parses arguments, picks the flow, and drives planning, running and reporting
configThe project and design file types, and the tool and tools tables flow configs share. Parsers for HJSON, TOML and JSON, chosen by extension
repoFinds the project file, then the design and flow config files, and checks them. The project file is the one nearest above the start directory, or the one --project gives
compatMakes a doris project from another tool’s config files, for --compat: OpenTitan’s dvsim lint configs. It writes ordinary config files for repo to load, and nothing else uses it, so it can be removed whole
coresThe FuseSoC core index: which core depends on which, read from the .core files under the cores roots without running FuseSoC
topsTops and their contexts: which top each design is run in the context of
selectChoosing jobs: each planned job’s attributes, the KEY=GLOB filters on them, and the designs and job IDs a command line names. plan plans every job of the chosen flows, then asks it which to keep, and why it left out the rest
settingsThe settings layers: finds and reads the settings files, applies --settings, -j and --set, checks every key and applies the system and user files’ limits
stepThe step model: Step, Invocation, Service, Artefact, Pattern, Precheck, Judge, Parse, Outcome
groupComposite steps: flattens them into their children when a job is planned
flowsThe Flow and Job traits, roles and bindings, plan_jobs, and what else flows share. One submodule per flow
flows::testrigTestRIG: its plan, result file and report
flows::lintLint: its plan, result file and report
flows::crossingCDC and RDC, one module: their config, plan, result file and report
toolsThe Tool trait, the capability traits (Simulator, ReferenceModel, CoverageReporter, Linter, Sources, CrossingChecker), the tool-neutral requests, and the tools with each capability, from the plugins
tools::wasmThe capability traits implemented on a plugin: requests to the plugin, and what it returns to invocations and steps
pluginTool plugins: loads the embedded ones and those in plugins.path, caches their compiled code, and gives a plugin the host interface while a step runs
tools::sourcesThe filelist and flatten steps, shared by every flow, from the source manager’s plan
execChecks a job’s step graph and runs the prechecks. Schedules the step graphs of a run’s jobs, within -j and the resource pools, and runs each step: the cache check, services, the command or a cache unit’s children side by side, completion checks, the parse function and the verdict. Measures each step
enforceEnforcing what a step holds: a cgroup per running step, a systemd slice or one doris makes, how its processes are started in it, the disk quota, and pinning to CPUs
cleanWhat is left of a step’s working directory when it ends, the marker in one that is kept whole, and finding and removing those for doris clean and dirs.work_max_age
metricsThe run’s metrics file, and the summary a run ends with
measurementsThe measurement store: a file of records per run, importing and removing them, and what they suggest a step holds
cacheCache keys and entries
gcGC roots, collection and pinning
treeHashing and copying files and directory trees, as git sees them
reportThe parts of an HTML report every flow shares
serveThe web server behind doris report view
uiOutput for people: progress lines and repo-relative paths
statusThe live status of a run: a table of how many steps of each name are in each phase, redrawn at the bottom of a terminal

Outside src/:

PathHolds
wit/plugin.witThe interface between doris and a tool plugin
sdk/doris-plugin, the crate a plugin is written with: the types it hands back, an Invocation builder, and helpers for options, files and linters
plugins/<tool>/The plugin of each tool built into doris. Verilator’s is a linter and a simulator
plugins/verilator-cov/Functional coverage from Verilator, which the Verilator plugin and the doris coverage reporter share: covergroups as cover properties, and the report on them
build.rsBuilds the plugins for wasm32-unknown-unknown, makes components of them, and embeds them

One run, end to end

flowchart LR
    main --> repo["<b>repo</b><br/>load and check config"]
    repo --> plan["<b>flows::*::plan</b><br/>a Job per design and tool"]
    tools["<b>tools::*</b><br/>plugins' invocations"] --> plan
    plan --> exec["<b>exec</b><br/>run the steps"]
    cache["<b>cache</b>"] <--> exec
    exec --> result["<b>Job::write_result</b><br/>result.json"]
    result --> report["<b>flows::*::report</b><br/>report.html"]
    exec --> gc["<b>gc</b><br/>the run's root"]
  1. repo walks up to the project file, expands its configs patterns, loads each file through config, and builds the list of designs with the flow configs that belong to each. No tool is run.
  2. The flow’s plan function turns a design and its config into jobs. It calls flows::plan_jobs, which works out the tools bound to each of the flow’s roles and calls Flow::plan once for each combination. That asks the tools’ plugins for the tool-specific parts and puts the steps together. Each job carries its attributes, and select chooses from every job of the chosen flows by the command line’s designs, job IDs and filters.
  3. exec runs every precheck the steps declare, such as each program being on PATH, then runs the steps of every job as one graph. For each step it asks cache for the key, restores a hit or runs the step once the resource pools have what it holds, and stores the result. cache asks each tool a step uses for its version, through Tool::probe. When a step ends, clean deletes what is not an output from its directory, or marks the directory as kept.
  4. Job::write_result writes the job’s result.json from the step reports and the step directories, with the version of each tool the job’s steps use.
  5. The flow’s report module writes the HTML pages from result files only.
  6. gc records the entries the run used in its root, with each job’s result.

Where the rules are kept

RuleDescribed inKept by
Planning never runs a command or reads the environmentInvocationshost_env and Arg::Port, answered by exec, and Tool::probe, asked by cache
A flow never names a toolFlows, roles and bindingsFlow::roles, and the Bindings its plan is given
A cache key holds no absolute pathCache keyscache, which writes paths relative to the step, job or root
A step writes only inside its own directoryRules steps keepStage::CopyTree, for a tool that builds next to its sources
A dependency is named once, by reading an artefactArtefacts and dependenciesStep::reads, and exec::validate, which refuses a path into the directory of a step that is not a dependency
Only declared outputs are keptWorking directories and clean-upclean, which leaves a passed step its outputs and nothing else
A job’s directory has one run at a timeRuns at the same timelock::JobLocks, taken by doris run after its prechecks, and lock::in_use, asked by clean
A crashed tool is never a design failureCompletion and verdictexec: completion checks first, then the judge
A report is made from result files onlyResult filesEach flow’s report module, which takes the result type alone