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

Subversion Repositories astron_statistics

[/] [astron_statistics/] [trunk/] [tb_mmf_st_sst.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
--
4
-- Copyright (C) 2012
5
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
6
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
7
--
8
-- This program 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:  Testbench for the st_sst unit. 
24
--           To be used in conjunction with python script: ../python/tc_mmf_st_sst.py
25
--
26
--
27
-- Usage in non-auto-mode (c_modelsim_start = 0 in python):
28
--   > as 5
29
--   > run -all
30
--   > Run python script in separate terminal: "python tc_mmf_st_xst.py --unb 0 --bn 0 --sim"
31
--   > Check the results of the python script. 
32
--   > Stop the simulation manually in Modelsim by pressing the stop-button.
33
--   > Evalute the WAVE window. 
34
 
35
LIBRARY IEEE, common_pkg_lib, common_ram_lib, mm_lib, diag_lib, dp_pkg_lib;
36
USE IEEE.std_logic_1164.ALL;
37
USE IEEE.numeric_std.ALL;
38
USE common_pkg_lib.common_pkg.ALL;
39
USE common_ram_lib.common_ram_pkg.ALL;
40
USE common_pkg_lib.common_str_pkg.ALL;
41
USE common_pkg_lib.tb_common_pkg.ALL;
42
USE mm_lib.tb_common_mem_pkg.ALL;
43
USE mm_lib.mm_file_unb_pkg.ALL;
44
USE mm_lib.mm_file_pkg.ALL;
45
USE dp_pkg_lib.dp_stream_pkg.ALL;
46
USE diag_lib.diag_pkg.ALL;
47
 
48
ENTITY tb_mmf_st_sst IS
49
  GENERIC(
50
    g_nof_stat      : NATURAL := 8; -- nof accumulators
51
    g_xst_enable    : BOOLEAN := TRUE;
52
    g_in_data_w     : NATURAL := 16;
53
    g_stat_data_w   : NATURAL := 56;  -- statistics accumulator width
54
    g_stat_data_sz  : NATURAL := 2;   -- statistics word width >= statistics accumulator width and fit in a power of 2 multiple 32b MM words
55
    g_nof_instances : NATURAL := 4;   -- The number of st_sst instances in parallel. 
56
    g_nof_frames    : NATURAL := 1
57
  );
58
END tb_mmf_st_sst;
59
 
60
ARCHITECTURE tb OF tb_mmf_st_sst IS
61
 
62
  CONSTANT c_sim                : BOOLEAN := TRUE;
63
 
64
  ----------------------------------------------------------------------------
65
  -- Clocks and resets
66
  ----------------------------------------------------------------------------   
67
  CONSTANT c_mm_clk_period      : TIME := 100 ps;
68
  CONSTANT c_dp_clk_period      : TIME := 2 ns;
69
  CONSTANT c_sclk_period        : TIME := 1250 ps;
70
  CONSTANT c_dp_pps_period      : NATURAL := 64;
71
 
72
  SIGNAL dp_pps                 : STD_LOGIC;
73
 
74
  SIGNAL mm_rst                 : STD_LOGIC := '1';
75
  SIGNAL mm_clk                 : STD_LOGIC := '0';
76
 
77
  SIGNAL dp_rst                 : STD_LOGIC;
78
  SIGNAL dp_clk                 : STD_LOGIC := '0';
79
 
80
  ----------------------------------------------------------------------------
81
  -- MM buses
82
  ----------------------------------------------------------------------------                                         
83
  SIGNAL reg_diag_bg_mosi       : t_mem_mosi;
84
  SIGNAL reg_diag_bg_miso       : t_mem_miso;
85
 
86
  SIGNAL ram_diag_bg_mosi       : t_mem_mosi;
87
  SIGNAL ram_diag_bg_miso       : t_mem_miso;
88
 
89
  SIGNAL ram_st_sst_mosi        : t_mem_mosi;
90
  SIGNAL ram_st_sst_miso        : t_mem_miso;
91
 
92
  SIGNAL reg_st_sst_mosi        : t_mem_mosi;
93
  SIGNAL reg_st_sst_miso        : t_mem_miso;
94
 
95
  SIGNAL ram_st_sst_mosi_arr    : t_mem_mosi_arr(g_nof_instances-1 DOWNTO 0);
96
  SIGNAL ram_st_sst_miso_arr    : t_mem_miso_arr(g_nof_instances-1 DOWNTO 0);
97
 
98
  SIGNAL reg_st_sst_mosi_arr    : t_mem_mosi_arr(g_nof_instances-1 DOWNTO 0);
99
  SIGNAL reg_st_sst_miso_arr    : t_mem_miso_arr(g_nof_instances-1 DOWNTO 0);
100
 
101
  -- Custom definitions of constants
102
  CONSTANT c_bg_block_len           : NATURAL  := g_nof_stat*g_nof_frames;
103
  CONSTANT c_complex_factor         : NATURAL  := sel_a_b(g_xst_enable, c_nof_complex, 1);
104
  CONSTANT c_ram_addr_w             : NATURAL  := ceil_log2(g_stat_data_sz*g_nof_stat*c_complex_factor);
105
 
106
  -- Configuration of the block generator:
107
  CONSTANT c_bg_nof_output_streams  : POSITIVE := g_nof_instances;
108
  CONSTANT c_bg_buf_dat_w           : POSITIVE := c_nof_complex*g_in_data_w;
109
  CONSTANT c_bg_buf_adr_w           : POSITIVE := ceil_log2(c_bg_block_len);
110
  CONSTANT c_bg_data_file_prefix    : STRING   := "UNUSED";
111
  CONSTANT c_bg_data_file_index_arr : t_nat_natural_arr := array_init(0, g_nof_instances, 1);
112
 
113
  -- Signal declarations to connect block generator to the DUT
114
  SIGNAL bg_siso_arr                : t_dp_siso_arr(c_bg_nof_output_streams-1 DOWNTO 0) := (OTHERS=>c_dp_siso_rdy);
115
  SIGNAL bg_sosi_arr                : t_dp_sosi_arr(c_bg_nof_output_streams-1 DOWNTO 0);
116
 
117
BEGIN
118
 
119
  ----------------------------------------------------------------------------
120
  -- Clock and reset generation
121
  ----------------------------------------------------------------------------
122
  mm_clk <= NOT mm_clk AFTER c_mm_clk_period/2;
123
  mm_rst <= '1', '0' AFTER c_mm_clk_period*5;
124
 
125
  dp_clk <= NOT dp_clk AFTER c_dp_clk_period/2;
126
  dp_rst <= '1', '0' AFTER c_dp_clk_period*5;
127
 
128
  ------------------------------------------------------------------------------
129
  -- External PPS
130
  ------------------------------------------------------------------------------  
131
  proc_common_gen_pulse(1, c_dp_pps_period, '1', dp_clk, dp_pps);
132
 
133
   ----------------------------------------------------------------------------
134
  -- Procedure that polls a sim control file that can be used to e.g. get
135
  -- the simulation time in ns
136
  ----------------------------------------------------------------------------
137
  mmf_poll_sim_ctrl_file(c_mmf_unb_file_path & "sim.ctrl", c_mmf_unb_file_path & "sim.stat");
138
 
139
  ----------------------------------------------------------------------------
140
  -- MM buses  
141
  ----------------------------------------------------------------------------
142
  u_mm_file_reg_diag_bg          : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "REG_DIAG_BG")
