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

Subversion Repositories astron_mm

[/] [astron_mm/] [trunk/] [tb_common_mem_mux.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) 2009
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
LIBRARY IEEE, common_pkg_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
USE common_pkg_lib.tb_common_pkg.ALL;
28
USE work.tb_common_mem_pkg.ALL;
29
 
30
ENTITY tb_common_mem_mux IS
31
 GENERIC (
32
    g_nof_mosi    : POSITIVE := 16;     -- Number of memory interfaces in the array.                       
33
    g_mult_addr_w : POSITIVE := 4       -- Address width of each memory-interface element in the array.
34
  );
35
END tb_common_mem_mux;
36
 
37
-- Usage:
38
--   > as 10
39
--   > run -all
40
 
41
 
42
ARCHITECTURE tb OF tb_common_mem_mux IS
43
 
44
  CONSTANT clk_period   : TIME    := 10 ns;
45
 
46
  CONSTANT c_data_w     : NATURAL := 32;
47
  CONSTANT c_test_ram   : t_c_mem := (latency  => 1,
48
                                      adr_w    => g_mult_addr_w,
49
                                      dat_w    => c_data_w,
50
                                      nof_dat  => 2**g_mult_addr_w,
51
                                      init_sl  => '0');
52
  SIGNAL rst      : STD_LOGIC;
53
  SIGNAL clk      : STD_LOGIC := '1';
54
  SIGNAL tb_end   : STD_LOGIC;
55
 
56
  SIGNAL mosi_arr : t_mem_mosi_arr(g_nof_mosi - 1 DOWNTO 0);
57
  SIGNAL miso_arr : t_mem_miso_arr(g_nof_mosi - 1 DOWNTO 0);
58
  SIGNAL mosi     : t_mem_mosi;
59
  SIGNAL miso     : t_mem_miso;
60
 
61
BEGIN
62
 
63
  clk <= NOT clk OR tb_end AFTER clk_period/2;
64
  rst <= '1', '0' AFTER clk_period*5;
65
 
66
  p_stimuli : PROCESS
67
    VARIABLE temp : INTEGER;
68
  BEGIN
69
    tb_end <= '0';
70
    mosi   <= c_mem_mosi_rst;
71
 
72
    -- Write the whole memory range
73
    FOR I IN 0 TO g_nof_mosi-1 LOOP
74
      FOR J IN 0 TO 2**g_mult_addr_w-1 LOOP
75
        proc_mem_mm_bus_wr(I*2**g_mult_addr_w + J, I+J, clk, mosi);
76
      END LOOP;
77
    END LOOP;
78
 
79
    -- Read back the whole range and check if data is as expected
80
    FOR I IN 0 TO g_nof_mosi-1 LOOP
81
      FOR J IN 0 TO 2**g_mult_addr_w-1 LOOP
82
        proc_mem_mm_bus_rd(I*2**g_mult_addr_w + J, clk, mosi);
83
        proc_common_wait_some_cycles(clk, 1);
84
        temp := TO_UINT(miso.rddata(31 DOWNTO 0));
85
        IF(temp /= I+J) THEN
86
          REPORT "Error! Readvalue is not as expected" SEVERITY ERROR;
87
        END IF;
88
      END LOOP;
89
    END LOOP;
90
    tb_end <= '1';
91
    WAIT;
92
  END PROCESS;
93
 
94
  generation_of_test_rams : FOR I IN 0 TO g_nof_mosi-1 GENERATE
95
    u_test_rams : ENTITY common_ram_lib.common_ram_r_w
96
    GENERIC MAP (
97
      g_ram       => c_test_ram,
98
      g_init_file => "UNUSED"
99
    )
100
    PORT MAP (
101
      rst       => rst,
102
      clk       => clk,
103
      clken     => '1',
104
      wr_en     => mosi_arr(I).wr,
105
      wr_adr    => mosi_arr(I).address(g_mult_addr_w-1 DOWNTO 0),
106
      wr_dat    => mosi_arr(I).wrdata(c_data_w-1 DOWNTO 0),
107
      rd_en     => mosi_arr(I).rd,
108
      rd_adr    => mosi_arr(I).address(g_mult_addr_w-1 DOWNTO 0),
109
      rd_dat    => miso_arr(I).rddata(c_data_w-1 DOWNTO 0),
110
      rd_val    => miso_arr(I).rdval
111
    );
112
  END GENERATE;
113
 
114
  d_dut : ENTITY work.common_mem_mux
115
  GENERIC MAP (
116
    g_nof_mosi    => g_nof_mosi,
117
    g_mult_addr_w => g_mult_addr_w
118
  )
119
  PORT MAP (
120
    mosi_arr => mosi_arr,
121
    miso_arr => miso_arr,
122
    mosi     => mosi,
123
    miso     => miso
124
  );
125
 
126
END tb;

powered by: WebSVN 2.1.0

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