Jump to content

Accessing a base test class data element in an extended class.


bap001

Recommended Posts

Hi ,

I have a basic UVM question,

How can I make base class data elements visible in extended classes?

Any help would be highly appreciated!

I tried declaring the "do_test" as protected too - that should not be needed but it does not work either.

I am missing something very basic here..

class dut_test extends uvm_test;

rand bit do_test;

function new(string name, uvm_component parent=null);

super.new(name,parent);

do_test = 1'b0;

endfunction

//Another function sets this bit

.....

endclass;

class dut_test_pkt extends dut_test;

//I want to access do_test from the base class in the build portion of this class.

//How do I do it?

......

//This is what I need to do - use it to constrain another cfg class..

virtual function void build_phase(uvm_phase phase);

super.build_phase(phase);

assert (cfg.randomize() with {

enable == do_test;

}

endclass

Link to comment
Share on other sites

Hi Dave,

Thanks for the response. I am using ISU 10.20. With it, I get a compile error that "dut_test" is not part of the class.

We have this complex environment of sequencers and agents talking to each other - and they work ok. We tried to do something as simple as this - it failed.

We have since gotten around this by adding another level of encapsulation and using a method to set this signal - not the best but made us go ahead..

I realized that I have one modification to what I posted above,

The hierarchy is as follows:

class test_base extends uvm_test

class dut_test extends test_base

-- dut_test declared here..

class dut_test_pkt extends dut_test

//Goal is to use dut_test here..

Is the problem because "dut_test" is not declared in the base class?

Thanks once again!

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...