|
From: Scott D. <sc...@da...> - 2004-06-11 18:50:04
|
On Fri, 11 Jun 2004, Eric Smith wrote:
> Scott wrote:
>> A perhaps somewhat simpler expression is:
>> v = ( ((sum ^ ~b) & (a ^ ~b)) & 0x80) ? 1 : 0;
>
> Does not seem to give the same results. An error in simplification?
I obviously didn't test it. Instead, I (mis)read the boolean equation from
a karnaugh map. I should've written:
v = ( ((sum ^ a) & (a ^ ~b)) & 0x80) ? 1 : 0;
Or you can write:
v = ( ((sum ^ a) & (~a ^ b)) & 0x80) ? 1 : 0;
The karnaugh map for addition looks like:
a,b
pp pn nn np
+---+---+---+---+
p | | | v | |
sum +---+---+---+---+
n | v | | | |
+---+---+---+---+
the 'p' and 'n refer to the sign (bit 7). The 'v' in the map corresponds
to the conditions where there is an overflow. To read this, you can see v
is true for two conditions. The first is when the sum is p and the two
inputs are n. There are numerous ways to extract the boolean equation from
the map. The most direct case is the first one I wrote. The others
involving xor's and and's.
a,b
pp pn nn np
+---+---+---+---+
p | 1 | | 1 | |
sum +---+---+---+---+
n | 1 | | 1 | |
+---+---+---+---+
This map is: a ^ ~b = ~a ^ b = ~(a ^ b)
a,b
pp pn nn np
+---+---+---+---+
p | | | 1 | 1 |
sum +---+---+---+---+
n | 1 | 1 | | |
+---+---+---+---+
This map is: sum ^ a = ~(sum ^ ~a) = ~(~sum ^ a)
Anding these two maps yields the overflow map. So there are at least 9
different ways of writing this with the xor's and and's.
Scott
PS. Do they still teach Karnaugh maps in logic design?
|