143
                                           PORT MAP(mm_rst, mm_clk, reg_diag_bg_mosi, reg_diag_bg_miso);
144
 
145
  u_mm_file_ram_diag_bg          : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "RAM_DIAG_BG")
146
                                           PORT MAP(mm_rst, mm_clk, ram_diag_bg_mosi, ram_diag_bg_miso);
147
 
148
  u_mm_file_ram_st_sst           : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "RAM_ST_SST")
149
                                           PORT MAP(mm_rst, mm_clk, ram_st_sst_mosi, ram_st_sst_miso);
150
 
151
  u_mm_file_reg_st_sst           : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "REG_ST_SST")
152
                                           PORT MAP(mm_rst, mm_clk, reg_st_sst_mosi, reg_st_sst_miso);
153
 
154
  ----------------------------------------------------------------------------
155
  -- Source: block generator
156
  ---------------------------------------------------------------------------- 
157
  u_bg : ENTITY diag_lib.mms_diag_block_gen
158
  GENERIC MAP(
159
    g_nof_streams        => c_bg_nof_output_streams,
160
    g_buf_dat_w          => c_bg_buf_dat_w,
161
    g_buf_addr_w         => c_bg_buf_adr_w,
162
    g_file_index_arr     => c_bg_data_file_index_arr,
163
    g_file_name_prefix   => c_bg_data_file_prefix
164
  )
