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

Subversion Repositories simu_mem

[/] [simu_mem/] [trunk/] [bench/] [vhdl/] [zbt_ram/] [testbench.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 mgeng
----------------------------------------------------------------------
2
----                                                              ----
3
---- Testbench for the ZBT_RAM simulation model                   ----
4
----                                                              ----
5
---- This file is part of the simu_mem project                    ----
6
----                                                              ----
7
---- Description                                                  ----
8
---- This testbench checks if the output of the simulation model  ----
9
---- matches the output of the reference model. Every mismatch    ----
10
---- prints an error message.                                     ----
11
----                                                              ----
12
---- Authors:                                                     ----
13
---- - Michael Geng, vhdl@MichaelGeng.de                          ----
14
----                                                              ----
15
----------------------------------------------------------------------
16
----                                                              ----
17
---- Copyright (C) 2008 Authors                                   ----
18
----                                                              ----
19
---- This source file may be used and distributed without         ----
20
---- restriction provided that this copyright statement is not    ----
21
---- removed from the file and that any derivative work contains  ----
22
---- the original copyright notice and the associated disclaimer. ----
23
----                                                              ----
24
---- This source file is free software; you can redistribute it   ----
25
---- and/or modify it under the terms of the GNU Lesser General   ----
26
---- Public License as published by the Free Software Foundation; ----
27
---- either version 2.1 of the License, or (at your option) any   ----
28
---- later version.                                               ----
29
----                                                              ----
30
---- This source is distributed in the hope that it will be       ----
31
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
32
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
33
---- PURPOSE. See the GNU Lesser General Public License for more  ----
34
---- details.                                                     ----
35
----                                                              ----
36
---- You should have received a copy of the GNU Lesser General    ----
37
---- Public License along with this source; if not, download it   ----
38
---- from http://www.gnu.org/licenses/lgpl.html                   ----
39
----                                                              ----
40
----------------------------------------------------------------------
41
-- CVS Revision History
42
--
43
-- $Log: not supported by cvs2svn $
44
--
45
LIBRARY ieee, RAM, samsung;
46
USE ieee.std_logic_1164.ALL;
47
USE work.patgen_pkg.ALL;
48
 
49
ENTITY testbench IS
50
  GENERIC (
51
    -- Address bus width
52
    A_width : POSITIVE := 21;
53
    -- Data bus width
54
    D_width : POSITIVE := 36;
55
 
56
    -- How many clock cycles shall be simulated?
57
    N_simulation_cycles : POSITIVE := 100000);
58
END ENTITY testbench;
59
 
60
ARCHITECTURE arch OF testbench IS
61
  CONSTANT clk_periode : TIME :=   4 ns;
62
  CONSTANT reset_time  : TIME := 100 ns;
63
 
64
  SIGNAL Clk, Rst : STD_LOGIC;
65
  SIGNAL clk_ena  : STD_LOGIC := '1';
66
  SIGNAL Count    : INTEGER;
67
 
68
  SIGNAL A            : STD_LOGIC_VECTOR (A_width - 1 DOWNTO 0);
69
  SIGNAL D_DUT        : STD_LOGIC_VECTOR (D_width - 1 DOWNTO 0);
70
  SIGNAL D_Reference  : STD_LOGIC_VECTOR (D_width - 1 DOWNTO 0);
71
  SIGNAL D_Patgen     : STD_LOGIC_VECTOR (D_width - 1 DOWNTO 0);
72
  SIGNAL ADV          : STD_LOGIC;
73
  SIGNAL WE_n         : STD_LOGIC;
74
  SIGNAL CKE_n        : STD_LOGIC;
75
  SIGNAL CS1_n        : STD_LOGIC;
76
  SIGNAL CS2          : STD_LOGIC;
77
  SIGNAL CS2_n        : STD_LOGIC;
78
  SIGNAL BW_n         : STD_LOGIC_VECTOR (D_width / 9 - 1 DOWNTO 0);
79
  SIGNAL OE_n         : STD_LOGIC;
80
  SIGNAL ZZ           : STD_LOGIC;
81
  SIGNAL LBO_n        : STD_LOGIC;
82
  SIGNAL ZZ_delayed_1 : STD_LOGIC;
83
  SIGNAL ZZ_delayed_2 : STD_LOGIC;
84
BEGIN
85
  ASSERT D_width mod 9 = 0
86
    REPORT "Error: D_width must be a multiple of 9"
87
    SEVERITY FAILURE;
88
 
89
  iDUT : ENTITY RAM.ZBT_RAM
90
    GENERIC MAP (
91
      Debug => 0)
92
    PORT MAP (
93
      Clk   => Clk,
94
      D     => D_DUT,
95
      Q     => D_DUT,
96
      A     => A,
97
      CKE_n => CKE_n,
98
      CS1_n => CS1_n,
99
      CS2   => CS2,
100
      CS2_n => CS2_n,
101
      WE_n  => WE_n,
102
      BW_n  => BW_n,
103
      OE_n  => OE_n,
104
      ADV   => ADV,
105
      ZZ    => ZZ,
106
      LBO_n => LBO_n);
107
 
108
  iReference : ENTITY Samsung.K7N643645M
109
    PORT MAP (
110
      Dq    => D_Reference,
111
      Addr  => A,
112
      K     => Clk,
113
      CKEb  => CKE_n,
114
      Bwa_n => BW_n (0),
115
      Bwb_n => BW_n (1),
116
      Bwc_n => BW_n (2),
117
      Bwd_n => BW_n (3),
118
      WEb   => WE_n,
119
      ADV   => ADV,
120
      OEb   => OE_n,
121
      CS1b  => CS1_n,
122
      CS2   => CS2,
123
      CS2b  => CS2_n,
124
      LBOb  => LBO_n,
125
      ZZ    => ZZ);
126
 
127
  pCheck : PROCESS (Rst, Clk) IS
128
  BEGIN
129
    IF (Rst = '0') AND rising_edge (Clk) THEN
130
      FOR BankNoMinus1 in 0 to D_width / 9 - 1 LOOP
131
        IF (ZZ_delayed_2 = '0') THEN
132
          IF ((D_DUT (      9 * (BankNoMinus1 + 1) - 1 DOWNTO 9 * BankNoMinus1) /= (8 DOWNTO 0 => 'U')) OR
133
              (D_Reference (9 * (BankNoMinus1 + 1) - 1 DOWNTO 9 * BankNoMinus1) /= (8 DOWNTO 0 => 'X'))) THEN
134
            ASSERT D_DUT (      9 * (BankNoMinus1 + 1) - 1 DOWNTO 9 * BankNoMinus1) =
135
                   D_Reference (9 * (BankNoMinus1 + 1) - 1 DOWNTO 9 * BankNoMinus1)
136
              REPORT "Error: DUT and reference model mismatch in Bank no " &
137
                INTEGER'IMAGE (BankNoMinus1)
138
              SEVERITY ERROR;
139
          END IF;
140
        END IF;
141
      END LOOP;
142
    END IF;
143
  END PROCESS pCheck;
144
 
145
  iPatgen : patgen
146
    GENERIC MAP (
147
      clk_periode => clk_periode)
148
    PORT MAP (
149
      Clk   => Clk,
150
      Rst   => Rst,
151
      Ena   => clk_ena,
152
      A     => A,
153
      D     => D_Patgen,
154
      CKE_n => CKE_n,
155
      CS1_n => CS1_n,
156
      CS2   => CS2,
157
      CS2_n => CS2_n,
158
      WE_n  => WE_n,
159
      BW_n  => BW_n,
160
      OE_n  => OE_n,
161
      ADV   => ADV,
162
      ZZ    => ZZ,
163
      LBO_n => LBO_n);
164
 
165
  D_DUT       <= D_Patgen;
166
  D_Reference <= D_Patgen;
167
 
168
  pClk : PROCESS IS
169
  BEGIN
170
    Rst <= '1';
171
    Clk <= '1';
172
    WAIT FOR reset_time;
173
    Rst <= '0';
174
 
175
    WHILE (clk_ena = '1') LOOP
176
      WAIT FOR clk_periode / 2;
177
      Clk <= NOT Clk;
178
    END LOOP;
179
 
180
    WAIT;
181
  END PROCESS pClk;
182
 
183
  pCounter : PROCESS (Clk, Rst) IS
184
  BEGIN
185
    IF (Rst = '1') THEN
186
      Count  <= 0;
187
      clk_ena <= '1';
188
      ZZ_delayed_1   <= '0';
189
      ZZ_delayed_2   <= '0';
190
    ELSIF rising_edge (Clk) THEN
191
      IF (Count < N_simulation_cycles) THEN
192
        Count <= Count + 1;
193
      ELSE
194
        clk_ena <= '0';
195
      END IF;
196
 
197
      ZZ_delayed_1 <= ZZ;
198
      ZZ_delayed_2 <= ZZ_delayed_1;
199
    END IF;
200
  END PROCESS pCounter;
201
END ARCHITECTURE;

powered by: WebSVN 2.1.0

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