-- Cálculo del valor máximo de dos vectores de 4 bits
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
- Declaración de la entidad
Entity maximo is
port (
a, b: in std_logic_vector (3 downto 0);
z: out std_logic_vector (3 downto 0));
end maximo ;
-- Definición de la arquitectura
Architecture bhr of maximo is
function max (x, y: in integer) return integer is -- Definición de la función
beginif x>y then return x;
else return y;
end if;end;
begin
Process (a)
Beginz <= conv_std_logic_vector( max (conv_integer(a), conv_integer(b)), 4); -- Llamada a la función
End process;
end bhr;