# In verilog, what effect does the not (!) operator have on high impedance and don't care conditions?

I'm writing some verilog and simulating it using modelsim. I have a block that looks like this:

        if(wr_req & !cam_busy & !lookup_latched & !cam_match_found & !cam_match_found_d1) begin
cam_we           <= 1;
cam_din          <= wr_cmp_data ;
wr_ack           <= 1;
lut_wr_data      <= wr_data;
end


lookup_latched is in high impedence. cam_match_found and cam_match_found_d1 are both in don't care states.

It seems to me like the statement should just ignore those signals.

The one issue I noticed was that the signals were being bitwise anded instead of logically anded (I didn't write the code). Will this have an affect on the result? (I imagine it will)

Thanks!

In verilog, a 'z' at the input of a gate transforms to an 'x' on the output of the gate. An 'x' at the input of the gate also translates to an 'x' on the output of the gate.

Therefore your code reduces to if(wr_req & !cam_busy & X & X & X)

The value of (something & X) can be either 0, or X, and in both cases the if statement will evaluate to false (if(X) is the same as if(0)).

The one issue I noticed was that the signals were being bitwise anded instead of logically anded (I didn't write the code). Will this have an affect on the result? (I imagine it will)

If those are all 1-bit signals, than logical AND (&&) is the same result as bitwise AND (&).

• Ah thank you! I just figured it out. I wasn't forcing a signal that I should have been on the input. I was still uncertain of the behavior – Caustic May 2 '13 at 4:56
• Also, 1-bit signals makes sense for the logical vs bitwise and, but for example, what would the behavior of 8'hXF && 8'hFF be? I'm assuming that this evaluates to true since there are non-zero bits in the first operand. Is this correct? – Caustic May 2 '13 at 5:02
• I believe that 8'hXF will reduce to true for purposes of logical operation, but it's probably not a good idea to use multi-bit values in a logical operation (will probably give lint or synthesis warnings). – Tim May 2 '13 at 5:16