Friday, 28 February 2014

UNIVERSAL LOGIC GATES

Universal logic gates


The 7400 chip, containing four NANDs. The two additional pins supply power (+5 V) and connect the ground.
Charles Sanders Peirce (winter of 1880–81) showed that NOR gates alone (or alternatively NAND gates alone) can be used to reproduce the functions of all the other logic gates, but his work on it was unpublished until 1933. The first published proof was by Henry M. Sheffer in 1913, so the NAND logical operation is sometimes called Sheffer stroke; the logical NOR is sometimes called Peirce's arrow. Consequently, these gates are sometimes called universal logic gates.

LOGIC GATES

TypeDistinctive shapeRectangular shapeBoolean algebra between A & BTruth table
ANDAND symbolAND symbolA \cdot B or A & B
INPUTOUTPUT
ABA AND B
000
010
100
111
OROR symbolOR symbolA+B
INPUTOUTPUT
ABA OR B
000
011
101
111
NOTNOT symbolNOT symbol\overline{A} or ~A
INPUTOUTPUT
ANOT A
01
10
In electronics a NOT gate is more commonly called an inverter. The circle on the symbol is called a bubble, and is used in logic diagrams to indicate a logic negation between the external logic state and the internal logic state (1 to 0 or vice versa). On a circuit diagram it must be accompanied by a statement asserting that the positive logic convention or negative logic convention is being used (high voltage level = 1 or high voltage level = 0, respectively). The wedge is used in circuit diagrams to directly indicate an active-low (high voltage level = 0) input or output without requiring a uniform convention throughout the circuit diagram. This is called Direct Polarity Indication. See IEEE Std 91/91A and IEC 60617-12. Both the bubble and the wedge can be used on distinctive-shape and rectangular-shape symbols on circuit diagrams, depending on the logic convention used. On pure logic diagrams, only the bubble is meaningful.
NANDNAND symbolNAND symbol\overline{A \cdot B} or A | B
INPUTOUTPUT
ABA NAND B
001
011
101
110
NORNOR symbolNOR symbol\overline{A + B} or A - B
INPUTOUTPUT
ABA NOR B
001
010
100
110
XORXOR symbolXOR symbolA \oplus B
INPUTOUTPUT
ABA XOR B
000
011
101
110
XNORXNOR symbolXNOR symbol\overline{A \oplus B} or {A \odot B}
INPUTOUTPUT
ABA XNOR B
001
010
100
111
Two more gates are the exclusive-OR or XOR function and its inverse, exclusive-NOR or XNOR. The two input Exclusive-OR is true only when the two input values are different, false if they are equal, regardless of the value. If there are more than two inputs, the gate generates a true at its output if the number of trues at its input is odd ([1]). In practice, these gates are built from combinations of simpler logic gates.



DIGITAL LOGIC

Digital Logic
Digital logic is a wide-open and rapidly-growing field, and yet every single digital device operates on some combination of three basic logic functions: AND, OR, and NOT. Even the most complex circuit contains some combination of these three functions, and can be reduced to them in the final analysis. These pages define and describe the three basic functions and some of the unending ways in which they can be usefully combined.
      In many cases, logic gates are combined in various ways and the output signal(s) is/are determined entirely by the current combination of input signals.
      Sequential Logic
      Sometimes a circuit must remember its current or previous state. In such cases, the output state of a circuit is determined by what has happened an in what order in the past.
      Alternate Flip-Flop Circuits
      There are many different ways to design flip-flops.
      Counters
      Flip-flops are much more useful when you combine them and use them in groups. In general, there are two categories of applications that use multiple flip-flops. One of these is the counter.
      Registers
      In addition to counters, we also have registers, which can hold a multi-bit value while something is done with that value.
      The 555 Timer
      The 555 timer is a deceptively simple circuit which has proved to be extremely useful in a wide range of applications.

gates

Digital logic gates[edit]

