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 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
--------------------------------------------------------------------------------
2
--
3 3 danv
-- Copyright 2020
4
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6
-- 
7
-- Licensed under the Apache License, Version 2.0 (the "License");
8
-- you may not use this file except in compliance with the License.
9
-- You may obtain a copy of the License at
10
-- 
11
--     http://www.apache.org/licenses/LICENSE-2.0
12
-- 
13
-- Unless required by applicable law or agreed to in writing, software
14
-- distributed under the License is distributed on an "AS IS" BASIS,
15
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
-- See the License for the specific language governing permissions and
17
-- limitations under the License.
18 2 danv
--
19
--------------------------------------------------------------------------------
20
 
21 4 danv
library ieee, common_pkg_lib, astron_counter_lib, astron_ram_lib;
22 2 danv
use IEEE.std_logic_1164.all;
23
use IEEE.numeric_std.all;
24
use common_pkg_lib.common_pkg.all;
25 4 danv
use astron_ram_lib.common_ram_pkg.all;
26 2 danv
 
27
entity rTwoOrder is
28
  generic   (
29
    g_nof_points  : natural := 8;
30
    g_bit_flip    : boolean := true;
31
    g_nof_chan    : natural := 0
32
  );
33
  port (
34
    clk     : in  std_logic;
35
    rst     : in  std_logic;
36
    in_dat  : in  std_logic_vector;
37
    in_val  : in  std_logic;
38
    out_dat : out std_logic_vector;
39
    out_val : out std_logic
40
  );
41
end entity rTwoOrder;
42
 
43
architecture rtl of rTwoOrder is
44
 
45
  constant c_nof_channels : natural := 2**g_nof_chan;
46
  constant c_dat_w        : natural := in_dat'length;
47
  constant c_page_size    : natural := g_nof_points*c_nof_channels;
48
  constant c_adr_points_w : natural := ceil_log2(g_nof_points);
49
  constant c_adr_chan_w   : natural := g_nof_chan;
50
  constant c_adr_tot_w    : natural := c_adr_points_w + c_adr_chan_w;
51
 
52
  signal adr_points_cnt   : std_logic_vector(c_adr_points_w -1 downto 0);
53
  signal adr_chan_cnt     : std_logic_vector(c_adr_chan_w   -1 downto 0);
54
  signal adr_tot_cnt      : std_logic_vector(c_adr_tot_w    -1 downto 0);
55
 
56
  signal in_init          : STD_LOGIC;
57
  signal nxt_in_init      : STD_LOGIC;
58
  signal in_en            : STD_LOGIC;
59
 
60
  signal cnt_ena   : std_logic;
61
 
62
  signal next_page        : STD_LOGIC;
63
 
64
  signal wr_en            : STD_LOGIC;
65
  signal wr_adr           : STD_LOGIC_VECTOR(c_adr_tot_w-1 DOWNTO 0);
66
  signal wr_dat           : STD_LOGIC_VECTOR(c_dat_w-1 DOWNTO 0);
67
 
68
  signal rd_en            : STD_LOGIC;
69
  signal rd_adr           : STD_LOGIC_VECTOR(c_adr_tot_w-1 DOWNTO 0);
70
  signal rd_dat           : STD_LOGIC_VECTOR(c_dat_w-1 DOWNTO 0);
71
  signal rd_val           : STD_LOGIC;
72
 
73
begin
74
 
75
  out_dat <= rd_dat;
76
  out_val <= rd_val;
77
 
78
  p_clk : process(clk, rst)
79
  begin
80
    if rst='1' then
81
      in_init      <= '1';
82
    elsif rising_edge(clk) then
83
      in_init      <= nxt_in_init;
84
    end if;
85
  end process;
86
 
87
  nxt_in_init <= '0' WHEN next_page='1' ELSE in_init;  -- keep in_init active until the first block has been written
88
 
89
  in_en <= NOT in_init;  -- disable reading of the first block for convenience in verification, because it contains undefined values
90
 
91
  wr_dat   <= in_dat;
92
  wr_en    <= in_val;
93
  rd_en    <= in_val AND in_en;
94
 
95
  next_page <= '1' when unsigned(adr_tot_cnt) = c_page_size-1  and wr_en='1' else '0';
96
 
97
  adr_tot_cnt <= adr_chan_cnt & adr_points_cnt;
98
 
99
  gen_bit_flip : if g_bit_flip=true generate
100
    wr_adr <= adr_chan_cnt & flip(adr_points_cnt);  -- flip the addresses to perform the reorder
101
  end generate;
102
  no_bit_flip : if g_bit_flip=false generate
103
    wr_adr <= adr_tot_cnt;        -- do not flip the addresses for easier debugging with tb_rTwoOrder
104
  end generate;
105
 
106
  rd_adr <= adr_tot_cnt;
107
 
108 4 danv
  u_adr_point_cnt : entity astron_counter_lib.common_counter
109 2 danv
  generic map(
110
    g_latency   => 1,
111
    g_init      => 0,
112
    g_width     => ceil_log2(g_nof_points)
113
  )
114
  PORT MAP (
115
    rst     => rst,
116
    clk     => clk,
117
    cnt_en  => cnt_ena,
118
    count   => adr_points_cnt
119
  );
120
 
121
  -- Generate on c_nof_channels to avoid simulation warnings on TO_UINT(adr_chan_cnt) when adr_chan_cnt is a NULL array
122
  one_chan : if c_nof_channels=1 generate
123
    cnt_ena <= '1' when in_val = '1' else '0';
124
  end generate;
125
  more_chan : if c_nof_channels>1 generate
126
    cnt_ena <= '1' when in_val = '1' and TO_UINT(adr_chan_cnt) = c_nof_channels-1 else '0';
127
  end generate;
128
 
129 4 danv
  u_adr_chan_cnt : entity astron_counter_lib.common_counter
130 2 danv
  generic map(
131
    g_latency   => 1,
132
    g_init      => 0,
133
    g_width     => g_nof_chan
134
  )
135
  PORT MAP (
136
    rst     => rst,
137
    clk     => clk,
138
    cnt_en  => in_val,
139
    count   => adr_chan_cnt
140
  );
141
 
142 4 danv
  u_buff : ENTITY astron_ram_lib.common_paged_ram_r_w
143 2 danv
  GENERIC MAP (
144
    g_str             => "use_adr",
145
    g_data_w          => c_dat_w,
146
    g_nof_pages       => 2,
147
    g_page_sz         => c_page_size,
148
    g_wr_start_page   => 0,
149
    g_rd_start_page   => 1,
150
    g_rd_latency      => 1
151
  )
152
  PORT MAP (
153
    rst          => rst,
154
    clk          => clk,
155
    wr_next_page => next_page,
156
    wr_adr       => wr_adr,
157
    wr_en        => wr_en,
158
    wr_dat       => wr_dat,
159
    rd_next_page => next_page,
160
    rd_adr       => rd_adr,
161
    rd_en        => rd_en,
162
    rd_dat       => rd_dat,
163
    rd_val       => rd_val
164
  );
165
 
166
end rtl;

powered by: WebSVN 2.1.0

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