@pellion The GIAN array can't be COEFF_CEL_REAL because its size depend on the number of cells.
@@ -0,0 +1,93 | |||
|
1 | ------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPP VHDL IP LIBRARY | |
|
3 | -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Jean-christophe Pellion | |
|
20 | -- Mail : jean-christophe.pellion@lpp.polytechnique.fr | |
|
21 | -- jean-christophe.pellion@easii-ic.com | |
|
22 | ---------------------------------------------------------------------------- | |
|
23 | LIBRARY ieee; | |
|
24 | USE ieee.std_logic_1164.ALL; | |
|
25 | USE ieee.numeric_std.ALL; | |
|
26 | USE ieee.math_real.ALL; | |
|
27 | ||
|
28 | PACKAGE lpp_lfr_filter_coeff IS | |
|
29 | ||
|
30 | --REAL | |
|
31 | TYPE COEFF_CEL_REAL IS ARRAY (1 TO 6) OF REAL; -- b0, b1, b2, a0, a1, a2 | |
|
32 | TYPE COEFF_CEL_ARRAY_REAL IS ARRAY (INTEGER RANGE <>) OF COEFF_CEL_REAL; | |
|
33 | --INTEGER | |
|
34 | TYPE COEFF_CEL_INTEGER IS ARRAY (1 TO 6) OF INTEGER; -- b0, b1, b2, a0, a1, a2 | |
|
35 | TYPE COEFF_CEL_ARRAY_INTEGER IS ARRAY (INTEGER RANGE <>) OF COEFF_CEL_INTEGER; | |
|
36 | ||
|
37 | ----------------------------------------------------------------------------- | |
|
38 | -- | |
|
39 | ----------------------------------------------------------------------------- | |
|
40 | FUNCTION get_IIR_CEL_FILTER_CONFIG ( | |
|
41 | COEFFICIENT_SIZE , POINT_POSITION, CEL_NUMBER : INTEGER; | |
|
42 | SOS_array : COEFF_CEL_ARRAY_REAL;--(INTEGER RANGE <>); | |
|
43 |
GAIN_array : COEFF_CEL_REAL
|
|
|
44 | ) RETURN STD_LOGIC_VECTOR; | |
|
45 | ||
|
46 | ||
|
47 | END lpp_lfr_filter_coeff; | |
|
48 | ||
|
49 | PACKAGE BODY lpp_lfr_filter_coeff IS | |
|
50 | ||
|
51 | FUNCTION get_IIR_CEL_FILTER_CONFIG ( | |
|
52 | COEFFICIENT_SIZE , POINT_POSITION, CEL_NUMBER : INTEGER; | |
|
53 | SOS_array : COEFF_CEL_ARRAY_REAL;--(INTEGER RANGE <>); | |
|
54 | GAIN_array : COEFF_CEL_REAL | |
|
55 | ) RETURN STD_LOGIC_VECTOR IS | |
|
56 | ||
|
57 | VARIABLE config_vector : STD_LOGIC_VECTOR((CEL_NUMBER * 5 * COEFFICIENT_SIZE)-1 DOWNTO 0); | |
|
58 | VARIABLE SOS_with_gain_array : COEFF_CEL_ARRAY_REAL(1 TO CEL_NUMBER); | |
|
59 | ||
|
60 | VARIABLE SOS_with_gain_array_integer : COEFF_CEL_ARRAY_INTEGER(1 TO CEL_NUMBER); | |
|
61 | BEGIN | |
|
62 | ||
|
63 | all_cel: FOR I IN 1 TO CEL_NUMBER LOOP | |
|
64 | all_param_b : FOR J IN 1 TO 3 LOOP | |
|
65 | SOS_with_gain_array(I)(J) := SOS_array(I)(J) * GAIN_array(I); | |
|
66 | END LOOP all_param_b; | |
|
67 | all_param_a : FOR J IN 4 TO 6 LOOP | |
|
68 | SOS_with_gain_array(I)(J) := SOS_array(I)(J); | |
|
69 | END LOOP all_param_a; | |
|
70 | END LOOP all_cel; | |
|
71 | ||
|
72 | all_cel_int: FOR I IN 1 TO CEL_NUMBER LOOP | |
|
73 | all_param_int: FOR J IN 1 TO 6 LOOP | |
|
74 | SOS_with_gain_array_integer(I)(J) := INTEGER( SOS_with_gain_array(I)(J) * REAL(2**(POINT_POSITION)) ); | |
|
75 | END LOOP all_param_int; | |
|
76 | END LOOP all_cel_int; | |
|
77 | ||
|
78 | all_cel_output: FOR I IN 1 TO CEL_NUMBER LOOP | |
|
79 | all_param_b_out: FOR J IN 1 TO 3 LOOP | |
|
80 | config_vector( (((I-1)*5)+3-J)*COEFFICIENT_SIZE + COEFFICIENT_SIZE -1 DOWNTO (((I-1)*5)+3-J)*COEFFICIENT_SIZE ) | |
|
81 | := std_logic_vector(TO_SIGNED(SOS_with_gain_array_integer(I)(J),COEFFICIENT_SIZE )); | |
|
82 | END LOOP all_param_b_out; | |
|
83 | config_vector( (((I-1)*5)+3)*COEFFICIENT_SIZE + COEFFICIENT_SIZE -1 DOWNTO (((I-1)*5)+3)*COEFFICIENT_SIZE ) | |
|
84 | := std_logic_vector(TO_SIGNED(SOS_with_gain_array_integer(I)(6),COEFFICIENT_SIZE)); | |
|
85 | config_vector( (((I-1)*5)+4)*COEFFICIENT_SIZE + COEFFICIENT_SIZE -1 DOWNTO (((I-1)*5)+4)*COEFFICIENT_SIZE ) | |
|
86 | := std_logic_vector(TO_SIGNED(SOS_with_gain_array_integer(I)(5),COEFFICIENT_SIZE)); | |
|
87 | END LOOP all_cel_output; | |
|
88 | ||
|
89 | RETURN config_vector; | |
|
90 | ||
|
91 | END FUNCTION; | |
|
92 | ||
|
93 | END lpp_lfr_filter_coeff; |
General Comments 0
You need to be logged in to leave comments.
Login now