Jump to content

Is this a bug in uvm?


Recommended Posts

Hi All,

I tried using uvm_pool in my environment.

Class: uvm_pool

Below is the code in uvm package uvm-1.0-p1:

// Function: get

//

// Returns the item with the given ~key~.

//

// If no item exists by that key, a new item is created with that key

// and returned.

virtual function T get (KEY key);

if (!pool.exists(key)) begin

T default_value;

pool[key] = default_value; end

return pool[key];

endfunction

In above code, default_value is added to the pool without making it new() (Bold lines above).

As per the comments, I am expecting non-null item even if it does not exist in the pool.

If the above code is written with the intention of having global pool which can have only the existing objects(non-null) then the above written comments for the function must be changed.

Code Should be like:

// Function: get

//

// Returns the item with the given ~key~.

//

// If no item exists by that key, a new item is created with that key

// and returned.

virtual function T get (KEY key);

if (!pool.exists(key)) begin

T default_value;

default_value = new();

pool[key] = default_value; end

return pool[key];

endfunction

Please let me know if it is a bug?

Thanks and Regards

Peer Mohammed

Link to comment
Share on other sites

Hi,

In my example I am using uvm_pool as a pool of type uvm_event (similar to ovm_event_pool as in OVM).

In OVM also, If no event exists by that name, a new event is created with that name and returned.

Please refer to OVM code. I am expecting the similar code in UVM.

Otherwise we must change the comment for the "get" function and must have to new() our item then add to the pool before using it(Other Way to achieve the same functionality).

Regards

Peer Mohammed

Link to comment
Share on other sites

  • 2 months later...

Finally...

That is not a bug.

The default entry for an object is ‘null’. The comment “a new item is created with that key†refers to the pool entry, not the object in the pool.

Are you sure this isn't a bug? The comment says that the item is the thing that is being returned, and a new item will be created if no item exists by the given key. A null item isn't a created item. Also, OVM and UVMea did what the comment said. It seems the problem new() not working with built-in types is an oversight in the language, i.e it should have been possible to say int i = new(), similar to C++ where int i() means int i=0 (to solve the same problem, I guess).

Regards,

Erling

Link to comment
Share on other sites

It is indeed not a bug. The pool entry is the item that is created. A 'null' value is a valid value for a class reference.

It would not be possible to create a version of uvm_pool that allocates classes by default as it would not work for non-class types nor for classes that require argument values in their constructors.

If you need the class to be created if it does not exist, you should test its existence first using pool.exists() and create it as necessary.

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