Saturday 29 October 2016

Digital Logic-Logic Gates



Logic Gates

If we think of two signals, A and B, as representing a truth value of two different propositions, then A could be either TRUE (a logical 1) or FALSE (a logical 0). B can take on the same values. Now consider a situation in which the output, C, is TRUE only when both A is TRUE and B is TRUE. We can construct a truth table for this situation. In that truth table, we insert all of the possible combinations of inputs, A and B, and for every combination of A and B we list the output, C.
 


A
B
C
False
False
False
False
True
False
True
False
False
True
True
True


An AND Example

Let's imagine a physician prescribing two drugs. For some conditions drug A is prescribed, and for other conditions drug B is prescribed. Taken separately each drug is safe. When used together dangerous side effects are produced.

Let
A = Truth of the statement "Drug 'A' is prescribed.".
B = Truth of the statement "Drug 'B' is prescribed.".
C = Truth of the statement "The patient is in danger.".

Then, the truth table below shows when the patient is in danger.
 

A
B
C
False
False
False
False
True
False
True
False
False
True
True
True
Notice that C is TRUE when both A AND B are true and only then!



AND GATES

An AND function can be implemented electrically using a device known as an AND gate. You might imagine a system in which zero (0) is represented by zero (0) volts, and one (1) is represented by three (3) volts, for example. If we are going to use electrical devices we need some sort of symbolic representation. There is a standard symbol for an AND gate shown below.





Often in lab work it's helpful to use an LED to show when a signal is 0 or 1. Usually a 1 is indicated with an LED that is ON (i.e. glowing). You can use the buttons below to check out this AND gate (Note what an AND gate symbol looks like!) with a simulated LED. Note the following in the simulation (and you can use this in your lab experiments).


To get a logical zero, connect the input of the gate to ground to have zero (0) volts input.
To get a logical one, connect the input of the gate to a five (5) volts source to have five volts at the input.
Each button controls one switch (two buttons - two switches) so that you can control the individual inputs to the gate.
Each time you click a button, you toggle the switch to the opposite position.



        Once we introduce Boolean variables, we can rethink the concept of a truth table. In the truth table below, if A, B and C are truth tables and we have an AND gate with A and B as inputs and C as the output, the truth table would look like this.

A
B
C
0
0
0
0
1
0
1
0
0
1
1
1



OR Gates


Consider a case where a pressure can be high and a temperature can be high Let's assume we have two sensors that measure temperature and pressure.. The first sensor has an output, T, that is 1 when a temperature in a boiler is too high, and 0 otherwise. The second sensor produces an output, P, that is 1 when the pressure is too high, and 0otherwise. Now, for the boiler, we have a dangerous situation when either the temperature or the pressure is too high. It only takes one. Let's construct a truth table for this situation. The output, D, is 1 when danger exists.   
 


T
P
D
False
False
False
False
True
True
True
False
True
True
True
True
        

What we have done is defined an OR gate. An OR gate is a gate for which the output is 1 whenever one or more of the inputs is 1. The output of an OR gate is 0 only when all inputs are 0. Shown below is a schematic symbol for an OR gate, together with the simulated LEDs and input buttons so that you can explore OR gate behavior.



In terms of Boolean variables, the truth table for an OR gate looks like this.
  
 


A
B
C
0
0
0
0
1
1
1
0
1
1
1
1


NOT Gates (Inverters)
A third important logical element is the inverter. An inverter does pretty much what it says. If the input is 0, the output is 1. Conversely, if the input is 1, the output is 0. The symbol for an inverter is shown below. Again, you can putter with this inverter with the simulated LEDs. X is the input to the inverter. The output is NOT-X represented as ~1 or:
The truth table for an inverter is pretty simple since there is only one input. Call the input A, and the output C, and the truth table is:

A
C
0
1
1
0

NAND Gates
        

There is another important kind of gate, the NAND gate. Actually, the way to start thinking about a NAND gate is to think of it as an AND gate with an inverter on the output. That's shown below.





Actually, however, the symbol for a NAND gate compresses the inverter down to a dot at the output of the NAND gate as shown below.



0 comments:

Post a Comment