Assume that you have two 8-bit 2's complement numbers, a[7:0] and b[7:0]. These numbers are added to produce s[7:0]. Also compute whether a (signed) overflow has occurred.
my stupid solution:
通过最高位和次高位的进位来判断是否溢出:最高位的进位与次高位的进位异或。
another solution:
直接看两个输入的符号位与最后结果的符号位是否一致,因为溢出只有两种情况:正+正=负,负+负=正,所以无需考虑两个输入的符号位不同的情况。