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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [rtl/] [bplib/] [s3board/] [tb/] [tb_s3_sram_memctl.vhd] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 wfjm
-- $Id: tb_s3_sram_memctl.vhd 649 2015-02-21 21:10:16Z mueller $
2 16 wfjm
--
3
-- Copyright 2007-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15
-- Module Name:    tb_s3_sram_memctl - sim
16
-- Description:    Test bench for s3_sram_memctl
17
--
18
-- Dependencies:   vlib/simlib/simclk
19 17 wfjm
--                 vlib/simlib/simclkcnt
20 16 wfjm
--                 bplib/issi/is61lv25616al
21
--                 s3_sram_memctl [UUT]
22
--
23
-- To test:        s3_sram_memctl
24
--                 
25
-- Verified (with tb_s3_sram_memctl_stim.dat):
26
-- Date         Rev  Code  ghdl  ise          Target     Comment
27
-- 2007-12-16   101  _ssim 0.26  8.1.03 I27   xc3s1000   c:ok
28
-- 2007-12-16   101  -     0.26  -            -          c:ok
29
--
30
-- Target Devices: generic
31 29 wfjm
-- Tool versions:  xst 8.2-14.7; ghdl 0.18-0.31
32 16 wfjm
-- Revision History: 
33
-- Date         Rev Version  Comment
34 17 wfjm
-- 2011-12-23   444   1.1    use new simclk/simclkcnt
35 16 wfjm
-- 2011-11-21   432   1.0.6  now numeric_std clean
36
-- 2010-05-23   293   1.0.5  output # busy cycles; change CHK pipeline logic
37
-- 2010-05-16   291   1.0.4  rename tb_memctl_s3sram->tb_s3_sram_memctl
38
-- 2008-03-24   129   1.0.3  CLK_CYCLE now 31 bits
39
-- 2008-02-17   117   1.0.2  use req,we rather req_r,req_w interface
40
-- 2008-01-20   113   1.0.1  rename memdrv -> memctl_s3sram
41
-- 2007-12-15   101   1.0    Initial version 
42
------------------------------------------------------------------------------
43
 
44
library ieee;
45
use ieee.std_logic_1164.all;
46
use ieee.numeric_std.all;
47
use ieee.std_logic_textio.all;
48
use std.textio.all;
49
 
50
use work.slvtypes.all;
51
use work.s3boardlib.all;
52
use work.simlib.all;
53
 
54
entity tb_s3_sram_memctl is
55
end tb_s3_sram_memctl;
56
 
57
architecture sim of tb_s3_sram_memctl is
58
 
59
  signal CLK   : slbit := '0';
60
  signal RESET : slbit := '0';
61
  signal REQ   : slbit := '0';
62
  signal WE    : slbit := '0';
63
  signal BUSY  : slbit := '0';
64
  signal ACK_R : slbit := '0';
65
  signal ACK_W : slbit := '0';
66
  signal ACT_R : slbit := '0';
67
  signal ACT_W : slbit := '0';
68
  signal ADDR : slv18 := (others=>'0');
69
  signal BE : slv4  := (others=>'0');
70
  signal DI : slv32 := (others=>'0');
71
  signal DO : slv32 := (others=>'0');
72
  signal O_MEM_CE_N : slv2   := (others=>'0');
73
  signal O_MEM_BE_N : slv4   := (others=>'0');
74
  signal O_MEM_WE_N : slbit  := '0';
75
  signal O_MEM_OE_N : slbit  := '0';
76
  signal O_MEM_ADDR  : slv18 := (others=>'0');
77
  signal IO_MEM_DATA : slv32 := (others=>'0');
78
 
79
  signal R_MEMON : slbit  := '0';
80
  signal N_CHK_DATA : slbit  := '0';
81
  signal N_REF_DATA : slv32 := (others=>'0');
82
  signal N_REF_ADDR : slv18 := (others=>'0');
83
  signal R_CHK_DATA_AL : slbit  := '0';
84
  signal R_REF_DATA_AL : slv32 := (others=>'0');
85
  signal R_REF_ADDR_AL : slv18 := (others=>'0');
86
  signal R_CHK_DATA_DL : slbit  := '0';
87
  signal R_REF_DATA_DL : slv32 := (others=>'0');
88
  signal R_REF_ADDR_DL : slv18 := (others=>'0');
89
 
90
  signal CLK_STOP : slbit := '0';
91 17 wfjm
  signal CLK_CYCLE : integer := 0;
92 16 wfjm
 
93
  constant clock_period : time :=  20 ns;
94
  constant clock_offset : time := 200 ns;
95
  constant setup_time : time :=  5 ns;
96
  constant c2out_time : time := 10 ns;
97
 
98
begin
99
 
