Sie sind auf Seite 1von 14

LOGIC CIRCUIT

DENT 1433

Type of combinational logic circuit chosen

In our group assignment, we chose encoder and decoder as our preferred combinational logic
circuit.

Basic operation of Encoder and Decoder

Encoder
A Digital Encoder more commonly called a Binary Encoder takes ALL its data inputs one at a
time and then converts them into a single encoded output. So we can say that a binary encoder, is
a multi-input combinational logic circuit that converts the logic level 1 data at its inputs into an
equivalent binary code at its output.

Generally, digital encoders produce outputs of 2-bit, 3-bit or 4-bit codes depending upon the
number of data input lines. An n-bit binary encoder has 2n input lines and n-bit output lines
with common types that include 4-to-2, 8-to-3 and 16-to-4 line configurations.

The output lines of a digital encoder generate the binary equivalent of the input line whose value
is equal to 1 and are available to encode either a decimal or hexadecimal input pattern to
typically a binary or B.C.D (binary coded decimal) output code.

4-to-2 Bit Binary Encoder

!
Figure 1.1: Illustration of 4-to-2 Encoder and Its Truth Table

LOGIC CIRCUIT

DENT 1433

One of the main disadvantages of standard digital encoders is that they can generate the wrong
output code when there is more than one input present at logic level 1. For example, if we
make inputs D1 and D2 HIGH at logic 1 both at the same time, the resulting output is neither at
01 or at 10 but will be at 11 which is an output binary number that is different to the actual
input present. Also, an output code of all logic 0s can be generated when all of its inputs are at
0 OR when input D0 is equal to one.

One simple way to overcome this problem is to Prioritise the level of each input pin and if
there was more than one input at logic level 1 the actual output code would only correspond to
the input with the highest designated priority. Then this type of digital encoder is known
commonly as a Priority Encoder or P-encoder for short.

Priority Encoder
The Priority Encoder solves the problems mentioned above by allocating a priority level to each
input. The priority encoders output corresponds to the currently active input which has the
highest priority. So when an input with a higher priority is present, all other inputs with a lower
priority will be ignored. The priority encoder comes in many different forms with an example of
an 8-input priority encoder along with its truth table shown below.

!
8-to-3 Bit Priority Encoder
!

!
Figure 1.2: Illustration of 8-to-3 Bit Priority Encoder and Its Truth Table

LOGIC CIRCUIT

DENT 1433

Priority encoders are available in standard IC form and the TTL 74LS148 is an 8-to-3 bit priority
encoder which has eight active LOW (logic 0) inputs and provides a 3-bit code of the highest
ranked input at its output. Priority encoders output the highest order input first for example, if
input lines D2, D3 and D5 are applied simultaneously the output code would be for input
D5 (101) as this has the highest order out of the 3 inputs. Once input D5 had been
removed the next highest output code would be for input D3 (011), and so on.
The truth table for a 8-to-3 bit priority encoder is given as:

Table 1: Truth Table of 8-to-3 Bit Priority Encoder

Where X equals dont care, that is logic 0 or a logic 1.

!
!

From this truth table, the Boolean expression for the encoder above with data inputs D0 to D7
and outputs Q0, Q1, Q2 is given as:
Output Q0

LOGIC CIRCUIT

DENT 1433

Output Q1

!
Output Q2

!
Then the final Boolean expression for the priority encoder including the zero inputs is defined as:

!
In practice these zero inputs would be ignored allowing the implementation of the final Boolean
expression for the outputs of the 8-to-3 priority encoder. We can constructed a simple encoder
from the expression above using individual OR gates as follows.

!
!
Digital Encoder using Logic Gates
!
!
!
!
!
!
!
!
!
Figure 1.3: Logic Circuit of 8-to-3 Bit Priority Encoder
!
!
4

LOGIC CIRCUIT

DENT 1433

Binary Decoder
Binary Decoders are another type of Digital Logic device that has inputs of 2-bit, 3-bit or 4-bit
codes depending upon the number of data input lines, so a decoder that has a set of two or more
bits will be defined as having an n-bit code, and therefore it will be possible to represent 2n
possible values. Thus, a decoder generally decodes a binary value into a non-binary one by
setting exactly one of its n outputs to logic 1.

