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

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

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 1835|回复: 9

[求助] 在systemverilog的书上,在程序中修改对象的代码 求解

[复制链接]
发表于 2016-11-2 16:34:19 | 显示全部楼层 |阅读模式

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

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

x
task generat(int n)
  trans tr;
  tr=new();
  repeat(n)
  begin
    tr.addr=$random();
    $display("tr.addr=%h",tr.addr);
    transmit(tr);
  end
endtask
书上的解释说打印的addr是不一样的,但是transmit发送出去的addr都是一样的,怎么理解?
发表于 2016-11-2 19:04:17 | 显示全部楼层
作者没有表达清楚,应该是这个意思:tr里面永远是最后一个随机出来的地址。
发表于 2016-11-2 19:38:28 | 显示全部楼层
回复 2# chensong0007
为啥呢
 楼主| 发表于 2016-11-3 13:48:30 | 显示全部楼层
????????
发表于 2016-11-3 14:40:29 | 显示全部楼层
句柄永远指向对象本身,现在翻译的书,不要太在意思文字了,往往会被误导。
 楼主| 发表于 2016-11-3 16:07:27 | 显示全部楼层



这是原版的书上写的
    What are the symptoms of this mistake? The code above creates only one
Transaction, so every time through the loop, generator_bad changes the object
at the same time it is being transmitted. When you run this, the $display shows
many addr values, but all transmitted Transaction objects have the same value
of addr.
 楼主| 发表于 2016-11-3 16:13:31 | 显示全部楼层
试了一下,把new放在循环的外面,发出去的也不会是同一个包啊
 楼主| 发表于 2016-11-3 16:14:31 | 显示全部楼层


句柄永远指向对象本身,现在翻译的书,不要太在意思文字了,往往会被误导。
chensong0007 发表于 2016-11-3 14:40



这是原版的
    What are the symptoms of this mistake? The code above creates only one
Transaction, so every time through the loop, generator_bad changes the object
at the same time it is being transmitted. When you run this, the $display shows
many addr values, but all transmitted Transaction objects have the same value
of addr.
 楼主| 发表于 2016-11-3 16:15:39 | 显示全部楼层
原版

What are the symptoms of this mistake? The code above creates only one
Transaction, so every time through the loop, generator_bad changes the object
at the same time it is being transmitted. When you run this, the $display shows
many addr values, but all transmitted Transaction objects have the same value
of addr.
发表于 2016-11-3 19:02:25 | 显示全部楼层
直接一点,你可以做实验去验证。如果transmit(tr)这个里面就实现了接口上的driver的话,那么每一次都是不是一样的。如果transmit(tr)只是传输一个句柄到另一个队列里面,那么最后每一次driver出来的信号都是一样的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

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

GMT+8, 2024-9-21 22:42 , Processed in 0.020932 second(s), 7 queries , Gzip On, Redis On.

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