Skip to main content

Module config

Module config 

Source
Expand description

The ConfigDb — path-addressed configuration (D11–D16, D65–D68).

A component is configured by code that never touches it, through a path named as a string. That is the capability the first rustdv pass removed when it replaced this with typed structs passed to constructors, and restoring it is most of the point of this branch.

Shape of the API (D66). get and set take a context, an offset, and a field:

ConfigDb::set(Some(ctx), "env.loga", "MSG", String::from("LOG A msg"));
ConfigDb::set(None,      "*",        "MSG", String::from("GLOBAL"));

let msg: String = ConfigDb::get(Some(ctx), "",     "MSG")?;  // me
let msg: String = ConfigDb::get(Some(ctx), "loga", "MSG")?;  // a child
let seqr: Rc<Sequencer> = ConfigDb::get(None, "", "SEQR")?;  // no context

The offset is relative to the context, so a lookup is position-independent — an absolute path would be the hand-typed string D7 forbids. None means no context: the offset is absolute. That form is not an edge case; a Sequence is not a component and has no path, so it is the only way a sequence can read at all.

Namespacing (D65). One namespace per (path, field). The type is not part of the key, which is where SystemVerilog differs: it passes uvm_resource#(T)::get_type() into the lookup, so a set and a get that disagree on type simply never meet and you get a silent return 0. Here the entry is found and the type checked, so a mismatch is its own error. The cost, stated rather than hidden: two different types can no longer share a field name at one path.

Storage (D67). Values must be Clone. Store a plain value and every reader gets a copy; wrap it in an Rc and every reader shares one object.

Debugging is built in, not bolted on (D68). ConfigDb::print dumps every entry with its precedences, because a resolved value tells you who won but not who was competing; ConfigDb::set_tracing logs every operation with the context, the offset, and the path they resolved to.

Structs§

ConfigDb
The configuration database. All methods are associated functions over an ambient per-test store (D11, D16).

Enums§

ConfigError
Why a get failed. SystemVerilog collapses all of these into return 0 and leaves your variable untouched; naming them is the point.