Digital logic is the application of the Boolean algebra of 0 and 1 to electronic hardware consisting of logic gates connected to form a circuit diagram. Each gate implements a Boolean operation, and is depicted schematically by a shape indicating the operation. The shapes associated with the gates for conjunction (AND-gates), disjunction (OR-gates), and complement (inverters) are as follows.[16]
LogicGates.GIF
The lines on the left of each gate represent input wires or ports. The value of the input is represented by a voltage on the lead. For so-called "active-high" logic 0 is represented by a voltage close to zero or "ground" while 1 is represented by a voltage close to the supply voltage; active-low reverses this. The line on the right of each gate represents the output port, which normally follows the same voltage conventions as the input ports.
Complement is implemented with an inverter gate. The triangle denotes the operation that simply copies the input to the output; the small circle on the output denotes the actual inversion complementing the input. The convention of putting such a circle on any port means that the signal passing through this port is complemented on the way through, whether it is an input or output port.
There being eight ways of labeling the three ports of an AND-gate or OR-gate with inverters, this convention gives a wide range of possible Boolean operations realized as such gates so decorated. Not all combinations are distinct however: any labeling

Digital logic gates[edit]

Digital logic is the application of the Boolean algebra of 0 and 1 to electronic hardware consisting of logic gates connected to form a circuit diagram. Each gate implements a Boolean operation, and is depicted schematically by a shape indicating the operation. The shapes associated with the gates for conjunction (AND-gates), disjunction (OR-gates), and complement (inverters) are as follows.[16]
LogicGates.GIF
The lines on the left of each gate represent input wires or ports. The value of the input is represented by a voltage on the lead. For so-called "active-high" logic 0 is represented by a voltage close to zero or "ground" while 1 is represented by a voltage close to the supply voltage; active-low reverses this. The line on the right of each gate represents the output port, which normally follows the same voltage conventions as the input ports.
Complement is implemented with an inverter gate. The triangle denotes the operation that simply copies the input to the output; the small circle on the output denotes the actual inversion complementing the input. The convention of putting such a circle on any port means that the signal passing through this port is complemented on the way through, whether it is an input or output port.
There being eight ways of labeling the three ports of an AND-gate or OR-gate with inverters, this convention gives a wide range of possible Boolean operations realized as such gates so decorated. Not all combinations are distinct however: any labeling of AND-gate ports with inverters realizes the same Boolean operation as the opposite labeling of OR-gate ports (a given port of the AND-gate is labeled with an inverter if and only if the corresponding port of the OR-gate is not so labeled). This follows from De Morgan's laws.
If we complement all ports on every gate, and interchange AND-gates and OR-gates, as in Figure 4 below, we end up with the same operations as we started with, illustrating both De Morgan's laws and the Duality Principle. Note that we did not need to change the triangle part of the inverter, illustrating self-duality for complement.
DeMorganGates.GIF
Because of the pairwise identification of gates via the Duality Principle, even though 16 schematic symbols can be manufactured from the two basic binary gates AND and OR by furnishing their ports with inverters (circles), they only represent eight Boolean operations, namely those operations with an odd number of ones in their truth table. Altogether there are 16 binary Boolean operations, the other eight being those with an even number of ones in their truth table, namely the following. The constant 0, viewed as a binary operation that ignores both its inputs, has no ones, the six operations xy, ¬x, ¬y (as binary operations that ignore one input), xy, and xy have two ones, and the constant 1 has four ones. of AND-gate ports with inverters realizes the same Boolean operation as the opposite labeling of OR-gate ports (a given port of the AND-gate is labeled with an inverter if and only if the corresponding port of the OR-gate is not so labeled). This follows from De Morgan's laws.
If we complement all ports on every gate, and interchange AND-gates and OR-gates, as in Figure 4 below, we end up with the same operations as we started with, illustrating both De Morgan's laws and the Duality Principle. Note that we did not need to change the triangle part of the inverter, illustrating self-duality for complement.
DeMorganGates.GIF
Because of the pairwise identification of gates via the Duality Principle, even though 16 schematic symbols can be manufactured from the two basic binary gates AND and OR by furnishing their ports with inverters (circles), they only represent eight Boolean operations, namely those operations with an odd number of ones in their truth table. Altogether there are 16 binary Boolean operations, the other eight being those with an even number of ones in their truth table, namely the following. The constant 0, viewed as a binary operation that ignores both its inputs, has no ones, the six operations xy, ¬x, ¬y (as binary operations that ignore one input), xy, and xy have two ones, and the constant 1 has four ones.

