uvm_config_db vs uvm_resource_db, where they come from and what are they good for

The origins
According to a story I was told, the origin of the uvm_resource_db stems from the fact that certain simulators (if I remember correctly Mentor's Modelsim/Questa), were unable to cope with the dot-notation. Eg. You could not write m_object.m_field = 1, instead you'd have to put the field value into uvm_resource_db and pull the value at the "other" side.

Uvm_config_db was created so as to simplify issues with namespace collisions. Set and get functions for the config_db accept as a first argument a uvm_component. The component is only used so as to get a full hierarchical name for the object's name, thereby protecting the namespace from being polluted.
Eg., an environment that would need to set a field within a agent/scoreboard residing within that environment would pass the set function this as its first argument and the agent/scoreboard's instance name as it's second argument. The component (agent/scoreboard) would be pulling the field's value from the config_db using this again as it's first argument to the get function, but the second argument is left empty. Thereby recreating the exact name again.

The need
Putting the origins aside, uvm_resource_db provides a easy way to share resources between various classes. It provides a way to publish resources by a certain class, without the consumers of these resources to have to know anything about the publisher besides the key by which to pull the resource.
Note that config_db should be used if the component hierarchy has a special meaning.
Another use case is for pushing resources before a instance has been created.

UVM uses the resource_db for publishing the uvm_reg_block to all, making it possible to find a reg_block by name using the static function uvm_reg_block::find_block().

Please share if you have more use-cases for using resource/config_db.

Thanks,

Tsvi

Comments

Popular posts from this blog

The crooked ways of UVM's register model's coverage methods

Don't use null as a sequencer argument to uvm_reg_sequence