Better Way to Create Testbench: For Error Cases

In reply to Reuben:
Hi Reuben,

I have used the callback method to inject an error. I have injected an error in SV testbench, so I have used a polymorphism to inject an error, but u can use the uvm_callback.

In my case, I have an abstract class “error_injector”, which has two virtual methods, pre_drive() and post_drive(). These methods are called from a driver class, before and after a drive() method. By default, these methods do nothing, but these methods can be overridden by its (error_injector’s) extended class.

So, using the callback method, we can,

  1. Inject an error
  2. provide a delay in the transaction
  3. drop the transaction