OpenCores
URL https://opencores.org/ocsvn/astron_r2sdf_fft/astron_r2sdf_fft/trunk

Subversion Repositories astron_r2sdf_fft

[/] [astron_r2sdf_fft/] [trunk/] [rTwoBFStage.vhd] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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
library ieee, common_pkg_lib, common_components_lib;
23
use IEEE.std_logic_1164.all;
24
use common_pkg_lib.common_pkg.all;
25
 
26
entity rTwoBFStage is
27
  generic (
28
    -- generics for this stage
29
    g_nof_chan      : natural := 0;   -- Exponent of nr of subbands (0 means 1 subband)
30
    g_stage         : natural;        -- The stage indices are ..., 3, 2, 1. The input stage has the highest index, the output stage has index 1.
31
    g_bf_lat        : natural := 1;   -- Digital pipelining latency
32
    -- generics for rTwoBF
33
    g_bf_use_zdly   : natural := 1;   -- >= 1. Stage high downto g_bf_use_zdly will will use g_bf_in_a_zdly and g_bf_out_zdly
34
    g_bf_in_a_zdly  : natural := 0;   -- g_bf_in_a_zdly+g_bf_out_d_zdly must be <= the stage z^(-1) delay, note that stage 1 has only one z^(-1) delay
35
    g_bf_out_d_zdly : natural := 0    -- The stage z^(-1) delays are ..., 4, 2, 1.
36
  );
37
  port (
38
    clk      : in  std_logic;
39
    rst      : in  std_logic;
40
    in_re    : in  std_logic_vector;
41
    in_im    : in  std_logic_vector;
42
    in_val   : in  std_logic;
43
    in_sel   : in  std_logic;
44
    out_re   : out std_logic_vector;
45
    out_im   : out std_logic_vector;
46
    out_val  : out std_logic;
47
    out_sel  : out std_logic
48
  );
49
end entity rTwoBFStage;
50
 
51
architecture str of rTwoBFStage is
52
 
53
  -- Optionally move some z-1 delay into this BF stage, default 0
54
  constant c_bf_in_a_zdly   : natural := sel_a_b(g_stage >= g_bf_use_zdly, g_bf_in_a_zdly, 0);
55
  constant c_bf_out_b_zdly  : natural := sel_a_b(g_stage >= g_bf_use_zdly, g_bf_out_d_zdly, 0);
56
 
57
  constant c_bf_zdly        : natural := c_bf_in_a_zdly+c_bf_out_b_zdly;
58
  constant c_feedback_zdly  : natural := pow2(g_stage-1);
59
 
60
  -- The BF adds, subtracts or passes the data on, so typically c_out_dat_w = c_in_dat_w + 1
61
  constant c_in_dat_w       : natural := in_re'length;   -- re and im have same width
62
  constant c_out_dat_w      : natural := out_re'length;  -- re and im have same width
63
 
64
  -- Concatenate im & re into complex data to potentially ease synthesis to make more efficient use of block RAM memory for z-1 data feedback line
65
  signal bf_complex        : std_logic_vector(c_nof_complex*c_in_dat_w-1 downto 0);
