**Logical vs. Bitwise NOT** What are the values of out1 and out2 ? reg [3…
**Logical vs. Bitwise NOT** What are the values of out1 and out2 ? reg [3:0] a; reg [3:0] out1; reg out2; initial begin a = 4'b0100; out1 = ~a; out2 = !a; end
- out1 = 4'b1011, out2 = 1'b0
- out1 = 4'b1011, out2 = 1'b1
- out1 = 4'b0000, out2 = 1'b0
- out1 = 4'b1111, out2 = 1'b1
Correct answer
A. out1 = 4'b1011, out2 = 1'b0
Explanation
The bitwise inversion operator ~ flips each bit individually: ~4'b0100 = 4'b1011 . The logical NOT operator ! tests whether the vector is zero: because a != 0 (True), !a returns 1'b0 (False).