1 |
2 |
danv |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
3 |
danv |
-- Copyright 2020
|
4 |
2 |
danv |
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
6 |
3 |
danv |
--
|
7 |
|
|
-- Licensed under the Apache License, Version 2.0 (the "License");
|
8 |
|
|
-- you may not use this file except in compliance with the License.
|
9 |
|
|
-- You may obtain a copy of the License at
|
10 |
|
|
--
|
11 |
|
|
-- http://www.apache.org/licenses/LICENSE-2.0
|
12 |
|
|
--
|
13 |
|
|
-- Unless required by applicable law or agreed to in writing, software
|
14 |
|
|
-- distributed under the License is distributed on an "AS IS" BASIS,
|
15 |
|
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16 |
|
|
-- See the License for the specific language governing permissions and
|
17 |
|
|
-- limitations under the License.
|
18 |
2 |
danv |
--
|
19 |
|
|
-------------------------------------------------------------------------------
|
20 |
|
|
|
21 |
|
|
-- Purpose: Test bench for functions in fft_pkg.vhd
|
22 |
|
|
--
|
23 |
|
|
-- Description:
|
24 |
|
|
-- Use signals to observe the result of functions in the Wave Window.
|
25 |
|
|
-- Manually verify that the functions yield the expected result.
|
26 |
|
|
-- Usage:
|
27 |
|
|
-- > as 3
|
28 |
|
|
-- > run 1 us
|
29 |
|
|
--
|
30 |
|
|
|
31 |
|
|
LIBRARY IEEE, common_pkg_lib;
|
32 |
|
|
USE IEEE.STD_LOGIC_1164.ALL;
|
33 |
|
|
USE common_pkg_lib.common_pkg.ALL;
|
34 |
|
|
USE work.fft_pkg.ALL;
|
35 |
|
|
USE work.tb_fft_pkg.ALL;
|
36 |
|
|
|
37 |
|
|
ENTITY tb_fft_functions IS
|
38 |
|
|
END tb_fft_functions;
|
39 |
|
|
|
40 |
|
|
ARCHITECTURE tb OF tb_fft_functions IS
|
41 |
|
|
|
42 |
|
|
CONSTANT c_wb_factor : NATURAL := 4;
|
43 |
|
|
CONSTANT c_nof_points : NATURAL := 32;
|
44 |
|
|
CONSTANT c_w : NATURAL := ceil_log2(c_nof_points);
|
45 |
|
|
|
46 |
|
|
-- index_arr = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
47 |
|
|
-- index_transpose_P_N_arr = 0 8 16 24 1 9 17 25 2 10 18 26 3 11 19 27 4 12 20 28 5 13 21 29 6 14 22 30 7 15 23 31
|
48 |
|
|
-- index_transpose_N_P_arr = 0 4 8 12 16 20 24 28 1 5 9 13 17 21 25 29 2 6 10 14 18 22 26 30 3 7 11 15 19 23 27 31
|
49 |
|
|
-- bin_complex_arr = 16 0 24 8 20 4 28 12 18 2 26 10 22 6 30 14 17 1 25 9 21 5 29 13 19 3 27 11 23 7 31 15
|
50 |
|
|
-- bin_complex_flip_arr = 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
51 |
|
|
-- bin_complex_flip_transpose_arr = 4 12 20 28 5 13 21 29 6 14 22 30 7 15 23 31 0 8 16 24 1 9 17 25 2 10 18 26 3 11 19 27
|
52 |
|
|
-- bin_complex_reorder_arr = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
53 |
|
|
-- bin_complex_reorder_transpose_arr = 0 8 16 24 1 9 17 25 2 10 18 26 3 11 19 27 4 12 20 28 5 13 21 29 6 14 22 30 7 15 23 31
|
54 |
|
|
-- bin_two_real_reorder_arr = 0 1 2 3 0 1 2 3 4 5 6 7 4 5 6 7 8 9 10 11 8 9 10 11 12 13 14 15 12 13 14 15
|
55 |
|
|
-- bin_two_real_reorder_transpose_arr = 0 4 8 12 0 4 8 12 1 5 9 13 1 5 9 13 2 6 10 14 2 6 10 14 3 7 11 15 3 7 11 15
|
56 |
|
|
SIGNAL index_arr : t_natural_arr(0 TO c_nof_points-1) := array_init(0, c_nof_points, 1);
|
57 |
|
|
SIGNAL index_transpose_P_N_arr : t_natural_arr(0 TO c_nof_points-1);
|
58 |
|
|
SIGNAL index_transpose_N_P_arr : t_natural_arr(0 TO c_nof_points-1);
|
59 |
|
|
SIGNAL index_transpose_N_P_flip_arr : t_natural_arr(0 TO c_nof_points-1);
|
60 |
|
|
SIGNAL index_flip_transpose_N_P_arr : t_natural_arr(0 TO c_nof_points-1);
|
61 |
|
|
SIGNAL index_flip_arr : t_natural_arr(0 TO c_nof_points-1);
|
62 |
|
|
SIGNAL index_flip_shift_arr : t_natural_arr(0 TO c_nof_points-1);
|
63 |
|
|
SIGNAL index_shift_flip_arr : t_natural_arr(0 TO c_nof_points-1);
|
64 |
|
|
SIGNAL bin_complex_arr : t_natural_arr(0 TO c_nof_points-1);
|
65 |
|
|
SIGNAL bin_complex_flip_arr : t_natural_arr(0 TO c_nof_points-1); -- flip()
|
66 |
|
|
SIGNAL bin_complex_flip_transpose_arr : t_natural_arr(0 TO c_nof_points-1);
|
67 |
|
|
SIGNAL bin_complex_reorder_arr : t_natural_arr(0 TO c_nof_points-1); -- fft_shift(flip())
|
68 |
|
|
SIGNAL bin_complex_reorder_transpose_arr : t_natural_arr(0 TO c_nof_points-1);
|
69 |
|
|
SIGNAL bin_two_real_reorder_arr : t_natural_arr(0 TO c_nof_points-1); -- separate(flip())
|
70 |
|
|
SIGNAL bin_two_real_reorder_transpose_arr : t_natural_arr(0 TO c_nof_points-1);
|
71 |
|
|
|
72 |
|
|
BEGIN
|
73 |
|
|
|
74 |
|
|
p_bin : PROCESS
|
75 |
|
|
BEGIN
|
76 |
|
|
FOR I IN 0 TO c_nof_points-1 LOOP
|
77 |
|
|
index_flip_arr(I) <= flip(I, c_w);
|
78 |
|
|
index_transpose_P_N_arr(I) <= transpose(I, c_wb_factor, c_nof_points/c_wb_factor);
|
79 |
|
|
index_transpose_N_P_arr(I) <= transpose(I, c_nof_points/c_wb_factor, c_wb_factor);
|
80 |
|
|
index_transpose_N_P_flip_arr(I) <= transpose(flip(I, c_w), c_nof_points/c_wb_factor, c_wb_factor);
|
81 |
|
|
index_flip_transpose_N_P_arr(I) <= flip(transpose(I, c_nof_points/c_wb_factor, c_wb_factor), c_w);
|
82 |
|
|
index_flip_shift_arr(I) <= flip(fft_shift(I, c_w), c_w);
|
83 |
|
|
index_shift_flip_arr(I) <= fft_shift(flip(I, c_w), c_w);
|
84 |
|
|
-- use_ use_ use_
|
85 |
|
|
-- index_flip fft_shift separate
|
86 |
|
|
bin_complex_arr(I) <= fft_index_to_bin_frequency(c_wb_factor, c_nof_points, I, FALSE, FALSE, FALSE);
|
87 |
|
|
bin_complex_flip_arr(I) <= fft_index_to_bin_frequency(c_wb_factor, c_nof_points, I, TRUE, FALSE, FALSE);
|
88 |
|
|
bin_complex_flip_transpose_arr(I) <= fft_index_to_bin_frequency(c_wb_factor, c_nof_points, I, TRUE, FALSE, FALSE);
|
89 |
|
|
bin_complex_reorder_arr(I) <= fft_index_to_bin_frequency(c_wb_factor, c_nof_points, I, TRUE, TRUE, FALSE);
|
90 |
|
|
bin_complex_reorder_transpose_arr(I) <= fft_index_to_bin_frequency(c_wb_factor, c_nof_points, I, TRUE, TRUE, FALSE);
|
91 |
|
|
bin_two_real_reorder_arr(I) <= fft_index_to_bin_frequency(c_wb_factor, c_nof_points, I, TRUE, FALSE, TRUE);
|
92 |
|
|
bin_two_real_reorder_transpose_arr(I) <= fft_index_to_bin_frequency(c_wb_factor, c_nof_points, I, TRUE, FALSE, TRUE);
|
93 |
|
|
END LOOP;
|
94 |
|
|
WAIT;
|
95 |
|
|
END PROCESS;
|
96 |
|
|
|
97 |
|
|
END tb;
|
98 |
|
|
|