How to use parameterized class as a return type of function

hi all,

I am getting the below error.



Error-[IND] Identifier not declared
slave_write_driver.sv, 78
  Identifier 'ADDR_WIDTH' has not been declared yet. If this error is not 
  expected, please check if you have set `default_nettype to none.
  


Error-[IND] Identifier not declared
slave_write_driver.sv, 78
  Identifier 'DATA_WIDTH' has not been declared yet. If this error is not 
  expected, please check if you have set `default_nettype to none.
  

I am using two different files named as ‘.sv’ and ‘.svh’
.sv file format is having the definition of the methods, and .svh file is having methods prototype in it.
below code is stored in .svh format file


      extern function slave_write_transaction #(ADDR_WIDTH,DATA_WIDTH) w_get_pkt();    

below code is stored in .sv format file


   
         function slave_write_transaction #(ADDR_WIDTH,DATA_WIDTH) axi_slave_write_driver::w_get_pkt();
            slave_write_transaction #(ADDR_WIDTH,DATA_WIDTH) w_packet=new();
            w_packet=w_queue.pop_front();
            return w_packet;
          endfunction:w_get_pkt


I had also used the typedef,


typedef slave_write_transaction #(ADDR_WIDTH,DATA_WIDTH) class_handle

but none of the solution worked.
I have included the file first .svh and then .sv file.

Am I missing something?
please help me out.

since main code is of hundreds of line, I did not find it appropriate to share it here.

thanks and regards

In reply to jj_bukhari:

Since the function return type appears before the class name scope, you need to add the class scope to the parameter names as well.

function slave_write_transaction #(axi_slave_write_driver::ADDR_WIDTH,axi_slave_write_driver::DATA_WIDTH) axi_slave_write_driver::w_get_pkt();
            slave_write_transaction #(ADDR_WIDTH,DATA_WIDTH) w_packet=new();
            w_packet=w_queue.pop_front();
            return w_packet;
          endfunction:w_get_pkt

If the typedef is inside the axi_slave_write_driver class, you can do

 function axi_slave_write_driver::class_handle axi_slave_write_driver::w_get_pkt();
            class_handle w_packet=new();
            w_packet=w_queue.pop_front();
            return w_packet;
          endfunction:w_get_pkt

Refer to section 8.25.1 Class scope resolution operator for parameterized classes

In reply to dave_59:

Thank you so much, dave.
thank you for being there every time for us.