以如下代码为例:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19module 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轮循内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复