| 1 |
2 |
danv |
--------------------------------------------------------------------------------
|
| 2 |
|
|
--
|
| 3 |
3 |
danv |
-- Copyright 2020
|
| 4 |
|
|
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
| 5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
| 6 |
|
|
--
|
| 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 |
|
|
|
| 22 |
|
|
-- Purpose: Get twiddles from ROM
|
| 23 |
|
|
-- Description:
|
| 24 |
|
|
-- The twiddles ROM is generated twiddlesPkg.vhd.
|
| 25 |
|
|
-- Remark:
|
| 26 |
|
|
-- . Default use g_lat=1 as for synthesis to improve fmax.
|
| 27 |
|
|
-- . Use g_lat=0 for no digital latency to show the pure functional behavior
|
| 28 |
|
|
-- of a pipelined FFT.
|
| 29 |
|
|
-- . When the pipelined FFT is used in a Wideband FFT configuration the
|
| 30 |
|
|
-- rTwoWeights unit compensates for this by estimating the virtual stage and
|
| 31 |
|
|
-- applying the twiddle-offset and the stage-offset.
|
| 32 |
|
|
|
| 33 |
|
|
library ieee, common_pkg_lib;
|
| 34 |
|
|
use IEEE.std_logic_1164.all;
|
| 35 |
|
|
use common_pkg_lib.common_pkg.all;
|
| 36 |
|
|
use work.twiddlesPkg.all;
|
| 37 |
|
|
|
| 38 |
|
|
entity rTwoWeights is
|
| 39 |
|
|
generic (
|
| 40 |
|
|
g_stage : natural := 4; -- The stage number of the pft
|
| 41 |
|
|
g_lat : natural := 1; -- latency 0 or 1
|
| 42 |
|
|
g_twiddle_offset : natural := 0; -- The twiddle offset: 0 for normal FFT. Other than 0 in wideband FFT
|
| 43 |
|
|
g_stage_offset : natural := 0 -- The Stage offset: 0 for normal FFT. Other than 0 in wideband FFT
|
| 44 |
|
|
);
|
| 45 |
|
|
port (
|
| 46 |
|
|
clk : in std_logic;
|
| 47 |
|
|
in_wAdr : in std_logic_vector;
|
| 48 |
|
|
weight_re : out wTyp;
|
| 49 |
|
|
weight_im : out wTyp
|
| 50 |
|
|
);
|
| 51 |
|
|
end;
|
| 52 |
|
|
|
| 53 |
|
|
architecture rtl of rTwoWeights is
|
| 54 |
|
|
|
| 55 |
|
|
constant c_virtual_stage : integer := g_stage + g_stage_offset; -- Virtual stage based on the real stage and the stage_offset.
|
| 56 |
|
|
constant c_nof_shifts : integer := -1*g_stage_offset; -- Shift factor when fft is used in wfft configuration
|
| 57 |
|
|
|
| 58 |
|
|
signal nxt_weight_re : wTyp;
|
| 59 |
|
|
signal nxt_weight_im : wTyp;
|
| 60 |
|
|
signal wAdr_shift : std_logic_vector(c_virtual_stage-1 downto 1);
|
| 61 |
|
|
signal wAdr_unshift : std_logic_vector(c_virtual_stage-1 downto 1);
|
| 62 |
|
|
signal wAdr_tw_offset: integer := 0;
|
| 63 |
|
|
|
| 64 |
|
|
begin
|
| 65 |
|
|
|
| 66 |
|
|
-- Estimate the correct twiddle address.
|
| 67 |
|
|
-- In case of a wfft configuration the address will be shifted and the twiddle offset will be added.
|
| 68 |
|
|
wAdr_unshift <= RESIZE_UVEC(in_wAdr, wAdr_unshift'length);
|
| 69 |
|
|
wAdr_shift <= SHIFT_UVEC(wAdr_unshift, c_nof_shifts) when in_wAdr'length > 0 else (others => '0');
|
| 70 |
|
|
wAdr_tw_offset <= TO_UINT(wAdr_shift) + g_twiddle_offset when in_wAdr'length > 0 else g_twiddle_offset;
|
| 71 |
|
|
|
| 72 |
|
|
-- functionality
|
| 73 |
|
|
p_get_weights : process(wAdr_tw_offset)
|
| 74 |
|
|
begin
|
| 75 |
|
|
if c_virtual_stage=1 then
|
| 76 |
|
|
nxt_weight_re <= wRe(wMap(0, 1));
|
| 77 |
|
|
nxt_weight_im <= wIm(wMap(0, 1));
|
| 78 |
|
|
else
|
| 79 |
|
|
nxt_weight_re <= wRe(wMap(wAdr_tw_offset, c_virtual_stage));
|
| 80 |
|
|
nxt_weight_im <= wIm(wMap(wAdr_tw_offset, c_virtual_stage));
|
| 81 |
|
|
end if;
|
| 82 |
|
|
end process;
|
| 83 |
|
|
|
| 84 |
|
|
-- latency
|
| 85 |
|
|
no_reg : if g_lat=0 generate
|
| 86 |
|
|
weight_re <= nxt_weight_re;
|
| 87 |
|
|
weight_im <= nxt_weight_im;
|
| 88 |
|
|
end generate;
|
| 89 |
|
|
|
| 90 |
|
|
gen_reg : if g_lat=1 generate
|
| 91 |
|
|
p_clk : process(clk)
|
| 92 |
|
|
begin
|
| 93 |
|
|
if rising_edge(clk) then
|
| 94 |
|
|
weight_re <= nxt_weight_re;
|
| 95 |
|
|
weight_im <= nxt_weight_im;
|
| 96 |
|
|
end if;
|
| 97 |
|
|
end process;
|
| 98 |
|
|
end generate;
|
| 99 |
|
|
|
| 100 |
|
|
assert g_lat<=1 report "rTwoWeights : g_lat must be 0 or 1" severity failure;
|
| 101 |
|
|
|
| 102 |
|
|
end rtl;
|