100 17 wfjm
  CLKGEN : simclk
101 16 wfjm
    generic map (
102
      PERIOD => clock_period,
103
      OFFSET => clock_offset)
104
    port map (
105
      CLK => CLK,
106
      CLK_STOP => CLK_STOP
107
    );
108
 
109 17 wfjm
  CLKCNT : simclkcnt port map (CLK => CLK, CLK_CYCLE => CLK_CYCLE);
110
 
111 16 wfjm
  MEM_L : entity work.is61lv25616al
112
    port map (
113
      CE_N => O_MEM_CE_N(0),
114
      OE_N => O_MEM_OE_N,
115
      WE_N => O_MEM_WE_N,
116
      UB_N => O_MEM_BE_N(1),
117
      LB_N => O_MEM_BE_N(0),
118
      ADDR => O_MEM_ADDR,
119
      DATA => IO_MEM_DATA(15 downto 0)
120
    );
121
 
122
  MEM_U : entity work.is61lv25616al
123
    port map (
124
      CE_N => O_MEM_CE_N(1),
125
      OE_N => O_MEM_OE_N,
126
      WE_N => O_MEM_WE_N,
127
      UB_N => O_MEM_BE_N(3),
128
      LB_N => O_MEM_BE_N(2),
129
      ADDR => O_MEM_ADDR,
130
      DATA => IO_MEM_DATA(31 downto 16)
131
    );
132
 
133
  UUT : s3_sram_memctl
134
    port map (
135
      CLK     => CLK,
136
      RESET   => RESET,
137
      REQ     => REQ,
138
      WE      => WE,
139
      BUSY    => BUSY,
140
      ACK_R   => ACK_R,
141
      ACK_W   => ACK_W,
142
      ACT_R   => ACT_R,
143
      ACT_W   => ACT_W,
144
      ADDR    => ADDR,
145
      BE      => BE,
146
      DI      => DI,
147
      DO      => DO,
148
      O_MEM_CE_N  => O_MEM_CE_N,
149
      O_MEM_BE_N  => O_MEM_BE_N,
150
      O_MEM_WE_N  => O_MEM_WE_N,
151
      O_MEM_OE_N  => O_MEM_OE_N,
152
      O_MEM_ADDR  => O_MEM_ADDR,
153
      IO_MEM_DATA => IO_MEM_DATA
154
    );
155
 
156
  proc_stim: process
157
    file fstim : text open read_mode is "tb_s3_sram_memctl_stim";
158
    variable iline : line;
159
    variable oline : line;
160
    variable ok : boolean;
161
    variable dname : string(1 to 6) := (others=>' ');
162
    variable idelta : integer := 0;
163
    variable iaddr : slv18 := (others=>'0');
164
    variable idata : slv32 := (others=>'0');
165
    variable ibe   : slv4 := (others=>'0');
166
    variable ival  : slbit := '0';
167
    variable nbusy : integer := 0;
168
 
169
  begin
170
 
171
    wait for clock_offset - setup_time;
172
 
173
    file_loop: while not endfile(fstim) loop
174
 
175
      readline (fstim, iline);
176
 
177
      readcomment(iline, ok);
178
      next file_loop when ok;
179
 
180
      readword(iline, dname, ok);
181
      if ok then
182
        case dname is
183
          when ".memon" =>              -- .memon
184
            read_ea(iline, ival);
185
            R_MEMON <= ival;
186
            wait for 2*clock_period;
187
 
188
          when ".reset" =>              -- .reset 
