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

Subversion Repositories astron_diagnostics

[/] [astron_diagnostics/] [trunk/] [mms_diag_data_buffer.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
--
3
-- Copyright (C) 2011
4
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6
--
7
-- This program is free software: you can redistribute it and/or modify
8
-- it under the terms of the GNU General Public License as published by
9
-- the Free Software Foundation, either version 3 of the License, or
10
-- (at your option) any later version.
11
--
12
-- This program is distributed in the hope that it will be useful,
13
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
-- GNU General Public License for more details.
16
--
17
-- You should have received a copy of the GNU General Public License
18
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
-------------------------------------------------------------------------------
21
 
22
-- Purpose: MM data buffer and Rx seq for multiple parallel SOSI streams
23
-- Description:                             
24
-- . g_use_db
25
--   The mms_diag_data_buffer can capture data from an input stream in a data
26
--   buffer when g_use_db=TRUE. Dependend on g_buf_use_sync the data buffer
27
--   is rewritten after each in_sync or when the last word was read via MM.
28
-- . g_use_rx_seq
29
--   The mms_diag_data_buffer can continously verify a input Rx data sequence
30
--   when g_use_rx_seq=TRUE. The expected sequence data is typically generated
31
--   by an remote upstream tx_seq source.
32
-- . The advantage of the rx_seq is that is can continously verify the
33
--   correctness of all rx data in hardware, whereas the DB can only take a
34
--   snapshot that then needs to be examined via MM. The advandage of the DB
35
--   is that it can take a snapshot of the values of the received data. The
36
--   DB requires RAM resources and the rx_seq does not.
37
--
38
-- Block diagram:
39
--
40
--                           g_use_db 
41
--                           g_buf_use_sync
42
--                              .
43
--                              .      g_use_tx_seq
44
--                              .          .
45
--                              .          .
46
--                      /-------------> Rx seq 
47
--                      |       .         |
48
--     in_sosi_arr -----*---> DB RAM      |
49
--     in_sync -------------> DB reg      |
50
--                              ||        |
51
--                              ||        |
52
--              MM ================================
53
--
54
-- Remark:
55
-- . A nice new feature would be to continuously write the DB and to stop
56
--   writting it on a trigger. This trigger can then eg. be when the rx_seq
57
--   detects an error. By delaying the trigger somewhat it the DB can then
58
--   capture some data before and after the trigger event.
59
 
60
LIBRARY IEEE, common_pkg_lib, technology_lib, dp_pkg_lib, common_ram_lib, mm_lib;
61
USE IEEE.STD_LOGIC_1164.ALL;
62
USE IEEE.NUMERIC_STD.ALL;
63
USE common_pkg_lib.common_pkg.ALL;
64
USE common_ram_lib.common_ram_pkg.ALL;
65
USE dp_pkg_lib.dp_stream_pkg.ALL;
66
USE work.diag_pkg.ALL;
67
USE technology_lib.technology_select_pkg.ALL;
68
 
69
ENTITY mms_diag_data_buffer IS
70
  GENERIC (
71
    g_technology   : NATURAL := c_tech_select_default;
72
    -- Generate configurations
73
    g_use_db       : BOOLEAN := TRUE;
74
    g_use_rx_seq   : BOOLEAN := FALSE;
75
    -- General
76
    g_nof_streams  : POSITIVE := 16;    -- each stream gets an data buffer
77
    -- DB settings
78
    g_data_type    : t_diag_data_type_enum := e_data;      -- define the sosi field that gets stored: e_data=data, e_complex=im&re, e_real=re, e_imag=im
79
    g_data_w       : NATURAL := 32;     -- the g_data_w is the width of the data, re, im values or of the combined im&re value
80
    g_buf_nof_data : NATURAL := 1024;   -- nof words per data buffer
81
    g_buf_use_sync : BOOLEAN := FALSE;  -- when TRUE start filling the buffer at the in_sync, else after the last word was read
82
    -- Rx_seq
83
    g_use_steps    : BOOLEAN := FALSE;
84
    g_nof_steps    : NATURAL := c_diag_seq_rx_reg_nof_steps;
85
    g_seq_dat_w    : NATURAL := 32  -- >= 1, test sequence data width. Choose g_seq_dat_w <= g_data_w
86
  );
87
  PORT (
88
    -- System
89
    mm_rst            : IN  STD_LOGIC;
90
    mm_clk            : IN  STD_LOGIC;
91
    dp_rst            : IN  STD_LOGIC;
92
    dp_clk            : IN  STD_LOGIC;
93
    -- MM interface
94
    reg_data_buf_mosi : IN  t_mem_mosi := c_mem_mosi_rst;  -- DB control register (one per stream)
95
    reg_data_buf_miso : OUT t_mem_miso;
96
 
97
    ram_data_buf_mosi : IN  t_mem_mosi := c_mem_mosi_rst;  -- DB buffer RAM (one per streams)
98
    ram_data_buf_miso : OUT t_mem_miso;
99
 
100
    reg_rx_seq_mosi   : IN  t_mem_mosi := c_mem_mosi_rst;  -- Rx seq control register (one per streams)
101
    reg_rx_seq_miso   : OUT t_mem_miso;
102
 
103
    -- ST interface
104
    in_sync           : IN  STD_LOGIC := '0';  -- input sync pulse in ST dp_clk domain that starts data buffer when g_use_in_sync = TRUE
105
    in_sosi_arr       : IN t_dp_sosi_arr(g_nof_streams-1 DOWNTO 0)
106
  );
107
END mms_diag_data_buffer;
108
 
109
ARCHITECTURE str OF mms_diag_data_buffer IS
110
 
111
  CONSTANT c_buf_mm_factor   : NATURAL := ceil_div(g_data_w, c_word_w);
112
  CONSTANT c_buf_nof_data_mm : NATURAL := g_buf_nof_data*c_buf_mm_factor;
113
 
114
  CONSTANT c_buf_adr_w : NATURAL := ceil_log2(c_buf_nof_data_mm);
115
  CONSTANT c_reg_adr_w : NATURAL := c_diag_db_reg_adr_w;
116
 
117
  TYPE t_data_arr IS ARRAY (INTEGER RANGE <>) OF STD_LOGIC_VECTOR(g_data_w-1 DOWNTO 0);
118
 
119
  SIGNAL in_data_arr           : t_data_arr(g_nof_streams-1 DOWNTO 0);
120
 
121
  SIGNAL ram_data_buf_mosi_arr : t_mem_mosi_arr(g_nof_streams-1 DOWNTO 0);
122
  SIGNAL ram_data_buf_miso_arr : t_mem_miso_arr(g_nof_streams-1 DOWNTO 0);
123
 
124
  SIGNAL reg_data_buf_mosi_arr : t_mem_mosi_arr(g_nof_streams-1 DOWNTO 0);
125
  SIGNAL reg_data_buf_miso_arr : t_mem_miso_arr(g_nof_streams-1 DOWNTO 0);
126
 
127
BEGIN
128
 
129
  no_db : IF g_use_db=FALSE GENERATE
130
    ram_data_buf_miso <= c_mem_miso_rst;
131
    reg_data_buf_miso <= c_mem_miso_rst;
132
  END GENERATE;
133
 
134
  gen_db : IF g_use_db=TRUE GENERATE
135
    -- Combine the internal array of mm interfaces for the data_buf to one array that is connected to the port of the MM bus
136
    u_mem_mux_data_buf : ENTITY mm_lib.common_mem_mux
137
    GENERIC MAP (
138
      g_nof_mosi    => g_nof_streams,
139
      g_mult_addr_w => c_buf_adr_w
140
    )
141
    PORT MAP (
142
      mosi     => ram_data_buf_mosi,
143
      miso     => ram_data_buf_miso,
144
      mosi_arr => ram_data_buf_mosi_arr,
145
      miso_arr => ram_data_buf_miso_arr
146
    );
147
 
148
    u_mem_mux_reg : ENTITY mm_lib.common_mem_mux
149
    GENERIC MAP (
150
      g_nof_mosi    => g_nof_streams,
151
      g_mult_addr_w => c_reg_adr_w
152
    )
153
    PORT MAP (
154
      mosi     => reg_data_buf_mosi,
155
      miso     => reg_data_buf_miso,
156
      mosi_arr => reg_data_buf_mosi_arr,
157
      miso_arr => reg_data_buf_miso_arr
158
    );
159
 
160
    gen_stream : FOR I IN 0 TO g_nof_streams-1 GENERATE
161
      in_data_arr(I) <= in_sosi_arr(I).im(g_data_w/2-1 DOWNTO 0) & in_sosi_arr(I).re(g_data_w/2-1 DOWNTO 0) WHEN g_data_type=e_complex ELSE
162
                        in_sosi_arr(I).re(g_data_w-1 DOWNTO 0)                                              WHEN g_data_type=e_real ELSE
163
                        in_sosi_arr(I).im(g_data_w-1 DOWNTO 0)                                              WHEN g_data_type=e_imag ELSE
164
                        in_sosi_arr(I).data(g_data_w-1 DOWNTO 0);                                             -- g_data_type=e_data is default
165
 
166
      u_diag_data_buffer : ENTITY work.diag_data_buffer
167
      GENERIC MAP (
168
        g_technology  => g_technology,
169
        g_data_w      => g_data_w,
170
        g_nof_data    => g_buf_nof_data,
171
        g_use_in_sync => g_buf_use_sync   -- when TRUE start filling the buffer at the in_sync, else after the last word was read
172
      )
173
      PORT MAP (
174
        -- Memory-mapped clock domain
175
        mm_rst      => mm_rst,
176
        mm_clk      => mm_clk,
177
 
178
        ram_mm_mosi => ram_data_buf_mosi_arr(I),
179
        ram_mm_miso => ram_data_buf_miso_arr(I),
180
 
181
        reg_mm_mosi => reg_data_buf_mosi_arr(I),
182
        reg_mm_miso => reg_data_buf_miso_arr(I),
183
 
184
        -- Streaming clock domain
185
        st_rst      => dp_rst,
186
        st_clk      => dp_clk,
187
 
188
        in_data     => in_data_arr(I),
189
        in_sync     => in_sync,
190
        in_val      => in_sosi_arr(I).valid
191
      );
192
    END GENERATE;
193
  END GENERATE;
194
 
195
  no_rx_seq : IF g_use_rx_seq=FALSE GENERATE
196
    reg_rx_seq_miso <= c_mem_miso_rst;
197
  END GENERATE;
198
 
199
  gen_rx_seq : IF g_use_rx_seq=TRUE GENERATE
200
    u_mms_diag_rx_seq : ENTITY work.mms_diag_rx_seq
201
    GENERIC MAP (
202
      g_nof_streams => g_nof_streams,
203
      g_use_steps   => g_use_steps,
204
      g_nof_steps   => g_nof_steps,
205
      g_seq_dat_w   => g_seq_dat_w,  -- >= 1, test sequence data width
206
      g_data_w      => g_data_w      -- >= g_seq_dat_w, user data width
207
    )
208
    PORT MAP (
209
      -- Clocks and reset
210
      mm_rst         => mm_rst,
211
      mm_clk         => mm_clk,
212
      dp_rst         => dp_rst,
213
      dp_clk         => dp_clk,
214
 
215
      -- Memory Mapped Slave
216
      reg_mosi       => reg_rx_seq_mosi,   -- multiplexed port for g_nof_streams MM control/status registers
217
      reg_miso       => reg_rx_seq_miso,
218
 
219
      -- Streaming interface
220
      rx_snk_in_arr  => in_sosi_arr
221
    );
222
  END GENERATE;
223
 
224
END str;

powered by: WebSVN 2.1.0

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