I’m just starting to put together an OVM based test bench and have come upon this question of when it’s appropriate to use set_config/get_config to pass object handles into components. What I’m hearing is that the OVM community is leaning toward always using it rather than have hierarchical references to child components.
I think I’m in a minority in thinking that hierarchical references to child objects is okay. If driver, for instance, is implemented in env, I think it’s fair for env to understand something about what’s inside of driver. In which case it might be fair to pass a reg handle to driver in this manner
driver.reg = reg;
Now, in case the author of driver wants to change the name or location of its internal reg, then I should pass the handle to reg something more like this so that driver can store the handle whereever makes sense for the current implementation without effecting my env code.
driver_obj.connect_reg(reg);
Using set_config/get_config, the env coder still needs to know some details about the internals of driver - the string value that driver will use to find the reg handle.
An analogy is that I have a bag of money for you, so I’ll put it out in the woods in a place you said you will look for it - rather than just hand the bag to you as long as you’re right here. There’s a chance I’ll misunderstand the string you said you’d look under - whereas handing it to you I’ll know right away that you got it.
I see three places where set_config/get_config is appropriate
- The test case sets the configuration object so that any component out there can get it to see what the test wants done
- The test bench top module can’t hand the interface handles to the env directly because env hasn’t been instantiated yet
- The value is meant for an object that will be declared some layers down from the parent - the parent shouldn’t know that full hierarchy
I’m sure there are others, but I don’t think it’s always appropriate to use set_config/get_config.
George