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

Subversion Repositories versatile_mem_ctrl

[/] [versatile_mem_ctrl/] [trunk/] [bench/] [tb.v] - Blame information for rev 95

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 mikaeljf
`include "tb_defines.v"
2 9 unneback
`timescale 1ns/1ns
3
module versatile_mem_ctrl_tb
4
  (
5
   output OK
6
   );
7
 
8 80 mikaeljf
   reg         wb_clk, wb_rst;
9
   reg         sdram_clk, sdram_rst;
10
   reg         tb_rst;
11 9 unneback
 
12 94 unneback
   wire [31:0] wbm_dat_i [1:nr_of_wbm];
13
   wire [3:0]  wbm_sel_i [1:nr_of_wbm];
14
   wire [31:0] wbm_adr_i [1:nr_of_wbm];
15
   wire [2:0]  wbm_cti_i [1:nr_of_wbm];
16
   wire [1:0]  wbm_bte_i [1:nr_of_wbm];
17
   wire        wbm_cyc_i [1:nr_of_wbm];
18
   wire        wbm_stb_i [1:nr_of_wbm];
19
   wire [31:0] wbm_dat_o [1:nr_of_wbm];
20
   wire        wbm_ack_o [1:nr_of_wbm];
21
   wire        wbm_clk   [1:nr_of_wbm];
22
   wire        wbm_rst;
23
 
24
   wire [31:0] wb_sdram_dat_i;
25
   wire [3:0]  wb_sdram_sel_i;
26
   wire [31:0] wb_sdram_adr_i;
27
   wire [2:0]  wb_sdram_cti_i;
28
   wire [1:0]  wb_sdram_bte_i;
29
   wire        wb_sdram_cyc_i;
30
   wire        wb_sdram_stb_i;
31
   wire [31:0] wb_sdram_dat_o;
32
   wire        wb_sdram_ack_o;
33 9 unneback
 
34
 
35
   wire [1:0]  ba, bad;
36
   wire [12:0] a, ad;
37
   wire [15:0] dq_i;
38
   wire [15:0] dq_o;
39
   wire [15:0] dq_io;
40 11 mikaeljf
   wire [1:0]  dqs, dqs_n, dqs_i, dqs_o, dqs_n_i, dqs_n_o, dqs_io, dqs_n_io;
41
   wire [1:0]  dqm, dqmd, dm_rdqs;
42
   wire        dq_oe, dqs_oe;
43 9 unneback
   wire        cs_n, cs_nd, ras, rasd, cas, casd, we, wed, cke, cked;
44 14 mikaeljf
   wire        ck_fb_i, ck_fb_o;
45 11 mikaeljf
 
46 15 mikaeljf
`ifdef SDR_16          // SDR SDRAM
47 9 unneback
   wb0 wb0i
48
     (
49
      .adr(wb0_adr_i),
50
      .bte(wb0_bte_i),
51
      .cti(wb0_cti_i),
52
      .cyc(wb0_cyc_i),
53
      .dat(wb0_dat_i),
54
      .sel(wb0_sel_i),
55
      .stb(wb0_stb_i),
56
      .we (wb0_we_i),
57
      .ack(wb0_ack_o),
58
      .clk(wb_clk),
59
      .dat_i(wb0_dat_o),
60
      .reset(wb_rst)
61
      );
62
   wb1 wb1i
63
     (
64
      .adr(wb1_adr_i),
65
      .bte(wb1_bte_i),
66
      .cti(wb1_cti_i),
67
      .cyc(wb1_cyc_i),
68
      .dat(wb1_dat_i),
69
      .sel(wb1_sel_i),
70
      .stb(wb1_stb_i),
71
      .we (wb1_we_i),
72
      .ack(wb1_ack_o),
73
      .clk(wb_clk),
74
      .dat_i(wb1_dat_o),
75
      .reset(wb_rst)
76
      );
77
   wb4 wb4i
78
     (
79
      .adr(wb4_adr_i),
80
      .bte(wb4_bte_i),
81
      .cti(wb4_cti_i),
82
      .cyc(wb4_cyc_i),
83
      .dat(wb4_dat_i),
84
      .sel(wb4_sel_i),
85
      .stb(wb4_stb_i),
86
      .we (wb4_we_i),
87
      .ack(wb4_ack_o),
88
      .clk(wb_clk),
89
      .dat_i(wb4_dat_o),
90
      .reset(wb_rst)
91
      );
92 11 mikaeljf
`endif
93 9 unneback
 
