For example, "11011"can be decomposed into
Sign bit data bit
1 10 1 1
The sign bit 1 represents a negative number, and the rest data bits are represented by complement, and the calculation formula is as follows:
Find the complement of the original code, that is, replace 1 with 0 and 0 with 1.
The binary code of 5 is 0 10 1, and its complement is 10 10.
Add 1 to the result to get the complement.
10 10 + 000 1 = 10 1 1
So11011means -5.
Off topic again.
In addition and subtraction of signed numbers in vhdl, it is necessary to pay attention to the problem of bit width overflow, and so is multiplication and division. If you are interested in this, you can leave me a message to discuss it.