0% found this document useful (0 votes)
72 views9 pages

Lecture 002 Digital Fundamentals-II

This document discusses Boolean algebra and logic. It introduces basic Boolean operations like AND, OR, and NOT. Truth tables are presented to show the output for each operation given different input combinations. Axioms of Boolean algebra are defined, along with theorems for single variables, two variables, and three variables. Methods for multiplying out and factoring Boolean expressions are described. Logical functions like NOT, AND, and OR are explained through their truth tables. Boolean logic represents the foundation for how digital computers manipulate binary values representing true and false states.

Uploaded by

MK Milly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views9 pages

Lecture 002 Digital Fundamentals-II

This document discusses Boolean algebra and logic. It introduces basic Boolean operations like AND, OR, and NOT. Truth tables are presented to show the output for each operation given different input combinations. Axioms of Boolean algebra are defined, along with theorems for single variables, two variables, and three variables. Methods for multiplying out and factoring Boolean expressions are described. Logical functions like NOT, AND, and OR are explained through their truth tables. Boolean logic represents the foundation for how digital computers manipulate binary values representing true and false states.

Uploaded by

MK Milly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Lecture 002-Digital computer Fundamentals

BOOLEAN ALGEBRA
Basic Boolean Operations

Basic Operations are AND, OR, and Complement (inverse)

Truth Tables list all combinations of inputs and the


corresponding outputs for combinational circuits.

An AND gate produces a 1 iff all inputs are 1


An OR gate produces a 1 iff one or more inputs are 1
A NOT gate (inverter) produces an output opposite to the input

X Y | XY | X+Y | X'
-----+----+-----+---
0 0| 0| 0 |1
0 1| 0| 1 |1 (provide symbols)
1 0| 0| 1 |0
1 1| 1| 1 |0

Combining AND with NOT and OR with NOT, we have NAND & NOR

X Y | (XY)' | (X+Y)'
-----+-------+-------
0 0| 1 | 1
0 1| 1 | 0 (provide symbols)
1 0| 1 | 0
1 1| 0 | 0

Show circuit diagram and truth table for F = XY + X'Y'Z

Draw circuit for F = (AB + C)' and ask class for Boolean expression

