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_wr_addr <= wr_addr;
cam_din <= wr_cmp_data ;
cam_data_mask <= wr_cmp_dmask;
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!
1 Answer 1
Your code will not work.
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 (&).
-
\$\begingroup\$ 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 \$\endgroup\$Caustic– Caustic2013年05月02日 04:56:25 +00:00Commented May 2, 2013 at 4:56
-
\$\begingroup\$ 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? \$\endgroup\$Caustic– Caustic2013年05月02日 05:02:37 +00:00Commented May 2, 2013 at 5:02 -
\$\begingroup\$ 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). \$\endgroup\$Tim– Tim2013年05月02日 05:16:29 +00:00Commented May 2, 2013 at 5:16
Explore related questions
See similar questions with these tags.