module的嵌套调用与执行顺序分析(systemverilog)

本文探讨了SystemVerilog中模块的嵌套调用和执行顺序。仿真从顶层模块sim_top开始,执行always、initial块及模块实例化等语句,而function、task则在调用时执行。在Questa 10.2环境下,变量默认为automatic,但赋值初值时需明确指定automatic或static。
摘要由CSDN通过智能技术生成

在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
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值