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

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

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 5716|回复: 4

[讨论] system verilog的array的问题, 欢迎来讨论.

[复制链接]
发表于 2011-4-8 17:10:01 | 显示全部楼层 |阅读模式

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

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

x
在标准的12.4.2中:
Elements of dynamic arrays, queues, and associative arrays that are passed by reference may get removed
from the array or the array may get resized before the called function or task completes. The specific array
element passed by reference shall continue to exist within the scope of the called tasks or functions until they
complete. Changes made to the values of array elements by the called task or function shall not be visible
outside the scope of those tasks or functions if those array elements were removed from the array before the
changes were made. These references shall be called outdated references.
那如果变成了outdated reference会怎么样?????

还有, 我怎么样直接传参数给一个"queue of string"
例如, 定义一个functionAAA, 参数为string的queue类型sq[$]
virtual function void AAA (string sq [$])
...
endfunction
调用这个function的时候, 如果我写
AAA({"SSS"});
他报错说:
formal and actual do not have assignment compatible data types (expecting datatype compatible with 'queue of string' but found 'packed array' instead).

我应该怎么写?
发表于 2011-4-14 21:36:14 | 显示全部楼层
上面一大段英文应该说的是pass by reference的意思。method参数有二种传递方式:by value, by reference,定义为ref类型的参数就是by reference的,定义为input/output/inout的就是by value的。by reference的方式下,在method call内部对参数作改变,method call外部能立即反映出来。而by value的方式下,直到method call结束后才反映出来。上面英文提到,当使用by reference方式时,在method call内部删除数组时,外面可以立即看到数组被删除,而使用by value方式时,method call内部删除数组后,外面的数组仍存在,并没有被删除
.
{"SSS"}是一个数组吧,所以这样传递肯定是不行的,类型不一致。我也不知道怎么做强制类型转换直接传进去。
发表于 2011-4-22 16:25:51 | 显示全部楼层
谢谢楼主 分享
发表于 2011-4-22 17:39:22 | 显示全部楼层
我理解这段话是说如果某个数组是by reference传进来的参数,如果相应的数组元素在外面已经被删除了,在函数或过程中依然可以看到,但这时对这些元素所做的修改已经无法再反映在函数或过程之外了。这种所谓过时的引用不是错误,但是可能引起逻辑功能上的意外。
发表于 2011-4-25 22:02:18 | 显示全部楼层
问题1:使用ref进行引用传递类似于C中的指针参数。
问题2:没这样写过,不知道原因。我一般是这样进行动态数组和队列的参数传递:
string sq_new[$];
sq_new[0] = "SSS";
AAA(sq_new);
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

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

GMT+8, 2024-5-13 06:03 , Processed in 0.023300 second(s), 9 queries , Gzip On, Redis On.

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