Boolean Logic

From ASM Book

Jump to: navigation, search

Boolean logic was developed by George Boole in the late 1800s. At its core, boolean logic is simple to master and will be useful later in programming. The following boolean examples will be represented using truth tables,logic gates, and the binary operation on two numbers, represented as binary numbers of course.

Along the lines of electronics, a gate operates by on and off states (0=off or 1=on). The inputs to the gate(A,B) are on the left and the output (C) is on the right. Following along in the part of the 'AND' example below, reading from the 'Truth Table', the inputs A and B are required to be 'on' in order for C to be on (1). It could be read

as the following 
IF A=0 AND B=0 then C=0
IF A=0 AND B=1 then C=0
IF A=1 AND B=0 then C=0
IF A=1 AND B=1 then C=1

Image:booleanlogic1.png


Notice that the result from NAND and NOR are the exact complement of the result from AND and OR, respectively.


Image:booleanlogic2.png


Contents

Uses of the operations

Combinations of the logic

One or more of these logical operations can be grouped together to form complex logic. Combining an AND and an OR, for example, in pseudocode: IF (A=1 AND B=1) OR G=1 then C=1 (A AND B must be true for C to be true.. G (an input) is optional. This has created a somewhat complex logical gate on which can be based a reaction, be it from software or other.

Coding the logic

FOR MORE BIT OPERATIONS, SEE Bit Operations.

Notes

Boolean logic is the basis for much of the internal processor logic. Addition and subtraction are actually simulated using Boolean logic!

The symbols showed above is those used in the USA, but in Sweden, The UK (and other IEC conforming countries another set of symbols is used (which according to some people (myself included) is more descriptive (Booleanly thinking, like OR (A OR B <=> A+B) [[>=1]] ) than the US versions)) Here is a good page that shows both in comparison:
http://chiptoxic.geekcoalition.co.uk/?q=logic_gates

Personal tools