Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 4.06 KB | None | 0 0
  1. --
  2. -- Centroidi posizionati su bordi
  3. --
  4.  
  5. library ieee;
  6. use ieee.std_logic_1164.all;
  7. use ieee.numeric_std.all;
  8. use ieee.std_logic_unsigned.all;
  9.  
  10. entity autogen_test_bench_4 is
  11. end autogen_test_bench_4;
  12.  
  13. architecture bhv of autogen_test_bench_4 is
  14.     constant c_CLOCK_PERIOD        : time := 100 ns;
  15.     signal   tb_done               : std_logic;
  16.     signal   mem_address           : std_logic_vector (15 downto 0) := (others => '0');
  17.     signal   tb_rst                : std_logic := '0';
  18.     signal   tb_start              : std_logic := '0';
  19.     signal   tb_clk                : std_logic := '0';
  20.     signal   mem_o_data,mem_i_data : std_logic_vector (7 downto 0);
  21.     signal   enable_wire           : std_logic;
  22.     signal   mem_we                : std_logic;
  23.  
  24.     type ram_type is array (65535 downto 0) of std_logic_vector(7 downto 0);
  25.     signal RAM: ram_type := (
  26.         0 => "10110001",
  27.         1 => std_logic_vector(to_unsigned(255, 8)),
  28.         2 => std_logic_vector(to_unsigned(7, 8)),
  29.         3 => std_logic_vector(to_unsigned(170, 8)),
  30.         4 => std_logic_vector(to_unsigned(48, 8)),
  31.         5 => std_logic_vector(to_unsigned(15, 8)),
  32.         6 => std_logic_vector(to_unsigned(111, 8)),
  33.         7 => std_logic_vector(to_unsigned(123, 8)),
  34.         8 => std_logic_vector(to_unsigned(88, 8)),
  35.         9 => std_logic_vector(to_unsigned(155, 8)),
  36.         10 => std_logic_vector(to_unsigned(25, 8)),
  37.         11 => std_logic_vector(to_unsigned(255, 8)),
  38.         12 => std_logic_vector(to_unsigned(9, 8)),
  39.         13 => std_logic_vector(to_unsigned(170, 8)),
  40.         14 => std_logic_vector(to_unsigned(48, 8)),
  41.         15 => std_logic_vector(to_unsigned(255, 8)),
  42.         16 => std_logic_vector(to_unsigned(13, 8)),
  43.         17 => std_logic_vector(to_unsigned(255, 8)),
  44.         18 => std_logic_vector(to_unsigned(8, 8)),
  45.         others => (others =>'0')
  46.     );
  47.  
  48.     constant EXPECTED_OUTPUT : std_logic_vector(7 downto 0) := "10000000";
  49.  
  50.     component project_reti_logiche is
  51.         port (
  52.             i_clk         : in  std_logic;
  53.             i_start       : in  std_logic;
  54.             i_rst         : in  std_logic;
  55.             i_data        : in  std_logic_vector(7 downto 0);
  56.             o_address     : out std_logic_vector(15 downto 0);
  57.             o_done        : out std_logic;
  58.             o_en          : out std_logic;
  59.             o_we          : out std_logic;
  60.             o_data        : out std_logic_vector (7 downto 0)
  61.     );
  62.     end component project_reti_logiche;
  63.  
  64. begin
  65. UUT:
  66.     project_reti_logiche port map (
  67.         i_clk          => tb_clk,
  68.         i_start        => tb_start,
  69.         i_rst          => tb_rst,
  70.         i_data         => mem_o_data,
  71.         o_address      => mem_address,
  72.         o_done         => tb_done,
  73.         o_en           => enable_wire,
  74.         o_we           => mem_we,
  75.         o_data         => mem_i_data
  76.     );
  77.  
  78. p_CLK_GEN:
  79.     process is
  80.     begin
  81.         wait for c_CLOCK_PERIOD/2;
  82.         tb_clk <= not tb_clk;
  83.     end process p_CLK_GEN;
  84. MEM:
  85.     process(tb_clk)
  86.     begin
  87.         if tb_clk'event and tb_clk = '1' then
  88.             if enable_wire = '1' then
  89.                 if mem_we = '1' then
  90.                     RAM(conv_integer(mem_address)) <= mem_i_data;
  91.                     mem_o_data                     <= mem_i_data after 2 ns;
  92.                 else
  93.                     mem_o_data <= RAM(conv_integer(mem_address)) after 2 ns;
  94.                 end if;
  95.             end if;
  96.         end if;
  97.     end process;
  98. test:
  99.     process is
  100.     begin
  101.         wait for 100 ns;
  102.         wait for c_CLOCK_PERIOD;
  103.         tb_rst <= '1';
  104.         wait for c_CLOCK_PERIOD;
  105.         tb_rst <= '0';
  106.         wait for c_CLOCK_PERIOD;
  107.         tb_start <= '1';
  108.         wait for c_CLOCK_PERIOD;
  109.         wait until tb_done = '1';
  110.         wait for c_CLOCK_PERIOD;
  111.         tb_start <= '0';
  112.         wait until tb_done = '0';
  113.         assert RAM(19) = EXPECTED_OUTPUT report "TEST FALLITO" severity failure;
  114.         assert false report "TEST #9 OK" severity failure;
  115.     end process test;
  116.  
  117. end bhv;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement