You are on page 1of 10

Concept of Factory

▪ What is Factory in Object Oriented Designs ?


▪ Factory is an abstraction of constructor in class based
programming
▪ A constructor creates objects as instances of a single class
▪ A factory can create objects by instantiating various classes
▪ A sub routine that returns “new” objects

Introduction to OVM and UVM 02/20/202 1


3
UVM Factory

▪ UVM Factory
▪ Allows an object of one type to be substituted with an
object of derived type without testbench edits/re-
compile
▪ Works on the concept of polymorphism which allows a
derived class object to be accessed using a base class
type handle

Introduction to OVM and UVM 02/20/202 2


3
UVM Factory

▪ A special look up table in which al l components


and transaction types are registered
▪ Call the Factory method to create the requested
component and transaction types rather than
default constructor
▪ ::type_id::create()
▪ Factory will extract the requested type and create
an object of it by calling the constructor

Introduction to OVM and UVM 02/20/202 3


3
UVM Factory – Example Usage

▪ Overriding Transactions
▪ Good Packet and Error Packet (derived from Good
Packet)
▪ If sequencer/driver/monitor are parameterized of Good
Packet – then a top level test can replace the good packet
with an errored packet in the test
▪ Overriding Components
▪ If there are multiple driver components (eg: if a design has
a 10G port that can also be configured as 10 1G ports)
▪ Based on config – same environment can build different
drivers by selecting the ones from factory
Introduction to OVM and UVM 02/20/202 4
3
UVM Factory - Coding

▪ Following three steps should be followed:

▪ Register all components and objects with UVM


Factory

▪ Use Factory method (type_id::create() ) for


creating new objects

▪ Use Factory overrides for creating re-usable and


configurable tests and testbenches
Introduction to OVM and UVM 02/20/202 5
3
Registering with Factory

▪ Components Registering
`uvm_component_utils(component_name)
▪ Transactions Registering
`uvm_object_utils(transaction_type)
▪ UVM ports and covergroups not registered with factory
▪ Use new() to construct them

Introduction to OVM and UVM 02/20/202 6


3
Creating Components
▪ Component constructor

▪ Objects Constructor

Introduction to OVM and UVM 02/20/202 7


3
Creating components - Factory

▪ Use ::type_id::create() instead of calling new()


▪ String name and parent

▪ Lots of complexity and confusion behind actual calling using


factory.
Introduction to OVM and UVM 02/20/202 8
3
Creating Objects - Factory

▪ No parent argument in constructor

Introduction to OVM and UVM 02/20/202 9


3
Factory Overrides

▪ Two types of override possible


▪ Type overrides
▪ Every time a component class type is created in a
testbench hierarchy, a substitute type is created in
its place. Applies to all instances of that component
type
▪ Instance override
▪ A specific component instance is overridden by
specifying its position in the uvm component
hierarchy

Introduction to OVM and UVM 02/20/202 10


3

You might also like