【深入理解计算机系统】 三:布尔逻辑与组合电路

4.1. Boolean Expressions

Today’s digital circuits are built so that they can perform very fast operations over data that is encoded in binary. The underlying operations are part of what is known as Boolean Algebra. This algebra consists of two values known as true and false, and three operations over those values: conjunction, disjunction and negation. When using digital circuits, the values are also known as 0 and 1, high and low, or on and off. The three operations are also known by the generic names andor and not respectively. These three operations receive a set of values that are either true or false, and produce another binary value and their definition is shown in the following table:

Definition of the operations in Boolean Algebra
Operation Symbols Result
Conjunction and, * true when both operands are one
Disjunction or, + true when any operand is one
Negation  x’, 
The opposite of the operand

Out of all the possible symbols to represent the negation operation, we will use the expression 

. The expressions in Boolean algebra are similar to regular mathematical expressions but with the difference that only Boolean operations are allowed. The following table shows some analogies and differences between expressions:
Analogies and differences between algebraic expressions
Regular Algebra Boolean Algebra
1+5=6 1 + 0 = 1
3*2=6 1*1 = 1
a+b a + b (disjunction)
a*b a*b (conjunction)
  a' (negation)

As you can see, the expressions are written representing the conjunction by the symbol *, the disjunction by the symbol +, and negation as an apostrophe following the symbol. In some cases, the conjunction is simply represented by concatenating together two symbols, and conjunction has precedence over disjunction. The following expressions are equivalent:

Any symbol in Boolean algebra can only take the values true and false as opposed to the more familiar decimal algebraic expressions where symbols can take any number. Thus, we can easily enumerate all possible values of a simple expression. For example, the expression for the conjunction of two symbols, 

, has four possible values for its symbols, and for each of them we can write the value of the expression:
Values of symbols and expression
Value of a Value of b Value of a*b
0 0 0
0 1 0
1 0 0
1 1 1

This type of table containing all possible combination of values for the symbols that appear in an expression and the result of evaluating the expression is known as the truth table. Thus, the previous table is the truth table of the conjunction of two symbols. Analogously we can create the truth table of the disjunction:

Truth table of the disjunction
Value of a Value of b Value of a+b
0 0 0
0 1 1
1 0 1
1 1 1

And for completeness, the truth table of the negation is:

Truth table of negation
Value of a Value of a'
0 1
1 0

Boolean expressions can be arbitrarily complex and contain arbitrary operations among symbols, but only using the three operations: conjunction, disjunction and negation. For any Boolean expression, the truth table is obtained by creating a column for each symbol that appears in the expression, one final column with the evaluation of the expression, and for each row, one possible combination of the values of its symbols. Let us consider the following Boolean expression:

The truth table derived from this expression will contain four columns, one for each of the symbols 

 and 
 an additional one for the result of the expression. There will be a row for any possible combination of values for the three variables. Since each of them can have two possible values, the table will contain eight rows:
Truth table for ab + bc(b+c)
a b c Result
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1

The values of the fourth column are obtained by substituting each appearance of a symbol by its corresponding value in the row and applying the operation rules previously described. For example, in the third row, the values for the variables are 

and 
. If we replace these values in the expression, we obtain 
. We can start simplifying the expression by applying the operand rules:
01 + 10(1 + 0) = 0*1 + 1*0*(1 + 0)
               = 0 + 1*0*(1 + 0)
               = 0 + 1*0*1
               = 0 + 0
               = 0

And if we consider the values in the fourth row:

01 + 11(1 + 1) = 0*1 + 1*1*(1 + 1)
               = 0 + 1*1*(1 + 1)
               = 0 + 1*1*1
               = 0 + 1
               = 1

The process of substituting the symbols in an expression by a specific set of values is called evaluation. The last column of the truth table of a Boolean expression is then obtained by performing as many evaluations as possible combinations of values for its symbols.

4.1.1. Identical Boolean Expressions

Consider the two Boolean expressions

你可能感兴趣的:(javascript,vue,jquery,java,spring,boot)