UVM_PKG

Hi All,

We include uvm_pkg as follows.

`include “uvm_macros.svh”
import uvm_pkg::*;

My question is that “uvm_macros.svh” is also included in uvm_pkg.sv also, why do we need to include “uvm_macros.svh” separately in tb_top ?
please reply.

Thanks,
Rahul

Compiler directives like the `define macros to not exist in any scope like a package. There are processed before recognizing any SystemVerilog syntax. They only exist while the current unit of code is being compiled (the compilation unit).

http://go.mentor.com/package-import-versus-include

In reply to dave_59:

Hi Dave,

Thanks for reply,

I have one more question. why do we not include the uvm_pkg::*, We just import the package, how does this package work without including?

Thanks

In reply to rahulkumarkhokher@gmail.com:

Did you read my article?

In reply to dave_59:

Hi Dave,

Thanks for reply.

I went through your article.

As per my understanding, we need to include the package first and then import, If i do not include package, only import , i get compilation error.
But this is not true for uvm_pkg, we import uvm_pkg, not include,why?

Thanks,
Rahul

In reply to rahulkumarkhokher@gmail.com:

A package needs to be compiled before it can be imported. There are many tool specific ways to compile SystemVerilog code. You can put the package filename on the command line before the file that will import it.

compile package_file.sv your_code.sv

Many tools will let you compile them separately

compile package_file.sv
compile your_code.sv

You can put include package_file.sv inside your_code.sv and just compile your_code.sv. But packages like the UVM rarely change, so it does not make sense to compile them over and over again. So the separate compilation approach is best. Most simulators have already compiled the UVM for you in their releases, so there is never a need for you to compile them either separately or using include.

How to import uvm_pkg and our pkg in uvm

In reply to baladevi:
What do you mean by “our” pkg? Please ask this as a new question topic and not under an old thread

In reply to baladevi:

You have to use the import statement in the places where you need a package. This could be an interface, a module or a class.
The Syntax is

import uvm_pkg::*;    //UVM pkg
import your_pkg::*;   // your pkg