Configuration
A project tells doris about its designs in config files that are committed to the repo. Config is plain data, checked against a schema. Loading it never runs a command, reads an environment variable or substitutes a string, so a config means the same thing on every machine.
The three kinds of file
| File | Name | One per | Holds |
|---|---|---|---|
| Project file | project.hjson, at the repo root | Repo | Where the other config files and the FuseSoC cores are, and the default tools |
| Design file | design.hjson | Design | Facts about the design that every flow shares |
| Flow config file | testrig.hjson, lint.hjson | Design and flow | What that flow needs beyond the design file |
project.hjson
hw/ip/aes/
design.hjson name, core, top, scope, mappings, tags
lint/lint.hjson
hw/ip/my_core/
design.hjson
lint/lint.hjson
dv/testrig/testrig.hjson
Each key belongs to exactly one kind of file, with one exception: the tool table, which binds tools to a flow’s roles. The project file gives defaults for it and a flow config file can replace them. There is no other overrides mechanism, so reading any other value never means working out which file wins.
A flow config file belongs to the nearest design.hjson above it, in its own directory or any parent within the repo. It does not name its design, so the name is written once. Three things follow:
- A flow config file with no design file above it is an error.
- There is one design file per directory. Two designs never share one.
- Two files configuring the same flow for one design is an error, and so are two designs with the same name in the same scope.
A design’s flows are the flow config files that belong to it: a design with a lint.hjson can be linted.
Flow config files don’t override design keys. When a flow needs something like a design key but different, it has its own key. TestRIG’s dut.core is a testbench wrapper around the design, not the design’s RTL core, so it lives in testrig.hjson.
Schemas
Every config file starts with a schema key, which says what the file is and which version of the format it uses:
| Schema | File |
|---|---|
dv/project/1 | Project file |
dv/design/1 | Design file |
dv/testrig/1 | TestRIG config |
dv/lint/1 | Lint config |
The schema decides what a file is. A flow config file’s flow comes from its schema, not its name, so naming it after the flow is a convention. The project and design file names are fixed, project.* and design.*, because doris looks for them by name while walking up directories. A project.hjson or design.hjson with some other schema belongs to something else and is skipped.
The schemas don’t name doris. They start dv/, not doris/, so another tool can read the same config files without taking on doris’s name.
The project file
{
schema: dv/project/1
configs: [
"hw/ip/*/design.hjson"
"hw/ip/*/dv/testrig/testrig.hjson"
"hw/**/lint/lint.hjson"
]
cores_root: [
hw
]
tool: {
lint: {
linter: [
verilator
verible
]
}
testrig: {
reference: sail
}
}
}
| Key | Required | Meaning |
|---|---|---|
configs | Yes | Glob patterns for design and flow config files, relative to the repo root |
root | No | The repo root, relative to the project file’s directory. By default it is that directory. For a project file kept below the root, given with --project |
cores_root | No | Directories FuseSoC searches for core files, relative to the repo root. Each is passed to FuseSoC as --cores-root |
tool | No | The default tools for each flow’s roles: a flow’s name, then a role’s. See Tools and roles |
filters | No | Named filter sets, used on the command line as @NAME: each an include and an exclude list of KEY=GLOB filters. A name is made of letters, digits, _ and -. See Named filter sets |
Config files are found, not listed. doris loads every file a configs pattern matches.
- A matched file with no
schema, or one doris does not know, is an error. It is not silently skipped. - A pattern that matches no file is a warning, or an error with
--strict. - A design file doesn’t have to match a pattern: one above a matched flow config file is found by walking up.
- A file that no pattern matches is not seen, so it is neither validated nor run.
Every directory in cores_root is an input of each filelist step, so a change to any file under one, as git sees it, reruns the FuseSoC steps of every design. Keep the list to the directories that hold core files and the sources they name.
The design file
{
schema: dv/design/1
name: aes
core: lowrisc:ip:aes:1.0
top: aes
}
| Key | Required | Meaning |
|---|---|---|
name | Yes | The design’s name, which commands take. No /, @ or #. See below for what it must be unique among |
core | No | The design’s RTL FuseSoC core. Lint needs it, and so does a top |
top | No | The design’s RTL top module |
scope | No | top makes the design a top. shared keeps a design below a top’s directory from being the top’s own |
mappings | No | FuseSoC --mapping for every flow that resolves core. A top’s also apply to each design in its context |
tags | No | Labels for the design’s jobs in every flow, which filters select on: letters, digits, _, - and .. A flow config can add its own |
A design file must be named design.hjson, or design.toml or design.json, even when a pattern matches it under another name. Two in one directory is an error.
Tops and contexts
A shared IP block often can’t be resolved by FuseSoC on its own. Its core depends on virtual cores, such as a top_pkg of bus widths, that each top provides with different values. So the block is not one build: it is one build per top that uses it.
doris models this with three scopes:
| Scope | Which designs | Named | Run |
|---|---|---|---|
| Top | A design whose file sets scope: top | earlgrey | On its own, with its own mappings |
| A top’s own | A design whose file is below a top’s directory | earlgrey/pwrmgr | In that top’s context |
| Shared | Every other design, and one below a top that sets scope: shared | uart | Once in the context of each top that uses it |
hw/top_earlgrey/
design.hjson name: earlgrey, scope: top, mappings
ip_autogen/pwrmgr/
design.hjson name: pwrmgr -> earlgrey/pwrmgr
hw/top_darjeeling/
design.hjson name: darjeeling, scope: top, mappings
ip_autogen/pwrmgr/
design.hjson name: pwrmgr -> darjeeling/pwrmgr
hw/ip/uart/
design.hjson name: uart -> shared
{
schema: dv/design/1
name: earlgrey
core: lowrisc:systems:top_earlgrey
top: top_earlgrey
scope: top
mappings: [
lowrisc:prim_generic:all:0.1
lowrisc:systems:top_earlgrey:0.1
]
}
A context is a top’s mappings. A design run in a top’s context is resolved with the top’s mappings, then its own, then the flow config’s, each given once. The mappings are written once, in the top, not in every block’s config.
A top uses a shared design if the top’s core depends on the design’s core, directly or through other cores. doris reads this from the core files under cores_root; nothing lists a top’s blocks. A shared design that no top uses, and every design in a project with no tops, is run on its own, with only its own mappings.
Names. A top’s own design is named TOP/NAME, so two tops can each have a pwrmgr. Three rules keep every name unambiguous:
- Tops and shared designs have different names from each other.
- A top’s own designs have different names from each other.
- A top’s own design can’t have a shared design’s name, because
earlgrey/uartalso names the shareduartin Earl Grey’s context.
A top can’t be below another top’s directory.
Only lint uses contexts so far. TestRIG simulates its own testbench core, with the mappings of its own config, and names a top’s own design TOP/NAME but is otherwise unchanged.
Two limits of reading the core files instead of running FuseSoC:
- A dependency through a virtual core is followed only when one core provides it. A design that a top reaches only through a virtual core with several providers is not found to be used by that top, and is run on its own.
- Only each core’s
defaulttarget is read, with everyflag ? (...)condition taken.
doris plan lint prints the jobs, so it shows which contexts each design got.
Flow config files
Each flow’s keys are on its own page:
Tools and roles
A flow needs a tool for each of its roles. Lint has one role, linter. TestRIG has three: dut, the simulator; reference, the reference model; and coverage, the coverage reporter, which can be left out. A tool table binds tools to roles: the role’s name, then a tool’s name or a list of names.
{
schema: dv/lint/1
tool: {
linter: [
verilator
slang
]
}
}
- A flow config’s
tooltable binds the roles of its flow. Each flow’s page lists its roles and the tools each can have: TestRIG and Lint. - The project file’s
tooltable gives the defaults, by flow name and then role.tool.lint.linterin the project file above is the linters of every lint config that names none. The table need not name every flow or every role. - A flow config’s binding for a role replaces the default for that role. The two lists are not joined. A role the flow config leaves out keeps its default.
- A role with no tool from either file is an error, unless the flow can do without one. TestRIG’s
coverageis the only such role. - Several tools for a role give a job for each. With several for more than one role, there is a job for each combination. See Jobs, steps and directories.
Options for a tool go in the flow config’s tools table, under the tool’s name and then the step it is used in, such as tools.verilator.build.args. Each flow’s page lists them. The project file has no tools table.
Rules every file follows
- Unknown keys are errors, in every file and every nested table. The message names the file, the line and column, and every valid key of that table.
- Paths are relative to the file that declares them, and are resolved once when the file is loaded. A file copied or vendored with its directory works unchanged.
- Lists stay lists. Command lines are built by doris from typed values, never by joining config strings.
- Nothing is read from the environment, and nothing is run.
- The top level is a map, keys are
snake_case, and there is nonull. An absent key means the default.
Some things a schema can’t express are checked as each file is loaded. These messages name the file but not a line.
- Tools and roles. A flow the project file’s
toolnames must exist. A role must be one of its flow’s. A tool must be one the role can have, and be named once for it. Every role that needs a tool must have one, from the flow config or the project file. Atools.<name>table must be for a tool that can fill a role of the flow. - The ISA string of a TestRIG config.
- That a lint config’s design has a
core. - The design a flow config belongs to, and duplicate names.
Writing HJSON
Config files are HJSON, which allows comments and leaves out most quotes and commas.
Values run to the end of the line. An unquoted value takes the rest of its line, so { name: aes } sets name to aes }, and [a, b] is one string. Write one value per line, as the examples here do, or quote values that share a line.
Quote glob patterns, so that hw/ip/*/dv isn’t read as the start of a /* comment.
The parser is chosen by file extension, and the loader also reads .toml and .json into the same types, with the same checks. Projects use HJSON, and the examples in this book do too.
doris files and other HJSON files. A repo can hold .hjson files that belong to other tools. doris only loads the files the project file’s patterns match, and tells its own by the schema key.
Validating
doris validate
doris validate loads every config file a run would: the project file, each file its patterns match, and each design file found above a flow config file. Loading carries on past a bad file, so every error and warning is reported at once. It exits 1, FAILED, if any file has an error, so it can run in CI or a pre-commit hook. Warnings don’t change the exit code, unless --strict makes them errors: doris --strict validate is the check for CI.
It checks config only. It doesn’t lint RTL, which is the lint flow, or check that the tools a run needs are installed, which is doris check.
Every other command that reads the project validates the same way before it does anything, and stops if there is an error. doris gc, doris settings and doris report view don’t load config, so a bad file doesn’t stop them.
Vendored designs
Vendored IP is found the same way as local IP: by its design and flow config files. Because paths are relative to the file, a config vendored from another repo works unchanged.
An upstream that has no doris config gets a local directory of its own for each design, outside the vendored tree. For example:
hw/vendor/my_core/ vendored code, untouched
hw/vendor/my_core.core a local core file, example::my_core
hw/ip/my_core/design.hjson name, core: example::my_core, top: my_core
hw/ip/my_core/dv/testrig/testrig.hjson
The design file can’t sit beside the vendored tree as a core file does, because a flow config file finds its design as the nearest design.hjson above it. Where it lives barely matters otherwise: it mostly holds FuseSoC core names, which FuseSoC resolves wherever the core file is.
What a project file can’t do
doris has no variants or filter sets. The project file gives default tools, but no options for them: a tools table is written in each flow config that needs one. Variants and filter sets are planned: see Configuration in the roadmap. How a run happens on a machine, such as pool sizes and where a tool is installed, is not project config but settings.