94 15 mikaeljf
`ifdef DDR_16          // DDR2 SDRAM
95 11 mikaeljf
   wb0_ddr wb0i
96
     (
97
      .adr(wb0_adr_i),
98
      .bte(wb0_bte_i),
99
      .cti(wb0_cti_i),
100
      .cyc(wb0_cyc_i),
101
      .dat(wb0_dat_i),
102
      .sel(wb0_sel_i),
103
      .stb(wb0_stb_i),
104
      .we (wb0_we_i),
105
      .ack(wb0_ack_o),
106
      .clk(wb_clk),
107
      .dat_i(wb0_dat_o),
108 80 mikaeljf
      .reset(tb_rst)
109 11 mikaeljf
      );
110
   wb1_ddr wb1i
111
     (
112
      .adr(wb1_adr_i),
113
      .bte(wb1_bte_i),
114
      .cti(wb1_cti_i),
115
      .cyc(wb1_cyc_i),
116
      .dat(wb1_dat_i),
117
      .sel(wb1_sel_i),
118
      .stb(wb1_stb_i),
119
      .we (wb1_we_i),
120
      .ack(wb1_ack_o),
121
      .clk(wb_clk),
122
      .dat_i(wb1_dat_o),
123 80 mikaeljf
      .reset(tb_rst)
124 11 mikaeljf
      );
125
   wb4_ddr wb4i
126
     (
127
      .adr(wb4_adr_i),
128
      .bte(wb4_bte_i),
129
      .cti(wb4_cti_i),
130
      .cyc(wb4_cyc_i),
131
      .dat(wb4_dat_i),
132
      .sel(wb4_sel_i),
133
      .stb(wb4_stb_i),
134
      .we (wb4_we_i),
135
      .ack(wb4_ack_o),
136
      .clk(wb_clk),
137
      .dat_i(wb4_dat_o),
138 80 mikaeljf
      .reset(tb_rst)
139 11 mikaeljf
      );
140
`endif
141
 
142 33 unneback
   versatile_mem_ctrl_top # (
143
    .nr_of_wb_clk_domains(2),
144 80 mikaeljf
    .nr_of_wb_ports_clk0(1),
145 33 unneback
    .nr_of_wb_ports_clk1(1),
146
    .nr_of_wb_ports_clk2(0),
147
    .nr_of_wb_ports_clk3(0))
