Can one component have two #imp?

usually we create an analysis_port in one component and one #imp in the other component with a write() function. Can we have two #imp in one component as shown below ?

class my_comp_1 extends uvm_monitor
uvm_analysis_port #(my_trans_1) ap1;
endclass

class my_comp_2 extends uvm_monitor
uvm_analysis_port #(my_trans_2) ap2;
endclass

class my_comp_3 extends …
uvm_analysis_imp #(my_trans_1, my_comp_3) imp1; // this is for ap1
uvm_analysis_imp #(my_trans_2, my_comp_3) imp2; // this is for ap2
endclass

How to implement write function in my_comp_3 ??

In reply to zz8318:

You can use “uvm_analysis_imp_decl(sfx)” macro. Here how it’s done


`uvm_analysis_imp_decl(_1)
`uvm_analysis_imp_decl(_2)
class my_comp_3 extends ....
uvm_analysis_imp_1 #(my_trans_1, my_comp_3) imp1; // this is for ap1
uvm_analysis_imp_2 #(my_trans_2, my_comp_3) imp2; // this is for ap2

/* Write function for imp1 */
function void write_1(my_trans_1 trans);
// TODO: Do something
endfunction

/* Write function for imp2 */
function void write_2(my_trans_2 trans);
// TODO: Do something
endfunction
endclass

In reply to chris_le:

Thank you for your quick help. Let me take a try.