https://zhuanlan.zhihu.com/p/106486751
http://blog.eetop.cn/blog-1561828-2316833.html
我们通过一个简单的例子来进行一下说明。
package my_pkg;
int y = 10;
task common();
$display("In my_pkg,Calledfrom somewhere");
endtask
program test_case;
import my_pkg::*;
initial begin
$display("y = %0d",y);
common();
end
endprogram
运行结果:
y = 10
In my_pkg,Calledfrom somewhere
package my_pkg_0;
int x = 25;
task common();
$display("In my_pkg_0,Calledfrom somewhere");
endtask
package my_pkg;
int y = 10;
task common();
$display("In my_pkg,Calledfrom somewhere");
endtask
program test_case;
import my_pkg::*;
import my_pkg_0::*;
task common();
$display("In program,Calledfromsomewhere");
endtask
initial begin
$display("x = %0d",x);
$display("y = %0d",y);
common();
my_pkg::common();
my_pkg_0::common();
end
endprogram
运行结果:
x = 25
y = 10
In program.Calledfromsomewhere
In my_pkg.Calledfromsomewhere
In my_pkg_0.Calledfromsomewhere
package my_pkg_0;
int x = 25;
task common();
$display("In my_pkg_0,Calledfrom somewhere");
endtask
package my_pkg;
import my_pkg_0::*;
export my_pkg_0::x;
export my_pkg_0::common;
int y = 10;
task common_0();
common();
$display("In my_pkg,Calledfrom somewhere");
endtask
program test_case;
import my_pkg::*
task common();
$display("In program,Calledfromsomewhere");
endtask
initial begin
$display("x = %0d",x);
$display("y = %0d",y);
common();
my_pkg::common();
my_pkg_0::common();
end
endprogram
运行结果:
x = 25
y = 10
In program.Calledfromsomewhere
In my_pkg_0.Calledfromsomewhere
In my_pkg.Calledfromsomewhere
In my_pkg_0.Calledfromsomewhere
原文:https://www.cnblogs.com/xuqing125/p/14772119.html