1
include "cls.sv"
module top();

    int x;
    spl_cls #(10) o_spl_cls;
    /*Code Continues, here o_spl_cls object has been created using  
     new();*/ 
    dummy  i_dummy(o_spl_cls); //I instantiated another module and passed  
                               //object 
endmodule

//This is my dummy module
module dummy(spl_cls i_spl_cls);
....
endmodule

//my spl_cls is
class spl_cls#(int data=0);
//...rest code
endclass

I am getting Error. How to pass parameterized object to another module instance or class?

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
Akshay Patil
  • 143
  • 2
  • 2
  • 10

1 Answers1

1

You will need to parameterize all references to spl_cls that you want to make assigments to.

module dummy(spl_cls#(10) i_spl_cls);
....
endmodule

A better solution would be to use a typedef

module top();
    typedef spl_cls #(10) spl_cls_10;
    int x;
    spl_cls_10 o_spl_cls;
    /*Code Continues, here o_spl_cls object has been created using  
     new();*/ 
    dummy #(spl_cls_10) i_dummy(o_spl_cls); //I instantiated another module and passed  
                               //object 
endmodule

//This is my dummy module
module dummy #(type C)(C i_spl_cls);
....
endmodule
dave_59
  • 39,096
  • 3
  • 24
  • 63