LAWS OF BOOLEAN ALGEBRA

Laws of Boolean Algebra

law of Boolean algebra is an identity such as x∨(yz) = (xy)∨z between two Boolean terms, where a Boolean term is defined as an expression built up from variables and the constants 0 and 1 using the operations ∧, ∨, and ¬. The concept can be extended to terms involving other Boolean operations such as ⊕, →, and ≡, but such extensions are unnecessary for the purposes to which the laws are put. Such purposes include the definition of a Boolean algebra as any model of the Boolean laws, and as a means for deriving new laws from old as in the derivation of x∨(yz) = x∨(zy) from yz = zy as treated in the section on axiomatization.

Monotone laws

Boolean algebra satisfies many of the same laws as ordinary algebra when we match up ∨ with addition and ∧ with multiplication. In particular the following laws are common to both kinds of algebra:
(Associativity of ∨)x∨(yz)=(xy)∨z
(Associativity of ∧)x∧(yz)=(xy)∧z
(Commutativity of ∨)xy=yx
(Commutativity of ∧)xy=yx
(Distributivity of ∧ over ∨)x∧(yz)=(xy)∨(xz)
(Identity for ∨)x∨0=x
(Identity for ∧)x∧1=x
(Annihilator for ∧)x∧0=0
Boolean algebra however obeys some additional laws, in particular the following:
(Idempotence of ∨)xx=x
(Idempotence of ∧)xx=x
(Absorption 1)x∧(xy)=x
(Absorption 2)x∨(xy)=x
(Distributivity of ∨ over ∧)x∨(yz)=(xy)∧(xz)
(Annihilator for ∨)x∨1=1
A consequence of the first of these laws is 1∨1 = 1, which is false in ordinary algebra, where 1+1 = 2. Taking x = 2 in the second law shows that it is not an ordinary algebra law either, since 2×2 = 4. The remaining four laws can be falsified in ordinary algebra by taking all variables to be 1, for example in Absorption Law 1 the left hand side is 1(1+1) = 2 while the right hand side is 1, and so on.
All of the laws treated so far have been for conjunction and disjunction. These operations have the property that changing either argument either leaves the output unchanged or the output changes in the same way as the input. Equivalently, changing any variable from 0 to 1 never results in the output changing from 1 to 0. Operations with this property are said to be monotone. Thus the axioms so far have all been for monotonic Boolean logic. Nonmonotonicity enters via complement ¬ as follows.[3]

Nonmonotone laws[edit]

The complement operation is defined by the following two laws.
(Complementation 1)      x∧¬x=0         
(Complementation 2)x∨¬x=1.
All properties of negation including the laws below follow from the above two laws alone.[3]
In both ordinary and Boolean algebra, negation works by exchanging pairs of elements, whence in both algebras it satisfies the double negation law (also called involution law)
(Double negation)     ¬¬x = x.       
But whereas ordinary algebra satisfies the two laws
(−x)(−y)=xy
(−x) + (−y)=−(x + y),
Boolean algebra satisfies De Morgan's laws,
(De Morgan 1)x)∧(¬y)=¬(xy)
(De Morgan 2)x)∨(¬y)=¬(xy).

Completeness[edit]

