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: Multi-testbench for fft_r2_wide using file data
|
22 |
|
|
-- Description:
|
23 |
|
|
-- Verify fft_r2_wide using and data generated by Matlab scripts:
|
24 |
|
|
--
|
25 |
|
|
-- - $RADIOHDL/applications/apertif/matlab/run_pfft.m
|
26 |
|
|
-- - $RADIOHDL/applications/apertif/matlab/run_pfft_complex.m
|
27 |
|
|
--
|
28 |
|
|
-- Usage:
|
29 |
|
|
-- > as 4
|
30 |
|
|
-- > run -all
|
31 |
|
|
|
32 |
|
|
LIBRARY IEEE, common_pkg_lib, rTwoSDF_lib;
|
33 |
|
|
USE IEEE.std_logic_1164.ALL;
|
34 |
|
|
USE common_pkg_lib.common_pkg.all;
|
35 |
|
|
USE rTwoSDF_lib.rTwoSDFPkg.all;
|
36 |
|
|
USE work.fft_pkg.all;
|
37 |
|
|
|
38 |
|
|
ENTITY tb_tb_fft_r2_wide IS
|
39 |
|
|
END tb_tb_fft_r2_wide;
|
40 |
|
|
|
41 |
|
|
ARCHITECTURE tb OF tb_tb_fft_r2_wide IS
|
42 |
|
|
|
43 |
|
|
CONSTANT c_fft_wb4_two_real : t_fft := ( true, false, true, 0, 4, 0, 128, 8, 16, 0, c_dsp_mult_w, 2, true, 56, 2);
|
44 |
|
|
CONSTANT c_fft_wb4_complex_fft_shift : t_fft := ( true, true, false, 0, 4, 0, 64, 8, 16, 0, c_dsp_mult_w, 2, true, 56, 2);
|
45 |
|
|
CONSTANT c_fft_wb4_complex_flipped : t_fft := (false, false, false, 0, 4, 0, 64, 8, 16, 0, c_dsp_mult_w, 2, true, 56, 2);
|
46 |
|
|
CONSTANT c_fft_wb4_complex : t_fft := ( true, false, false, 0, 4, 0, 64, 8, 16, 0, c_dsp_mult_w, 2, true, 56, 2);
|
47 |
|
|
|
48 |
|
|
CONSTANT c_fft_wb1_complex : t_fft := ( true, false, false, 0, 1, 0, 64, 8, 16, 0, c_dsp_mult_w, 2, true, 56, 2);
|
49 |
|
|
CONSTANT c_fft_wb64_complex : t_fft := ( true, false, false, 0,64, 0, 64, 8, 16, 0, c_dsp_mult_w, 2, true, 56, 2);
|
50 |
|
|
|
51 |
|
|
CONSTANT c_diff_margin : natural := 2;
|
52 |
|
|
|
53 |
|
|
-- Real input
|
54 |
|
|
CONSTANT c_impulse_chirp : string := "data/run_pfft_m_impulse_chirp_8b_128points_16b.dat"; -- 25600 lines
|
55 |
|
|
CONSTANT c_sinusoid_chirp : string := "data/run_pfft_m_sinusoid_chirp_8b_128points_16b.dat"; -- 25600 lines
|
56 |
|
|
CONSTANT c_noise : string := "data/run_pfft_m_noise_8b_128points_16b.dat"; -- 1280 lines
|
57 |
|
|
CONSTANT c_dc_agwn : string := "data/run_pfft_m_dc_agwn_8b_128points_16b.dat"; -- 1280 lines
|
58 |
|
|
-- Complex input
|
59 |
|
|
CONSTANT c_phasor_chirp : string := "data/run_pfft_complex_m_phasor_chirp_8b_64points_16b.dat"; -- 12800 lines
|
60 |
|
|
CONSTANT c_phasor : string := "data/run_pfft_complex_m_phasor_8b_64points_16b.dat"; -- 320 lines
|
61 |
|
|
CONSTANT c_noise_complex : string := "data/run_pfft_complex_m_noise_complex_8b_64points_16b.dat"; -- 620 lines
|
62 |
|
|
-- Zero input
|
63 |
|
|
CONSTANT c_zero : string := "UNUSED";
|
64 |
|
|
CONSTANT c_unused : string := "UNUSED";
|
65 |
|
|
|
66 |
|
|
SIGNAL tb_end : STD_LOGIC := '0'; -- declare tb_end to avoid 'No objects found' error on 'when -label tb_end'
|
67 |
|
|
|
68 |
|
|
BEGIN
|
69 |
|
|
|
70 |
|
|
-- -- DUT generics
|
71 |
|
|
-- --g_fft : t_fft := ( true, false, true, 0, 4, 0, 128, 8, 16, 0, c_dsp_mult_w, 2, true, 56, 2); -- two real inputs A and B
|
72 |
|
|
-- g_fft : t_fft := ( true, false, true, 0, 4, 0, 32, 8, 16, 0, c_dsp_mult_w, 2, true, 56, 2); -- two real inputs A and B
|
73 |
|
|
-- --g_fft : t_fft := ( true, false, false, 0, 4, 0, 32, 8, 16, 0, c_dsp_mult_w, 2, true, 56, 2); -- complex input reordered
|
74 |
|
|
-- --g_fft : t_fft := (false, false, false, 0, 4, 0, 32, 8, 16, 0, c_dsp_mult_w, 2, true, 56, 2); -- complex input flipped
|
75 |
|
|
-- -- type t_rtwo_fft is record
|
76 |
|
|
-- -- use_reorder : boolean; -- = false for bit-reversed output, true for normal output
|
77 |
|
|
-- -- use_fft_shift : boolean; -- = false for [0, pos, neg] bin frequencies order, true for [neg, 0, pos] bin frequencies order in case of complex input
|
78 |
|
|
-- -- use_separate : boolean; -- = false for complex input, true for two real inputs
|
79 |
|
|
-- -- nof_chan : natural; -- = default 0, defines the number of channels (=time-multiplexed input signals): nof channels = 2**nof_chan
|
80 |
|
|
-- -- wb_factor : natural; -- = default 1, wideband factor
|
81 |
|
|
-- -- twiddle_offset : natural; -- = default 0, twiddle offset for PFT sections in a wideband FFT
|
82 |
|
|
-- -- nof_points : natural; -- = 1024, N point FFT
|
83 |
|
|
-- -- in_dat_w : natural; -- = 8, number of input bits
|
84 |
|
|
-- -- out_dat_w : natural; -- = 13, number of output bits, bit growth: in_dat_w + natural((ceil_log2(nof_points))/2 + 2)
|
85 |
|
|
-- -- out_gain_w : natural; -- = 0, output gain factor applied after the last stage output, before requantization to out_dat_w
|
86 |
|
|
-- -- stage_dat_w : natural; -- = 18, data width used between the stages(= DSP multiplier-width)
|
87 |
|
|
-- -- guard_w : natural; -- = 2, Guard used to avoid overflow in FFT stage.
|
88 |
|
|
-- -- guard_enable : boolean; -- = true when input needs guarding, false when input requires no guarding but scaling must be skipped at the last stage(s) (used in wb fft)
|
89 |
|
|
-- -- stat_data_w : positive; -- = 56 (= 18b+18b)+log2(781250)
|
90 |
|
|
-- -- stat_data_sz : positive; -- = 2 (complex re and im)
|
91 |
|
|
-- -- end record;
|
92 |
|
|
-- --
|
93 |
|
|
-- -- TB generics
|
94 |
|
|
-- g_diff_margin : integer := 2; -- maximum difference between HDL output and expected output (> 0 to allow minor rounding differences)
|
95 |
|
|
--
|
96 |
|
|
-- -- Two real input data files A and B used when g_fft.use_separate = true
|
97 |
|
|
-- -- * 128 points = 64 subbands
|
98 |
|
|
-- --g_data_file_a : string := "data/run_pfft_m_sinusoid_chirp_8b_128points_16b.dat";
|
99 |
|
|
-- --g_data_file_a_nof_lines : natural := 25600;
|
100 |
|
|
-- --g_data_file_b : string := "UNUSED";
|
101 |
|
|
-- --g_data_file_b_nof_lines : natural := 0;
|
102 |
|
|
--
|
103 |
|
|
-- -- * 32 points = 16 subbands
|
104 |
|
|
-- g_data_file_a : string := "data/run_pfft_m_sinusoid_chirp_8b_32points_16b.dat";
|
105 |
|
|
-- g_data_file_a_nof_lines : natural := 6400;
|
106 |
|
|
-- --g_data_file_a : string := "data/run_pfft_m_sinusoid_8b_32points_16b.dat";
|
107 |
|
|
-- --g_data_file_a_nof_lines : natural := 160;
|
108 |
|
|
--
|
109 |
|
|
-- --g_data_file_b : string := "data/run_pfft_m_impulse_chirp_8b_32points_16b.dat";
|
110 |
|
|
-- --g_data_file_b_nof_lines : natural := 6400;
|
111 |
|
|
-- g_data_file_b : string := "UNUSED";
|
112 |
|
|
-- g_data_file_b_nof_lines : natural := 0;
|
113 |
|
|
--
|
114 |
|
|
-- -- One complex input data file C used when g_fft.use_separate = false
|
115 |
|
|
-- -- * 64 points = 64 channels
|
116 |
|
|
-- --g_data_file_c : string := "data/run_pfft_complex_m_phasor_chirp_8b_64points_16b.dat";
|
117 |
|
|
-- --g_data_file_c_nof_lines : natural := 12800;
|
118 |
|
|
-- --g_data_file_c : string := "data/run_pfft_complex_m_phasor_8b_64points_16b.dat";
|
119 |
|
|
-- --g_data_file_c_nof_lines : natural := 320;
|
120 |
|
|
-- --g_data_file_c : string := "data/run_pfft_complex_m_noise_8b_64points_16b.dat";
|
121 |
|
|
-- --g_data_file_c_nof_lines : natural := 640;
|
122 |
|
|
--
|
123 |
|
|
-- -- * 32 points = 32 channels
|
124 |
|
|
-- g_data_file_c : string := "data/run_pfft_complex_m_phasor_chirp_8b_32points_16b.dat";
|
125 |
|
|
-- g_data_file_c_nof_lines : natural := 6400;
|
126 |
|
|
-- --g_data_file_c : string := "data/run_pfft_complex_m_phasor_8b_32points_16b.dat";
|
127 |
|
|
-- --g_data_file_c_nof_lines : natural := 160;
|
128 |
|
|
-- --g_data_file_c : string := "data/run_pfft_complex_m_noise_8b_32points_16b.dat";
|
129 |
|
|
-- --g_data_file_c_nof_lines : natural := 320;
|
130 |
|
|
--
|
131 |
|
|
-- g_data_file_nof_lines : natural := 6400; -- actual number of lines with input data to simulate from the data files, must be <= g_data_file_*_nof_lines
|
132 |
|
|
-- g_enable_in_val_gaps : boolean := TRUE -- when false then in_val flow control active continuously, else with random inactive gaps
|
133 |
|
|
|
134 |
|
|
-- Two real input data A and B
|
135 |
|
|
u_act_two_real_chirp : ENTITY work.tb_fft_r2_wide GENERIC MAP (c_fft_wb4_two_real, c_diff_margin, c_sinusoid_chirp, 25600, c_impulse_chirp, 25600, c_unused, 0, 25600, FALSE);
|
136 |
|
|
u_act_two_real_a0 : ENTITY work.tb_fft_r2_wide GENERIC MAP (c_fft_wb4_two_real, c_diff_margin, c_zero, 25600, c_impulse_chirp, 25600, c_unused, 0, 5120, FALSE);
|
137 |
|
|
u_act_two_real_b0 : ENTITY work.tb_fft_r2_wide GENERIC MAP (c_fft_wb4_two_real, c_diff_margin, c_sinusoid_chirp, 25600, c_zero, 25600, c_unused, 0, 5120, FALSE);
|
138 |
|
|
u_rnd_two_real_noise : ENTITY work.tb_fft_r2_wide GENERIC MAP (c_fft_wb4_two_real, c_diff_margin, c_noise, 1280, c_dc_agwn, 1280, c_unused, 0, 1280, TRUE);
|
139 |
|
|
|
140 |
|
|
-- Complex input data
|
141 |
|
|
u_act_complex_chirp : ENTITY work.tb_fft_r2_wide GENERIC MAP (c_fft_wb4_complex, c_diff_margin, c_unused, 0, c_unused, 0, c_phasor_chirp, 12800, 12800, FALSE);
|
142 |
|
|
u_act_complex_fft_shift : ENTITY work.tb_fft_r2_wide GENERIC MAP (c_fft_wb4_complex_fft_shift, c_diff_margin, c_unused, 0, c_unused, 0, c_phasor_chirp, 12800, 1280, FALSE);
|
143 |
|
|
u_act_complex_flipped : ENTITY work.tb_fft_r2_wide GENERIC MAP (c_fft_wb4_complex_flipped, c_diff_margin, c_unused, 0, c_unused, 0, c_phasor_chirp, 12800, 1280, FALSE);
|
144 |
|
|
u_rnd_complex_noise : ENTITY work.tb_fft_r2_wide GENERIC MAP (c_fft_wb4_complex, c_diff_margin, c_unused, 0, c_unused, 0, c_noise_complex, 640, 640, TRUE);
|
145 |
|
|
|
146 |
|
|
-- Extreme wb_factor=1 and wb_factor=nof_points
|
147 |
|
|
u_act_wb1_complex_noise : ENTITY work.tb_fft_r2_wide GENERIC MAP (c_fft_wb1_complex, c_diff_margin, c_unused, 0, c_unused, 0, c_noise_complex, 640, 640, FALSE);
|
148 |
|
|
u_act_wb64_complex_noise : ENTITY work.tb_fft_r2_wide GENERIC MAP (c_fft_wb64_complex, c_diff_margin, c_unused, 0, c_unused, 0, c_noise_complex, 640, 640, FALSE);
|
149 |
|
|
END tb;
|