decoders and encoders lecture l4.2. decoders and encoders binary decoders binary encoders priority...

25
Decoders and Encoders Lecture L4.2

Post on 19-Dec-2015

308 views

Category:

Documents


2 download

TRANSCRIPT

Decoders and Encoders

Lecture L4.2

Decoders and Encoders

• Binary Decoders

• Binary Encoders

• Priority Encoders

Decoders

3-to-8 Decoder

Behavior

for i in 0 to 7 loop if(i = conv_integer(A)) then Y(i) <= ‘1’; else Y(i) <= ‘0’; end if;end loop;

A2 A1 A0 Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7

0 0 0 1 0 0 0 0 0 0 00 0 1 0 1 0 0 0 0 0 00 1 0 0 0 1 0 0 0 0 00 1 1 0 0 0 1 0 0 0 01 0 0 0 0 0 0 1 0 0 01 0 1 0 0 0 0 0 1 0 01 1 0 0 0 0 0 0 0 1 01 1 1 0 0 0 0 0 0 0 1

A2 A1 A0 Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7

0 0 0 1 0 0 0 0 0 0 00 0 1 0 1 0 0 0 0 0 00 1 0 0 0 1 0 0 0 0 00 1 1 0 0 0 1 0 0 0 01 0 0 0 0 0 0 1 0 0 01 0 1 0 0 0 0 0 1 0 01 1 0 0 0 0 0 0 0 1 01 1 1 0 0 0 0 0 0 0 1

A: in STD_LOGIC_VECTOR(2 downto 0);Y: out STD_LOGIC_VECTOR(0 to 7);

library IEEE;use IEEE.STD_LOGIC_1164.all;use IEEE.STD_LOGIC_arith.all;use IEEE.STD_LOGIC_unsigned.all;

entity decode38 is port(

A : in STD_LOGIC_VECTOR(2 downto 0); Y : out STD_LOGIC_VECTOR(0 to 7)

);end decode38;

architecture decode38 of decode38 isbegin process(A) variable j: integer; begin

j := conv_integer(A);for i in 0 to 7 loop

if(i = j) then Y(i) <= '1'; else Y(i) <= '0'; end if;

end loop; end process;end decode38;

3-to-8 Decoder

3-to-8 Decoder

Decoder Networks

4-input tree decoder

Decoder uses

Decoder uses

Decoders and Encoders

• Binary Decoders

• Binary Encoders

• Priority Encoders

Binary encoders

A0 = D1 + D3 + D5 + D7

A1 = D2 + D3 + D6 + D7

A2 = D4 + D5 + D6 + D7

Uses of binary encoders

Decoders and Encoders

• Binary Decoders

• Binary Encoders

• Priority Encoders

entity pencoder is

port (

x: in STD_LOGIC_VECTOR (7 downto 0);

E: in STD_LOGIC;

y: out STD_LOGIC_VECTOR (2 downto 0);

A: out STD_LOGIC

);

end pencoder;

architecture pencoder_arch of pencoder isbegin pe: process(x,E) variable k: integer; begin y <= "000"; A <= '0'; if E = '1' then for j in 0 to 7 loop if x(j) = '1' then

y <= conv_std_logic_vector(j,3); A <= '1'; end if; end loop; end if; end process pe;end pencoder_arch;