Jump to content

Decoder: Difference between revisions

From Logic World Wiki
DjSapsan (talk | contribs)
added "part of"
DjSapsan (talk | contribs)
 
(One intermediate revision by the same user not shown)
Line 19: Line 19:


So, if you want 256 outputs, you will need a decoder with 8 input bits.   
So, if you want 256 outputs, you will need a decoder with 8 input bits.   
Each output has a specific pattern of {{on}} and {{off}} bits coming from the input. Here are the steps to build it:
Each output has a specific pattern of {{on}} and {{off}} bits coming from the input. The circuit is basically a number of [[AND Gate|AND]] gates for each possible combination.
 
Here are the steps to build it:


* Place a row of input items.   
* Place a row of input items.   
* Connect each input bit to a NOT gate to get its inverted value. And add a Buffer to pass the non-inverted value and match the delay with the NOT gate.   
* Connect each input bit to both a [[Inverter|NOT]] gate and a [[Buffer]].The NOT gate is required to have the inverted value and the Buffer is required to match the delay with the NOT gate.   
* Place a row of NOT gates to serve as the outputs.   
* Place a row of NOT gates to serve as the outputs.   
* Go through each output NOT gate and connect them to the corresponding inputs (normal or inverted) to match its binary value. For example, the output corresponding to number 12 (binary 1100) should receive the following binary values:
* Go through each output NOT gate and connect them to the corresponding inputs (normal or inverted) to match its binary value. For example, the output corresponding to number 12 (binary 1100) should receive the following binary values:

Latest revision as of 22:55, 12 September 2025

Decoder
In Logic World, a Decoder is a circuit that takes a binary input and activates one specific output bit corresponding to that input.
It is commonly used to select one element out of many, for example a cell in memory.
The Decoder always outputs a single bit.
Effectively it's translating a binary value into a unary value.
4-bit decoder. Input on the left is 1110. The 14th output bit on the right is activated.
4-bit decoder. Input on the left is 1110. The 14th output bit on the right is activated.

Construction

A Decoder is one of the simplest circuits to build. First, determine how many bits you need. The number of output bits from input bits is given by:

o=2i

And vice versa:

i=log2(o)

So, if you want 256 outputs, you will need a decoder with 8 input bits. Each output has a specific pattern of ON and OFF bits coming from the input. The circuit is basically a number of AND gates for each possible combination.

Here are the steps to build it:

  • Place a row of input items.
  • Connect each input bit to both a NOT gate and a Buffer.The NOT gate is required to have the inverted value and the Buffer is required to match the delay with the NOT gate.
  • Place a row of NOT gates to serve as the outputs.
  • Go through each output NOT gate and connect them to the corresponding inputs (normal or inverted) to match its binary value. For example, the output corresponding to number 12 (binary 1100) should receive the following binary values:
    • 1st bit – normal
    • 2nd bit – normal
    • 3rd bit – inverted
    • 4th bit – inverted
and so on for each value.

You can design a decoder in different ways. If you are building one for the first time, you may want to explicitly place each wire and gate to match the real electronic analog or to be visually understandable.

When you become more experienced, you can skip unnecessary details and make it as simple as the screenshot above demonstrates. This design, optimized for speed and size, uses the trick of connecting wires from output pins directly to the required items, avoiding additional buffers and wire routing. On the screenshot below you can see the side view and how it allows it to make it compact.

Side view of the decoder
Side view of the decoder

Speed

The compact design above computes the output in 2 ticks.

Part of

Decoders are used primarily as part of the following circuits:

RAM, ROM
Control Unit
Multiplexer, Demultiplexer
Lookup_Table

See also