1 |
2 |
danv |
--------------------------------------------------------------------------------
|
2 |
|
|
-- Author: Raj Thilak Rajan : rajan at astron.nl: Nov 2009
|
3 |
|
|
-- Copyright (C) 2009-2010
|
4 |
|
|
-- ASTRON (Netherlands Institute for Radio Astronomy)
|
5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
6 |
|
|
--
|
7 |
|
|
-- This file is part of the UniBoard software suite.
|
8 |
|
|
-- The file is free software: you can redistribute it and/or modify
|
9 |
|
|
-- it under the terms of the GNU General Public License as published by
|
10 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
11 |
|
|
-- (at your option) any later version.
|
12 |
|
|
--
|
13 |
|
|
-- This program is distributed in the hope that it will be useful,
|
14 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
-- GNU General Public License for more details.
|
17 |
|
|
--
|
18 |
|
|
-- You should have received a copy of the GNU General Public License
|
19 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20 |
|
|
--------------------------------------------------------------------------------
|
21 |
|
|
|
22 |
|
|
-- Purpose : Butterfly
|
23 |
|
|
-- Description :
|
24 |
|
|
-- Default the rTwoBF is combinatorial and it can not be pipelined because
|
25 |
|
|
-- of the feedback shift register.
|
26 |
|
|
-- However for the FFT input stages with larger feedback shift registers it
|
27 |
|
|
-- may be beneficial for achieving timing closure to move some of the z^(-1)
|
28 |
|
|
-- shift delay out from the d to a feedback shift register into this rTwoBF.
|
29 |
|
|
-- The shift must only occur for valid data, so therefor then the in_val
|
30 |
|
|
-- input is also needed.
|
31 |
|
|
-- The g_in_a_zdly allows getting a delay shift into this rTwoBF for input
|
32 |
|
|
-- in_a. The g_out_d_zdly allows getting a delay shift into this rTwoBF for
|
33 |
|
|
-- output out_d. Externally the feedback shift register depth must then be
|
34 |
|
|
-- decreased by g_in_a_zdly+g_out_d_zdly.
|
35 |
|
|
-- Remarks:
|
36 |
|
|
-- . For the last FFT output stages the feedback shift register depth is ...,
|
37 |
|
|
-- 4, 2, 1 so then there is less need to use g_in_a_zdly or g_in_a_zdly
|
38 |
|
|
-- other than 0.
|
39 |
|
|
-- . Default use g_in_a_zdly=0 and g_out_d_zdly=0, so then clk and in_val can
|
40 |
|
|
-- be left not connected.
|
41 |
|
|
-- . Alternatively one can use g_in_a_zdly=0 and g_out_d_zdly=1 for all
|
42 |
|
|
-- stages.
|
43 |
|
|
|
44 |
|
|
library ieee, common_pkg_lib, common_components_lib;
|
45 |
|
|
use IEEE.std_logic_1164.all;
|
46 |
|
|
use common_pkg_lib.common_pkg.all;
|
47 |
|
|
|
48 |
|
|
entity rTwoBF is
|
49 |
|
|
generic (
|
50 |
|
|
g_in_a_zdly : natural := 0; -- default 0, 1
|
51 |
|
|
g_out_d_zdly : natural := 0 -- default 0, optionally use 1
|
52 |
|
|
);
|
53 |
|
|
port (
|
54 |
|
|
clk : in std_logic := '0';
|
55 |
|
|
in_a : in std_logic_vector;
|
56 |
|
|
in_b : in std_logic_vector;
|
57 |
|
|
in_sel : in std_logic;
|
58 |
|
|
in_val : in std_logic := '0';
|
59 |
|
|
out_c : out std_logic_vector;
|
60 |
|
|
out_d : out std_logic_vector
|
61 |
|
|
);
|
62 |
|
|
end;
|
63 |
|
|
|
64 |
|
|
architecture rtl of rTwoBF is
|
65 |
|
|
|
66 |
|
|
signal in_a_dly : std_logic_vector(in_a'range);
|
67 |
|
|
signal out_d_ely : std_logic_vector(out_d'range);
|
68 |
|
|
|
69 |
|
|
begin
|
70 |
|
|
|
71 |
|
|
-- Optionally some z-1 delay gets move here into this BF stage, default 0
|
72 |
|
|
u_in_dly : entity common_components_lib.common_delay
|
73 |
|
|
generic map (
|
74 |
|
|
g_dat_w => in_a'length,
|
75 |
|
|
g_depth => g_in_a_zdly
|
76 |
|
|
)
|
77 |
|
|
port map (
|
78 |
|
|
clk => clk,
|
79 |
|
|
in_val => in_val,
|
80 |
|
|
in_dat => in_a,
|
81 |
|
|
out_dat => in_a_dly
|
82 |
|
|
);
|
83 |
|
|
|
84 |
|
|
u_out_dly : entity common_components_lib.common_delay
|
85 |
|
|
generic map (
|
86 |
|
|
g_dat_w => out_d'length,
|
87 |
|
|
g_depth => g_out_d_zdly
|
88 |
|
|
)
|
89 |
|
|
port map (
|
90 |
|
|
clk => clk,
|
91 |
|
|
in_val => in_val,
|
92 |
|
|
in_dat => out_d_ely,
|
93 |
|
|
out_dat => out_d
|
94 |
|
|
);
|
95 |
|
|
|
96 |
|
|
-- BF function: add, subtract or pass the data on dependent on in_sel
|
97 |
|
|
out_c <= ADD_SVEC(in_a_dly, in_b, out_c'length) when in_sel='1' else in_a_dly;
|
98 |
|
|
out_d_ely <= SUB_SVEC(in_a_dly, in_b, out_d'length) when in_sel='1' else in_b;
|
99 |
|
|
|
100 |
|
|
end rtl;
|