# Passing derived class transactions to a base class analysis port

**URL:** <https://verificationacademy.com/forums/t/passing-derived-class-transactions-to-a-base-class-analysis-port/29472>\
**Category:** UVM\
**Tags:** UVM, base-class, casting, tlm\_fifo, derived-class\
**Created:** [May 16, 2014, 2:23pm UTC](https://verificationacademy.com/forums/t/passing-derived-class-transactions-to-a-base-class-analysis-port/29472 "2014-05-16T14:23:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sperber](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/59ef9b/32.png) [@sperber](https://verificationacademy.com/forums/u/sperber)\
**Post date:** [May 16, 2014, 2:23pm UTC](https://verificationacademy.com/forums/t/passing-derived-class-transactions-to-a-base-class-analysis-port/29472/1 "2014-05-16T14:23:03Z")

</div>

I have a base class and at least 2 derived classes that extend the base class :

class base\_class extends uvm\_sequence\_item;

class der\_class1 extends base\_class;

class der\_class2 extends base\_class;

I have an analysis port in my monitor of base class type :

uvm\_analysis\_port#(base\_class) base\_class\_ap;

My monitor constructs only the different derived class objects. Can I just pass the derived class to the base class analysis port?

der\_class1 tr1;  
… construct and populate …  
base\_class\_ap.write(tr1);

or

der\_class2 tr2;  
… construct and populate …  
base\_class\_ap.write(tr2);

On the export end I assume I would need to do a $cast(der\_class1\_obj, base\_class\_obj) to convert the transactions back to their correct derived class?

Any corrections to what I have here?

---

<div class="post-metadata">

**Author:** ![tfitz](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tfitz/32/3025_2.png) [@tfitz](https://verificationacademy.com/forums/u/tfitz)\
**Post date:** [May 16, 2014, 2:37pm UTC](https://verificationacademy.com/forums/t/passing-derived-class-transactions-to-a-base-class-analysis-port/29472/2 "2014-05-16T14:37:47Z")

</div>

_In reply to [sperber](https://verificationacademy.com/forums/t/passing-derived-class-transactions-to-a-base-class-analysis-port/29472):_

Nope. You’ve got it exactly right.

---

<div class="post-metadata">

**Author:** ![haitao73](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/haitao73/32/2385_2.png) [@haitao73](https://verificationacademy.com/forums/u/haitao73)\
**Post date:** [May 17, 2014, 3:48am UTC](https://verificationacademy.com/forums/t/passing-derived-class-transactions-to-a-base-class-analysis-port/29472/3 "2014-05-17T03:48:50Z")

</div>

Yes, you can use the base\_class reference the class1 and class2  
in export, use $cast(class1, base\_class) to check the item received from port is  
the type you wanted. if the base\_class ref object type is not you wanted eg. class2,  
the $cast shall return false.
