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

Subversion Repositories astron_r2sdf_fft

[/] [astron_r2sdf_fft/] [trunk/] [rTwoOrder.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-2011
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_counter_lib, common_ram_lib;
23
use IEEE.std_logic_1164.all;
24
use IEEE.numeric_std.all;
25
use common_pkg_lib.common_pkg.all;
26
use common_ram_lib.common_ram_pkg.all;
27
 
28
entity rTwoOrder is
29
  generic   (
30
    g_nof_points  : natural := 8;
31
    g_bit_flip    : boolean := true;
32
    g_nof_chan    : natural := 0
33
  );
34
  port (
35
    clk     : in  std_logic;
36
    rst     : in  std_logic;
37
    in_dat  : in  std_logic_vector;
38
    in_val  : in  std_logic;
39
    out_dat : out std_logic_vector;
40
    out_val : out std_logic
41
  );
42
end entity rTwoOrder;
43
 
44
architecture rtl of rTwoOrder is
45
 
46
  constant c_nof_channels : natural := 2**g_nof_chan;
47
  constant c_dat_w        : natural := in_dat'length;
48
  constant c_page_size    : natural := g_nof_points*c_nof_channels;
49
  constant c_adr_points_w : natural := ceil_log2(g_nof_points);
50
  constant c_adr_chan_w   : natural := g_nof_chan;
51
  constant c_adr_tot_w    : natural := c_adr_points_w + c_adr_chan_w;
52
 
53
  signal adr_points_cnt   : std_logic_vector(c_adr_points_w -1 downto 0);
54
  signal adr_chan_cnt     : std_logic_vector(c_adr_chan_w   -1 downto 0);
55
  signal adr_tot_cnt      : std_logic_vector(c_adr_tot_w    -1 downto 0);
56
 
57
  signal in_init          : STD_LOGIC;
58
  signal nxt_in_init      : STD_LOGIC;
59
  signal in_en            : STD_LOGIC;
60
 
61
  signal cnt_ena   : std_logic;
62
 
63
  signal next_page        : STD_LOGIC;
64
 
65
  signal wr_en            : STD_LOGIC;
66
  signal wr_adr           : STD_LOGIC_VECTOR(c_adr_tot_w-1 DOWNTO 0);
67
  signal wr_dat           : STD_LOGIC_VECTOR(c_dat_w-1 DOWNTO 0);
68
 
69
  signal rd_en            : STD_LOGIC;
70
  signal rd_adr           : STD_LOGIC_VECTOR(c_adr_tot_w-1 DOWNTO 0);
71
  signal rd_dat           : STD_LOGIC_VECTOR(c_dat_w-1 DOWNTO 0);
72
  signal rd_val           : STD_LOGIC;
73
 
74
begin
75
 
76
  out_dat <= rd_dat;
77
  out_val <= rd_val;
78
 
79
  p_clk : process(clk, rst)
80
  begin
81
    if rst='1' then
82
      in_init      <= '1';
83
    elsif rising_edge(clk) then
84
      in_init      <= nxt_in_init;
85
    end if;
86
  end process;
87
 
88
  nxt_in_init <= '0' WHEN next_page='1' ELSE in_init;  -- keep in_init active until the first block has been written
89
 
90
  in_en <= NOT in_init;  -- disable reading of the first block for convenience in verification, because it contains undefined values
91
 
92
  wr_dat   <= in_dat;
93
  wr_en    <= in_val;
94
  rd_en    <= in_val AND in_en;
95
 
96
  next_page <= '1' when unsigned(adr_tot_cnt) = c_page_size-1  and wr_en='1' else '0';
97
 
98
  adr_tot_cnt <= adr_chan_cnt & adr_points_cnt;
99
 
100
  gen_bit_flip : if g_bit_flip=true generate
101
    wr_adr <= adr_chan_cnt & flip(adr_points_cnt);  -- flip the addresses to perform the reorder
102
  end generate;
103
  no_bit_flip : if g_bit_flip=false generate
104
    wr_adr <= adr_tot_cnt;        -- do not flip the addresses for easier debugging with tb_rTwoOrder
105
  end generate;
106
 
107
  rd_adr <= adr_tot_cnt;
108
 
109
  u_adr_point_cnt : entity common_counter_lib.common_counter
110
  generic map(
111
    g_latency   => 1,
112
    g_init      => 0,
113
    g_width     => ceil_log2(g_nof_points)
114
  )
115
  PORT MAP (
116
    rst     => rst,
117
    clk     => clk,
118
    cnt_en  => cnt_ena,
119
    count   => adr_points_cnt
120
  );
121
 
122
  -- Generate on c_nof_channels to avoid simulation warnings on TO_UINT(adr_chan_cnt) when adr_chan_cnt is a NULL array
123
  one_chan : if c_nof_channels=1 generate
124
    cnt_ena <= '1' when in_val = '1' else '0';
125
  end generate;
126
  more_chan : if c_nof_channels>1 generate
127
    cnt_ena <= '1' when in_val = '1' and TO_UINT(adr_chan_cnt) = c_nof_channels-1 else '0';
128
  end generate;
129
 
130
  u_adr_chan_cnt : entity common_counter_lib.common_counter
131
  generic map(
132
    g_latency   => 1,
133
    g_init      => 0,
134
    g_width     => g_nof_chan
135
  )
136
  PORT MAP (
137
    rst     => rst,
138
    clk     => clk,
139
    cnt_en  => in_val,
140
    count   => adr_chan_cnt
141
  );
142
 
143
  u_buff : ENTITY common_ram_lib.common_paged_ram_r_w
144
  GENERIC MAP (
145
    g_str             => "use_adr",
146
    g_data_w          => c_dat_w,
147
    g_nof_pages       => 2,
148
    g_page_sz         => c_page_size,
149
    g_wr_start_page   => 0,
150
    g_rd_start_page   => 1,
151
    g_rd_latency      => 1
152
  )
153
  PORT MAP (
154
    rst          => rst,
155
    clk          => clk,
156
    wr_next_page => next_page,
157
    wr_adr       => wr_adr,
158
    wr_en        => wr_en,
159
    wr_dat       => wr_dat,
160
    rd_next_page => next_page,
161
    rd_adr       => rd_adr,
162
    rd_en        => rd_en,
163
    rd_dat       => rd_dat,
164
    rd_val       => rd_val
165
  );
166
 
167
end rtl;

powered by: WebSVN 2.1.0

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