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

Subversion Repositories astron_r2sdf_fft

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

powered by: WebSVN 2.1.0

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