systemVerilog中数组的解释

sara8d

我是SystemVerilog的新手。我开始从网站学习我阅读了以下示例,但不了解结果。

//EXAMPLE: arrays 

module arr; 
bit [2:0][3:0] arr [4:0][5:0]; 

initial 
begin 
  $display(" $left %0d $right %0d $low %0d $high %0d $increment %0d $size %0d $dimensions %0d",$left(arr),$right(arr),$low(arr),$high(arr),$increment(arr),$size(arr),$dimensions(arr) ); 
end 
endmodule 

结果:

$ left 4 $ right 0 $ low 0 $ high 4 $ increment 1 $ size 5 $ dimensions 4

请说明结果。

马修·泰勒(Matthew Taylor)

SystemVerilog多维数组具有两种类型的维:packedunpacked可以有任意数量的打包尺寸(写在变量名之前)和任意数量的未打包尺寸(写在变量名之后)。尺寸从1从左到右)编号首先是未包装的尺寸因此,在对数组的元素建立索引时,第一个未打包的维将成为最高有效索引(最先写入),而最后一个打包的维将成为最低有效索引(最后写入),从而导致奇怪的排序。这并不像它最初看起来那样愚蠢,因为可以将打包尺寸的索引留在列表的末尾。

因此,在您的示例中,尺寸的编号如下所示:

bit [2:0][3:0] arr [4:0][5:0];
      3    4         1    2

System Verilog中具有以下阵列查询功能

$left/$right(arrayname, dimension) – returns the left or right bound
$low/$high(arrayname, dimension)   – returns the lowest or highest bound
$increment(arrayname, dimension)   – returns 1 if $left >= $right and -1 otherwise
$size(arrayname, dimension)        – returns the number of elements of the given dimension
$dimensions(arrayname)             – returns the number of dimensions
$unpacked_dimensions(arrayname)    – returns the number of unpacked dimensions 

当您调用系统函数(例如$left未指定您要表示的维数)时,它默认为维1。系统功能正在输出尺寸1的值,因为未指定尺寸。您也可以在这些系统功能中指定尺寸。因此,此代码:

module arr; 

  bit [2:0][3:0] arr [4:0][5:0]; 

  initial begin 
    $display(" DIMENSION 1 (the default) : $left %0d $right %0d $low %0d $high %0d $increment %0d $size %0d $dimensions %0d",
               $left(arr),$right(arr),$low(arr),$high(arr),$increment(arr),$size(arr),$dimensions(arr) ); 
    $display(" DIMENSION 1 (specified)   : $left %0d $right %0d $low %0d $high %0d $increment %0d $size %0d $dimensions %0d",
               $left(arr,1),$right(arr,1),$low(arr,1),$high(arr,1),$increment(arr,1),$size(arr,1),$dimensions(arr) ); 
    $display(" DIMENSION 2 (specified)   : $left %0d $right %0d $low %0d $high %0d $increment %0d $size %0d $dimensions %0d",
               $left(arr,2),$right(arr,2),$low(arr,2),$high(arr,2),$increment(arr,2),$size(arr,2),$dimensions(arr) ); 
    $display(" DIMENSION 3 (specified)   : $left %0d $right %0d $low %0d $high %0d $increment %0d $size %0d $dimensions %0d",
               $left(arr,3),$right(arr,3),$low(arr,3),$high(arr,3),$increment(arr,3),$size(arr,3),$dimensions(arr) ); 
    $display(" DIMENSION 4 (specified)   : $left %0d $right %0d $low %0d $high %0d $increment %0d $size %0d $dimensions %0d",
               $left(arr,4),$right(arr,4),$low(arr,4),$high(arr,4),$increment(arr,4),$size(arr,4),$dimensions(arr) ); 
    end 

endmodule 

http://www.edaplayground.com/x/4NzY

输出此:

DIMENSION 1 (the default) : $left 4 $right 0 $low 0 $high 4 $increment 1 $size 5 $dimensions 4
DIMENSION 1 (specified)   : $left 4 $right 0 $low 0 $high 4 $increment 1 $size 5 $dimensions 4
DIMENSION 2 (specified)   : $left 5 $right 0 $low 0 $high 5 $increment 1 $size 6 $dimensions 4
DIMENSION 3 (specified)   : $left 2 $right 0 $low 0 $high 2 $increment 1 $size 3 $dimensions 4
DIMENSION 4 (specified)   : $left 3 $right 0 $low 0 $high 3 $increment 1 $size 4 $dimensions 4

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

SystemVerilog中的struct切片数组

来自分类Dev

SystemVerilog 中解包数组元素的单独绑定

来自分类Dev

如何在systemverilog中获取值数组作为plusargs?

来自分类Dev

SystemVerilog中动态数组参数的默认值

来自分类Dev

如何在systemverilog中获取值数组作为plusargs?

来自分类Dev

在 SystemVerilog 中制作二维数组/矩阵

来自分类Dev

Systemverilog接口突破数组

来自分类Dev

基于另一个数组在SystemVerilog中约束整个数组

来自分类Dev

基于另一个数组在SystemVerilog中约束整个数组

来自分类Dev

如何在C ++模板中调用静态数组的解释器?

来自分类Dev

VBA中的数组下标-有人可以解释吗?

来自分类Dev

转义字符在 SAS 中解释为数组

来自分类Dev

VBA 从数组解释中获取唯一值

来自分类Dev

我应该如何解释 numpy 数组中的循环?

来自分类Dev

无法解释的数组中的最后一项

来自分类Dev

随机化过程中的Systemverilog唯一数组值

来自分类Dev

解释数组文档(C ++)

来自分类Dev

解释指针数组

来自分类Dev

awk数组解释?

来自分类Dev

在PostgreSQL中解释与解释分析

来自分类Dev

在SystemVerilog中约束整个对象

来自分类Dev

SystemVerilog中的随机WIDTH掩码

来自分类Dev

systemVerilog中的按位求反

来自分类Dev

在SystemVerilog中约束整个对象

来自分类Dev

SystemVerilog中的随机WIDTH掩码

来自分类Dev

将字节数组解释为Python 2.7中的long数组

来自分类Dev

SystemVerilog数组是按值或引用传递的吗?

来自分类Dev

排序SystemVerilog关联数组的最佳方法?

来自分类Dev

具有不同输入的systemverilog接口数组