Skip to content
Snippets Groups Projects
Select Git revision
  • d81f992807bb509fc7754a0daebbca19a2f873ee
  • master default protected
  • L2SDP-LIFT
  • L2SDP-1113
  • HPR-158
5 results

tb_common_adder_tree.vhd

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    tb_common_adder_tree.vhd 6.98 KiB
    -------------------------------------------------------------------------------
    --
    -- Copyright (C) 2009
    -- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
    -- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
    --
    -- This program is free software: you can redistribute it and/or modify
    -- it under the terms of the GNU General Public License as published by
    -- the Free Software Foundation, either version 3 of the License, or
    -- (at your option) any later version.
    --
    -- This program is distributed in the hope that it will be useful,
    -- but WITHOUT ANY WARRANTY; without even the implied warranty of
    -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    -- GNU General Public License for more details.
    --
    -- You should have received a copy of the GNU General Public License
    -- along with this program.  If not, see <http://www.gnu.org/licenses/>.
    --
    -------------------------------------------------------------------------------
    
    -- Usage:
    -- > as 10
    -- > run -all
    -- . Observe in_data_arr_p and the expected result and the result of the DUT in the Wave window
    -- . This TB verifies the DUT architecture that was compile last. Default after a fresh mk the (str)
    --   is compiled last, to simulate the (recursive) manually compile it and the simulate again.
    --   Within the recursive architecture it is not possible to explicitely configure it to recursively 
    --   use the recursive architecture using FOR ALL : ENTITY because the instance label is within a
    --   generate block.
    -- . The p_verify makes the tb self checking and asserts when the results are not equal
      
    LIBRARY IEEE;
    USE IEEE.std_logic_1164.ALL;
    USE IEEE.numeric_std.ALL;
    USE work.common_pkg.ALL;
    USE work.tb_common_pkg.ALL;
    
    
    ENTITY tb_common_adder_tree IS
      GENERIC (
        g_representation : STRING  := "SIGNED";
        g_pipeline       : NATURAL := 1;  -- amount of pipelining per stage
        g_nof_inputs     : NATURAL := 31;  -- >= 1
        g_symbol_w       : NATURAL := 8;
        g_sum_w          : NATURAL := 8  -- worst case bit growth requires g_symbol_w + ceil_log2(g_nof_inputs);
      );
    END tb_common_adder_tree;
    
    
    ARCHITECTURE tb OF tb_common_adder_tree IS
    
      CONSTANT clk_period      : TIME := 10 ns;
      
      CONSTANT c_data_vec_w    : NATURAL := g_nof_inputs*g_symbol_w;
      CONSTANT c_nof_stages    : NATURAL := ceil_log2(g_nof_inputs);
      
      CONSTANT c_pipeline_tree : NATURAL := g_pipeline*c_nof_stages;
      
      TYPE t_symbol_arr IS ARRAY (INTEGER RANGE <>) OF STD_LOGIC_VECTOR(g_symbol_w-1 DOWNTO 0);  
      
      -- Use the same symbol value g_nof_inputs time in the data_vec
      FUNCTION func_data_vec(symbol : INTEGER) RETURN STD_LOGIC_VECTOR IS
        VARIABLE v_data_vec : STD_LOGIC_VECTOR(c_data_vec_w-1 DOWNTO 0);
      BEGIN
        FOR I IN 0 TO g_nof_inputs-1 LOOP
          v_data_vec((I+1)*g_symbol_w-1 DOWNTO I*g_symbol_w) := TO_UVEC(symbol, g_symbol_w);
        END LOOP;
        RETURN v_data_vec;
      END;