Encoders do just the inverse of decoders: they take in a number of wires and tell which wire has a 1 on it by giving out the binary number of that wire. Just reverse all the arrows in Fig. 4.2.1 and reverse the truth table, letting the many outputs be the inputs and let A, B, and C be the outputs.
The circuit for an encoder, however, is not merely the reverse of the circuit for a decoder because logic gates cannot be "run backwards." Instead, we can use either the sum of products (minterm) construction or a closely related chain of reasoning.
There are 8 input wires to a 3×8 encoder. One and only one of which will have a 1 on it, while the others will have a 0. This is a very important requirement, because if it is violated, say by two input wires simultaneously being at logic 1, then the output is invalid.
Here is a way to visualize what the encoder does. There are eight wires going into it, labeled from 0 to 7. Only one of these wires can have 1 on it. That wire's number is then shown in a window in binary (see Chapter 6 if you are unfamiliar with binary numbers.) Fig. 4.3.1 shows wire 6 with 1 on it and the encoder proudly displaying 110 (6 in binary).
Fig. 4.3.1: When wire 6 lights up, the encoder displays the binary number 110
In a real encoder, there are no lights, but there will be 1 for some of the output wires and 0 for others, corresponding to the binary number of the input wire which is high. The only trick is to figure out how to set those output wires to 1.
Let's call the output wires X2, X1 and X0. Thus, when input wire 6, I6, is 1, X2=1, X1=1 and X0=0. If we connected I6 directly to X2 and X1, but left X0 alone, we would achieve our goal of displaying 110 (which is binary for 6).
We are not done because we need to also account for I7, I5, I4 and so on. Each of these will activate a unique set of the three output wires: X2, X1 and X0, but only at different times. Once we figure out what the binary representations are for 0, 1, 2, ... up to 7, we then connect the input wires to their respect output wires but first passing them all into OR gates that feed those output wires. This is shown below:
Notice that 0 is left dangling, not connected to anything, because the number 0 means that none of the OR gates should have a 1 on their input -- all of the three outputs should be 0.
Decoders can be thought of translators of binary numbers to unary, and encoders the opposite. Remember that unary is a numeration system, used only in theory, that signifies the magnitude of a natural number by a number of 0s. For example, 5 is 00000, while 23,473,309 is 0000.... well, you get the idea! To get the unary number, lay out the output wires of a decoder in left to right order, starting with the highest address, and count all the 0s from the right end (the I0 wire) to the first 1.