If a binary decoder receives n inputs (usually grouped as a single Binary or Boolean number) it
activates one and only one of its 2n outputs based on that input with all other outputs deactivated.

!
!
!
!
!

Figure 2.1: Simple 1-to-2 binary decoder

So for example, an inverter ( NOT-gate ) can be classed as a 1-to-2 binary decoder as 1-input and
2-outputs (21) is possible because with an input A it can produce two outputs A and A (not-A) as
shown.

Then we can say that a standard combinational logic decoder is an n-to-m decoder, where
m 2n, and whose output, Q is dependent only on its present input states. In other words, a
binary decoder looks at its current inputs, determines which binary code or binary number is
present at its inputs and selects the appropriate output that corresponds to that binary input.

!
2-to-4 Binary Decoder
!
!
!
!
!
!
!
!
Figure 2.2: Logic Circuit of 2-to-4 Binary Decoder
!
5

LOGIC CIRCUIT

!
!
!
!
!
!
!

DENT 1433

Figure 2.3: Illustration of 2-to-4 Binary Decoder and Its Truth Table

This simple example above of a 2-to-4 line binary decoder consists of an array of four AND
gates. The 2 binary inputs labelled A and B are decoded into one of 4 outputs, hence the
description of 2-to-4 binary decoder. Each output represents one of the miniterms of the 2 input
variables, (each output = a miniterm).

The binary inputs A and B determine which output line from Q0 to Q3 is HIGH at logic level
1 while the remaining outputs are held LOW at logic 0 so only one output can be active
(HIGH) at any one time. Therefore, whichever output line is HIGH identifies the binary code
present at the input, in other words it de-codes the binary input.

Some binary decoders have an additional input pin labelled Enable that controls the outputs
from the device. This extra input allows the decoders outputs to be turned ON or OFF as
required. These types of binary decoders are commonly used as memory address decoders in
microprocessor memory applications.

But some binary decoders are constructed using NAND gates instead of AND gates for their
decoded output, since NAND gates are cheaper to produce than ANDs as they require fewer
transistors to implement within their design.

The use of NAND gates as the decoding element, results in an active-LOW output while the
rest will be HIGH. As a NAND gate produces the AND operation with an inverted output, the
NAND decoder looks like this with its inverted truth table.

!
!
!
!
!

LOGIC CIRCUIT

DENT 1433

2-to-4 Line NAND Binary Decoder

!
!
!
!
!
!
!
!
!
!
!

Figure 2.4: Logic Circuit of 2-to-4 NAND Binary Decoder and Its Truth Table

Then for the NAND decoder, only one output can be LOW and equal to logic 0 at any given
time, with all the other outputs being HIGH at logic 1.

Decoders are also available with an additional Enable input pin which allows the decoded
output to be turned ON or OFF by applying a logic 1 or logic 0 respectively to it. So for
example, when the enable input is at logic level 0, (EN = 0) all outputs are OFF at logic
0 (for AND gates) regardless of the state of the inputs A and B. Generally to implement this
enabling function the 2-input AND or NAND gates are replaced with 3-input AND or NAND
gates. The additional input pin represents the enable function.

Application of Encoder and Decoder In Real World

There are infinite ways that encoders and decoders are applied in real life. For encoders, we will
take a look at the operation of Keyboard Encoder, Rotary Encoders, Positional Encoders and
Interrupt Requests. As for decoders, we will learn how Memory Address Decoder and BCD
to 7-Segment Display Decoder operate.

!
!
!
!

LOGIC CIRCUIT

DENT 1433

Operation of Encoder and Decoder Application


Encoder

Keyboard Encoder
Priority encoders can be used to reduce the number of wires needed in a particular circuits or
application that have multiple inputs. For example, assume that a microcomputer needs to read
the 104 keys of a standard QWERTY keyboard where only one key would be pressed either
HIGH or LOW at any one time.

One way would be to connect all 104 wires from the individual keys on the keyboard directly to
the computers input but this would be impractical for a small home PC. Another alternative and
better way would be to interface the keyboard to the PC using a priority encoder.

