概述
以如下代码为例:
module exe;
int array1[3:1]='{1,13,24};
int array2[1:5]='{23,33,45,65,90};
int array3[int]='{12:1, 45:2, 66:7};
int array4[string]='{"one":111, "ten":234, "twenty":0091};
initial begin
foreach (array1[i])
$display("array1[i]=%d",i,array1[i]);
foreach (array2[i])
$display("array2[i]=%d",i,array2[i]);
foreach (array3[i])
$display("array1[i]=%d",i,array3[i]);
foreach (array4[str])
//注意字符串索引用str
$display("array4[%s]=%d",str,array4[str]);
//这里%s表示将索引的字符串直接打印,如果仍用str,会根据ASICII码转换成相应的数字
end
endmodule
上述代码打印结果为
最后
以上就是疯狂夕阳为你收集整理的sv中数组foreach轮循的顺序的全部内容,希望文章能够帮你解决sv中数组foreach轮循的顺序所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复