Factory in VMM was implemented by assigning different blueprints to factory place holders like randomize_obj and scenario_set[] for atomic generator and scenario generator respectively. With the introduction of factory services from VMM1.1 replacing any type of object say a transaction or transactor can be done easily using methods like override_with_new() or override_with_copy(). We can replace one particular instance of an object with the derived object or we can replace all the instances of the object with the derived object.
Following are the steps one has to follow to use VMM factory services.
- Use the macro `vmm_class_factory(class_name) to register the class to factory services
- Use create_instance() to create an object instead of using new()
- Use override_with_new() or override_with_copy() to replace and existing object with a derived object.
- Use pattern matching to replace all the instance of the class or a particular instance of the class.