this is my code:

module zero(out,A,B);
   output signed[5:0] out;
   input signed[5:0] A,B;
   assign out = A[5:0]<<<2 + B[5:0]>>>1;

but the output is always zero.

is there anything wrong?

(I don't want to use @always)

  • \$\begingroup\$ is this a school assignment? \$\endgroup\$ – jsotola Jan 19 '19 at 21:23
  • \$\begingroup\$ Can you share your testbench? \$\endgroup\$ – The Photon Jan 19 '19 at 21:23
  • \$\begingroup\$ How do you know that the output is always zero? \$\endgroup\$ – Elliot Alderson Jan 19 '19 at 21:24
  • \$\begingroup\$ I am new to hardware description languages and because of this i can't handle this @jsotola \$\endgroup\$ – mohamadreza Jan 19 '19 at 21:24
  • \$\begingroup\$ Please answer the three questions that were asked in the first three comments to your question. Even if you are new to HDL you should be able to answer these questions. \$\endgroup\$ – Elliot Alderson Jan 19 '19 at 21:25

From our discussion in comments, it seems the problem is operator precedence. According to this, + has higher precedence than <<<, so your expression will calculate (A <<< (2 + B)) >>> 1 rather than what you might expect.

This can be solved by adding parentheses to ensure the expected order of operations.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.