Electronic – Choosing Appropriate Bit Length

verilog

So, this has been bothering me for a couple semesters, and I guess I'm just too embarrassed to ask the professor for clarification, but I always feel a little in the dark about "choosing appropriate bit length" for output of binary arithmetic.

Say, for instance I am using verilog to code an adder that adds 3 10-bit 2's complement numbers, and will need to output a one-bit overflow detector. Should I choose the output to be 10-bit? Or should I increase it to 11 bit to avoid overflow for convenience?

I have no specific code as it's just a conceptual question.

Thanks!

Best Answer

If you adds two 10-bit 2's complement numbers, you need 11 bit to display all possible results. If you add three such words, you will need 12 bits. You may use only the 10 most significant bits of the result but you will loose precision.

If you know that all inputs are restricted to -170 < x < 170, 10 bits will be enough to hold all possible results.

If you use a 10 bit output plus a overflow signal, you do know the result is bigger than 511, but you don't know if it is larger or smaller than 1023.

I would like a solution that does not deliver false results without an error indication.