10 input-4 output Encoder

                     <ABEL CODE>


module E10x4BCD;
title ’10 inputs to 4 outputs – BCD Encoder’;
Enc10x4 device ‘P22V10’;


“Input pins
I0,I1,I2,I3,I4,I5,I6,I7,I8,I9 pin 2,3,4,5,6,7,8,9,10,11;
“output pins
O1,O2,O3,O4 pin 23,22,21,20;


equations
O1 = I0#I2#I4#I6#I8;
O2 = I1#I2#I5#I6;
O3 = I3#I4#I5#I6;
O4 = I7#I8;
end E10x4BCD;

                 <VHDL CODE>


library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;

entity Enc10x4 is
    port ( input : in std_logic_vector(9 downto 0);
    output : out std_logic_vector(3 downto 0));
end Enc10x4;

architecture Enc10x4_arch of Enc10x4 is
begin
    process(input)
    begin
    if  (input = “0000000000” or input = “1000000000”) then
       output <= “0000”;
    else
       for i in 8 downto 0 loop
         if (input(i) >= ‘1’) then
          output <= conv_std_logic_vector(i+1,4);
         end if
       end loop;         
    end if;
    end process;
end Enc10x4_arch;

사용자 삽입 이미지

You may also like...

댓글 남기기