165
  PORT MAP(
166
    -- System
167
    mm_rst               => mm_rst,
168
    mm_clk               => mm_clk,
169
    dp_rst               => dp_rst,
170
    dp_clk               => dp_clk,
171
    en_sync              => dp_pps,
172
    -- MM interface      
173
    reg_bg_ctrl_mosi     => reg_diag_bg_mosi,
174
    reg_bg_ctrl_miso     => reg_diag_bg_miso,
175
    ram_bg_data_mosi     => ram_diag_bg_mosi,
176
    ram_bg_data_miso     => ram_diag_bg_miso,
177
    -- ST interface      
178
    out_siso_arr         => bg_siso_arr,
179
    out_sosi_arr         => bg_sosi_arr
180
  );
181
 
182
  -- Combine the internal array of mm interfaces for the beamlet statistics to one array that is connected to the port of bf
183
  u_mem_mux_ram_sst : ENTITY mm_lib.common_mem_mux
184
  GENERIC MAP (
185
    g_nof_mosi    => g_nof_instances,
186
    g_mult_addr_w => c_ram_addr_w
187
  )
188
  PORT MAP (
189
    mosi     => ram_st_sst_mosi,
190
    miso     => ram_st_sst_miso,
191
    mosi_arr => ram_st_sst_mosi_arr,
192
    miso_arr => ram_st_sst_miso_arr
193
  );
194
 
195
  u_mem_mux_reg_sst : ENTITY mm_lib.common_mem_mux
196
  GENERIC MAP (
197
    g_nof_mosi    => g_nof_instances,
198
    g_mult_addr_w => 1
199
  )
200
  PORT MAP (
201
    mosi     => reg_st_sst_mosi,
202
    miso     => reg_st_sst_miso,
203
    mosi_arr => reg_st_sst_mosi_arr,
204
    miso_arr => reg_st_sst_miso_arr
205
  );
206
 
207
  ----------------------------------------------------------------------------
208
  -- DUT: Device Under Test
209
  ---------------------------------------------------------------------------- 
210
  gen_duts : FOR I IN 0 TO g_nof_instances-1 GENERATE
211
    u_dut : ENTITY work.st_sst
212
    GENERIC MAP(
213
      g_nof_stat       => g_nof_stat,
214
      g_xst_enable     => g_xst_enable,
215
      g_in_data_w      => g_in_data_w,
216
      g_stat_data_w    => g_stat_data_w,
217
      g_stat_data_sz   => g_stat_data_sz
218
    )
219
    PORT MAP(
220
      mm_rst           =>  mm_rst,
221
      mm_clk           =>  mm_clk,
222
      dp_rst           =>  dp_rst,
223
      dp_clk           =>  dp_clk,
224
 
225
      -- Streaming
226
      in_complex       => bg_sosi_arr(I),
227
 
228
      -- Memory Mapped
229
      ram_st_sst_mosi  => ram_st_sst_mosi_arr(I),
230
      ram_st_sst_miso  => ram_st_sst_miso_arr(I),
231
      reg_st_sst_mosi  => reg_st_sst_mosi_arr(I),
232
      reg_st_sst_miso  => reg_st_sst_miso_arr(I)
233
    );
234
  END GENERATE;
235
 
236
END tb;

powered by: WebSVN 2.1.0

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