At this point we can now claim to have defined Boolean algebra, in the sense that the laws we have listed up to now entail the rest of the subject. The laws Complementation 1 and 2, together with the monotone laws, suffice for this purpose and can therefore be taken as one possible complete set of laws or axiomatization of Boolean algebra. Every law of Boolean algebra follows logically from these axioms. Furthermore Boolean algebras can then be defined as the models of these axioms as treated in the section thereon.
To clarify, writing down further laws of Boolean algebra cannot give rise to any new consequences of these axioms, nor can it rule out any model of them. Had we stopped listing laws too soon, there would have been Boolean laws that did not follow from those on our list, and moreover there would have been models of the listed laws that were not Boolean algebras.
This axiomatization is by no means the only one, or even necessarily the most natural given that we did not pay attention to whether some of the axioms followed from others but simply chose to stop when we noticed we had enough laws, treated further in the section on axiomatizations. Or the intermediate notion of axiom can be sidestepped altogether by defining a Boolean law directly as any tautology, understood as an equation that holds for all values of its variables over 0 and 1. All these definitions of Boolean algebra can be shown to be equivalent.
Boolean algebra has the interesting property that x = y can be proved from any non-tautology. This is because the substitution instance of any non-tautology obtained by instantiating its variables with constants 0 or 1 so as to witness its non-tautologyhood reduces by equational reasoning to 0 = 1. For example the non-tautologyhood of xy = x is witnessed by x = 1 and y = 0 and so taking this as an axiom would allow us to infer 1∧0 = 1 as a substitution instance of the axiom and hence 0 = 1. We can then show x = y by the reasoning x = x∧1 = x∧0 = 0 = 1 = y∨1 = y∨0 =y.

Duality principle[edit]

There is nothing magical about the choice of symbols for the values of Boolean algebra. We could rename 0 and 1 to say α and β, and as long as we did so consistently throughout it would still be Boolean algebra, albeit with some obvious cosmetic differences.
But suppose we rename 0 and 1 to 1 and 0 respectively. Then it would still be Boolean algebra, and moreover operating on the same values. However it would not be identical to our original Boolean algebra because now we find ∨ behaving the way ∧ used to do and vice versa. So there are still some cosmetic differences to show that we've been fiddling with the notation, despite the fact that we're still using 0s and 1s.
But if in addition to interchanging the names of the values we also interchange the names of the two binary operations, now there is no trace of what we have done. The end product is completely indistinguishable from what we started with. We might notice that the columns for xy and xy in the truth tables had changed places, but that switch is immaterial.
When values and operations can be paired up in a way that leaves everything important unchanged when all pairs are switched simultaneously, we call the members of each pair dual to each other. Thus 0 and 1 are dual, and ∧ and ∨ are dual. The Duality Principle, also called De Morgan duality, asserts that Boolean algebra is unchanged when all dual pairs are interchanged.
One change we did not need to make as part of this interchange was to complement. We say that complement is a self-dual operation. The identity or do-nothing operation x (copy the input to the output) is also self-dual. A more complicated example of a self-dual operation is (xy) ∨ (yz) ∨ (zx). It can be shown that self-dual operations must take an odd number of arguments; thus there can be no self-dual binary operation.
The principle of duality can be explained from a group theory perspective by fact that there are exactly four functions that are one-to-one mappings (automorphisms) of the set of Booleanpolynomials back to itself: the identity function, the complement function, the dual function and the contradual function (complemented dual). These four functions form a group under function composition, isomorphic to the Klein four-groupacting on the set of Boolean polynomials.

Thursday, 27 February 2014

Boolean algebra

In mathematics and mathematical logicBoolean algebra is the subarea of algebra in which the values of the variables are the truth values true and false, usually denoted 1 and 0 respectively. Instead of elementary algebra where the values of the variables are numbers, and the main operations are addition and multiplication, the main operations of Boolean algebra are the conjunctionand, denoted ∧, the disjunction or, denoted ∨, and the negation not, denoted ¬.
Boolean algebra was introduced in 1854 by George Boole in his book An Investigation of the Laws of Thought. According to Huntington the term "Boolean algebra" was first suggested bySheffer in 1913.
Boole's first book The Mathematical Analysis of Logic published in 1847 included the original theory. This was proposed as a Mathematical language dealing with the questions of logic which is now needed in the design of modern digital equipment, and now exists as a core data type in all modern programming languages generally abbreviated to as type bool, representing true or false within assertion logic.
Boolean algebra has been fundamental in the development of computer science and digital logic. It is also used in set theory and statistics.

