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

Subversion Repositories versatile_library

[/] [versatile_library/] [trunk/] [bench/] [tb_wb_cache.v] - Blame information for rev 140

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

Line No. Rev Author Line
1 102 unneback
module vl_wb_cache_tb ();
2
 
3
   wire [31:0] wbm_a_dat_o;
4
   wire [3:0]  wbm_a_sel_o;
5
   wire [31:0] wbm_a_adr_o;
6
   wire [2:0]  wbm_a_cti_o;
7
   wire [1:0]  wbm_a_bte_o;
8
   wire        wbm_a_we_o ;
9
   wire        wbm_a_cyc_o;
10
   wire        wbm_a_stb_o;
11
   wire [31:0] wbm_a_dat_i;
12
   wire        wbm_a_ack_i;
13
   reg         wbm_a_clk  ;
14
   reg         wbm_a_rst  ;
15
 
16
   wire [31:0] wbm_b_dat_o;
17
   wire [3:0]  wbm_b_sel_o;
18
   wire [31:0] wbm_b_adr_o;
19
   wire [2:0]  wbm_b_cti_o;
20
   wire [1:0]  wbm_b_bte_o;
21
   wire        wbm_b_we_o ;
22
   wire        wbm_b_cyc_o;
23
   wire        wbm_b_stb_o;
24
   wire [31:0] wbm_b_dat_i;
25
   wire        wbm_b_ack_i;
26
   wire        wbm_b_stall_i;
27
   reg         wbm_b_clk  ;
28
   reg         wbm_b_rst  ;
29
 
30
parameter wb_clk_period = 20;
31
 
32
parameter [1:0] linear = 2'b00,
33
                beat4  = 2'b01,
34
                beat8  = 2'b10,
35
                beat16 = 2'b11;
36
 
37
parameter [2:0] classic = 3'b000,
38
                inc     = 3'b010,
39
                eob     = 3'b111;
40
parameter rd = 1'b0;
41
parameter wr = 1'b1;
42
 
43
parameter instructions = 32;
44
 
