UVMLint - why not to "re-declare" is_active inside agent?

 Building on PySlint, UVMLint is adding rules for UVM based testbenches. A recent user reported the following violation:


That's just a short reporting, with detailed message to follow (users can add more information at their end with PySlint API soon). Let's understand why this is considered a bad practice in UVM. 

To speed things up (and to add spice to it), we used Google Bard on "what is is_active in UVM agent" and below is a response: 

The is_active variable in a UVM agent is an enum type of uvm_active_passive_enum. It specifies whether the agent is active or passive. An active agent has a driver and sequencer, while a passive agent only has a monitor.

The is_active variable is a useful tool for controlling the behavior of UVM agents. By setting the is_active variable, you can control whether an agent has a driver and sequencer, or whether it only has a monitor.

Not bad for a GenerativeAI conversation, isn't? As a quick recap, UVM agent is a specialized component and its UVM looks as follows:


UVM Base Class that defines uvm_agent is shown below:
A derived agent (such as hbus_agent) inherits this field is_active and hence no need to re-declare. Say a sample user code looks as follows:



UVMLint would flag that line-20 and report it as poor code. Why? Well, below are some rationales:

  • The value of is_active as declared above would be set to be UVM_PASSIVE - this is against the UVM standard implementation that makes it UVM_ACTIVE as the default.
  • Protected would prevent an env class unable to access this field - a common code style other UVCs (that do not override base class's is_active unlike above).
  • What's the point of using uvm_agent here as base class and not uvm_component? - make no mistake; we are not suggesting you do that, rather questioning why the re-declaration in user agent code.
So if you want to check for such issues in your UVM testbenches, start innovating on top of open-source PySlint https://github.com/AsFigo/pyslint








Comments

Popular posts from this blog

Don't go "wild" with Associative arrays in SystemVerilog - PySlint it!

Porting a complete UVC to Verilator + UVM - an anecdote!

Opensource testbench generator for VHDL designs, OSVVM included!