3

I was going through basics of UVM tutorials. Everywhere I read the transaction objects are always extended from uvm_sequence_item and not uvm_transaction since uvm_sequence_item has additional features like transaction id, etc. If that is the case, why is the uvm_transaction class even there in the UVM class hierarchy?

Who is using uvm_transaction other than uvm_sequence_item extending from it?

Is it because of legacy?

jskroch
  • 333
  • 2
  • 8
user1978273
  • 484
  • 10
  • 24

3 Answers3

5

This is what the UVM Class Reference says about this:

"The uvm_transaction class is the root base class for UVM transactions. Inheriting all the methods of uvm_object, uvm_transaction adds a timing and recording interface.

This class provides timestamp properties, notification events, and transaction recording support.

Use of this class as a base for user-defined transactions is deprecated. Its subtype, uvm_sequence_item, shall be used as the base class for all user-defined transaction types."

AndresM
  • 1,293
  • 10
  • 19
  • Yes. I understand that. My question is, why can't uvm_sequence_item has whatever it has now plus uvm_transaction? Why do we need uvm_transaction separately? – user1978273 Jul 09 '16 at 03:07
  • You are probably overthinking this - You are right, we could have had `uvm_sequence_item` implemented with whatever it has now plus all the code inside `uvm_transaction`, and that would have been just fine. The base class developers probably started out with the latter, and then implemented additional stuff by extending that class. At that point in time, they probably decided to make `uvm_sequence_item` as the recommended base class for any user-defined types. – AndresM Jul 09 '16 at 05:43
1

If you refer uvm class hierarchy (Link:[https://www.google.co.in/search?biw=1366&bih=620&tbm=isch&sa=1&btnG=Search&q=uvm+class+hierarchy#imgrc=Laxc9UWNpnGTpM%3A][1] ) then you find out that uvm_transaction parent class while uvm_sequence is child class.

So, child class can access all the property of parent class. But parent class can not access child class property.

uvm_sequence_item has its own functionality like get_sequencer_id,set_sequencer_id, get_root_sequence.

These methods used by sequencer internally in case of layer sequences.

You call sequence by start method, uvm_do family or config_db.

Each of these method call start_item(req) and finish_item(req).

task start_item(uvm_sequence_item item) 
task finish_item(uvm_sequence_item item)

If you observes data type in first argument in both the function is uvm_sequence_item.

There are total eight uvm classes.

(1) uvm_driver.svh
(2) uvm_push_driver.svh
(3) uvm_sequencer.svh
(4) uvm_push_sequencer.svh
(5) uvm_sequencer_library.svh
(6) uvm_sequencer_analysis_fifo.svh
(7) uvm_sequence.svh
(8) uvm_sequencer_param_base.svh

These classes are parameterized with uvm_sequence_item not with uvm_transaction.

If you use uvm_transaction instead of uvm_sequence_item then ti will shout an error(set_sequence_id not found which is property of uvm_sequence_item not uvm_transaction ) from uvm_sequencer_param_base.svh.

So, communication of sequence,sequencer and driver is not completed.

In most of the cases which I observe if you have a code in which you are not going to use uvm_sequencer then you can use uvm_transaction it will not shout an error.

But if your code contains uvm_sequener and you use uvm_transaction then it will shout an error (Could not find member 'set_sequence_id').

Ashutosh Rawal
  • 301
  • 1
  • 4
  • 16
0

Note that from uvm_transaction class, uvm_sequence_item as well as uvm_objects are inherited. So, the static behaviour and non-static behaviour (so to say) class hierarchy all starts from uvm_transaction.

Now, I can add whatever functionality I want to, to uvm_sequence_item so that every inheritor of uvm_sequence_item can get this. I can do this without modifying uvm_transction_item. Otherwise, any change in uvm_transaction would lead to unwanted functionality in the component class hierarchy (static behaviour) and can even lead to unintended side effects.

PS: one of the difference between other OOPs languages and SV is that multiple inheritance is not allowed in SV. For example, in case of C++, I can inherit from 2 classes in a new class. This is not allowed in SV. So, the only way one can get the properties of uvm_transaction as well as from uvm_sequence_item is by inheriting from uvm_sequence_item. This maybe the source of your confusion.

Sharanbr
  • 345
  • 1
  • 5
  • 18