sir, can you please explain the overflow step? i didn't really get what you've done. if overflow result is 0 that means theres no error else if its 1 that means theres an error. If MSB of x and MSB of xored are equal to each other and not equal to MSB of s, we get error, right? so in this case we can just write if ( x[n-1] == xored y[n-1] && x[n-1] != s[n-1] overflow = 1; else overflow = 0;
@sharafmakk29363 ай бұрын
Two cases: you interpret that numbers as unsigned -> overflow doesn't tell you anything, it's just a random signal of some bits in the input, while the carry out should really be interpreted as the fifth bit of s, because it literally is. if you treat the numbers as signed -> the overflow tells you that you added two positive or negative numbers and got something that cannot be expressed in the range, like you added to positive numbers (have 0 at MSB) and got a negative number in s(has MSB 1), which is obviously false. the carry out can be explained in terms of when it happens mathematically, but for our purposes, it doesn't matter, it just means that bitwise addition of the two representations of the numbers give out a carry.