Package undefined

I have a one file called my_package.sv, in that I have written one package called my_package as shown below:


package my_package;
...
...
endpackage

Now I want to import this package in top module, whenever I try to import, it gives an error as undefined package.
This is my top module code:


module top;
`include "uvm_macros.svh"
 import uvm_pkg::*;
 import my_package::*;
...
...
endmodule

Can any one clarify why it is showing the error?

In reply to Manoj J:

It looks like you did not compile ‘my_package’ or you compiled it into another library than the other code.

In reply to chr_sue:

how to compile the my_package file prior to the top file?

In reply to chr_sue:

I tried like this way also, by including the package file


`include "my_package.sv"
module top;
      `include "uvm_macros.svh"
       import uvm_pkg::*;
       import my_package::*;

endmodule

In reply to Manoj J:

You have to compile your package prior to the compilation of your module top.

In reply to chr_sue:

Will it not get compiled before top module when it is written like above?

In reply to Shipra_s:

If you are using the include in top of the toplevel module the package is in the file scope of this file.
Importing the package using the import statement like this

import my_pkg::*;

requires the scope of the package. my_pkg:: is the scope resolution operator.

In reply to Manoj J:

What you wrote should have worked. Perhaps you have a misspelling. Can you show us the exact error message