unit 4- logic gates

15
Digital Electronic Systems Unit 4 Logic Gates The term gate is used to describe a circuit that performs a basic logic operation. All gates have both inputs and outputs. The number of inputs can vary depending on the gate in question but there is generally only one output. As discussed in unit 1, there are three primary logic gates from which, by various combinations, all other gates can be made. These are the NOT Gate (inverter), the AND Gate and the OR Gate. This unit revisits these gates and proceeds to introduce a number of other gates. NOT Gate (Inverter) The NOT gate has a single input and a single output. The gate very simply inverts the input. The symbol and truth table for the NOT gate are shown below. Symbol The circle on the symbol indicates that the output F is the inverse (or complement) of the input A. Truth Table A F 0 1 1 0 The above table is known as a truth table. In this table, every possible combination of input is written in order and the output is determined for each input. There are possible combinations in the case of an n-input gate. In other words, there are two possible combinations in the case of a one-input gate, four possible combinations of input in the case of a two-input gate etc.. Boolean Expression 1

Upload: traian-vladu

Post on 06-Dec-2015

26 views

Category:

Documents


3 download

DESCRIPTION

microcontrollers and electronics,MCU Unit,beginners course,

TRANSCRIPT

Page 1: Unit 4- Logic Gates

Digital Electronic Systems Unit 4

Logic Gates

The term gate is used to describe a circuit that performs a basic logic operation. All gates have both inputs and outputs. The number of inputs can vary depending on the gate in question but there is generally only one output.

As discussed in unit 1, there are three primary logic gates from which, by various combinations, all other gates can be made. These are the NOT Gate (inverter), the AND Gate and the OR Gate. This unit revisits these gates and proceeds to introduce a number of other gates.

NOT Gate (Inverter)

The NOT gate has a single input and a single output. The gate very simply inverts the input. The symbol and truth table for the NOT gate are shown below.

Symbol

The circle on the symbol indicates that the output F is the inverse (or complement) of the input A.

Truth Table

A F0 11 0

The above table is known as a truth table. In this table, every possible combination of input is written in order and the output is determined for each input. There are possible combinations in the case of an n-input gate. In other words, there are two possible combinations in the case of a one-input gate, four possible combinations of input in the case of a two-input gate etc..

Boolean Expression

or verbally“F = A bar”

Boolean algebra is the mathematics of digital systems. A letter designates a variable and a bar over a letter designates the inverse (or complement) of the variable. More generally, a bar over a quantity designates the inverse (or complement) of that quantity.

1

Page 2: Unit 4- Logic Gates

Digital Electronic Systems Unit 4

AND Gate

The AND gate has multiple inputs and a single output. The output of any AND gate is HIGH only when all of its inputs are HIGH.

Symbol

In this case the output is HIGH (or logic level 1) only if the inputs A and B are HIGH (or logic level 1). Thus we can write a table defining all the possible states that might occur for this two input AND gate.

Truth Table

A B F0 0 00 1 01 0 01 1 1

Boolean Expression

F = A . Bor verbally

“F = A and B”

The AND gate performs Boolean Multiplication as illustrated in the timing diagram below. Boolean multiplication follows the same rules as binary multiplication, as discussed in unit 2.

Timing Diagram

2

Page 3: Unit 4- Logic Gates

Digital Electronic Systems Unit 4

3-Input AND Gate

Symbol

Truth Table

A B C F0 0 0 00 0 1 00 1 0 00 1 1 01 0 0 01 0 1 01 1 0 01 1 1 1

As can be seen when we have a three input AND gate the same rule applies as did for the two input gate, i.e. ALL the inputs must be HIGH if we are to achieve a HIGH on the output.

Boolean Expression

F = A . B . C

Or more commonly, it is written as

F = ABC

In boolean expressions, when variables are written next to each other with no symbol in between, it is implicitly assumed that they are ANDed.

3

Page 4: Unit 4- Logic Gates

Digital Electronic Systems Unit 4

OR Gate

The OR gate can have two or more inputs. The output of an OR gate is HIGH when one or more of the inputs are HIGH.

Symbol

Truth Table

A B F0 0 00 1 11 0 11 1 1

Boolean Expression

F = A + BOr verbally

“F = A or B”

The OR gate performs Boolean Addition - not to be confused with binary addition as discussed in unit 2.

Timing Diagram

4

Page 5: Unit 4- Logic Gates

Digital Electronic Systems Unit 4

3-Input OR Gate

Symbol

Truth Table

A B C F0 0 0 00 0 1 10 1 0 10 1 1 11 0 0 11 0 1 11 1 0 11 1 1 1

