Assigning agent configuration object with database versus direct assignment

My agents currently use the config database to pull their configuration, at the beginning of the build phase. The env performs the sets during its build phase.

I would prefer to assign the configuration directly in the environment. This seems like it would be an easy thing to do, but how does one assign the configuration object of a component BEFORE it has been built?

[edit] In other words, how can an agent get a configuration reference without using the database?

In reply to bmorris:

  • Old way to do this is Verilog way, use agent class with parameters.

  • Use some static types which can be configured before agent creation, access these using the hanlde.

  • Declare configuration parameters in package and access these inside the agent,
    e.g. if(my_pkg::agent_is_active)

  • You can do hierarchical access if you are not using package, $root or uvm_test_top or something.

  • As build_phase() is top-down. You can create agent in env and then assign configurations immediately in env build_phase().

  • Easy comes at a cost. Using configurations is most of the times a better way.

In reply to MayurKubavat:

This is true.

“- You can create agent in env and then assign configurations immediately in env build_phase().”

This won’t work because the building of the agent doesn’t actually begin until the build_phase of the env ends. aka the commands aren’t blocking.

thanks

In reply to bmorris:

I believe you are talking a Little bit theoratically about configurations. What do you really mean when saying configurations?
If you have a configuration object with data to be randomized then you have to use the config_db.
If you mean only simple Parameters a package approach is useful.

In reply to bmorris:

You can only do this by passing the config object as a constructor argument. If you’re using the UVM factory, you’re out of luck, since there you can only have a fixed signature for the create(…) function (i.e. name and parent).