diff --git a/libraries/base/common/hdllib.cfg b/libraries/base/common/hdllib.cfg index 1865a499ce3842715e65e11f235940b3203dc0e9..364afa6f1f603ba56b350ff55ddf6a3d3f58d3c4 100644 --- a/libraries/base/common/hdllib.cfg +++ b/libraries/base/common/hdllib.cfg @@ -8,6 +8,7 @@ synth_files = src/vhdl/common_pkg.vhd src/vhdl/common_str_pkg.vhd src/vhdl/common_mem_pkg.vhd + src/vhdl/common_math_pkg.vhd src/vhdl/common_field_pkg.vhd src/vhdl/common_lfsr_sequences_pkg.vhd src/vhdl/common_interface_layers_pkg.vhd diff --git a/libraries/base/common/src/vhdl/common_math_pkg.vhd b/libraries/base/common/src/vhdl/common_math_pkg.vhd new file mode 100644 index 0000000000000000000000000000000000000000..0b280e2d0693810e000262187088a216a71ca5ba --- /dev/null +++ b/libraries/base/common/src/vhdl/common_math_pkg.vhd @@ -0,0 +1,75 @@ + +------------------------------------------------------------------------------- +-- +-- Copyright (C) 2017 +-- 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/>. +-- +------------------------------------------------------------------------------- + +-- Author: HJ Pepping , Original cos/sin LUT in fringe_stopping_pkg. +-- E. Kooistra, 10 Apr 2017, Moved to this more common pkg. + +LIBRARY IEEE; +USE IEEE.STD_LOGIC_1164.ALL; +USE IEEE.MATH_REAL.ALL; +USE work.common_pkg.ALL; + + +PACKAGE common_math_pkg IS + + -- Function to create the lookup_table + FUNCTION func_create_look_up_table_cos(N : POSITIVE; W : POSITIVE) RETURN t_nat_integer_arr; + FUNCTION func_create_look_up_table_sin(N : POSITIVE; W : POSITIVE) RETURN t_nat_integer_arr; + + -- Function to sum all values in the lookup table, to determine the DC value + FUNCTION func_sum_look_up_table(table : t_nat_integer_arr) RETURN INTEGER; + +END common_math_pkg; + + +PACKAGE BODY common_math_pkg IS + + FUNCTION func_create_look_up_table_cos(N : POSITIVE; W : POSITIVE) RETURN t_nat_integer_arr IS + VARIABLE table : t_nat_integer_arr(N-1 DOWNTO 0); + BEGIN + FOR I IN 0 TO N-1 LOOP + table(I) := INTEGER(ROUND(REAL(2**(W-1)-1)*COS(2.0*MATH_PI*REAL(I)/REAL(N)))); + END LOOP; + RETURN table; + END; + + FUNCTION func_create_look_up_table_sin(N : POSITIVE; W : POSITIVE) RETURN t_nat_integer_arr IS + VARIABLE table : t_nat_integer_arr(N-1 DOWNTO 0); + BEGIN + FOR I IN 0 TO N-1 LOOP + table(I) := INTEGER(ROUND(REAL(2**(W-1)-1)*SIN(2.0*MATH_PI*REAL(I)/REAL(N)))); + END LOOP; + RETURN table; + END; + + FUNCTION func_sum_look_up_table(table : t_nat_integer_arr) RETURN INTEGER IS + VARIABLE dc : INTEGER := 0; + BEGIN + FOR I IN table'RANGE LOOP + dc := dc + table(I); + END LOOP; + RETURN dc; + END; + + +END common_math_pkg; + diff --git a/libraries/base/common/src/vhdl/common_pkg.vhd b/libraries/base/common/src/vhdl/common_pkg.vhd index 089a9a669d63b5f440f283181d6d6365e511eaa0..e1fb5910813ae87b708c0743376790bc0d680ff1 100644 --- a/libraries/base/common/src/vhdl/common_pkg.vhd +++ b/libraries/base/common/src/vhdl/common_pkg.vhd @@ -403,13 +403,6 @@ PACKAGE common_pkg IS FUNCTION nat_arr_to_concat_slv(nat_arr: t_natural_arr; nof_elements: NATURAL) RETURN STD_LOGIC_VECTOR; - -- Function to create the lookup_table - FUNCTION func_create_look_up_table_cos(N : POSITIVE; W : POSITIVE) RETURN t_nat_integer_arr; - FUNCTION func_create_look_up_table_sin(N : POSITIVE; W : POSITIVE) RETURN t_nat_integer_arr; - - -- Function to sum all values in the lookup table, to determine the DC value - FUNCTION func_sum_look_up_table(table : t_nat_integer_arr) RETURN INTEGER; - ------------------------------------------------------------------------------ -- Component specific functions ------------------------------------------------------------------------------ @@ -2068,34 +2061,6 @@ PACKAGE BODY common_pkg IS END; - FUNCTION func_create_look_up_table_cos(N : POSITIVE; W : POSITIVE) RETURN t_nat_integer_arr IS - VARIABLE table : t_nat_integer_arr(N-1 DOWNTO 0); - BEGIN - FOR I IN 0 TO N-1 LOOP - table(I) := INTEGER(ROUND(REAL(2**(W-1)-1)*COS(2.0*MATH_PI*REAL(I)/REAL(N)))); - END LOOP; - RETURN table; - END; - - FUNCTION func_create_look_up_table_sin(N : POSITIVE; W : POSITIVE) RETURN t_nat_integer_arr IS - VARIABLE table : t_nat_integer_arr(N-1 DOWNTO 0); - BEGIN - FOR I IN 0 TO N-1 LOOP - table(I) := INTEGER(ROUND(REAL(2**(W-1)-1)*SIN(2.0*MATH_PI*REAL(I)/REAL(N)))); - END LOOP; - RETURN table; - END; - - FUNCTION func_sum_look_up_table(table : t_nat_integer_arr) RETURN INTEGER IS - VARIABLE dc : INTEGER := 0; - BEGIN - FOR I IN table'RANGE LOOP - dc := dc + table(I); - END LOOP; - RETURN dc; - END; - - ------------------------------------------------------------------------------ -- common_fifo_* ------------------------------------------------------------------------------