Callbacks in system verilog and uvm

can someone explain me callbacks?i have gone though the vmm central site,i couldnot understand.please with some simple example explaination is required

See: Verification Course Blog | VeriLog Courses | CVC

HTH
Ajeetha, CVC

You might want to read this article about callbacks in C/C++.

Note that SystemVerilog does not have function pointers, but you can use a handle to a class with a method and call the method. Callbacks is a methodology that was developed before objected-oriented programming became popular. We prefer that you use virtual methods to achieve the same functionality in most cases, as it has less performance overhead.

In reply to dave_59:

Hi Dave,

If I were to compare polimorphism to callback style, I would say both seem like a function call but virtual function look up would seem more expensive since its searched on run time. What makes callback style to have performance penalty when compared to virtual function lookup?
Is it due to new object allocation in case of callbacks?

In reply to emin:

For a virtual method, the compiler builds a method table before runtime and sets an index into that table when constructing the object based on its type. There is no searching. There is just one level on indirection.

The way callback are implemented in the UVM, you have have to construct an object and register it by placing it in a list. The at the place you want the callback, you have to iterate through the list and call the method for each object. And it has to go through this step regardless of whether or not any callbacks are registered. And what’s worse, the method in the callback is defined as a virtual method anyways.