boolean logic operations???
I need help undrstanding the 4 basic operations NOT, AND, OR AND XOR
eg (4>7)OR(8<5)=?????
1100 OR 0011=?????
NOT 1111=?????
1100 XOR 1100=???
etc...........
guidance greatly appreciated
Neil
Community archive
I need help undrstanding the 4 basic operations NOT, AND, OR AND XOR
eg (4>7)OR(8<5)=?????
1100 OR 0011=?????
NOT 1111=?????
1100 XOR 1100=???
etc...........
guidance greatly appreciated
Neil
by thechas
NOT = the opposite of what you have.
1 NOT = 0
0 NOT = 1
OR = Any valid input generates a valid output.
00 OR = 0
01 OR = 1
10 OR = 1
11 OR = 1
AND = All inputs valid (true) = valid output.
00 AND = 0
01 AND = 0
10 AND = 0
11 AND = 1
XOR (exclusive or) only 1 input can be valid for a valid output
00 XOR = 0
01 XOR = 1
10 XOR = 1
11 XOR = 0
The above are all truth tables for 2 input logic gates.
However, the boolean logic holds true across multiple inputs or terms
Chas
by neilmay2
with reference to my examples:
eg(4>7)OR(8<5)would give me an output of FALSE?
1100 OR 0011 " " " " " " TRUE?
NOT 1111 " " " " " " TRUE?
1100 XOR 1100" " " " " " TRUE?
ETC...etc
NEIL
by thechas
Examples 3 and 4 should provide the opposite results.
1111 NOT = 0000
1100 XOR 1100 = False as both terms are the same.
Chas
PS, when you post a discussion, it can take several days for it to build and fill in all your questions.
Someof us can be contacted via the peer directory at Tech Republic.
by guruofdos
requoting your examples...
eg (4>7)OR(8<5)=?????
1100 OR 0011=?????
NOT 1111=?????
1100 XOR 1100=???
Firstly, Boolean logic works on binary values.
In the first example, convert your decimal to binary:
We have (0100>0111)OR (1000<0101)
Evaluating the contents of the parentheses 0100 is not bigger than 0111 so that expression evaluates to FALSE or 0. Again the right hand evaluates to FALSE or 0 because 1000 is not less than 0101.
We now have simplified the expression to FALSE OR FALSE. The output of this condition MUST be FALSE because the OR logic states that the output is TRUE if one OR more inputs are TRUE. In this case neither input is TRUE.
When performing Boolean operators on Binary numbers, the logic is performed on bit positions.
Your second example is 1100 OR 0011. Take the first bit of each number (most significant bit) and perform the OR logic on these bits. We have 1 OR 0 which gives a 1. The second, third and fourth bits also give the same result, so our OR function gives us an answer of 1111. True or false are only valid for single bits, or expressions that can equate to 1 or 0.
Not inverts each bit so NOT 1111 gives us 0000...but 'inverting' numbers is a little more complex because it depends on your range. A 4 bit number can either hold values from 0 to 15 or -7 to +7 if the 4th bit is used to hold sign. If bit 4 represents sign, then 1111 meaning -7 becomes 0000 meaning 0. 1010, or -2, becomes 0101, or +6.
XOR is the same as OR except only one input is allowed to be 1 to give an output of 1. 0000 XOR 1100 would give 1100. 1100 XOR 1100 would give 0000.
by guruofdos
Sorry....it's 4am, I haven't slept for 3 days, my father died yesterday and I'm a bit frazzled.
Correction on signed 4 bit binary... Unsigned 4 bit has a range of 0-15. Signed 4 bit binary has a range of -8 to +7
Using the MSB as a sign, where1 means negative number...
0000 is 0
0001 is 1
0010 is 2
etc. up to
0111 which is 7
1000 is -8
1001 is -7
1010 is -6
1011 is -5
1100 is -4
1101 is -3
1110 is -2
1111 is -1
so 0101 (5) inverted (NOT) gives 1010 which is -6
and 0100 (4) inverted gives 1011 which is -5
and 1000 (-8) inverted gives 0111 which is 7
To practice Boolean logic on binary numbers (or decimal, octal or hex) use the Windows calculator in Scientific View, which allows entry of numbers in different bases and the performing of AND, OR XOR and NOT functions. Unfortunately it cannot support 4 bit numbers (nibbles, where two nibbles = 1 byte...logically!) or true signing so it is of only limited use, but worth a look.
by guruofdos
And firstly, thank you to those who sent messages of condolence. No, it wasn't a joke!
Ok.....if you add logic functions together you can create other functions. Consider 2 input gates (although gates can have any number of inputs).
A NOT function (inverter) tacked on to the output of an AND gate gives a NAND (NOT-AND), and inverting an OR gives us a NOR (NOT-OR) gate.
NAND NOR
A B Q A B Q
0 0 1 0 0 1
0 1 1 0 1 0
1 0 1 1 0 0
1 1 0 1 1 0
In the early days oflogic, discrete components (resistors, diodes, transistors) were used to make logic gates. The SIMPLEST logic curcuit needing fewest components is an inverter or NOT gate, needing just one transistor and two resistors. Adding a second base resistor to the transistor gives us the most basic 'useful' gate, a 2 input NAND (I won't go into transistor theory here!)
When silicon chips (integrated circuits) were first made, the on-chip components were a lot bigger than today....millimeters rather than microns and so designers got more gates onto a 'chip' by using the simplest gates....NAND. The first available chips were NAND, and nothing else!
Take a common TTL chip, the 7400. This has 4
2-input NAND gates in a single 14 pin DIL package.Now NAND on it's own isn't much use, BUT, and this is the clever bit...ALL other logic functions can be made from NAND gates!!!
Tie the two inputs of a NAND together and you have an inverter (NOT). Connect THIS to another NAND output and you havean AND gate (NOT NAND, or NOT NOT AND... the two NOTS cancel).
If you use two NANDs, wired as inverters and connect them to the inputs of another NAND, you have an OR. Invert the output of this and you have NOR. So from just basic NANDS, we now have inverters (NOT), NAND, AND, NOR and OR.
by guruofdos
A and B are the inputs....
Take A and B into a NAND
and also connect A and B into an OR made from 3 NANDS
Using another NAND, combine the outputs of the NAND and OR. As a homework excersise, do the truth tables yourself!
The result is actually XNOR! Use one more NAND wired as an inverter and lo and behold....XOR.
I learned Boolean Reduction and the associated logic methods, Venn Diagrams, Karnaugh Maps and such like at my fathers knee when I was a mere slip of a lad. It's a dying art, and I'm not even sure it's taught in electronics anymore...I certainly had to study it at college back in '83 and it is the fundamental root of digital electronics. Even the latest, fastest processor that Intel or AMD can turn out has evolved from the basics of NAND gates and combinational logic. Tying outputs of combinational circuits back to inputs results in sequential or feedback logic and this gives us latches, registers, flip flops and counters....but that is a whole new subject and I'm not going any further than I have already out of deference to you, dear reader! If you want to get more info, there are a lot of books in a library!!!
To quote my late father...
"Learn something new every day..." and "I may be none the wiser,but at least I am better informed."
by guruofdos
Although your logic is correct, your answers are INCORRECT. The terms TRUE and FALSE can ONLY be used if the answer to a logical operation can ONLY evaluate to 1 or 0.
If you have two four-bit terms e.g. 1100 and 1010, then only if every possiblemanipulation of the numbers results in 1 or 0 can the answer to that manipulation be considered as TRUE or FALSE.
Consider comparisons. No matter what the numbers, the result of a greater than or less than operation can ONLY be TRUE or FALSE .Consider the binary 1100 and 0011. Performing logical AND results in 0000, which you might think is FALSE, but OR gives 1111, or 15, which is not exactly TRUE is it? OK, XOR gives 1111, NAND gives 1111 and NOR gives 0000. Yes, the answer for individual bits may be TRUE or FALSE, but when performing Boolean operations on more than one bit, the result of a zero operation is always 0000 for four bits....never FALSE.
TRUE and FALSE should be reserved for individual bits, flags or signal lines but binary answers should always be given in binary.
For 4 bit binary zero is ALWAYS 0000, never simply 0!
Is XXXX>YYYY can evaluate to TRUE OR FALSE...but as XXXX or YYYY can have 16 values, TRUE OR FALSE are not valid.
There are operationsthat give outputs OTHER than 0000 or 1111 (zero or 15), such as rotates, shifts and multiplication or division, and so for the given inputs, the expressions could evaluate to say 1001 or 1011....which could never be described as TRUE or FALSE.
0100 OR 0010 gives a result of 0110, which is not FALSE or TRUE! In decimal...it's 6.
by thechas
Thanks Guru.
My use of Boolean has been limited to logic circuits where the answer is always a 1 or a 0.
Chas
by guruofdos
at the tender age of 7....but ended up learning computer programming and hardware design....took me a while to grasp the difference!!!
Most of my apps are real world, so at the end of the day, the LED is either on or off!! The door is open or closed...TRUE or FALSE.
That's why I loved the BIT instruction in Z80 assembly language...you could actually tell if one bit on a port or register was TRUE OR FALSE without having to worry about other bits in a byte...On a PC you cannot work bit-wiseand so have to 'mask' bytes to get the required bit patterns, then test using Boolean methods.
On a Z80 CPU, the instruction would be
BIT 7,A
for test BIT 7 (MSB) of Accumulator...and it would return a TRUE or FALSE condition depending on the value of the bit (1 or 0). The PC method means reading a whole byte, masking the unwanted bits (e.g. ANDING them with 0) and then checking the answer.
LD AL,byte
LD AH, mask
AND AL,AH
CMP AL result
JZ ..... etc
or in an interpreted orcompiled language level language...
Mask=&80h
A=(A AND Mask)
If A=&80h THEN ....
The if A=&80h is an operation that does return a TRUE or FALSE, but the AND operation results in a number.
This discussion is closed to new replies.
Sort by Trending