-- Codificador
library ieee;
use ieee.std_logic_1164.ALL;
use ieee.std_logic_arith.ALL;
use ieee.std_logic_unsigned.ALL;
- Declaración de la entidad
Entity codificador1 is
port (
a: in std_logic_vector(7 downto 0);
b: out std_logic_vector(2 downto 0));
end codificador1 ;
-- Definición de la arquitectura
Architecture bhr of codificador1 is
Process (a)
variable i: integer range 0 to 8;
Begini:=0;
while i<8 loopif a(i)='1' then b<=conv_std_logic_vector(i,3);
end if;
i:=i+1End loop;
End process;
end bhr;