2
\$\begingroup\$

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!

asked May 2, 2013 at 4:25
\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

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 (&).

answered May 2, 2013 at 4:41
\$\endgroup\$
3
  • \$\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\$ Commented 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\$ Commented 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\$ Commented May 2, 2013 at 5:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.