Professional Documents
Culture Documents
BASIC GATES
While each logical element or condition must always have a logic
value of either "0" or "1", we also need to have ways to combine different
logical signals or conditions to provide a logical result.
For example, consider the logical statement: "If I move the switch on
the wall up, the light will turn on." At first glance, this seems to be a correct
statement. However, if we look at a few other factors, we realize that
there's more to it than this. In this example, a more complete statement
would be: "If I move the switch on the wall up and the light bulb is good
and the power is on, the light will turn on."
Light = Switch
This means nothing more than that the light will follow the action of the
switch, so that when the switch is up/on/true/1 the light will also be
on/true/1. Conversely, if the switch is down/off/false/0 the light will also be
off/false/0.
When we deal with logical circuits (as in computers), we not only need
to deal with logical functions; we also need some special symbols to
denote these functions in a logical diagram. There are three fundamental
logical operations, from which all other functions, no matter how complex,
can be derived. These functions are named and, or, and not. Each of
these has a specific symbol and a clearly-defined behavior, as follows:
Binary gates deals with digital signal & digital is 0 or 1.
2
An algebraic function is F = x - y
An algebraic function is f = x + y
of the time.
While the three basic functions AND, OR, and NOT are sufficient to
accomplish all possible logical functions and operations, some
combinations are used so commonly that they have been given names
and logic symbols of their own.
x y f
0 0 1
0 1 1
1 0 1
1 1 0
F = xy’ + x’y
= x + y where x & y are inputs.
x y f
0 0 0
0 1 1
1 0 1
1 1 0
F = xy’ + x’y
= x + y where x & y are inputs.
x y f
0 0 0
0 1 1
1 0 1
1 1 0
The three derived functions shown above are by no means the only
ones, but these form the basis of all the others.
7
The practical problem with the circuit above is that it contains three
different kinds of gates: AND, OR, and NOT. While this illustrates a
practical application using all three of the basic gate types, it is
cumbersome to construct on a printed circuit board.
There are commercial packages which contain four XOR gates, but
often only a single XOR function is wanted in a given application.
F = xy + x’ y’
=x.y
x y f
0 0 1
0 1 0
1 0 0
1 1 1
This can easily be done with a single quad two-input NAND gate, as
shown in the circuit below:
There are many ways in which the simple logic gates we have
examined can be combined to perform useful functions. Some of these
circuits produce outputs which are only dependent upon the current logic
states of all inputs. These are called combinational logic circuits. Other
circuits are designed to actually remember the past states of their inputs,
and to produce outputs based on those past signals as well as the current
states of their inputs. These circuits can act in accordance with a
sequence of input signals, and are therefore known as sequential logic
circuits.
Multiplexer
Function table
S1 S0 Y
0 0 IO
0 1 I1
1 0 I2
1 1 I3
row and column addressing. A set of multiplexers is used to first select the
row address to the memory, then switch to the column address. This
scheme allows large amounts of memory to be incorporated into the
computer while limiting the number of copper traces required to connect
that memory to the rest of the computer circuitry. In such an application,
this circuit is commonly called a data selector.
Multiplexers are not limited to two data inputs. If we use two addressing
inputs, we can multiplex up to four data signals. With three addressing
inputs, we can multiplex eight signals. If you would like to see a
demonstration of a four-input multiplexer, This demonstration requires 64
separate images, each approximately 4K bytes in size, so it will take a
little while to load. For this reason, it is not included in the list of digital
pages at the top of each page.
In order for a logical circuit to "remember" and retain its logical state even
after the controlling input signal(s) have been removed, it is necessary for
12
the circuit to include some form of feedback. We might start with a pair of
inverters, each having its input connected to the other's output. The two
outputs will always have opposite logic levels.
The problem with this is that we don't have any additional inputs that
we can use to change the logic states if we want. We can solve this
problem by replacing the inverters with NAND or NOR gates, and using
the extra input lines to control the circuit.
The circuit shown below is a basic NAND latch. The inputs are
generally designated "S" and "R" for "Set" and "Reset" respectively.
Because the NAND inputs must normally be logic 1 to avoid affecting the
latching action, the inputs are considered to be inverted in this circuit.
When the switch is moved to the other setting or the button is pressed,
the very first contact will cause the latch to change state, but additional
bounces will have no further effect. This eliminates the contact bounce
and sends a single, clean digital transition to the next circuit. All of the
interactive digital demonstrations behave in a debounced fashion, and
would use this type of circuit if constructed physically.
One problem with the basic RS NAND latch is that the input levels
need to be inverted, sitting idle at logic 1, in order for the circuit to work. It
would be helpful, as well as more intuitive, if we had normal inputs which
would idle at logic 0, and go to logic 1 only to control the latch. This much
we can do simply by placing inverters at the inputs.
14
RS Flip Flop
Q S R Q (t + 1)
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 indeterminate
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 indeterminate
If we start with the CLK input at logic 0 as initially depicted above, the
S and R inputs are disconnected from the input (master) latch. Therefore,
any changes in the input signals cannot affect the state of the final
outputs.
When the CLK signal goes to logic 1, the S and R inputs are able to
control the state of the input latch, just as with the single RS latch circuit
you already examined. However, at the same time the inverted CLK signal
applied to the output (slave) latch prevents the state of the input latch from
having any effect here. Therefore, any changes in the R and S input
signals are tracked by the input latch while CLK is at logic 1, but are not
reflected at the Q and Q' outputs.
When CLK falls again to logic 0, the S and R inputs are again isolated
from the input latch. At the same time, the inverted CLK signal now allows
the current state of the input latch to reach the output latch. Therefore, the
Q and Q' outputs can only change state when the CLK signal falls from a
logic 1 to logic 0. This is known as the falling edge of the CLK signal;
hence the designation edge-triggered flip-flop.
There is still one problem left to solve: the possible race condition
which may occur if both the S and R inputs are at logic 1 when CLK falls
from logic 1 to logic 0. In the example above, we automatically assume
that the race will always end with the master latch in the logic 1 state, but
this will not be certain with real components. Therefore, we need to have a
way to prevent race conditions from occurring at all. That way we won't
have to figure out which gate in the circuit won the race on this particular
occasion.
The solution is to add some additional feedback from the slave latch to
the master latch. The resulting circuit is called a JK flip-flop.
16
JK flip flop
If the Q output is a logic 1 (the flip-flop is in the "Set" state), the S input
can't make it any more set than it already is. Therefore, we can disable the
S input without disabling the flip-flop under these conditions. In the same
way, if the Q output is logic 0 (the flip-flop is Reset), the R input can be
disabled without causing any harm. If we can accomplish this without too
much trouble, we will have solved the problem of the "race" condition.
In most ways, the JK flip-flop behaves just like the RS flip-flop. The Q
and Q' outputs will only change state on the falling edge of the CLK signal,
and the J and K inputs will control the future output state pretty much as
before. However, there are some important differences.
17
Q J K Q (t + 1)
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 0
Since one of the two logic inputs is always disabled according to the
output state of the overall flip-flop, the master latch cannot change state
back and forth while the CLK input is at logic 1. Instead, the enabled input
can change the state of the master latch once, after which this latch will
not change again. This was not true of the RS flip-flop.
If both the J and K inputs are held at logic 1 and the CLK signal
continues to change, the Q and Q' outputs will simply change state with
each falling edge of the CLK signal. (The master latch circuit will change
state with each rising edge of CLK.) We can use this characteristic to
advantage in a number of ways. A flip-flop built specifically to operate this
way is typically designated as a T (for Toggle) flip-flop. The lone T input is
in fact the CLK input for other types of flip-flops.
D flip flop
One essential point about the D flip-flop is that when the clock input
falls to logic 0 and the outputs can change state, the Q output always
takes on the state of the D input at the moment of the clock edge. This
was not true of the RS and JK flip-flops. The RS master section would
repeatedly change states to match the input signals while the clock line is
logic 1, and the Q output would reflect whichever input most recently
received an active signal. The JK master section would receive and hold
an input to tell it to change state, and never change that state until the
next cycle of the clock. This behavior is not possible with a D flip-flop.
Q D Q (t + 1
0 0 0
0 0 1
1 0 0
1 1 1
Digital Counter
One common requirement in digital circuits is counting, both forward
and backward. Digital clocks and watches are everywhere, timers are
found in a range of appliances from microwave ovens to VCRs, and
counters for other reasons are found in everything from automobiles to
test equipment.
Instead of changing
the state of the input
clock with each click, you
will send one complete
clock pulse to the
counter when you click
the input button. The
button image will reflect
the state of the clock
pulse, and the counter
image will be updated at
the end of the pulse. For
a clear view without
taking excessive time,
each clock pulse has a
duration or pulse width of
300 ms (0.3 second).
The demonstration
system will ignore any
clicks that occur within
the duration of the pulse.
A major problem with the counters is that the individual flip-flops do
not all change state at the same time. Rather, each flip-flop is used to
trigger the next one in the series. Thus, in switching from all 1s (count =
15) to all 0s (count wraps back to 0), we don't see a smooth transistion.
Instead, output A falls first, changing the apparent count to 14. This
triggers output B to fall, changing the apparent count to 12. This in turn
triggers output C, which leaves a count of 8 while triggering output D to
fall. This last action finally leaves us with the correct output count of zero.
We say that the change of state "ripples" through the counter from one
flip-flop to the next. Therefore, this circuit is known as a "ripple counter."
same time. To accomplish this, we need to apply the same clock pulse to
all flip-flops.
However, we do not want all flip-flops to change state with every clock
pulse. Therefore, we'll need to add some controlling gates to determine
when each flip-flop is allowed to change state, and when it is not. This
requirement denies us the use of T flip-flops, but does require that we still
use edge-triggered circuits. We can use either RS or JK flip-flops for this;
we'll use JK flip-flops for the demonstrations on this page.
States
Count
To determine the gates required at each flip- D C B A
flop input, let's start by drawing up a truth table for 0 0 0 0 0
all states of the counter. Such a table is shown to
the right. 0 0 0 1 1
States
Count
Johnson Counter A B C D E
0 0 0 0 0 0
In some cases, we want a counter that
provides individual digit outputs rather than a 1 0 0 0 0 1
binary or BCD output. Of course, we can do
this by adding a decoder circuit to the binary 1 1 0 0 0 2
counter. However, in many cases it is much
1 1 1 0 0 3
simpler to use a different counter structure,
that will permit much simpler decoding of 1 1 1 1 0 4
individual digit outputs.
1 1 1 1 1 5
For example, consider the counting
sequence to the right. It actually resembles 0 1 1 1 1 6
the behavior of a shift register more than a 0 0 1 1 1 7
counter, but that need not be a problem.
0 0 0 1 1 8
24
However, you can see the count correction gates operating at the
bottom ,how they work.
The least significant bit (LSB) is always available first at the serial
output.
Summary:-
This chapter has introduced the logical gates and the advantages of the
logical gates can be extended to use them as Multiplexer or counter.
Multiplexer: It is a device which has many outputs.
Counter: Counter can be used tocount the value upto certain states.
Demultiplexer:: Demultiplexer is a device which has one input and many
outputs.
Review Exercises:
1. How NAND and NOR gates can be used as universal gates?
2. Draw the diagram of 3 bit asynchronous counter.
3. How 4 bit asynchronous counter can be used to count 10.