66
  signal bf_complex_dly    : std_logic_vector(bf_complex'range);
67
  signal bf_re             : std_logic_vector(in_re'range);
68
  signal bf_re_dly         : std_logic_vector(in_re'range);
69
  signal bf_im             : std_logic_vector(in_im'range);
70
  signal bf_im_dly         : std_logic_vector(in_im'range);
71
  signal bf_sel            : std_logic;
72
  signal bf_val            : std_logic;
73
  signal bf_val_dly        : std_logic;
74
 
75
  signal stage_complex     : std_logic_vector(c_nof_complex*c_out_dat_w-1 downto 0);
76
  signal stage_complex_dly : std_logic_vector(stage_complex'range);
77
  signal stage_re          : std_logic_vector(out_re'range);
78
  signal stage_im          : std_logic_vector(out_im'range);
79
  signal stage_sel         : std_logic;
80
  signal stage_val         : std_logic;
81
 
82
begin
83
 
84
  ------------------------------------------------------------------------------
85
  -- butterfly
86
  ------------------------------------------------------------------------------
87
 
88
  u_bf_re : entity work.rTwoBF
89
  generic map (
90
    g_in_a_zdly  => c_bf_in_a_zdly,
91
    g_out_d_zdly => c_bf_out_b_zdly
92
  )
93
  port map (
94
    clk     => clk,
95
    in_a    => bf_re_dly,
96
    in_b    => in_re,
97
    in_sel  => in_sel,
98
    in_val  => in_val,
99
    out_c   => stage_re,
100
    out_d   => bf_re
101
  );
102
 
103
  u_bf_im : entity work.rTwoBF
104
  generic map (
105
    g_in_a_zdly  => c_bf_in_a_zdly,
106
    g_out_d_zdly => c_bf_out_b_zdly
107
  )
108
  port map (
109
    clk     => clk,
110
    in_a    => bf_im_dly,
111
    in_b    => in_im,
112
    in_sel  => in_sel,
113
    in_val  => in_val,
114
    out_c   => stage_im,
115
    out_d   => bf_im
116
  );
117
 
118
 
119
  ------------------------------------------------------------------------------
120
  -- feedback fifo
121
  ------------------------------------------------------------------------------
122
 
123
  bf_sel <= in_sel;
124
  bf_val <= in_val;
125
 
126
  bf_complex <= bf_im & bf_re;
127
  bf_re_dly  <= bf_complex_dly(  c_in_dat_w-1 downto 0);
128
  bf_im_dly  <= bf_complex_dly(2*c_in_dat_w-1 downto c_in_dat_w);
129
 
130
  -- share FIFO for Im & Re
131
  u_feedback : entity common_components_lib.common_delay
132
  generic map (
133
    g_dat_w  => bf_complex'length,
134
    g_depth  => c_feedback_zdly*(2**g_nof_chan)-c_bf_zdly
135
  )
136
  port map (
137
    clk     => clk,
138
    in_dat  => bf_complex,
139
    in_val  => bf_val,
140
    out_dat => bf_complex_dly
141
  );
142
 
143
  -- compensate for feedback fifo
144
  u_stage_sel : entity common_components_lib.common_bit_delay
145
  generic map (
146
    g_depth => c_feedback_zdly*(2**g_nof_chan)
147
  )
148
  port map (
149
    clk     => clk,
150
    rst     => rst,
151
    in_clr  => '0',
152
    in_val  => bf_val,
153
    in_bit  => bf_sel,
154
    out_bit => stage_sel
155
  );
156
 
157
  -- compensate for feedback fifo
158
  u_stage_val : entity common_components_lib.common_bit_delay
159
  generic map (
160
    g_depth => c_feedback_zdly*(2**g_nof_chan)
161
  )
162
  port map (
163
    clk     => clk,
164
    rst     => rst,
165
    in_clr  => '0',
166
    in_val  => bf_val,
167
    in_bit  => bf_val,
168
    out_bit => bf_val_dly
169
  );
170
 
171
  -- after the z^(-1) stage delay the bf_val_dly goes high and remains high and acts as an enable for in_val to out_val
172
  stage_val <= in_val and bf_val_dly;
173
 
174
 
175
  ------------------------------------------------------------------------------
176
  -- stage output pipelining
177
  ------------------------------------------------------------------------------
178
 
179
  stage_complex <= stage_im & stage_re;
180
 
181
  u_pipeline_out : entity common_components_lib.common_pipeline
182
  generic map (
183
    g_pipeline  => g_bf_lat,
184
    g_in_dat_w  => stage_complex'length,
185
    g_out_dat_w => stage_complex'length
186
  )
187
  port map (
188
    clk     => clk,
189
    in_dat  => stage_complex,
190
    out_dat => stage_complex_dly
191
  );
192
 
193
  out_re <= stage_complex_dly(  c_out_dat_w-1 downto 0);
194
  out_im <= stage_complex_dly(2*c_out_dat_w-1 downto c_out_dat_w);
195
 
196
  u_out_sel : entity common_components_lib.common_pipeline_sl
197
  generic map (
198
    g_pipeline => g_bf_lat
199
  )
200
  port map (
201
    clk     => clk,
202
    in_dat  => stage_sel,
203
    out_dat => out_sel
204
  );
205
 
206
  u_out_val : entity common_components_lib.common_pipeline_sl
207
  generic map (
208
    g_pipeline => g_bf_lat
209
  )
210
  port map (
211
    clk     => clk,
212
    in_dat  => stage_val,
213
    out_dat => out_val
214
  );
215
 
216
end str;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.