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

Subversion Repositories versatile_fft

[/] [versatile_fft/] [trunk/] [multiple_units/] [src/] [fft_data_switch.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 wzab
-------------------------------------------------------------------------------
2
-- Title      : fft_top
3
-- Project    : Pipelined, DP RAM based FFT processor
4
-------------------------------------------------------------------------------
5
-- File       : fft_switch.vhd
6
-- Author     : Wojciech Zabolotny
7
-- Company    : 
8
-- Licanse    : BSD
9
-- Created    : 2014-01-18
10
-- Platform   : 
11
-- Standard   : VHDL'93
12
-------------------------------------------------------------------------------
13
-- Description: This file implements a data switching block connecting
14
--              consecutive stages of the FFT processor based on a dual
15
--              port RAM
16
-------------------------------------------------------------------------------
17
-- Copyright (c) 2014 
18
-------------------------------------------------------------------------------
19
-- Revisions  :
20
-- Date        Version  Author  Description
21
-- 2014-01-18  1.0      wzab    Created
22
-------------------------------------------------------------------------------
23
library ieee;
24
use ieee.std_logic_1164.all;
25
use ieee.numeric_std.all;
26
use ieee.math_real.all;
27
use ieee.math_complex.all;
28
library work;
29
use work.icpx.all;
30
use work.fft_support_pkg.all;
31
 
32
entity fft_data_switch is
33
 
34
  generic (
35
    LOG2_FFT_LEN : integer := 4;
36
    STAGE        : integer := 2
37
    );
38
  port (
39
    in0    : in  icpx_number;
40
    in1    : in  icpx_number;
41
    out0   : out icpx_number;
42
    out1   : out icpx_number;
43
    enable : in  std_logic;
44
    rst_n  : in  std_logic;
45
    clk    : in  std_logic);
46
 
47
end fft_data_switch;
48
 
49
architecture fft_s_beh of fft_data_switch is
50
 
51
  constant LOG2_STAGE_N : integer := LOG2_FFT_LEN-STAGE-1;
52
  constant STAGE_N      : integer := 2 ** LOG2_STAGE_N;
53
  constant STAGE_N2     : integer := 2 ** (LOG2_STAGE_N-1);
54
  constant ADDR_WIDTH   : integer := LOG2_STAGE_N;
55
  constant STEP_LIMIT   : integer := 2**(LOG2_FFT_LEN-2-STAGE)-1;
56
  constant CYCLE_LIMIT  : integer := 2**STAGE-1;
57
 
58
  signal in0_del, in1_del      : icpx_number := icpx_zero;
59
  signal phase_del, phase_del2 : integer range 0 to 1;
60
 
61
  signal step, step_del : integer range 0 to STEP_LIMIT;
62
  signal phase          : integer range 0 to 1;
63
  signal cycle          : integer range 0 to CYCLE_LIMIT;
64
 
65
 
66
  component dp_ram_rbw_icpx
67
    generic (
68
      ADDR_WIDTH : integer);
69
    port (
70
      clk    : in  std_logic;
71
      we_a   : in  std_logic;
72
      addr_a : in  std_logic_vector(ADDR_WIDTH-1 downto 0);
73
      data_a : in  icpx_number;
74
      q_a    : out icpx_number;
75
      we_b   : in  std_logic;
76
      addr_b : in  std_logic_vector(ADDR_WIDTH-1 downto 0);
77
      data_b : in  icpx_number;
78
      q_b    : out icpx_number);
79
  end component;
80
 
81
  signal dpr_wa, dpr_wb                 : std_logic                               := '0';
82
  signal dpr_aa, dpr_ab                 : std_logic_vector(ADDR_WIDTH-1 downto 0) := (others => '0');
83
  signal dpr_ia, dpr_ib, dpr_qa, dpr_qb : icpx_number;
84
 
85
begin  -- fft_top_beh
86
 
87
  dp_ram_1 : dp_ram_rbw_icpx
88
    generic map (
89
      ADDR_WIDTH => ADDR_WIDTH)
90
    port map (
91
      clk    => clk,
92
      we_a   => dpr_wa,
93
      addr_a => dpr_aa,
94
      data_a => dpr_ia,
95
      q_a    => dpr_qa,
96
      we_b   => dpr_wb,
97
      addr_b => dpr_ab,
98
      data_b => dpr_ib,
99
      q_b    => dpr_qb);
100
 
101
  dpr_aa <= std_logic_vector(to_unsigned(step, ADDR_WIDTH));
102
  -- It is important, that synthesis tool recognizes the addition below
103
  -- as a simple bit operation!
104
  dpr_ab <= std_logic_vector(to_unsigned(step+STAGE_N2, ADDR_WIDTH));
105
 
106
  -- Output values router.
107
  dr1 : process (dpr_qa, dpr_qb, in0_del, phase_del) is
108
  begin  -- process dr1
109
    if phase_del = 0 then
110
      out0 <= dpr_qb;
111
      out1 <= dpr_qa;
112
    else
113
      out1 <= in0_del;
114
      out0 <= dpr_qa;
115
    end if;
116
  end process dr1;
117
 
118
  -- purpose: main state machine
119
  -- type   : combinational
120
  st1 : process (in0, in1, phase) is
121
  begin  -- process st1
122
    dpr_wa <= '0';
123
    dpr_wb <= '0';
124
    dpr_ia <= icpx_zero;
125
    dpr_ib <= icpx_zero;
126
    if phase = 0 then
127
      dpr_ia <= in0;
128
      dpr_ib <= in1;
129
      dpr_wa <= '1';
130
      dpr_wb <= '1';
131
    else
132
      -- phase = 1
133
      dpr_ia <= in1;
134
      dpr_wa <= '1';
135
    end if;
136
  end process st1;
137
 
138
  -- We always access data on addresses:
139
  -- "step" and "step+N/2"
140
 
141
  -- Main process of our router
142
  -- This block always introduces latency of one cycle!
143
  process (clk, rst_n) is
144
  begin  -- process
145
    if rst_n = '0' then                 -- asynchronous reset (active low)
146
      in0_del    <= icpx_zero;
147
      in1_del    <= icpx_zero;
148
      phase_del  <= 0;
149
      phase_del2 <= 0;
150
      step_del   <= 0;
151
    elsif clk'event and clk = '1' then  -- rising clock edge
152
      -- prepare the delayed version of control signals
153
      in0_del    <= in0;
154
      in1_del    <= in1;
155
      phase_del  <= phase;
156
      phase_del2 <= phase_del;
157
      step_del   <= step;
158
    end if;
159
  end process;
160
 
161
  st2 : process (clk, rst_n) is
162
  begin  -- process st2
163
    if rst_n = '0' then                 -- asynchronous reset (active low)
164
      step  <= 0;
165
      phase <= 0;
166
      cycle <= 0;
167
    elsif clk'event and clk = '1' then  -- rising clock edge
168
      if enable = '1' then
169
        if step = STEP_LIMIT then
170
          step <= 0;
171
          if phase = 1 then
172
            phase <= 0;
173
            if cycle = CYCLE_LIMIT then
174
              cycle <= 0;
175
            else
176
              cycle <= cycle+1;
177
            end if;
178
          else
179
            phase <= 1;
180
          end if;
181
        else
182
          step <= step+1;
183
        end if;
184
      end if;
185
    end if;
186
  end process st2;
187
 
188
 
189
end fft_s_beh;

powered by: WebSVN 2.1.0

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