Search code examples
system-veriloguvm

Usage of a super.body() variable is illegal as it's considered "not declared"


I extended the usage of my virtual task body() in a sequence class, and in the parent class declaration of body(), I declared a variable. However, upon using it in the extended class' body() , I faced a compilation error Identifier 'q' has not been declared yet.

Here is an example:

// Inside a base sequence class
virtual task body();
  byte q [$];
  ... 
  .. // rest of the code
  .
endtask : body


// Inside extended sequence class
virtual task body();
  super.body();

  q.push_back('hFF); // X Compilation error: Identifier 'q' has not been declared yet.

  ... 
  .. // rest of the code
  .

endtask : body

I cannot see any logical reason why the variable hasn't been seen. I can, of course, declare it outside of the task scope as a class member, but I want to refine these minor holes in my SV understanding.

Any help please ? Thanks in advance.


Solution

  • q is local to the body task in the super class. The body task in the derived class is a different task and hence a different scope. There is no way you should be able to see it from the body task in the derived class, any more than you'd be able to see it from any other task.