在systemverilog中,module可以被嵌套调用。最顶层的module名应与vsim.do中指定的模块名相同:vsim -t fs -novopt sim_top glbl,此表示仿真顶层模块名为:sim_top.仿真是从顶层模块中执行,其中的always,initial,模块实例化等有实际意义的语句均会被执行,但function、task等语句只有在调用时才会被执行,就跟c语言中相同。
tips:在questa10.2中,当变量在声明时缺省是automatic,但赋有初值的变量在定义时需指定automatic or static.
Examp:
`timescale 1ns/1ps
module module1();
task frame();
automatic byte preamble[1:7]='{10,10,10,10,10,10,10};
$display("4th byte of preamble=%0b\n",preamble[4]);
endtask
initial
begin
frame();
$display("%m : Inside Module1 ");
//$root.top.U.U.frame();//using frame within instance U within instance U
end
endmodule
module module2();
task vlanframe();
typedef struct {bit [15:0]tag_type;bit [15:0]control_info;}vlan_byte;
automatic vlan_byte v1='{'d33024,11110000};
automatic vlan_byte v2 [0:1]='{'{'d33024,0001