在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 6736|回复: 5

请教下$cast这个函数的用法

[复制链接]
发表于 2009-9-21 23:36:19 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
对$cast的使用还是不太明白,看到这段代码,不知道是什么意思,或者说为什么这样写?这样写有什么好处?
virtual function bit compare(vmm_data actual , vmm_data expected);

abp_rw act,exp;
$cast(act,actual);

abp_rw 是一个extends vmm_data的一个class

求高人指教~
发表于 2009-9-22 07:04:37 | 显示全部楼层
For specified example, act is an object of class apb_rw, extended from vmm_data. SystemVerilog std says that assignment of parent class object (Actual) to child class object (act) should be done through casting. Child class object by the way can be used anywhere, where a parent class object can be used without casting.
发表于 2009-9-22 10:35:58 | 显示全部楼层
类似于C++中的dynamic_cast
发表于 2009-9-22 12:06:09 | 显示全部楼层
$cast is used to pass arguments(or also we call it handle):
$cast(act,actual) means act points to the object referenced by actual
I think there is no big difference with direct passing method "act=actual" if you don't want to check type of object.
 楼主| 发表于 2009-9-22 22:13:19 | 显示全部楼层
谢谢各位,学到不少~非常感谢!!
发表于 2009-9-24 09:32:32 | 显示全部楼层
顶两位高手的解答,很清楚,让这个也困扰我很久的问题得到解答!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-7 01:07 , Processed in 0.027678 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表