If IF-statement in Verilog has invalid value in condition, only else branch is evaluated. (In simulation.)
For example below in module SimpleIfStatement2b if a = 1'bx: b=0'b1
I was searching in Vegilog-2005 standard for this behavior and and can not find it.
Is this behavior a part of standard or it is only in implementation of iverilog simulator? Is this also a case in VHDL/SystemVerilog/SystemC? Where is standard describing this?
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
stdout:
$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