The 104 individual buttons or keys could be encoded into a standard ASCII code of only 7-bits
(0 to 127 decimal) to represent each key or character of the keyboard and then input as a much
smaller 7-bit B.C.D code directly to the computer. Keypad encoders such as the 74C923 20-key
encoder are available to do just that.

Rotary Encoders
A rotary encoder, also called a shaft encoder, is an electro-mechanical device that converts the
angular position or motion of a shaft or axle to an analog or digital code. There are two main
types: absolute and incremental (relative). The output of absolute encoders indicates the current
position of the shaft, making them angle transducers. The output of incremental encoders
provides information about the motion of the shaft, which is typically further processed
elsewhere into information such as speed, distance, and position.

!
!
!
!
!
!
!
!

Figure 3.1: Illustration of Rotary Encoders

LOGIC CIRCUIT

DENT 1433

Rotary encoders are used in many applications that require precise shaft unlimited rotation
including industrial controls, robotics, special purpose photographic lenses, computer input
devices (such as optomechanical mice and trackballs), controlled stress rheometers, and rotating
radar platforms.

!
Positional Encoders
!
!
!
!
!
!
!
!

Figure 3.2: Illustration of Positional Encoders

Table 3.1: Truth table generated by Positional Encoders

Another more common application is in magnetic positional control as used on ships navigation
or for robotic arm positioning etc. Here for example, the angular or rotary position of a compass
is converted into a digital code by a 74LS148 8-to-3 line priority encoder and input to the
systems computer to provide navigational data and an example of a simple 8 position to 3-bit
9

LOGIC CIRCUIT

DENT 1433

output compass encoder is shown above. Magnets and reed switches could be used at each
compass point to indicate the needles angular position.

Interrupt Requests
Other applications especially for Priority Encoders may include detecting interrupts in
microprocessor applications. Here the microprocessor uses interrupts to allow peripheral devices
such as the disk drive, scanner, mouse, or printer etc, to communicate with it, but the
microprocessor can only talk to one peripheral device at a time so needs some way of knowing
when a particular peripheral device wants to communicate with it.

The processor does this by using Interrupt Requests or IRQ signals to assign priority to all
the peripheral devices to ensure that the most important peripheral device is serviced first. The
order of importance of the devices will depend upon their connection to the priority encoder.

!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

Table 3.2: IRQ Number, Their Typical Uses and Descriptions

Because implementing such a system using priority encoders such as the standard 74LS148
priority encoder IC involves additional logic circuits, purpose built integrated circuits such as the
8259 Programmable Priority Interrupt Controller is available.

!
!
!
!

10

LOGIC CIRCUIT

DENT 1433

Decoder

Memory Address Decoder.


Binary Decoders are most often used in more complex digital systems to access a particular
memory location based on an address produced by a computing device. In modern
microprocessor systems the amount of memory required can be quite high and is generally more
than one single memory chip alone.

One method of overcoming this problem is to connect lots of individual memory chips together
and to read the data on a common Data Bus. In order to prevent the data being read from
each memory chip at the same time, each memory chip is selected individually one at time and
this process is known as Address Decoding.

In this type of application, the address represents the coded data input, and the outputs are the
particular memory element select signals. Each memory chip has an input called Chip Select or
CS which is used by the MPU (micro-processor unit) to select the appropriate memory chip
when required. Generally a logic 1 on the chip select (CS) input selects the memory device
while a logic 0 on the input de-selects it.

So by selecting or de-selecting each chip one at a time, allows us to select the correct memory
address device for a particular address location. The advantage of address decoding is that when
we specify a particular memory address, the corresponding memory location exists ONLY in one
of the chips.

For example, Lets assume we have a very simple microprocessor system with only 1Kb (one
thousand bytes) of RAM memory and 10 memory address lines available. The memory consists
of 1288-bit (1288 = 1024 bytes) devices and for 1Kb we would need 8 individual memory
chips but in order to select the correct memory chip we would also require a 3-to-8 line binary
decoder as shown below.

!
!
!
!
!
!

11

LOGIC CIRCUIT