Whereas in elementary algebra expressions denote mainly numbers, in Boolean algebra they denote the truth values false and true. These values are represented with the bits (or binary digits) being 0 and 1. They do not behave like the integers 0 and 1, for which 1 + 1 = 2, but may be identified with the elements of the two-element field GF(2), for which 1 + 1 = 0 with + serving as the Boolean operation XOR.
Boolean algebra also deals with functions which have their values in the set {0, 1}. A sequence of bits is a commonly used such function. Another common example is the subsets of a set E: to a subset F of E is associated the indicator function that takes the value 1 on F and 0 outside F.
As with elementary algebra, the purely equational part of the theory may be developed without considering explicit values for the variables.

Basic operations

The basic operations of Boolean algebra are the following ones:
  • And (conjunction), denoted xy (sometimes x AND y or Kxy), satisfies xy = 1 if x = y = 1 and xy = 0 otherwise.
  • Or (disjunction), denoted xy (sometimes x OR y or Axy), satisfies xy = 0 if x = y = 0 and xy = 1 otherwise.
  • Not (negation), denoted ¬x (sometimes NOT x, Nx or !x), satisfies ¬x = 0 if x = 1 and ¬x = 1 if x = 0.
If the truth values 0 and 1 are interpreted as integers, these operation may be expressed with the ordinary operations of the arithmetic:
xy = xy,
xy = x + y - xy,
¬x = 1 - x.
Alternatively the values of xyxy, and ¬x can be expressed by tabulating their values with truth tables as follows.
Figure 1. Truth tables
xyxyxy
0000
1001
0101
1111
x¬x
01
10
NOTE:
One may consider that only the negation and one of the two other operations are basic, because of the following identities that allow to define the conjunction in terms of the negation and the disjunction, and vice versa:
x ∧ y = ¬(¬x ∨ ¬y)
x ∨ y = ¬(¬x ∧ ¬y)


Derived operations

We have so far seen three Boolean operations. We referred to these as basic, meaning that they can be taken as a basis for other Boolean operations that can be built up from them by composition, the manner in which operations are combined or compounded. Here are some examples of operations composed from the basic operations.
x → y=¬x ∨ y
x ⊕ y=(x ∨ y) ∧ ¬(x ∧ y)
x ≡ y=¬(x ⊕ y)
These definitions give rise to the following truth tables giving the values of these operations for all four possible inputs.
xyx → yx ⊕ yx ≡ y
00101
10010
01110
11101
The first operation, x → y, or Cxy, is called material implication. If x is true then the value of x → y is taken to be that of y. But if x is false then we ignore the value of y; however we must return some truth value and there are only two choices, so we choose the value that entails less, namely true. (Relevance logic addresses this by viewing an implication with a false premise as something other than either true or false.)
The second operation, x ⊕ y, or Jxy, is called exclusive or to distinguish it from disjunction as the inclusive kind. It excludes the possibility of both x and y. Defined in terms of arithmetic it is addition mod 2 where 1 + 1 = 0.
The third operation, the complement of exclusive or, is equivalence or Boolean equality: x ≡ y, or Exy, is true just when x and y have the same value. Hence x ⊕ y as its complement can be understood as x ≠ y, being true just when x and y are different. Its counterpart in arithmetic mod 2 is x + y + 1.
Given two operands, each with two possible values, we have 22 = 4 possible combinations of inputs. Because each output can have two possible values, we have a total of 24 = 16 possible binary Boolean operations.