189
            write(oline, string'(".reset"));
190
            writeline(output, oline);
191
            RESET <= '1';
192
            wait for clock_period;
193
            RESET <= '0';
194
            wait for 9*clock_period;
195
 
196
          when ".wait " =>              -- .wait
197
            read_ea(iline, idelta);
198
            wait for idelta*clock_period;
199
 
200
          when "read  " =>              -- read
201
            readgen_ea(iline, iaddr, 16);
202
            readgen_ea(iline, idata, 16);
203
            ADDR <= iaddr;
204
            REQ <= '1';
205
            WE  <= '0';
206
 
207
            writetimestamp(oline, CLK_CYCLE, ": stim read ");
208
            writegen(oline, iaddr, right, 6, 16);
209
            write(oline, string'("     "));
210
            writegen(oline, idata, right, 9, 16);
211
 
212
            nbusy := 0;
213
            while BUSY = '1' loop
214
              nbusy := nbusy + 1;
215
              wait for clock_period;
216
            end loop;
217
 
218
            write(oline, string'("  nbusy="));
219
            write(oline, nbusy, right, 2);
220
            writeline(output, oline);
221
 
222
            N_CHK_DATA <= '1', '0' after clock_period;
223
            N_REF_DATA <= idata;
224
            N_REF_ADDR <= iaddr;
225
 
226
            wait for clock_period;
227
            REQ <= '0';
228
 
229
          when "write " =>              -- write
230
            readgen_ea(iline, iaddr, 16);
231
            read_ea(iline, ibe);
232
            readgen_ea(iline, idata, 16);
233
            ADDR <= iaddr;
234
            BE   <= ibe;
235
            DI   <= idata;
236
            REQ  <= '1';
237
            WE   <= '1';
238
 
239
            writetimestamp(oline, CLK_CYCLE, ": stim write");
240
            writegen(oline, iaddr, right, 6, 16);
241
            writegen(oline, ibe  , right, 5,  2);
242
            writegen(oline, idata, right, 9, 16);
243
 
244
            nbusy := 0;
245
            while BUSY = '1' loop
246
              nbusy := nbusy + 1;
247
              wait for clock_period;
248
            end loop;
249
 
250
            write(oline, string'("  nbusy="));
251
            write(oline, nbusy, right, 2);
252
            writeline(output, oline);
253
 
254
            wait for clock_period;
255
            REQ <= '0';
256
 
257
          when others =>                -- bad directive
258
            write(oline, string'("?? unknown directive: "));
259
            write(oline, dname);
260
            writeline(output, oline);
261
            report "aborting" severity failure;
262
        end case;
263
      else
264
        report "failed to find command" severity failure;
265
 
266
      end if;
267
 
268
      testempty_ea(iline);
269
 
270
    end loop; -- file fstim
271
 
272
    wait for 10*clock_period;
273
 
274
    writetimestamp(oline, CLK_CYCLE, ": DONE ");
275
    writeline(output, oline);
276
 
277
    CLK_STOP <= '1';
278
 
279
    wait;                               -- suspend proc_stim forever
280
                                        -- clock is stopped, sim will end
281
 
282
  end process proc_stim;
283
 
284
 
285
  proc_moni: process
286
    variable oline : line;
287
  begin
288
 
289
    loop
290
      wait until rising_edge(CLK);
291
 
292
      if ACK_R = '1' then
293
        writetimestamp(oline, CLK_CYCLE, ": moni ");
294
        writegen(oline, DO, right, 9, 16);
295
        if R_CHK_DATA_DL = '1' then
296
          write(oline, string'("  CHECK"));
297
          if R_REF_DATA_DL = DO then
298
            write(oline, string'(" OK"));
299
          else
300
            write(oline, string'(" FAIL, exp="));
301
            writegen(oline, R_REF_DATA_DL, right, 9, 16);
302
            write(oline, string'(" for a="));
303
            writegen(oline, R_REF_ADDR_DL, right, 5, 16);
304
          end if;
305
          R_CHK_DATA_DL <= '0';
306
        end if;
307
        writeline(output, oline);
308
      end if;
309
 
310
      if R_CHK_DATA_AL = '1' then
311
        R_CHK_DATA_DL <= R_CHK_DATA_AL;
312
        R_REF_DATA_DL <= R_REF_DATA_AL;
313
        R_REF_ADDR_DL <= R_REF_ADDR_AL;
314
        R_CHK_DATA_AL <= '0';
315
      end if;
316
      if N_CHK_DATA = '1' then
317
        R_CHK_DATA_AL <= N_CHK_DATA;
318
        R_REF_DATA_AL <= N_REF_DATA;
319
        R_REF_ADDR_AL <= N_REF_ADDR;
320
      end if;
321
 
322
    end loop;
323
 
324
  end process proc_moni;
325
 
326
 
327
  proc_memon: process
328
    variable oline : line;
329
  begin
330
 
331
    loop
332
      wait until rising_edge(CLK);
333
 
334
      if R_MEMON = '1' then
335
        writetimestamp(oline, CLK_CYCLE, ": mem  ");
336
        write(oline, string'(" ce="));
337
        write(oline, not O_MEM_CE_N, right, 2);
338
        write(oline, string'(" be="));
339
        write(oline, not O_MEM_BE_N, right, 4);
340
        write(oline, string'(" we="));
341
        write(oline, not O_MEM_WE_N, right);
342
        write(oline, string'(" oe="));
343
        write(oline, not O_MEM_OE_N, right);
344
        write(oline, string'(" a="));
345
        writegen(oline, O_MEM_ADDR, right, 5, 16);
346
        write(oline, string'(" d="));
347
        writegen(oline, IO_MEM_DATA, right, 8, 16);
348
        writeline(output, oline);
349
      end if;
350
 
351
    end loop;
352
 
353
  end process proc_memon;
354
 
355
 
356
end sim;

powered by: WebSVN 2.1.0

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