Ask class to draw circuit for F = (A + C)(B' + D)

Real logic circuits behavior is a function of time.


Logic values cannot change instantaneously. Also, there
is a time delay associated with every logic gate.

** Axioms

Axioms: minimal set of definitions assumed to be true

X = 0 if X <> 1 X = 1 if X <> 0

If X = 0, X' = 1 If X = 1, X' = 0

0.0=0 1+1=1
1.1=1 0+0=0

0.1=1.0=0 1+0=0+1=1

The above five axioms completely define switching algebra.


All other facts about the system can be proved starting with
the axioms.

Single-Variable Theorems:

X+0=X X(1) = X -- Identities

X+1=1 X(0) = 0 -- Null elements

X+X=X XX = X -- Idempotency

(X')' = X -- Involution

X + X' = 1 XX' = 0 -- Complements

These theorems are easily proved by showing that they


are valid for both possible values of X.

Any boolean expression can be substituted for the


variable X in the above theorems.

Two- and Three-Variable Theorems:

XY = YX X+Y=Y+X -- Commutativity

X(YZ) = (XY)Z X + (Y + Z) = (X + Y) + Z -- Associativity

From the above we see that any number of boolean variables


ANDed together will have a value of '1' iff every variable
has a value of '1'.

Likewise, any number of boolean variables ORed together


will have a value of '0' iff every variable has a value of '0'.

(D1): X(Y + Z) = XY + XZ (D2): X + YZ = (X + Y)(X + Z)


-- Distributivity

X + XY = X X(X + Y) = X -- Covering

XY + XY' = X (X + Y)(X + Y') = X -- Combining

(X + Y')Y = XY XY' + Y = X + Y
Any boolean expression can be substituted for X and Y
in the above theorems.

Example: Simplify AB'(C + D) + (C + D)'

AB'(C + D) + (C + D)' = AB' + (C + D)'


by XY' + Y = X + Y, where X = AB' and Y = (C + D)'

Multiplying Out and Factoring:

SUM OF PRODUCTS: An expression is said to be in sum-of-products


form when all products are the products of single variables only.

Example: AB + AC + CD' + E is a sum of products


A(B+C) + CD + E' is not a sum of products

The distributive laws are used to multiply out an


expression to obtain a sum-of-products form. Applying D2
first, when applicable, can reduce the amount of work required
to arrive at a simplified sum-of-products form.

Multiplying Out Example:

(A + B)(B + C)(B + D')(ACD' + E)


= (A + B)(B + CD')(ACD' + E) by D2
= (B + ACD')(ACD' + E) by D2 & Comm. law
= ACD' + BE by D2 & Comm. law

(A + B')(A + D' + C)(A + D' + B)


= (A + B')(A + D' + BC) D2
= A + B'(D' + BC) D2
= A + B'D' D1

PRODUCT OF SUMS: An expression is said to be in product-of-sums


form when all sums are sums of single variables.

Example: (A + B')CD is a product of sums


(AB + C)(B + C) is not a product of sums

The distributive laws can be used to factor an expression


repeatedly until the expression is in a product-of-sums form.
Applying D1 first can reduce the amount of work required to fully
factor an expression.

Factoring Example:
ABC + A'B'C + CD'
= C(AB + A'B') + CD' by D1
= C(AB + A'B' + D') by D1
= C((AB + A')(AB + B') + D') by D2
= C((A + A')(B + A')(A + B')(B + B') + D') by D2
= C((B + A')(A + B') + D')
= C(B + A'+ D')(A + B'+ D') by D2

ABC + A'B'C
= C(AB + A'B') D1
= C((AB + A')(AB + B')) D2
= C((A' + A)(A' + B)(B' + A)(B' + A)) D2
= C(A' + B)(B' + A)

Boolean Logic and Logical Functions

Every bit in a computer system can hold a value of either “one” or “zero”, which represent the basic “on” or
“off” states inherent in a binary digital system. In the preceding topics in this section, I demonstrated how
groups of these bits can be collected into sets to represent larger binary numbers, and then how those can be
used for performing various mathematical operations.

However, as I mentioned when I introduced the concept of binary information, we can also interpret the “on”
and “off' values of a binary digit as “true” or “false” respectively. These can represent various logical conditions
within a computer or other system. Furthermore, there are various logical operations that can be used to
manipulate and combine these “true” or “false” values to represent more complex logical states. One of the
pioneers of using binary values in logical thought was British mathematician George Boole (1815-1864), and in
recognition of his contribution to this field, this system of binary values and conditions is commonly called
boolean logic.

Boolean Logical Functions

Boolean logic defines a number of boolean logical functions, which are also sometimes called operators. Each
of these uses a logical algorithm to compute an output value based on the value of one or more inputs. The
algorithm determines when the output is a “true” value, based on what combination of “true” and “false” values
the inputs take. For this reason, the table that shows the inputs and outputs for a logical function is called a truth
table. Each of the logical functions is analogous to a “real world” logical operation that we use to define various
logical situations, as we will see.

It is much easier to see how boolean logic works by looking at examples, rather than reading these types of
formal descriptions. So, let's just jump right in and see it in action, by looking at the different functions and how
they work.

The NOT Function

Let's start with the simplest, the NOT function. As you might expect, this is a just a negation; the output is the
opposite of the input. The NOT function takes only one input, so it is called a unary function or operator. The
truth table for NOT is shown in Table 9. As you can see, the output is true when the input is false, and vice-
versa.
Table 9: NOT Operator Truth Table
Input Output
False True
True False

The NOT function logically represents the opposite of a condition. For example, suppose we have a bit called
“B1” whose logical meaning is that when the bit is “true”, a particular pixel on a screen is lit up. Then the
boolean expression “NOT B1” would be the opposite: it would be false when the pixel is lit up, and thus true
only when the pixel is not lit up. Pretty straight-forward.

Now, before proceeding further, I am going to play a little trick on you.  As I said above, boolean logic is
based on “true” and “false” values. However, I also said that “true” and “false” are represented in computers by
“one” or “zero” values. For this reason, boolean logic is often expressed in terms of ones and zeroes, instead of
“true” and “false”. The circuits inside computer processors and other devices manipulate one and zero bits
directly using these functions. In some (but not all) cases they interpret “one” and “zero” as “true” and “false”,
but in either case the two representations are functionally equivalent.

Table 10 shows the same truth table as Table 9, but using bit values: each "True" is represented as a 1 and each
"False" as a 0.

Table 10: NOT Operator Truth Table (Using Bit Values)


Input Output
0 1
1 0

The AND and OR Functions

There are two other primary boolean functions that are widely used: the AND function and the OR function. The
output of an AND function is true only if its first input and its second input and its third input (etc.) are all true.
The output of an OR function is true if the first input is true or the second input is true or the third input is true
(again, etc.)

Both AND and OR can have any number of inputs, with a minimum of two. Table 11 shows the truth table for
the AND function, with two inputs. You can see that the output is a 1 only when both inputs are 1, and is 0
otherwise.

Table 11: AND Operator Truth Table


Input #1 Input #2 Output
0 0 0
0 1 0
1 0 0
1 1 1

Like the NOT function, the AND function represents a logical operation similar to how we use the word in our
every day lives. For example, at lunch time, I might suggest to a colleague "let's go out for lunch and stop at the
post office".

The truth table for the OR function (again with two inputs) is shown in Table 12. Here, the output is 1 whenever
a 1 appears in at least one input, not necessarily both as in the previous table.

Table 12: OR Operator Truth Table


Input #1 Input #2 Output
0 0 0
0 1 1
1 0 1
1 1 1

Interestingly, unlike the AND function, the boolean OR function in fact does not have the same meaning as the
way that we routinely use the word “or” in English. When we say “or”, we usually mean one “or” the other, but
not both: “you can have apple pie or chocolate cake for dessert”. In the boolean OR however, the output is true
as long as any of the inputs is true, even if more than one is.

Exclusive-OR (XOR or EOR)

A modification of OR called Exclusive-OR (abbreviated either XOR or EOR) represents the way we normally
use “or” in the real world. Its output is only true if one input is true or the other, but not both. The truth table for
XOR is as shown in Table 13. Notice the difference between this table and Table 12: the output is 0 in the case
where both inputs is 1.

Table 13: Exclusive OR (XOR) Operator Truth Table


Input #1 Input #2 Output
0 0 0
0 1 1
1 0 1
1 1 0

Combining Boolean Functions to Create Boolean Expressions

The functions described above can also be combined in arbitrary ways to produce more complex logical
conditions. Boolean logic expressions are used in many different contexts in the computing field. A common
place that most people use them is in a World Wide Web search engine. For example, if you enter “cheese AND
(cheddar OR swiss) NOT wisconsin” into a search engine, the program will return pages that contain the word
“cheese” that also contain the word “cheddar” or “swiss” (or both), but that do not contain the word
“wisconsin”.

(Sorry, Wisconsinite cheese lovers—but I live in Vermont! )

Boolean functions are the building blocks of much of the circuitry within computer hardware. The functions are
implemented as tiny gates that are designed to allow electrical energy to flow to the output only based on
certain combinations of inputs as described by the truth tables for functions like NOT, AND, OR and others. In
networking, boolean logic is important for describing certain conditions and functions in the operation of
networks. Boolean functions are also very important because they are used to set, clear and mask strings of
binary digits, which we will explore in the next topic.

Key Concept: Boolean logic is a system that uses boolean functions to produce outputs based on varying
conditions in their input data. The most common boolean functions are NOT, which produces as output
the opposite of its input; AND, which is true (1) only if all of its inputs are true (1); OR, which is true if
any of its inputs is true; and XOR, which is true only if exactly one of its inputs is true (or put another way, if
the inputs are different). These functions can be used in boolean logic expressions that represent conditional
states for making decisions, and can also be used for bit manipulation.

Bit Masking (Setting, Clearing and Inverting) Using Boolean Logical Functions

The boolean functions NOT, AND, OR and XOR describe different ways that logical expressions can be used to
manipulate “true” and “false” values to represent both simple and complex decisions or conditions. However,
these functions can also be used in a more mundane manner, to allow the direct manipulation of binary data.
This use of boolean logic is very important in a number of different applications in networking.

As I mentioned in the topic introducing binary numbers, giving a bit a value of one is called setting the bit,
while giving it a value of zero is either resetting or clearing it. In some situations bits are handled
“individually”, and are set or cleared simply by assigning a one or zero value to each bit. However, it is
common to have large groups of bits that are used collectively to represent a great deal of information, where
many bits need to be set or cleared at once. In this situation, the boolean functions “come to the rescue”.

Setting Groups of Bits Using the OR Function

Setting bits en masse can be done by exploiting the properties of the OR function. Recall that the OR function's
output is true (one) if any of its inputs is true (one). Thus, if you “OR” a bit with a value known to be one, the
result is always going to be a one, no matter what the other value is. In contrast, if you “OR” with a zero, the
original value, one or zero, is not changed.

By using a string with zeroes and ones in particular spots, you can set certain bits to 1 while leaving others
unchanged. This procedure is comparable to how a painter masks areas that he does not want to be painted,
using plastic or perhaps masking tape. Thus, the process is called masking. The string of digits used in the
operation is called the bit mask, or more simply, just the mask.

An example will illustrate. Suppose we have the 12-bit binary input number 101001011010, and we want to set
the middle six bits to be all ones. To do this, we simply OR the number with the 12-bit mask 000111111000.
Table 14 shows how this works, with the changed bits in the result highlighted—we simply OR each bit in the
input with its corresponding bit in the mask:
Table 14: Setting Bits Using an OR Bit Mask
Input 1 0 1 0 0 1 0 1 1 0 1 0
Mask 0 0 0 1 1 1 1 1 1 0 0 0
Result of OR Operation 1 0 1 1 1 1 1 1 1 0 1 0

Clearing Groups of Bits Using the AND Function

To clear a certain pattern of bits, you do a similar masking operation, but using the AND function instead. If you
AND a bit with zero, it will clear it to zero regardless of what the bit was before, while ANDing with one will
leave the bit unchanged. So, to take the same example above and clear the middle six bits, we AND with the
reverse bit mask, 111000000111. This is shown in Table 15 and illustrated in Figure 10.

Figure 10: Clearing Bits Using an AND Bit Mask

This diagram shows how a bit mask can be used to clear certain bits in a binary number while preserving others.
The mask shown here can be likened to a painter’s mask; each 1 represents a “transparent” area that keeps the
corresponding input bit value, while each 0 is a bit where the original value is to be cleared. After performing an
AND on each bit pair, the first three and last three bits are preserved while the middle six, since they were each
ANDed with 0, are forced to 0 in the output.
Table 15: Clearing Bits Using an AND Bit Mask
Input 1 0 1 0 0 1 0 1 1 0 1 0
Mask 1 1 1 0 0 0 0 0 0 1 1 1
Result of AND Operation 1 0 1 0 0 0 0 0 0 0 1 0

We can also look at this “clearing” function a different way. We are clearing the bits where the mask is a zero,
and in so doing “selecting” the bits where the mask is a one. Thus, ANDing with a bit mask means that you
“keep” the bits where the mask is a one and “remove” the bits where it is a zero.
Inverting Groups of Bits Using the XOR Function

There are also situations in which we want to invert some bits; that is, change a one value to a zero, or a zero
value to a one. To do this, we use the XOR function. While this is not as intuitive as the way masking works
with OR and AND, if you refer to the XOR truth table (Table 13) you will see that if you XOR with a one, the
input value is flipped, while XORing with a zero causes the input to be unchanged. To see how this works, let's
take the same input example and invert the middle six bits, as shown in Table 16.

Table 16: Inverting Bits Using an XOR Bit Mask


Input 1 0 1 0 0 1 0 1 1 0 1 0
Mask 0 0 0 1 1 1 1 1 1 0 0 0
Result of XOR Operation 1 0 1 1 1 0 1 0 0 0 1 0

In the world of networking, bit masking is most commonly used for the manipulation of addresses. In particular,
masking is perhaps best known for its use in differentiating between the host and subnetwork (subnet) portions
of Internet Protocol (IP) addresses, a process called subnet masking and described in the section on IP subnet
addressing.

Note: Masks are often expressed in either hexadecimal or decimal notation for simplicity of expression,
as shown in the IP subnetting summary tables. However, the masks are always applied in binary, as
described above. You should convert the mask to binary if you want to see exactly how the masking
operation is going to work.

Key Concept: The properties of the OR and AND boolean functions make them useful when certain bits
of a data item need to be set (changed to 1) or cleared (changed to 0), a process called bit masking. To set
bits to one, a mask is created and used in a bit-by-bit OR with the input; where the mask has a value of 1,
the bit is forced to a 1, while each 0 bit leaves the corresponding original bit unchanged. Similarly, a mask
used with AND clears certain bits; each 1 bit in the mask leaves the original bit alone, while each 0 forces the
output to 0. Finally, XOR can be used to invert selected bits using a mask.

You might also like