Again it can be seen from the table that the output is LOW only when all the inputs are LOW.

Boolean Expression

F = A + B + C

Now that the three basic gates have been considered, they can be combined to generate other operations.

5

Page 6: Unit 4- Logic Gates

Digital Electronic Systems Unit 4

NAND Gate

This is a combination of the AND gate and the NOT gate in that order.

Symbol

Both representations are equivalent. Note that the “bubble” (o) in the top symbol indicates the presence of an inverter on the output line. The top representation is more common. The bottom representation indicates how a NAND gate may be broken down.

Truth Table

A B F0 0 10 1 11 0 11 1 0

Boolean Expression

Or more commonly,

As can be seen from the table, the inputs are ANDed together and then NOTed (inverted) to give the final output. The timing diagram shown below illustrates this.

Timing Diagram

6

Page 7: Unit 4- Logic Gates

Digital Electronic Systems Unit 4

NOR Gate

This is a combination of the OR gate and the NOT gate in that order.

Symbol

Both representations are equivalent. Note that the “bubble” (o) in the top symbol indicates the presence of an inverter on the output line. The top representation is more common. The bottom representation indicates how a NOR gate may be broken down.

Truth Table

A B F0 0 10 1 01 0 01 1 0

Boolean Expression

As can be seen from the table, the inputs are ORed together and then NOTed (inverted) to give the final output. The timing diagram shown below illustrates this.

Timing Diagram

7

Page 8: Unit 4- Logic Gates

Digital Electronic Systems Unit 4

XOR Gate (Exclusive OR)

Another gate which is made up of the AND, OR and NOT gates and which is commonly used is an XOR gate. XOR gates connected to form an adder circuit allow a computer to perform addition, subtraction, multiplication and division in it’s Arithmetic Logic Unit (ALU). Shown below is its basic layout.

Logic Diagram

Again this is too large to be commonly used so it is summarised into a small logic symbol, which is shown below.

Symbol

The truth table for this symbol is shown below. It can be seen that the output goes HIGH only when the inputs differ. If both inputs go HIGH the output goes LOW. If both inputs go LOW the output goes LOW.

Truth Table

A B F0 0 00 1 11 0 11 1 0

8

Page 9: Unit 4- Logic Gates

Digital Electronic Systems Unit 4

Timing Diagram

Boolean Expression

The formula that describes the function of this gate is as follows.

This is more commonly expressed in Boolean algebra by a dedicated symbol – an addition sign enclosed in a circle, as follows:

XNOR Gate (Exclusive NOR)

This is a combination of the XOR gate and the NOT gate (Inverter) in that order.

Symbol

Truth Table

A B F0 0 10 1 01 0 01 1 1

As can be seen from the truth table, the inputs are XORed together and then NOTed (inverted) to give the final output.

9

Page 10: Unit 4- Logic Gates

Digital Electronic Systems Unit 4

Boolean Expression

Timing Diagram

Direct applications of the basic logic operations

(Terminology - A Bit is a Binary Digit. A byte is made up of 8 bits. )

Logic gates are the building blocks of computers. Most of the functions in a computer, with the exception of certain types of memory, are implemented with logic gates used on a very large scale. For example, a microprocessor, which is the main part of a computer, is made up of hundreds and thousands of logic gates.

Application 1 - Computers need to selectively manipulate certain bits in one or more bytes of data. Selective bit manipulations are achieved using a mask. For example, to clear (make all 0’s) the right four bits in a data byte, but keep the information in the left four bits, the data byte is ANDed with 11110000. Notice that any bit ANDed with zero will be 0 and any bit ANDed with one will remain the same.

Ex 1: What is the resulting byte if 101010112 is ANDed with the mask 111100002?

Application 2 : Another mask operation that is used in computer programming selectively makes certain bits in a data byte equal to 1 while not affecting any other bit. This is called setting (setting a bit to 1). This is achieved using the OR operation. A mask is used that contains a 1 in any position where a data bit is to be set.

Ex 2: How would one force the most significant bit in a data byte to equal 1, but leave all of the other bits unchanged?

10

Page 11: Unit 4- Logic Gates

Digital Electronic Systems Unit 4

Active low inputs

An active low input is represented by either a small circle at the input point to a gate or by a “bar” over the input variable on a data sheet. This small circle represents a NOT gate (inverter).

Consider for example - chip select, an active low input to an integrated circuit. Chip select is enabled only when the input voltage is low. The “bar” indicates that the input is active low.

Shown below is an example of an AND gate with active low inputs.

Truth Table

A B F0 0 10 1 01 0 01 1 0

Timing Diagram

11