Professional Documents
Culture Documents
Topics to be covered: Logic Gates, realization of logic circuits, Half and Full Adders, Flip-
Flops, Registers and Counters, A/D and D/A Conversion.
LOGIC GATES
Digital electronics deals with the manipulation of numbers. This is achieved by representing
numbers in a digital form and using logic operations to provide the processing needed. To
achieve this there is a large variety of different types of logic gate and digital circuit building
blocks that can be employed.
A logic gate is an elementary building block of a digital circuit. Most logic gates have two inputs
and one output. At any given moment, every terminal is in one of the two binary conditions low
(0) or high (1), represented by different voltage levels. The logic state of a terminal can change
often, as the circuit processes data. In most logic gates, the low state is approximately zero volts
(0 V), while the high state is approximately five volts positive (+5 V).
There are seven basic logic gates: AND, OR, NOT, NAND, NOR, Ex-OR and Ex-NOR.
1. NOT: The NOT gate is possibly the simplest type of logic gate. It takes a single input
and inverts it. Using this logic gate or logic circuit, a logic "1" becomes logic "0" and a
logic "0" becomes logic "1".
Truth Table
A B
0 1
1 0
2. AND / NAND: The AND and NAND logic gates are normally viewed together because
the output of one is the inverse of the other. The basic function of this type of logic gate
is the same. AND gate, produces an output of "1" only when both inputs are "1",
otherwise it produces a "0". The NAND type of logic gate produces the inverse of this.
Truth Table
A B C
0 0 0
1 0 0
0 1 0
1 1 1
3. OR / NOR: OR gates and NOR gates are another form of logic gate that form one of the
basic building blocks of digital technology. The OR gate gives a logical "1" when one of
the either inputs (or both inputs) is high.
Similarly the NOR gate is the inverse of this and goes low, "0" when one or the either
inputs (or both inputs) is high.
Truth Table
A B C
0 0 0
1 0 1
0 1 1
1 1 1
Truth Table
A B C
0 0 1
1 0 0
0 1 0
1 1 0
Truth Table
A B C
0 0 0
1 0 1
0 1 1
1 1 0
Truth Table
A B C
0 0 1
1 0 0
0 1 0
1 1 1
Half Adder
Half Adder is the adder which adds two inputs and produces two outputs. The two inputs are A
and B and the output carry is designated as COut and the normal output is designated as S which
is Sum.
Half Adder Truth Table
Inputs Outputs
A B Sum Cout
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Block Diagram
Block Diagram –
Flip-Flops
Flip flops are actually an application of logic gates. A flip flop is an electronic circuit with two
stable states that can be used to store binary data. The stored data can be changed by applying
varying inputs. Flip flops can also be considered as the most basic idea of a Random Access
Memory [RAM]. When a certain input value is given to them, they will be remembered and
executed, if the logic gates are designed correctly. A higher application of flip flops is helpful in
designing better electronic circuits.
The most commonly used application of flip flops is in the implementation of a feedback circuit.
As a memory relies on the feedback concept, flip flops can be used to design it.
There are mainly four types of flip flops that are used in electronic circuits. They are
The SET-RESET flip flop is designed with the help of two NOR gates and also two NAND
gates. These flip flops are also called S-R Latch.
The design of such a flip flop includes two inputs, called the SET [S] and RESET [R]. There are
also two outputs, Q and Q’. The diagram and truth table is shown below.
From the diagram it is evident that the flip flop has mainly four states. They are
S=1, R=0—Q=1, Q’=0 This state is also called the SET state.
In both the states you can see that the outputs are just compliments of each other and that the
value of Q follows the value of S.
The circuit of the S-R flip flop using NAND Gate and its truth table is shown below.
S-R flip flop with NAND gate has four states. They are
S=1, R=0—Q=0, Q’=1 This state is also called the SET state.
In both the states you can see that the outputs are just compliments of each other and that the
value of Q follows the compliment value of S.
If both the values of S and R are switched to 0 it is an invalid state because the values of both Q
and Q’ are 1. They are supposed to be compliments of each other. Normally, this state must be
avoided.
If both the values of S and R are switched to 1, then the circuit remembers the value of S and R
in their previous state.
D Flip Flop
D flip flop is actually a slight modification of the clocked SR flip-flop. From the figure you can
see that the D input is connected to the S input and the complement of the D input is connected
to the R input. The D input is passed on to the flip flop when the value of CP is ‘1’.
Clock D Qn+1
0 X Qn (Memory)
1 0 0
1 1 1
In a D flip flop, the output can be only changed at the clock edge, and if the input changes at
other times, the output will be unaffected.
The change of state of the output is dependent on the rising edge of the clock. The output (Q) is
same as the input and can only change at the rising edge of the clock.
J-K Flip-flop
A J-K flip flop can also be defined as a modification of the S-R flip flop. The only difference is
that the intermediate state is more refined and precise than that of a S-R flip flop.
The behavior of inputs J and K is same as the S and R inputs of the S-R flip flop. The letter J
stands for SET and the letter K stands for CLEAR.
When both the inputs J and K have a HIGH state, the flip-flop switch to the complement state.
So, for a value of Q = 1, it switches to Q=0 and for a value of Q = 0, it switches to Q=1.
The input condition of J=K=1, gives an output inverting the output state. However, the outputs
are same when one tests the circuit practically.
Clk J K Qn+1
0 X X Qn (Memory)
1 0 0 Qn (Memory)
1 0 1 0
1 0 1 1
1 1 1 Qn (Compliment of Qn)
T Flip Flop
A T flip flops is like JK flip-flop. These are basically single input version of JK flip flops. This
modified form of JK flip-flop is obtained by connecting both inputs J and K together. This flip-
flop has only one input along with the clock input.
These flip-flops are called T flip-flops because of their ability to complement its state (i.e.)
Toggle, hence the name Toggle flip-flop.
Truth Table
Clk T Q n+1
0 X Qn(Memory)
1 0 Qn(Memory) as J=0 & K=0
1 1 Qn (Compliment of Qn) Toggling state
as J=1 & K=1
Counters:
Counter is a device which stores (and sometimes displays) the number of times a particular
event or process has occurred, often in relationship to a clock signal. Counters are used in digital
electronics for counting purpose, they can count specific event happening in the circuit. For
example, in UP counter a counter increases count for every rising edge of clock. Not only
counting, a counter can follow the certain sequence based on design. They are designed with the
help of flip flops.
It is evident from timing diagram that Q0 is changing as soon as the falling edge of clock pulse is
encountered, Q1 is changing when falling edge of Q0 is encountered (because Q0 is clock pulse
for second flip flop), Q2 is changing when falling edge of Q1 is encountered (because Q1 is clock
pulse for third flip flop) Q3 is changing when falling edge of Q2 is encountered (because Q2 is
clock pulse for fourth flip flop). In this way ripples are generated through Q0, Q1, Q2, Q3 hence it
is also called RIPPLE counter.
2. Synchronous Counter
Synchronous counter has one global clock which drives each flip flop so output changes in
parallel. The one advantage of synchronous counter over asynchronous counter is, it can operate
on higher frequency than asynchronous counter as it does not have cumulative delay because of
same clock is given to each flip flop.
Shift registers are categorized into types majorly by their mode of operation, either serial or
parallel. There are four (4) basic types of shift registers:
Serial in – Serial out shift registers are shift registers that streams in data serially (one bit per
clock cycle) and streams out data too in the same way, one after the other.
1. At the first clock pulse, the data at “data in” will be present at the Stage A output.
2. After the second pulse stage A data is transferred to stage B output, and data at “data
in” is transferred to stage A output.
3. After the third clock pulse, stage C is replaced by stage B output; stage B is replaced
by stage A output; and stage A is replaced by data present at “data in”.
4. After the fourth clock, the data which was first present at “data in” is at stage D output.
5. The “first in” data is “first out” as it is shifted from “data in” to “data out”.
These types of shift registers are used for the conversion of data from serial to parallel. The data
comes in one after the other per clock cycle and can either be shifted or replaced or be read off
at each output. This means when the data is read in, each read in bit becomes available
simultaneously on their respective output line (QA to QD for the 4-bit shift register shown below).
3. Parallel in – Serial out Shift Register
For this type of shift register, the data is supplied in parallel, for example consider the 4-bit shift
register shown below.
This register can be used to store and shift a 4-bit word, with the write/shift (WS) control input
controlling the mode of operation of the shift register. When the WS control line is low (Write
Mode), data can be written and clocked in via DA to DD. To shift the data out serially, the WS
control line is brought HIGH (Shift mode), the register then shifts the data out on clock input.
For parallel in – parallel out shift register, the output data across the parallel outputs appear
simultaneously as the input data is fed in.
The input data at each of the input pins from DA to DD are read in at the same time when the
device is clocked and at the same time, the data read in from each of the inputs is passed out at
the corresponding output (from QA to QD).
Analog to Digital Converter
Analog to digital converter is a converter which converts the analog (continuously variable)
signal to digital signal. This is an electronic integrated circuit which directly converts the
continuous form of signal to discrete form. It can be expressed as A/D or A-to-D or A-D or
ADC. The input (analog) to this system can have any value in a range and are directly measured.
But for output (digital) of an N-bit A/D converter, it should have only 2N discrete values.
ADC Process
There are mainly two steps involved in the process of analog to digital conversion. They are
From the above table we can observe that only one digital value is used to represent the whole
range of voltage in an interval. Thus, an error will occur and it is called quantization error. This
is the noise introduced by the process of quantization. Here the maximum quantization error is
Application of ADC: ADCs are used in Computers, Cell phones, Microcontrollers, Digital
signal processing, Digital storage oscilloscopes, Scientific instruments etc.
Digital to Analog Converter (DAC)
Digital to Analog Converter (DAC) is a device that transforms digital data into an analog signal.
A DAC can reconstruct sampled data into an analog signal with precision. The digital data may
be produced from a microprocessor, Application Specific Integrated Circuit (ASIC), or Field
Programmable Gate Array (FPGA), but ultimately the data requires the conversion to an analog
signal in order to interact with the real world.
In the voltage domain, that is if the input signals are voltages, the addition of the binary bits can
be achieved using the inverting summing amplifier shown in the above figure.
The input resistors of the op-amp have their resistance values weighted in a binary format. When
the logic circuit receives binary 1, the switch connects the resistor to the reference voltage. When
the logic circuit receives binary 0, the switch connects the resistor to ground. All the digital input
bits are simultaneously applied to the DAC.
The DAC generates analog output voltage corresponding to the given digital data signal. For the
DAC the given digital voltage is b3 b2 b1 b0 where each bit is a binary value (0 or 1).
The output voltage produced at output side is
V0=R0/R (b3+b2/2+b1/4+b0/8) Vref