Jump to content

override UVM phase?


Recommended Posts

I think you are a bit confused about overriding. If you want to override the default behavior of build_phase(...) which is a function, then you just declare your own implementation:

class my_driver extends uvm_driver #(my_item);
  // factory registration stuff
  
  function void build_phase(uvm_phase phase);
    // super.build_phase means calling the build_phase function
    // as it was defined in the base class (our case uvm_driver)
    super.build_phase(phase);

    // up to now our build_phase does the exact same thing that
    // it did in the base class
    
    // add your extra code here
    // - code that does more stuff that you need
  endfunction

Whenever you extend a class (create a subclass) and redefine a method, this means you are overriding the method (method means function or task). Method overrides control what object actually do. When you instantiate an object of type my_driver and call build_phase, then the implementation we have defined above will get executed.

 

Type and instance overrides are a different thing that applies to the factory. They control what types of objects actually get instantiated.

Link to comment
Share on other sites

To reinforce Tudor's reply, you will need to "override" twice - once in the OO sense, and once in the factory sense:

1. derive a new driver class (assuming you are overriding an existing driver)

2. implement your new build_phase -- IMPORTANT: you will probably want to call super.build_phase from within your new implementation

3. set_type_override or set_instance_override in the test class (or possibly the environment) during the build_phase of that class

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...