Dave,
We had a similar requirement when trying to wrap UVM pkg into our own, custom package. Do you think it is reasonable to ask for an extension in the language for it? Consider:
package our_uvm_pkg;
import uvm_pkg::all; // Just a notion, for now it won’t work
export uvm_pkg::all; // Just a notion, for now it won’t work
// More code, uses some of the uvm base classes, but not all
endpackage : our_uvm_pkg
The benefit is user then has to import only “our_uvm_pkg” and gets all what’s provided by UVM.
In reply to kiranag:
You have to look at the flow of source code to determine which symbols are candidate versus actually being imported. It can change over the span of a scope.
package p1;
int a,b,c,d;
endpackage
package p2;
int a;
import p1::*; // the identifiers b,c, and d all become candidates for importing
// 'a' is already declared in this local scope
function f1;
$display(b); // 'b' moves from being a candidate to actually imported.
endfunction
int c; // 'c' is no longer a candidate for importing
//int b; // this would be an error because 'b' was already imported.
endpackage
So the
import p1::*; wildcard import statement actually imports only one symbol; ‘b’. This distinction becomes more important when you have the same symbol being a candidate for import coming from multiple packages. That’s OK until someone tries to actually import the symbol - which package do you import it from? It means you eithe rneed to make the symbol name unique in each package, or the intent was not to import the symbol by declaring locally beforehand.
I follow this coding style putting all the files in a pkg.sv file but there is this compilation error. Not sure what caused this.
Error-[SE] Syntax error
Following verilog source has syntax error :
“project/verif/vkits/glbk/lbk_pkg.sv”, 66: token is ‘endpackage’
endpackage:lbk_pkg
^
System verilog keyword ‘endpackage’ is not expected to be used in this
context.
// Forward class declarations to work around compile errors
typedef class config_vseq_c;
typedef class reg_comp_rst_vseq_c;
typedef class lbk_sec_reg_walk_seq_c;
typedef class lbk_non_sec_reg_walk_seq_c;
typedef class lbk_reg_walk_seq_c;
typedef class no_op_seq_c;
typedef class csr_background_read_vseq_c;
typedef class env_c;
typedef class lbk_p2x_cfg_c;
typedef class lbk_x2p_cfg_c;
//---------------------------------------------------------------------
// Group: Includes
// (include package member files here, alphabetically.) include “cvm_pcc_defs.vh”
include "lbk_ecam_cfg_function.sv" include “lbk_types.sv” include "lbk_cfg.sv" include “lbk_pkt_cfg.sv” include "lbk_pkt.sv" include “lbk_trans_sb.sv” include "lbk_chan_cred_sb.sv" include “lbk_perf_sb.sv” include "lbk_ebp_sb.sv" include “lbk_exer_seq_cfg.sv” include "lbk_test_vseq_lib.sv" include “lbk_vsqr.sv” include "lbk_config_vseq_lib.sv" include “lbk_env.sv” include "lbk_p2x_cfg.sv" include “lbk_x2p_cfg.sv”
In reply to kiranag:
You have to look at the flow of source code to determine which symbols are candidate versus actually being imported. It can change over the span of a scope.
package p1;
int a,b,c,d;
endpackage
package p2;
int a;
import p1::*; // the identifiers b,c, and d all become candidates for importing
// 'a' is already declared in this local scope
function f1;
$display(b); // 'b' moves from being a candidate to actually imported.
endfunction
int c; // 'c' is no longer a candidate for importing
//int b; // this would be an error because 'b' was already imported.
endpackage
So the
import p1::*; wildcard import statement actually imports only one symbol; ‘b’. This distinction becomes more important when you have the same symbol being a candidate for import coming from multiple packages. That’s OK until someone tries to actually import the symbol - which package do you import it from? It means you eithe rneed to make the symbol name unique in each package, or the intent was not to import the symbol by declaring locally beforehand.
Dave, just to be 100% sure: In your example, if the last line of the package was
export p1::;, then another module with
import p2::; would get
p1::b. Correct? Therefore, export statements should be at the end of packages? This still is a big pain and not what’s expected. I agree with the suggestion of
export XX::all; or similar. Do you know of any work on this in the 1800 committee?
It doesn’t matter where the wildcard export statement is located in the package. Whatever was actually imported by the point of the endpackage gets exported.
The 1800 SystemVerilog committee has been dormant for the last 3 years. Vendors needed a chance to catch up after too many years of change, and users want stability.
In reply to dhrogoff:
It doesn’t matter where the wildcard export statement is located in the package. Whatever was actually imported by the point of the endpackage gets exported.
Makes sense. Thanks.
The 1800 SystemVerilog committee has been dormant for the last 3 years. Vendors needed a chance to catch up after too many years of change, and users want stability.
In reply to dave_59:
Hello Dave,
Hope you doing good
I have a dummy uvm environment with all components like for environment(seqr,driver,monitor,scoreboard) and a package file (env_pkg.sv) ,
for sequences( seq_pkg.sv) and for tests(test_pkg.sv)
Iget error as "Error-[SV-LCM-PND] Package not defined
top.sv, 6
top, “seq_pkg::”
Package scope resolution failed. Token ‘seq_pkg’ is not a package.
Originating module ‘top’.
Move package definition before the use of the package.
Error-[SV-LCM-PND] Package not definedtop.sv, 7
top, “env_pkg::”
Package scope resolution failed. Token ‘env_pkg’ is not a package.
Originating module ‘top’.
Move package definition before the use of the package.
Please guide ,thnks