Bhanu,
This is a common question that comes up periodically.
Last year I posted my preferred solution, copied here.
The important point is, all instances share the Same
register model so changing a value in the monitor will
be seen in the scoreboard. This may, or may not, be
what you desire to occurr.
JPK
Tushar,
For this requirement there is the set/get config_object.
new() is admittedly thin when it comes to arguments
if you want to register the class with the factory. It might
not be the best for your needs anyway.
If you have a block that you want several objects to share,
look into set_config_object. With it you build one instance
of an object or component, like your regs, and other objects,
virtually anywhere in the testbench hierarchy, can obtain a
reference to the object.
Example:
Setting the object:
In the top level build the reg;
Code:
$cast(shadow_reg, create_component("shadow", "shadow_reg"));
shadow.build();</pre>
Next do a set_config;
Code:
set_config_object("*","shadow_reg", shadow_reg,0);
// This is setup to penetrate all levels of hierarchy
// You can limit that by replacing the '*' with a
// more specific path</pre>
Get the handle in an object;
Code:
bit success = get_config_object("shadow_reg", my_shadow, 0);
// Note: the last argument [0] causes a reference copy
// instead of a clone.</pre>
Now all objects appear to have their own copy of the reg, while
actually sharing the single one instance in the top of the TB.