!
!
!
!
!
!
!
!
!
!
!
!
!

DENT 1433

Figure 3.3: Memory Address Decoder utilizing a 3-to-8 Line Decoder

The binary decoder requires only 3 address lines, (A0 to A2) to select each one of the 8 chips (the
lower part of the address), while the remaining 7 address lines (A3 to A9) select the correct
memory location on that chip (the upper part of the address). Having selected a memory location
using the address bus, the information at the particular internal memory location is sent to a
common Data Bus for use by the microprocessor. This is of course a simple example but the
principals remain the same for all types of memory chips or modules.

Binary Decoders are very useful devices for converting one digital format to another, such as
binary or BCD type data into decimal or octal etc and commonly available decoder ICs are the
TTL 74LS138 3-to-8 line binary decoder or the 74ALS154 4-to-16 line decoder. They are also
very useful for interfacing to 7-segment displays such as the TTL 74LS47.

!
BCD to 7-Segment Display Decoder
!

Typically 7-segment displays consist of seven individual coloured LEDs (called the segments),
within one single display package. In order to produce the required numbers or HEX characters
from 0 to 9 and A to F respectively, on the display the correct combination of LED segments
need to be illuminated and BCD to 7-segment Display Decoders such as the 74LS47 do just that.
A standard 7-segment LED display generally has 8 input connections, one for each LED segment
and one that acts as a common terminal or connection for all the internal display segments. Some

12

LOGIC CIRCUIT

DENT 1433

single displays have also have an additional input pin to display a decimal point in their lower
right or left hand corner.

!
In electronics there are two important types of 7-segment LED digital display.
!

The Common Cathode Display (CCD) In the common cathode display, all the cathode
connections of the LEDs are joined together to logic 0 or ground. The individual segments
are illuminated by application of a HIGH, logic 1 signal to the individual Anode terminals.

The Common Anode Display (CAD) In the common anode display, all the anode connections
of the LEDs are joined together to logic 1 and the individual segments are illuminated by
connecting the individual Cathode terminals to a LOW, logic 0 signal.

Meanwhile, Binary Coded Decimal (BCD or 8421 BCD) numbers are made up using just 4
data bits (a nibble or half a byte) similar to the Hexadecimal numbers we saw in the binary
tutorial, but unlike hexadecimal numbers that range in full from 0 through to F, BCD numbers
only range from 0 to 9, with the binary number patterns of 1010 through to 1111 (A to F) being
invalid inputs for this type of display and so are not used.

A binary coded decimal (BCD) to 7-segment display decoder such as the TTL 74LS47 or
74LS48, have 4 BCD inputs and 7 output lines, one for each LED segment. This allows a smaller
4-bit binary number (half a byte) to be used to display all the denary numbers from 0 to 9 and by
adding two displays together, a full range of numbers from 00 to 99 can be displayed with just a
single byte of 8 data bits.

!
!
!
!
!
!
!
!
!
!

Figure 3.4: BCD to 7-Segment Decoder

13

LOGIC CIRCUIT

DENT 1433

The use of packed BCD allows two BCD digits to be stored within a single byte (8-bits) of data,
allowing a single data byte to hold a BCD number in the range of 00 to 99.

!
An example of the 4-bit BCD input ( 0100 ) representing the number 4 is given below.
!
!
!
!
!
!
!
!
!
!
!
!
!
Figure 3.5: A BCD to 7-Segment Decoder connected to a 7-segment display as a package
!

In practice current limiting resistors of about 150 to 220 would be connected in series
between the decoder/driver chip and each LED display segment to limit the maximum current
flow. Different display decoders or drivers are available for the different types of display
available, e.g. 74LS48 for common-cathode LED types, 74LS47 for common-anode LED types,
or the CMOS CD4543 for liquid crystal display (LCD) types.

Liquid crystal displays (LCDs) have one major advantage over similar LED types in that they
consume much less power and nowadays, both LCD and LED displays are combined together to
form larger Dot-Matrix Alphanumeric type displays which can show letters and characters as
well as numbers in standard Red or Tri-colour outputs.

!
!
!
!
!
!

14

Das könnte Ihnen auch gefallen