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

powered by: WebSVN 2.1.0

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