# Decoders Explained

concept
Say you have four logic inputs $$A_0A_1A_2A_3$$ and you want to detect when they equal $$1001$$. A decoder is a piece of circuitry that does exactly this, it will output a high when a precise combination of inputs is given to it. We use a decoder to detect when a certain binary signal is being sent to us.
You can build a simple decoder with some logic gates. For instance to detect when four inputs are $$1001$$ exactly we could build the following circuit: You can see that we'll get an output of $$1$$ when and only when our input is exactly $$1001$$ This is nice and we'll even use it later when we deal with counters, but imagine a device which would be the opposite of an encoder, we give it some binary input and it sends an output on one of its many output lines which corresponds to that input.
fact
Decoders are the opposite of encoders. Where encoders take a large number of inputs and code which one is high as a binary number, a decoder will accept a binary number and send the corresponding output line high in response. Here the decoder receives the binary for 3 and output line 3 goes high while the others remain low.
So when you give your decoder the binary input $$1001$$ you'll get line 9 go high in response.
example

Determine the output of the following decoder with input $$0110$$

Since our input corresponds to binary 6 output line 6 will go high while the others remain low.
practice problems