4-to-2 Line Encoder
Digital Encoder
An encoder does the opposite of a decoder: it takes several input lines, of which exactly one is active, and produces the binary code of the position of that active line. With four inputs D0–D3, only one may be high at a time (one-hot); the encoder compresses that into a 2-bit code Y1Y0. Y1 = D2 + D3, Y0 = D1 + D3 — each output is a single OR gate away from the inputs, so this is a one gate delay circuit.
Inputs (one-hot)
Y1 = D2 + D3, Y0 = D1 + D3 (1 gate delay — OR, OR)
Valid only when exactly one input is high; D0 is implied by Y1=Y0=0 and needs no gate at all.