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 |
|
|
-- Purpose : Butterfly
|
22 |
|
|
-- Description :
|
23 |
|
|
-- Default the rTwoBF is combinatorial and it can not be pipelined because
|
24 |
|
|
-- of the feedback shift register.
|
25 |
|
|
-- However for the FFT input stages with larger feedback shift registers it
|
26 |
|
|
-- may be beneficial for achieving timing closure to move some of the z^(-1)
|
27 |
|
|
-- shift delay out from the d to a feedback shift register into this rTwoBF.
|
28 |
|
|
-- The shift must only occur for valid data, so therefor then the in_val
|
29 |
|
|
-- input is also needed.
|
30 |
|
|
-- The g_in_a_zdly allows getting a delay shift into this rTwoBF for input
|
31 |
|
|
-- in_a. The g_out_d_zdly allows getting a delay shift into this rTwoBF for
|
32 |
|
|
-- output out_d. Externally the feedback shift register depth must then be
|
33 |
|
|
-- decreased by g_in_a_zdly+g_out_d_zdly.
|
34 |
|
|
-- Remarks:
|
35 |
|
|
-- . For the last FFT output stages the feedback shift register depth is ...,
|
36 |
|
|
-- 4, 2, 1 so then there is less need to use g_in_a_zdly or g_in_a_zdly
|
37 |
|
|
-- other than 0.
|
38 |
|
|
-- . Default use g_in_a_zdly=0 and g_out_d_zdly=0, so then clk and in_val can
|
39 |
|
|
-- be left not connected.
|
40 |
|
|
-- . Alternatively one can use g_in_a_zdly=0 and g_out_d_zdly=1 for all
|
41 |
|
|
-- stages.
|
42 |
|
|
|
43 |
|
|
library ieee, common_pkg_lib, common_components_lib;
|
44 |
|
|
use IEEE.std_logic_1164.all;
|
45 |
|
|
use common_pkg_lib.common_pkg.all;
|
46 |
|
|
|
47 |
|
|
entity rTwoBF is
|
48 |
|
|
generic (
|
49 |
|
|
g_in_a_zdly : natural := 0; -- default 0, 1
|
50 |
|
|
g_out_d_zdly : natural := 0 -- default 0, optionally use 1
|
51 |
|
|
);
|
52 |
|
|
port (
|
53 |
|
|
clk : in std_logic := '0';
|
54 |
|
|
in_a : in std_logic_vector;
|
55 |
|
|
in_b : in std_logic_vector;
|
56 |
|
|
in_sel : in std_logic;
|
57 |
|
|
in_val : in std_logic := '0';
|
58 |
|
|
out_c : out std_logic_vector;
|
59 |
|
|
out_d : out std_logic_vector
|
60 |
|
|
);
|
61 |
|
|
end;
|
62 |
|
|
|
63 |
|
|
architecture rtl of rTwoBF is
|
64 |
|
|
|
65 |
|
|
signal in_a_dly : std_logic_vector(in_a'range);
|
66 |
|
|
signal out_d_ely : std_logic_vector(out_d'range);
|
67 |
|
|
|
68 |
|
|
begin
|
69 |
|
|
|
70 |
|
|
-- Optionally some z-1 delay gets move here into this BF stage, default 0
|
71 |
|
|
u_in_dly : entity common_components_lib.common_delay
|
72 |
|
|
generic map (
|
73 |
|
|
g_dat_w => in_a'length,
|
74 |
|
|
g_depth => g_in_a_zdly
|
75 |
|
|
)
|
76 |
|
|
port map (
|
77 |
|
|
clk => clk,
|
78 |
|
|
in_val => in_val,
|
79 |
|
|
in_dat => in_a,
|
80 |
|
|
out_dat => in_a_dly
|
81 |
|
|
);
|
82 |
|
|
|
83 |
|
|
u_out_dly : entity common_components_lib.common_delay
|
84 |
|
|
generic map (
|
85 |
|
|
g_dat_w => out_d'length,
|
86 |
|
|
g_depth => g_out_d_zdly
|
87 |
|
|
)
|
88 |
|
|
port map (
|
89 |
|
|
clk => clk,
|
90 |
|
|
in_val => in_val,
|
91 |
|
|
in_dat => out_d_ely,
|
92 |
|
|
out_dat => out_d
|
93 |
|
|
);
|
94 |
|
|
|
95 |
|
|
-- BF function: add, subtract or pass the data on dependent on in_sel
|
96 |
|
|
out_c <= ADD_SVEC(in_a_dly, in_b, out_c'length) when in_sel='1' else in_a_dly;
|
97 |
|
|
out_d_ely <= SUB_SVEC(in_a_dly, in_b, out_d'length) when in_sel='1' else in_b;
|
98 |
|
|
|
99 |
|
|
end rtl;
|