1

当你有一个binary number,A = 5'b00100并且你得到它的否定version时, B.

 reg signed [4:0] A, B;
 B = -A;

这是做什么的?

4

2 回答 2

2

它将创建数字的二进制补码:翻转位并加一!

于 2012-11-22T13:49:52.427 回答
0

in the above case if both A/B are declared as 'signed', then the simple logic of B = -A should work and i tried in a simple case and it works. Verilog already does everything in 2's complement.

于 2018-05-24T19:06:37.443 回答