Components
Encoders
An
Octal-to-Binary Encoder
This encoder has eight inputs, one for each of the octal digits, and three outputs
that generate the corresponding binary number.
It is assumed that only one input has a value of 1 at any given time.
Octal-to-Binary Encoder
The encoder can be implemented with OR gates using inputs
A0 D1 D3 D5 D7
A1 D2 D3 D6 D7
A2 D4 D5 D6 D7
4
Octal-to-Binary Encoder
The encoder can be implemented with three 4-input OR gates.
The encoder just defined the limitation that only one input can be active any
;given time.
If two inputs are active simultaneously, the output produces an incorrect
combination.
For example, if D3 and D6 are 1 simultaneously, the output of the encoder will be
111 because all the three outputs are equal to 1.
This represents neither a binary 3 nor a binary 6.
To resolve this ambiguity, some encoder circuit must establish an input priority to
ensure that only ;one input is encoded.
If D3 and D6 are 1 at the same time, the output will be 110 because D6 has
higher priority than D3.
Another ambiguity in the octal-to-binary encoder is that an output of all 0s is
generated with all the inputs are 0, but this output is the same as when D0 is equal
to 1.
This discrepancy can be resolved by providing one more output to indicate
5
that at least one input is equal to 1.
Decimal-to-BCD Encoder
This type of encoder has ten inputs, one for each decimal digit, and four outputs
corresponding to the BCD code.
This is basic 10-line-to-4 line encoder.
10
Decimal-to-BCD Encoder
The BCD (8421) code is listed on the previous slide.
For instance, the most significant bit of the BCD code, A3, is a 1 for
decimal digit 8 or 9.
The OR expression for bit A3 in terms of the decimal digits can
therefore be written
A3 = 8 + 9
Bit A2 is a 1 for decimal digit 4,5,6 or 7 and can be expressed as an
OR function as A2 =4 + 5 + 6 + 7
Bit A1 is a 2 for decimal digit 2,3,6, or 7 and can be expressed as
A1= 1 + 3 + 5 + 7
Decimal-to-BCD Encoder
When a HIGH appears on one of the decimal digit input lines, the appropriate
levels occur on the four BCD output lines.
For instance, if input line 9 is HIGH (assuming all other input lines are LOW), this
condition will produce a HIGH on outputs A0 and A3, which is the BCD code
(1001) for decimal 9.
12
13
An Encoder Application
A classical application example is a keyboard encoder.
The ten decimal digits on the keyboard of a computer, for example, must be
encoded for processing by the logic circuitry.
When one of the keys is pressed, the decimal digit is encoded to the
corresponding BCD code.
Keys are represented by 10 push buttons switches each with a pull-up resistor
to +V.
The pull-up resistor ensure that the line is HIGH when a key is not
depressed.
When a key is depressed, the line is connected to ground, and a LOW is
applied to the corresponding encoder input.
The zero key is not connected because the BCD output represents zero none
of the other key is depressed.
The BCD output of the encoder goes into a storage device, and each
successive BCD code is stored until the entire number has been entered.
14
An Encoder Application
15
16
Multiplexers
A Multiplexers (MUX) is a device that allows digital information from
several sources to be routed onto a single line for transmission over that
line to a common destination.
The basic Multiplexers has several data-input lines and a single output line.
It also has data-select inputs, which permit digital data on any one of the
inputs to be switched to the output line.
Multiplexers are also known as data selectors.
Normally there are 2n input lines and n selection inputs whose bit
combinations determine which input is selected.
Each of the four inputs D0 through D3 is applied to one input of an AND gate.
Selection inputs S1 and S0 are decoded to select a particular AND gate.
The outputs of the AND gates are applied to a single OR gate to provide the
1-line output.
17
Multiplexers
To visualize the operation of the circuit, consider the case when (S1, S0) = 10.
The AND gate associated with input D2 has two of its input equal to 1 and the
third input connected to D2.
The other three AND gates have at least one input equal to 0, which makes their
outputs equal to 0.
The OR gate output is now equal to the value of D2, providing a path form the
selected input to the output.
A multiplier is also called a data selector, since it selects one of many inputs and
steers the binary information to the output line.
The truth table row 00 D0 represents all rows in which (S1,S0)=00 and, for D0=1,
gives Y=1 and for D0=0, gives Y=0.
Since there are six variables, and only S1 and S0 are fixed, this single row
represents 16 rows of the corresponding full truth table.
18
19
Multiplexers Logic
20
Multiplexers
The AND gates and inverters in the multiplexer resemble a decoder circuit and
indeed, they decode the selection input lines.
In general, a 2n-to-1 line multiplexer is constructed from an n-to-2n decoder by
adding 2n input lines to it, one from each data input.
The size of the mulitplexer is specified by the number 2n of its data input lines
and the single output line.
It is implied that the multiplexer contain n selection inputs.
The term multiplexer is often abbreviated as MUX.
21
Mux
input[1:0] select;
input[3:0] d;
output q;
reg q;
wire[1:0] select;
wire[3:0] d;
always @( select or d )
begin
if( select == 0)
q = d[0];
if( select == 1)
q = d[1];
if( select == 2)
q = d[2];
if( select == 3)
q = d[3];
end
22
endmodule
24
25
26
Algorithm
F(A,B,C,D) = m(1,3,4,11,12,13,14,15)
29
Example
30
DeMultiplexers
A demultiplexer (DEMUX) basically reverses the multiplexing function.
It takes data from one line and distribute them to a given number of output
lines.
OR
Demultiplexer receives information form a single line and transmits it to one of 2n
possible output lines.
Demultiplexer is also called data distributor.
Decoder can also be used as demultiplexer.
The selection of the specific output is controlled by the bit combination of n
selection lines.
31
1-line-to-4-line Demultiplexer
The data-input lines goes to all of the AND gates.
The two data-select lines enable only one gate at a time, and the data
appearing on the data-input line will pass through the selected gate to the
associated data-output line.
32
74154 as a Demulitplexer
74154 can also be used as a 4-lineto-16 line decoder.
This device and other decoders are
also used in demultiplexing applications.
In demultiplexer applications, the input
lines are used as the data-select lines.
One of the Enable inputs is used as
the data-input line, with the other Enable
input held LOW to enable the internal
negative-AND gate at the bottom of the
diagram.
33
Demux is a Decoder
With an enable
34
Decoder
Encoder
Mux
DeMux
35