Академический Документы
Профессиональный Документы
Культура Документы
3: SUMADOR
En la figura 3.3 se muestra el diagrama de un sumador de 4 bits. El circuito
tiene dos entradas (a, b) y una salida (sum). Se presentan dos soluciones.
En la primera, todas las entradas son de tipo SIGNED, mientras que en la
segunda todas las salidas son de tipo INTEGER. Nota que en la solucin 2
que se us una conversin de funcin en la lnea 13, para una tipo de a + b
de la suma. Notar tambin que la inclusin del paquete std_logic_arith
(lnea 4 de cada solucin), el cual se especifica el tipo de dato SIGNED.
Volver a llamar un valor SIGNED es representado como un vector, esto es,
similar a STD_LOGIC_VECTOR, no como un INTEGER.
ENTITY SUMADOR_TB IS
END SUMADOR_TB;
ARCHITECTURE behavior OF SUMADOR_TB IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT SUMADOR
PORT(
a : IN SIGNED (3 DOWNTO 0);
b : IN SIGNED (3 DOWNTO 0);
sum : OUT SIGNED (4 DOWNTO 0)
);
END COMPONENT;
--Inputs
signal a : SIGNED (3 DOWNTO 0) := (others => '0');
signal b : SIGNED (3 DOWNTO 0) := (others => '0');
--Outputs
signal sum : SIGNED (4 DOWNTO 0);
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
--constant <clock>_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: SUMADOR PORT MAP (
a => a,
b => b,
sum => sum
);
stim_proc: PROCESS
BEGIN
a <=
wait
a <=
wait
"0000" ;
for 50 ns;
"1111" ;
for 350 ns;
b <= "0100" ;
wait for 50 ns;
b <= "1111" ;
wait for 150 ns;
-- b <= "0100" after 50 ns, "1100" after 500 ns, "1011" after 400 ns;
END PROCESS;
-- Stimulus process
END;
SIMULACION:
SEGUNDA SOLUCION:
is
in SIGNED (3 DOWNTO 0);
in SIGNED (3 DOWNTO 0);
: out INTEGER RANGE -16 TO 15);
BEGIN
-- Instantiate the Unit under Test (UUT)
uut: SUMADOR PORT MAP (
a => a,
b => b,
sum => sum
);
-- Clock process definitions
a <= "0000" after 0 ns , "1010" after 50 ns , "1111" after 100
ns ,"1010" after 150 ns , "1111" after 200 ns ,"1010" after 250 ns ,
"1111" after 300 ns ;
b <= "0000" after 0 ns , "1111" after 50 ns , "0000" after 100 ns ,
"1111" after 150 ns , "0000" after 200 ns, "1111" after 250 ns ,
"0000" after 300 ns;
END;
SIMULACION: