News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Boolean Expression Simplification

Started by HiddenDragon, December 02, 2010, 02:23:42 AM

Previous topic - Next topic

HiddenDragon

Alright so my friend came up with a problem. You have two leads. If both are 0, you want a light on. If both are 1 you want a light on. If you have 10 or 01 then you want a light off. I've tried figuring it out, as has he but we can't get it.

I was thinking you would need something like this:

+ stands for OR
* stands for AND
' stands for NOT

A*B + (AB)'

Using DeMorgan's theorum, that gets simplified to

A*B + (A'+B')

Distribution

A*A' + A*B' + B*A' + B*B'

Simplify

0 + A*B' + B*A' + 0

AB' + BA'


But that doesn't work in a truth table. Any help?

redskull

put one through a NOT, then both through a NAND.

(A' * B)'

-r

***Nevermind, that doesn't work.  need sleep!
Strange women, lying in ponds, distributing swords, is no basis for a system of government

jj2007

Or, Masm-wise:
include \masm32\include\masm32rt.inc

.code
start:
mov eax, 0
mov edx, 0
xor eax, edx
dec eax
print str$(eax), 9, "00", 13, 10
mov eax, 0
mov edx, 1
xor eax, edx
dec eax
print str$(eax), 9, "01", 13, 10
mov eax, 1
mov edx, 0
xor eax, edx
dec eax
print str$(eax), 9, "10", 13, 10
mov eax, 1
mov edx, 1
xor eax, edx
dec eax
inkey str$(eax), 9, "11", 13, 10
exit

end start


-1      00
0       01
0       10
-1      11

HiddenDragon

What's that supposed to tell me jj?

I drew out the truth table for A*B+A'*B'


  |00|01 |10 |11 |
  |--+---+---+---|
00|0 | 0 | 0 | 0 |
01|0 | 0 | 0 | 0 |
10|0 | 0 | 0 | 0 |
11|0 | 0 | 0 | 1 |


But that only returns 1 if they are all 1.

dedndave

i would use an XNOR gate
that's an XOR gate with any one of the 3 leads inverted   :bg

A' XOR B = A XOR B' = (A XOR B)'

HiddenDragon


jj2007

Quote from: HiddenDragon on December 02, 2010, 03:11:48 AM
What's that supposed to tell me jj?

> You have two leads. If both are 0, you want a light on. If both are 1 you want a light on. If you have 10 or 01 then you want a light off.
That is exactly what the code demonstrates. Have you run it?

dedndave

        mov     eax,A
        xor     eax,B
        not     eax



you can now handle 32 lights at once   :P

HiddenDragon

Alright thanks then jj but I didn't need a programmatic solution. I just needed the boolean expression for it.

RuiLoureiro

see this truth table

         A     B     B'   AB' ||  A'    BA'      AB'+BA'   (AB'+BA')'
ON     0     0  |  1    0   ||  1     0           0         1
OFF    0     1  |  0    0   ||  1     1           1         0
OFF    1     0  |  1    1   ||  0     0           1         0
ON     1     1  |  0    0   ||  0     0           0         1

drizz

The truth cannot be learned ... it can only be recognized.

dedndave

the symbol for XNOR is a circle with a dot in the center



or

(AB' + A'B)'

as Rui mentioned

RuiLoureiro

#12
To solve problems like that we can use Z tables like this:

.  means  AND
+  means  OR
'  means  NOT

        Z table    Grouping 0's    we have: Z' = A'. B + A . B'
            B                                       => Z  = (A'B + AB')'
    A  | 0    1
    --------------    Grouping 1's    we have: Z  = A'. B' + A . B
     0 | 1
     1 |      1
    --------------

HiddenDragon,

            Your error comes from this:  A*B + (AB)'   
            it doesnt solve the problem

            EDIT: Search WIKIPEDIA for XNOR

Slugsnack

Yes, sound like you just want a XNOR gate. Perhaps you're not allowed to use those ? But since you're learning this stuff, you must know all gates can be constructed from NAND gates. So here is a diagram showing just that:

vanjast

Wrt gates, there are no discrete XNOR gates AFAIK, so you can make one up out of and XOR plus Inverter, or use array logic.