148
   dut (
149
    .wb_adr_i_0({{wb0_adr_i[31:2],wb0_we_i,wb0_bte_i,wb0_cti_i},{wb1_adr_i[31:2],wb1_we_i,wb1_bte_i,wb1_cti_i}}),
150
    .wb_dat_i_0({{wb0_dat_i,wb0_sel_i},{wb1_dat_i,wb1_sel_i}}),
151
    .wb_dat_o_0({wb0_dat_o,wb1_dat_o}),
152
    .wb_stb_i_0({wb0_stb_i,wb1_stb_i}),
153
    .wb_cyc_i_0({wb0_cyc_i,wb1_cyc_i}),
154
    .wb_ack_o_0({wb0_ack_o,wb1_ack_o}),
155
 
156
    .wb_adr_i_1({wb4_adr_i[31:2],wb4_we_i,wb4_bte_i,wb4_cti_i}),
157
    .wb_dat_i_1({wb4_dat_i,wb4_sel_i}),
158
    .wb_dat_o_1(wb4_dat_o),
159
    .wb_stb_i_1(wb4_stb_i),
160
    .wb_cyc_i_1(wb4_cyc_i),
161
    .wb_ack_o_1(wb4_ack_o),
162
 
163
    .wb_adr_i_2(2'b0),
164
    .wb_dat_i_2(2'b0),
165
    .wb_dat_o_2(),
166
    .wb_stb_i_2(2'b0),
167
    .wb_cyc_i_2(2'b0),
168 32 mikaeljf
    .wb_ack_o_2(),
169 33 unneback
 
170
    .wb_adr_i_3(2'b0),
171
    .wb_dat_i_3(2'b0),
172
    .wb_dat_o_3(),
173
    .wb_stb_i_3(2'b0),
174
    .wb_cyc_i_3(2'b0),
175 32 mikaeljf
    .wb_ack_o_3(),
176 9 unneback
 
177 33 unneback
   // SDR SDRAM 16
178 13 mikaeljf
`ifdef SDR_16
179 33 unneback
   .ba_pad_o(ba),
180
   .a_pad_o(a),
181
   .cs_n_pad_o(cs_n),
182
   .ras_pad_o(ras),
183
   .cas_pad_o(cas),
184
   .we_pad_o(we),
185
   .dq_o(dq_o),
186
   .dqm_pad_o(dqm),
187
   .dq_i(dq_i),
188
   .dq_oe(dq_oe),
189
   .cke_pad_o(cke),
190
`endif
191
`ifdef DDR_16
192
   // DDR2 SDRAM 16
193
   .ck_pad_o(ck),
194
   .ck_n_pad_o(ck_n),
195
   .cke_pad_o(cke),
196
   .ck_fb_pad_o(ck_fb_o),
197
   .ck_fb_pad_i(ck_fb_i),
198
   .cs_n_pad_o(cs_n),
199
   .ras_pad_o(ras),
200
   .cas_pad_o(cas),
201
   .we_pad_o(we),
202
   .dm_rdqs_pad_io(dm_rdqs),
203
   .ba_pad_o(ba),
204
   .addr_pad_o(a),
205
   .dq_pad_io(dq_io),
206
   .dqs_pad_io(dqs_io),
207
   .dqs_oe(dqs_oe),
208
   .dqs_n_pad_io(dqs_n_io),
209
   .rdqs_n_pad_i(),
210
   .odt_pad_o(),
211
`endif
212
   // misc     
213
   .wb_clk({wb_clk,wb_clk}),
214
   .wb_rst({wb_rst,wb_rst}),
215
   .sdram_clk(sdram_clk),
216
   .sdram_rst(wb_rst)
217
   );
218
 
219
`ifdef SDR_16
220 9 unneback
   assign #1 dq_io = dq_oe ? dq_o : {16{1'bz}};
221
   assign #1 dq_i  = dq_io;
222
   assign #1 dqmd = dqm;
223 11 mikaeljf
   assign #1 dqs_io = dqs_oe ? dqs_o : {2{1'bz}};
224
   assign #1 dqs_i  = dqs_io;
225
   assign #1 dqs_n_io = dqs_oe ? dqs_n_o : {2{1'bz}};
226
   assign #1 dqs_n_i  = dqs_n_io;
227 13 mikaeljf
`endif
228 9 unneback
 
229 13 mikaeljf
`ifdef DDR_16
230
   assign #1 dqmd = dqm;
231 15 mikaeljf
   assign    ck_fb_i = ck_fb_o;
232 13 mikaeljf
`endif
233
 
234 9 unneback
   assign #1 ad = a;
235
   assign #1 bad = ba;
236
   assign #1 cked = cke;
237
   assign #1 cs_nd = cs_n;
238
   assign #1 rasd = ras;
239
   assign #1 casd = cas;
240
   assign #1 wed = we;
241
 
242 15 mikaeljf
`ifdef SDR_16          // SDR SDRAM Simulation model
243 9 unneback
mt48lc16m16a2 sdram
244
  (
245
   .Dq(dq_io),
246
   .Addr(ad),
247
   .Ba(bad),
248
   .Clk(sdram_clk),
249
   .Cke(cked),
250
   .Cs_n(cs_nd),
251
   .Ras_n(rasd),
252
   .Cas_n(casd),
253
   .We_n(wed),
254
   .Dqm(dqmd)
255
   );
256 11 mikaeljf
`endif
257 15 mikaeljf
`ifdef DDR_16          // DDR2 SDRAM Simulation model
258 11 mikaeljf
ddr2 ddr2_sdram
259
  (
260
   .ck(ck),
261
   .ck_n(ck_n),
262
   .cke(cke),
263
   .cs_n(cs_n),
264
   .ras_n(ras),
265
   .cas_n(cas),
266
   .we_n(we),
267
   .dm_rdqs(dm_rdqs),
268
   .ba(ba),
269
   .addr(a),
270
   .dq(dq_io),
271
   .dqs(dqs_io),
272
   .dqs_n(dqs_n_io),
273
   .rdqs_n(),
274
   .odt()
275
   );
276
`endif
277 80 mikaeljf
 
278
   // Wishbone reset
279 9 unneback
   initial
280
     begin
281 80 mikaeljf
        #0      wb_rst = 1'b1;
282
        #200    wb_rst = 1'b1;
283 15 mikaeljf
        #200000 wb_rst = 1'b0;
284 9 unneback
     end
285 80 mikaeljf
 
286
   // SDRAM reset
287
   initial
288
     begin
289
        #0      sdram_rst = 1'b1;
290
        #200    sdram_rst = 1'b1;
291
        #200000 sdram_rst = 1'b0;
292
     end
293 9 unneback
 
294 80 mikaeljf
   // Test bench reset
295 9 unneback
   initial
296
     begin
297 80 mikaeljf
        #0      tb_rst = 1'b1;
298
        #200    tb_rst = 1'b1;
299
        //#200000 tb_rst = 1'b0;
300
        #300000 tb_rst = 1'b0;   // hold reset to let initialization complete
301
     end
302
 
303
   // Wishbone clock
304
   initial
305
     begin
306 9 unneback
        #0 wb_clk = 1'b0;
307
        forever
308 94 unneback
          #(wb0_clk_period/2) wb_clk = !wb_clk;
309 9 unneback
     end
310 80 mikaeljf
 
311
   // SDRAM clock
312 9 unneback
   initial
313
     begin
314
        #0 sdram_clk = 1'b0;
315
        forever
316 94 unneback
          #(sdram_clk_period/2) sdram_clk = !sdram_clk;
317 9 unneback
     end
318
 
319
endmodule // versatile_mem_ctrl_tb

powered by: WebSVN 2.1.0

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