45
// {adr_o,bte_o,cti_o,dat_o,sel_o,we_o,cyc_o,stb_o}
46
parameter [32+2+3+32+4+1+1+1:1] inst_rom0 [0:instructions-1]= {
47
                {32'h0,linear,classic,32'h0,4'b1111,rd,1'b0,1'b0},
48
                {32'h100,linear,classic,32'h12345678,4'b1111,wr,1'b1,1'b1}, // write 0x12345678 @ 0x100
49
                {32'h100,linear,classic,32'h0,4'b1111,rd,1'b1,1'b1},        // read  @ 0x100            
50
                {32'h1100,beat4,eob,32'h87654321,4'b1111,wr,1'b1,1'b1},     // write 0x87654321 @ 0x1100 with 01,111
51
                {32'h1100,linear,classic,32'h0,4'b1111,rd,1'b1,1'b1},       // read  @ 0x1100
52
                {32'h0,linear,classic,32'h0,4'b1111,rd,1'b0,1'b0},
53
                {32'h100,beat4,inc,32'h00010002,4'b1111,wr,1'b1,1'b1},      // write burst @ 0x100
54
                {32'h104,beat4,inc,32'h00030004,4'b1111,wr,1'b1,1'b1},
55
                {32'h108,beat4,inc,32'h00050006,4'b1111,wr,1'b1,1'b1},
56
                {32'h10c,beat4,eob,32'h00070008,4'b1111,wr,1'b1,1'b1},
57
                {32'h104,linear,classic,32'hA1FFFFFF,4'b1000,wr,1'b1,1'b1}, // write byte a1 @ 104              
58
                {32'h108,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b1},             // read burst
59
                {32'h10c,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b1},
60
                {32'h100,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b1},
61
                {32'h104,beat4,eob,32'h0,4'b1111,rd,1'b1,1'b1},
62
                {32'h100,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b1},             // read burst with strobe going low once
63
                {32'h104,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b1},
64
                {32'h104,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b0},
65
                {32'h108,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b1},
66
                {32'h10c,beat4,eob,32'h0,4'b1111,rd,1'b1,1'b1},
67
                {32'h100,linear,inc,32'hdeaddead,4'b1111,1'b1,1'b1,1'b1}, // write
68
                {32'h104,linear,eob,32'h55555555,4'b1111,1'b1,1'b1,1'b1}, //            
69
                {32'h100,linear,inc,32'h0,4'b1111,1'b0,1'b1,1'b1}, // read
70
                {32'h104,linear,eob,32'h0,4'b1111,1'b0,1'b1,1'b1}, // read
71
                {32'h100,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b1}, // read burst with strobe going low
72
                {32'h104,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b0},
73
                {32'h104,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b1},
74
                {32'h108,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b1},
75
                {32'h108,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b0},
76
                {32'h10c,beat4,inc,32'h0,4'b1111,rd,1'b1,1'b0},
77
                {32'h10c,beat4,eob,32'h0,4'b1111,rd,1'b1,1'b1},
78
                {32'h0,linear,classic,32'h0,4'b1111,rd,1'b0,1'b0}};
79
 
80
        parameter [31:0] dat0 [0:instructions-1] = {
81
                32'h0,
82
                32'h0,
83
                32'h0,
84
                32'h12345678,
85
                32'h0,
86
                32'h87654321,
87
                32'h0,
88
                32'h0,
89
                32'h0,
90
                32'h0,
91
                32'h0,
92
                32'h0,
93
                32'h00050006,
94
                32'h00070008,
95
                32'h00010002,
96
                32'ha1030004,
97
                32'h00010002,
98
                32'ha1030004,
99
                32'h0,
100
                32'h00050006,
101
                32'h00070008,
102
                32'h0,
103
                32'h0,
104
                32'hdeaddead,
105
                32'h55555555,
106
                32'hdeaddead,
107
                32'h0,
108
                32'h55555555,
109
                32'h00050006,
110
                32'h0,
111
                32'h0,
112
                32'h00070008};
113
 
114
 
115
vl_wb_cache
116
# (
117
    .dw_s(32),
118
    .aw_s(16),
119
    .dw_m(32),
120
    .wbs_max_burst_width(4),
121
    .wbm_burst_size(4),
122
    .aw_offset(2),
123
    .aw_slot(5),
124
    .valid_mem(1),
125
    .async(1),
126
    .debug(0))
127
dut (
128
    .wbs_dat_i(wbm_a_dat_o),
129
    .wbs_adr_i(wbm_a_adr_o[17:2]),
130
    .wbs_sel_i(wbm_a_sel_o),
131
    .wbs_cti_i(wbm_a_cti_o),
132
    .wbs_bte_i(wbm_a_bte_o),
133
    .wbs_we_i(wbm_a_we_o),
134
    .wbs_stb_i(wbm_a_stb_o),
135
    .wbs_cyc_i(wbm_a_cyc_o),
136
    .wbs_dat_o(wbm_a_dat_i),
137
    .wbs_ack_o(wbm_a_ack_i),
138
    .wbs_clk(wbm_a_clk),
139
    .wbs_rst(wbm_a_rst),
140
 
141
    .wbm_dat_o(wbm_b_dat_o),
142
    .wbm_adr_o(wbm_b_adr_o[17:2]),
143
    .wbm_sel_o(wbm_b_sel_o),
144
    .wbm_cti_o(wbm_b_cti_o),
145
    .wbm_bte_o(wbm_b_bte_o),
146
    .wbm_we_o(wbm_b_we_o),
147
    .wbm_stb_o(wbm_b_stb_o),
148
    .wbm_cyc_o(wbm_b_cyc_o),
149
    .wbm_dat_i(wbm_b_dat_i),
150
    .wbm_ack_i(wbm_b_ack_i),
151
    .wbm_stall_i(wbm_b_stall_i),
152
    .wbm_clk(wbm_b_clk),
153
    .wbm_rst(wbm_b_rst));
154
assign wbm_b_adr_o[31:18] = 14'h00;
155
assign wbm_b_adr_o[1:0] = 2'b00;
156
 
157
wbm # ( .inst_rom(inst_rom0), .dat(dat0), .testcase("\nTest case:\nwb_b3_dpram A side\n"))
158
wbmi0(
159
            .adr_o(wbm_a_adr_o),
160
            .bte_o(wbm_a_bte_o),
161
            .cti_o(wbm_a_cti_o),
162
            .dat_o(wbm_a_dat_o),
163
            .sel_o(wbm_a_sel_o),
164
            .we_o (wbm_a_we_o),
165
            .cyc_o(wbm_a_cyc_o),
166
            .stb_o(wbm_a_stb_o),
167
            .dat_i(wbm_a_dat_i),
168
            .ack_i(wbm_a_ack_i),
169
            .clk(wbm_a_clk),
170
            .reset(wbm_a_rst),
171
            .OK(wbm_OK)
172
);
173
 
174
vl_wb_ram # (
175
    .dat_width(32),
176
    .adr_width(16),
177
    .memory_init(2),
178
    .mode("B4"))
179
main_mem (
180
    .wbs_dat_i(wbm_b_dat_o),
181
    .wbs_adr_i(wbm_b_adr_o[17:2]),
182
    .wbs_sel_i(wbm_b_sel_o),
183
    .wbs_we_i (wbm_b_we_o),
184
    .wbs_bte_i(wbm_b_bte_o),
185
    .wbs_cti_i(wbm_b_cti_o),
186
    .wbs_stb_i(wbm_b_stb_o),
187
    .wbs_cyc_i(wbm_b_cyc_o),
188
    .wbs_dat_o(wbm_b_dat_i),
189
    .wbs_stall_o(wbm_b_stall_i),
190
    .wbs_ack_o(wbm_b_ack_i),
191
    .wb_clk(wbm_b_clk),
192
    .wb_rst(wbm_b_rst));
193
 
194
initial
195
    begin
196
        #0      wbm_a_rst = 1'b1;
197
        #200    wbm_a_rst = 1'b0;
198
    end
199
 
200
// Wishbone clock
201
initial
202
    begin
203
        #0 wbm_a_clk = 1'b0;
204
        forever
205
            #(wb_clk_period/2) wbm_a_clk = !wbm_a_clk;
206
    end
207
 
208
initial
209
    begin
210
        #0      wbm_b_rst = 1'b1;
211
        #200    wbm_b_rst = 1'b0;
212
    end
213
 
214
// Wishbone clock
215
initial
216
    begin
217
        #0 wbm_b_clk = 1'b0;
218
        forever
219
            #(wb_clk_period/5) wbm_b_clk = !wbm_b_clk;
220
    end
221
 
222
initial
223
    #20000 $finish;
224
endmodule

powered by: WebSVN 2.1.0

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