0
\$\begingroup\$

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;
endmodule

but the output is always zero.

is there anything wrong?

(I don't want to use @always)

asked Jan 19, 2019 at 21:21
\$\endgroup\$
20
  • \$\begingroup\$ is this a school assignment? \$\endgroup\$ Commented Jan 19, 2019 at 21:23
  • \$\begingroup\$ Can you share your testbench? \$\endgroup\$ Commented Jan 19, 2019 at 21:23
  • \$\begingroup\$ How do you know that the output is always zero? \$\endgroup\$ Commented Jan 19, 2019 at 21:24
  • \$\begingroup\$ I am new to hardware description languages and because of this i can't handle this @jsotola \$\endgroup\$ Commented Jan 19, 2019 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\$ Commented Jan 19, 2019 at 21:25

1 Answer 1

2
\$\begingroup\$

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.

answered Jan 19, 2019 at 22:05
\$\endgroup\$

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.