Bloques Combinacionales en VHDL - 1103147
Bloques Combinacionales en VHDL - 1103147
Por:
Carlos Antonio Guareño Vélez - 1103147
.
.
Experimento:
Full Adder de dos entradas de 4 bits
Objetivos:
Para el objetivo de esta practica es desarrollar un Sumador completo(full adder)
de dos entradas de 4 bits mediante VHDL. Comprobaremos su funcionamiento con
la herramienta EDA Playground haciendo un testbench y analizando las señales
resultantes.
Procedimiento:
Código Design
-- Implementar en VHDL un Full Adder de dos entradas de 4 bits
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
--Necesaria para el operador &
use IEEE.std_logic_unsigned.all;
entity full4bits is
port(
a, b : in std_logic_vector(3 downto 0);
S : out std_logic_vector(4 downto 0));
end full4bits;
end full4bits_ARCH;
Codigo testbench
-- Testbench for OR gate
library IEEE;
use IEEE.std_logic_1164.all;
entity testbench is
-- empty
end testbench;
architecture tb of testbench is
-- DUT component
component full4bits is
port(
a, b : in std_logic_vector(3 downto 0);
S : out std_logic_vector(4 downto 0));
end component;
begin
-- Connect DUT
DUT: full4bits port map(a_in, b_in, S_out);
process
begin
a_in <= "1111";
b_in <= "1000";
wait for 1 ns;
assert(S_out= "10111") report "Fallo prueba 0" severity error;
-- Clear inputs
a_in <= "0000";
b_in <= "0000";
Resultados:
Análisis:
Como podemos observar, los resultados de las 4 mostradas por S_out son
correctos, por lo que comprobamos su funcionamiento.
Asignación:
Display BCD a 7 segmentos
Objetivo:
Procedimiento:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity test is
port (
clk : in std_logic;
bcd : in std_logic_vector(3 downto 0);
segment7 : out std_logic_vector(6 downto 0)
);
end test;
begin
process (clk,bcd)
BEGIN
if (clk'event and clk='1') then
case bcd is
when "0000"=> segment7 <="0000001"; -- '0'
when "0001"=> segment7 <="1001111"; -- '1'
when "0010"=> segment7 <="0010010"; -- '2'
when "0011"=> segment7 <="0000110"; -- '3'
when "0100"=> segment7 <="1001100"; -- '4'
when "0101"=> segment7 <="0100100"; -- '5'
when "0110"=> segment7 <="0100000"; -- '6'
when "0111"=> segment7 <="0001111"; -- '7'
when "1000"=> segment7 <="0000000"; -- '8'
when "1001"=> segment7 <="0000100"; -- '9'
end process;
end Behavioral;
Resultados:
library ieee;
use ieee.std_logic_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
ENTITY test_tb IS
END test_tb;
end;
Análisis:
Basándonos en el código del testbench podemos comprobar el correcto funcionamiento del circuito.