System verilog 系统Verilog内部运算符操作数位长度

System verilog 系统Verilog内部运算符操作数位长度,system-verilog,System Verilog,如何在系统Verilog中计算“内部”子表达式的位长度? 表达式的类型似乎取决于操作数是数值文字还是变量 以下系统Verilog程序: `define M( x ) $display( `"x -- %b`", x ) module top (); bit [3:0] a, b; initial begin // (a+b) could be evaluated either to 0 or 16, depending on the bit length of the ex

如何在系统Verilog中计算“内部”子表达式的位长度? 表达式的类型似乎取决于操作数是数值文字还是变量

以下系统Verilog程序:

`define M( x ) $display( `"x -- %b`", x )

module top ();

  bit [3:0] a, b;

  initial begin
    // (a+b) could be evaluated either to 0 or 16, depending on the bit length of the expression.

    a = 15;
    b = 1;

    `M(4'd1 inside { [(a+b):17] } );  // 0
    `M(4'd1);
    `M(   b inside { [(a+b):17] } );  // 1
    `M(   b);

  end

endmodule
产出:

Chronologic VCS simulator copyright 1991-2019
Contains Synopsys proprietary information.
Compiler version P-2019.06-SP1-1_Full64; Runtime version P-2019.06-SP1-1_Full64;  May  8 20:27 2020
4'd1 inside { [(a+b):17] } -- 0
4'd1 -- 0001
b inside { [(a+b):17] } -- 1
b -- 0001
           V C S   S i m u l a t i o n   R e p o r t 
Time: 0
CPU Time:      0.250 seconds;       Data structure size:   0.0Mb
Fri May  8 20:27:08 2020

PS:Verific对标准的解释与Synopsys不同。

对于相同值和宽度的两个不同操作数,它会产生不同的结果,这肯定是一个工具错误


然而,正确答案有点含糊不清,因为IEEE 1800-2017 LRM中的自定表达式导致的表11-21位长度中遗漏了
运算符。这是针对LRM的一个示例,一致认为is的行为应该与
语句中的
大小写相同,因为在进行任何比较之前,所有操作数的大小都将调整为最大大小的操作数。在此示例中,文本
17
的宽度为32位,且宽度最大。因此
inside
运算符的结果应该是
1'b0

对于相同值和宽度的两个不同操作数,它会产生不同的结果,这肯定是一个工具错误

然而,正确答案有点含糊不清,因为IEEE 1800-2017 LRM中的自定表达式导致的表11-21位长度中遗漏了
运算符。这是针对LRM的一个示例,一致认为is的行为应该与
语句中的
大小写相同,因为在进行任何比较之前,所有操作数的大小都将调整为最大大小的操作数。在此示例中,文本
17
的宽度为32位,且宽度最大。因此,
内部
运算符的结果应该是
1'b0