条件中具有无效值的 IF 语句的 Verilog 行为

Verilog behavior of IF statement with invalid value in condition

如果 Verilog 中的 IF 语句在条件中具有无效值,则仅评估 else 分支。 (在模拟中。)

例如下面在模块 SimpleIfStatement2b 中如果 a = 1'bx: b=0'b1

我在 Vegilog-2005 标准中搜索此行为,但找不到。

此行为是标准的一部分还是仅在 iverilog 模拟器的实现中? VHDL/SystemVerilog/SystemC也是这样吗? 描述这个的标准在哪里?

module SimpleIfStatement2b(input a,
        output reg b
    );

    always @(a) begin: assig_process_reg_d
        if (a) begin
            b <= 1'b0;
        end else begin
            b <= 1'b1;
        end
    end
endmodule


module main;
    reg a;
    wire b;

  SimpleIfStatement2b DUT (
    .a(a),
    .b(b)
  );

  initial begin
    a = 1'bx;
    repeat(1) #10;
    a = 1'b0;
    repeat(1) #10;
    a = 1'b1;
    repeat(1) #10;
    a = 1'b0;
    repeat(1) #10;
    a = 1'bx;
    repeat(1) #10;
    a = 1'b1;
    repeat(1) #10;
    a = 1'bx;
    repeat(10) #10;

  end

  initial begin
    repeat(10) #10;
    $finish;
  end

  initial
    $monitor("At %t, a=%b, b=%b,", $time, a, b, ); 
endmodule

http://tpcg.io/nAY75e

标准输出:

$iverilog -o main *.v
$vvp main
At                    0, a=x, b=x 
At                   10, a=0, b=1 
At                   20, a=1, b=0 
At                   30, a=0, b=1 
At                   40, a=x, b=1 
At                   50, a=1, b=0 
At                   60, a=x, b=1 

这是标准行为。

如果 'if' 条件被评估为 False,则它将继续 运行 'Else' 部分。

可以这样想:

如果我告诉你:

"If you are older than 100, High Five! Otherwise, do a starjump."

只有你超过 100 岁,我才会高五你。否则(就像 'Else' 部分)我会告诉你做一个 starjump。如果您超过 100 岁,您将不会进行 starjump,因为您已经通过 'If' 条件,但如果您不超过 100 岁,您将进行 starjump(即 'if' 条件是假)。

IEEE 标准第 9.4 节,条件语句。第二段: