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
| Module | Does |
|---|---|
main | The command line: parses arguments, picks the flow, and drives planning, running and reporting |
config | The project and design file types, and the tool and tools tables flow configs share. Parsers for HJSON, TOML and JSON, chosen by extension |
repo | Finds 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 |
compat | Makes 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 |
cores | The FuseSoC core index: which core depends on which, read from the .core files under the cores roots without running FuseSoC |
tops | Tops and their contexts: which top each design is run in the context of |
select | Choosing 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 |
settings | The settings layers: finds and reads the settings files, applies --settings, -j and --set, checks every key and applies the system and user files’ limits |
step | The step model: Step, Invocation, Service, Artefact, Pattern, Precheck, Judge, Parse, Outcome |
group | Composite steps: flattens them into their children when a job is planned |
flows | The Flow and Job traits, roles and bindings, plan_jobs, and what else flows share. One submodule per flow |
flows::testrig | TestRIG: its plan, result file and report |
flows::lint | Lint: its plan, result file and report |
flows::crossing | CDC and RDC, one module: their config, plan, result file and report |
tools | The 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::wasm | The capability traits implemented on a plugin: requests to the plugin, and what it returns to invocations and steps |
plugin | Tool 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::sources | The filelist and flatten steps, shared by every flow, from the source manager’s plan |
exec | Checks 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 |
enforce | Enforcing 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 |
clean | What 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 |
metrics | The run’s metrics file, and the summary a run ends with |
measurements | The measurement store: a file of records per run, importing and removing them, and what they suggest a step holds |
cache | Cache keys and entries |
gc | GC roots, collection and pinning |
tree | Hashing and copying files and directory trees, as git sees them |
report | The parts of an HTML report every flow shares |
serve | The web server behind doris report view |
ui | Output for people: progress lines and repo-relative paths |
status | The 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/:
| Path | Holds |
|---|---|
wit/plugin.wit | The 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.rs | Builds 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"]
repowalks up to the project file, expands itsconfigspatterns, loads each file throughconfig, and builds the list of designs with the flow configs that belong to each. No tool is run.- The flow’s
planfunction turns a design and its config into jobs. It callsflows::plan_jobs, which works out the tools bound to each of the flow’s roles and callsFlow::planonce for each combination. That asks the tools’ plugins for the tool-specific parts and puts the steps together. Each job carries its attributes, andselectchooses from every job of the chosen flows by the command line’s designs, job IDs and filters. execruns every precheck the steps declare, such as each program being onPATH, then runs the steps of every job as one graph. For each step it askscachefor the key, restores a hit or runs the step once the resource pools have what it holds, and stores the result.cacheasks each tool a step uses for its version, throughTool::probe. When a step ends,cleandeletes what is not an output from its directory, or marks the directory as kept.Job::write_resultwrites the job’sresult.jsonfrom the step reports and the step directories, with the version of each tool the job’s steps use.- The flow’s
reportmodule writes the HTML pages from result files only. gcrecords the entries the run used in its root, with each job’s result.
Where the rules are kept
| Rule | Described in | Kept by |
|---|---|---|
| Planning never runs a command or reads the environment | Invocations | host_env and Arg::Port, answered by exec, and Tool::probe, asked by cache |
| A flow never names a tool | Flows, roles and bindings | Flow::roles, and the Bindings its plan is given |
| A cache key holds no absolute path | Cache keys | cache, which writes paths relative to the step, job or root |
| A step writes only inside its own directory | Rules steps keep | Stage::CopyTree, for a tool that builds next to its sources |
| A dependency is named once, by reading an artefact | Artefacts and dependencies | Step::reads, and exec::validate, which refuses a path into the directory of a step that is not a dependency |
| Only declared outputs are kept | Working directories and clean-up | clean, which leaves a passed step its outputs and nothing else |
| A job’s directory has one run at a time | Runs at the same time | lock::JobLocks, taken by doris run after its prechecks, and lock::in_use, asked by clean |
| A crashed tool is never a design failure | Completion and verdict | exec: completion checks first, then the judge |
| A report is made from result files only | Result files | Each flow’s report module, which takes the result type alone |