Same class names in different files

Hi,

I have taken up verification of a subsystem. It has a 3rd party UVC, which has a file name cpu_virtual_sequence.sv and it has the line below:

class virtual_sequence extends uvm_sequence;

My predecessor had added one more file called top_virtual_sequence.sv file at one hierarchy up and it has the same line below:

class virtual_sequence extends uvm_sequence;

This was compiling and running fine. Now I have changed the top_virtual_sequence.sv as below (as part of clean up and good coding guideline):

class top_virtual_sequence extends uvm_sequence;

This change gives compile error (which is related to the UVC). My question is:
Is it possible to have same class name inside two different files?

Thanks,
mpattaje

In reply to mpattaje:

Yes if they belong to different packages.

In reply to mpattaje:

Of course you can. But you are overwriting the first class definition with the second one when compiling the code, i.e. you could exclude the first class definition from the compile. When you are renaming this sequence you are doing something differently.

In reply to mpattaje:
You can declare two of the same class names as long as they are declared in different scopes. It does not matter if they are in the same file or different files; they need to be in different scopes, otherwise that is a compilation error.
Then you need to be careful of how you reference the class name if you are outside the scope where the class is declared. If the class is declared in a package, you can choose which package to import, or you can explicitly reference the package_name::class_name.