在做设计验证机需要写很多的代码,其中大部分在任务和函数中使用。systemverilog在这方面增加了很多改进,使其更加接近C语言,从而使代码的编写变得更加容易,尤其是在处理参数的传递上。
- 在Systemverilog中,过程块和其方法通过域进行划分,分为硬件部分和软件部分,具体的内容如下图:
针对function参数类型设置考题如下:
typedef struct{
bit [1:0] cmd;
bit [7:0] addr;
bit [31:0] data;
} trans;
function automatic void op_copy(trans t,trans s);
t = s;
endfunction
initial begin
trans s;
trans t;
s.cmd = 'h1;
s.addr = 'h10;
s.data = 'h100;
op_copy(t,s);
t.cmd = 'h2;
end
问:t 中的三个成员变量{cmd,addr, data}最后的数值是多少?
{‘h2,'h0,'h0}
由于function的参数,默认的 方向都是input,这里trans t 变量被