完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
刚接触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用的是破解版的。 |
|
相关推荐
1个回答
|
|
自答一下吧,终于知道在一个块中,一定要先声名,也就是说要把initial块改为
initial begin Tr t1 ; Tr t2 ; BadTr t3 ; BadTr t4 ; ... 这样就过啦!希望有一样问题的兄弟可以参考! |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
基本FPGA或者树莓派或者其它微处理器(尽量压缩成本且完成项目)DFB激光器稳频
1469 浏览 1 评论
2564 浏览 1 评论
助力AIoT应用:在米尔FPGA开发板上实现Tiny YOLO V4
1207 浏览 0 评论
3716 浏览 1 评论
3325 浏览 0 评论
2337 浏览 58 评论
6190 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-2-3 01:49 , Processed in 0.905142 second(s), Total 37, Slave 31 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号