# Constructing an Encoder

I understand an Encoder is 2^n input lines and n output lines.

I want to construct an Encoder from scratch so I can understand how it works, so that I can construct any other Encoder in the future.

I believe that the Input lines are an address to the output lines. So for a 4 by 2 encoder we would first construct a truth table. My biggest problem is I can't construct the output part of the truth table for an encoder. I don't know how to get the output, if I knew the logic I could build it.

Encoder Truth table with what I think the output is. http://www.flickr.com/photos/76226081@N08/8931456484/

Every time the input lines are x x 0 0 I put a 1 for O0.
Every time the input lines are x x 0 1 I put a 1 for O1
`
• en.wikipedia.org/wiki/Priority_encoder#Simple_encoder Jun 3 '13 at 1:43
• Key point, the only valid inputs are when exactly one of the inputs is high. That means there are lots of don't cares in the output columns of the truth table. Jun 3 '13 at 1:45
• So only I3 and I2 matter? Edit: Actually I don't get it, what do you mean by "when exactly one of the inputs is high" Jun 3 '13 at 1:49
• The only valid inputs are 0001, 0010, 0100, 1000. Any other input is not valid. That's what I mean by exactly one of the inputs must be high. Jun 3 '13 at 1:57
• Jun 3 '13 at 5:49