刚接触systemverilog,最近在采用questasim10.1版本进行
仿真时,发现貌似questasim不支持扩展类的操作?
代码如下:
`
timescale 1ns/1ns
module sv_practice() ;
class Tr;
int c ;
virtual function Tr copy();
copy=new();
copy_data(copy);
endfunction
virtual function void copy_data (input Tr t);
t.c=c;
endfunction
endclass
class BadTr extends Tr;
int d ;
virtual function Tr copy();
BadTr bad;
bad=new();
copy_data(bad);
return bad;
endfunction
virtual function void copy_data (input Tr t);
BadTr bad;
super.copy_data(t);
$cast(bad,t);
bad.d=d;
endfunction
endclass:BadTr
initial
begin
Tr t1 ;
Tr t2 ;
t1 = new();
t1.c = 11 ;
t2 = t1.copy();
$display ("t1.c=%0d",t1.c);
$display ("t2.c=%0d",t2.c);
BadTr t3 ;
BadTr t4 ;
t3 = new();
t3.d = 55 ;
t4 = t3.copy();
$display ("t3.d=%0d",t3.d);
$display ("t4.d=%0d",t4.d);
end
endmodule
这段代码在用questasim进行编译的时候,在“BadTr t3”附近报错,报告如下:
** Error: D:/Project/self-study/SV/copy/sv_practice.sv(47): Illegal declaration after the statement near line '43'. Declarations must precede statements. Look for stray semicolons.
这是什么意思?我quesasim用的是破解版的。
0