The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: HiddenDragon on December 02, 2010, 02:23:42 AM

Title: Boolean Expression Simplification
Post by: HiddenDragon on December 02, 2010, 02:23:42 AM
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?
Title: Re: Boolean Expression Simplification
Post by: redskull on December 02, 2010, 02:30:25 AM
put one through a NOT, then both through a NAND.

(A' * B)'

-r

***Nevermind, that doesn't work.  need sleep!
Title: Re: Boolean Expression Simplification
Post by: jj2007 on December 02, 2010, 03:01:46 AM
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
Title: Re: Boolean Expression Simplification
Post by: HiddenDragon on December 02, 2010, 03:11:48 AM
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.
Title: Re: Boolean Expression Simplification
Post by: dedndave on December 02, 2010, 03:13:08 AM
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)'
Title: Re: Boolean Expression Simplification
Post by: HiddenDragon on December 02, 2010, 03:14:47 AM
Thanks for the edit and the help.
Title: Re: Boolean Expression Simplification
Post by: jj2007 on December 02, 2010, 03:30:29 AM
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?
Title: Re: Boolean Expression Simplification
Post by: dedndave on December 02, 2010, 03:40:32 AM
        mov     eax,A
        xor     eax,B
        not     eax



you can now handle 32 lights at once   :P
Title: Re: Boolean Expression Simplification
Post by: HiddenDragon on December 02, 2010, 12:08:58 PM
Alright thanks then jj but I didn't need a programmatic solution. I just needed the boolean expression for it.
Title: Re: Boolean Expression Simplification
Post by: RuiLoureiro on December 02, 2010, 12:40:46 PM
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
Title: Re: Boolean Expression Simplification
Post by: drizz on December 02, 2010, 03:10:43 PM
A*B + (A+B)'
Title: Re: Boolean Expression Simplification
Post by: dedndave on December 02, 2010, 03:46:47 PM
the symbol for XNOR is a circle with a dot in the center

(http://img574.imageshack.us/img574/9576/xnor.jpg)

or

(AB' + A'B)'

as Rui mentioned
Title: Re: Boolean Expression Simplification
Post by: RuiLoureiro on December 02, 2010, 05:01:34 PM
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
Title: Re: Boolean Expression Simplification
Post by: Slugsnack on December 02, 2010, 05:37:20 PM
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:
(http://upload.wikimedia.org/wikipedia/en/2/2f/XNOR_Using_NAND.png)
Title: Re: Boolean Expression Simplification
Post by: vanjast on December 03, 2010, 11:31:28 PM
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.
Title: Re: Boolean Expression Simplification
Post by: dedndave on December 03, 2010, 11:51:46 PM
oh yah - they are quite common
in CMOS, they are CD4077 or motorola 14077