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 44

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