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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [sim/] [iverilog/] [memory/] [tb_memory.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
`timescale 1ps/1ps
2
 
3
module tb_memory();
4
 
5
reg             clk;
6
reg             rst_n;
7
 
8
//REQ:
9
reg             read_do;
10
wire            read_done;
11
wire            read_page_fault;
12
wire            read_ac_fault;
13
 
14
reg  [1:0]      read_cpl;
15
reg  [31:0]     read_address;
16
reg  [3:0]      read_length;
17
reg             read_lock;
18
reg             read_rmw;
19
wire [63:0]     read_data;
20
//END
21
 
22
//REQ:
23
reg             write_do;
24
wire            write_done;
25
wire            write_page_fault;
26
wire            write_ac_fault;
27
 
28
reg  [1:0]      write_cpl;
29
reg  [31:0]     write_address;
30
reg  [2:0]      write_length;
31
reg             write_lock;
32
reg             write_rmw;
33
reg  [31:0]     write_data;
34
//END
35
 
36
//REQ:
37
reg             tlbcheck_do;
38
wire            tlbcheck_done;
39
wire            tlbcheck_page_fault;
40
 
41
reg  [31:0]     tlbcheck_address;
42
reg             tlbcheck_rw;
43
//END
44
 
45
//RESP:
46
reg             tlbflushsingle_do;
47
wire            tlbflushsingle_done;
48
 
49
reg   [31:0]    tlbflushsingle_address;
50
//END
51
 
52
//RESP:
53
reg             tlbflushall_do;
54
//END
55
 
56
//RESP:
57
reg             invdcode_do;
58
wire            invdcode_done;
59
//END
60
 
61
//RESP:
62
reg             invddata_do;
63
wire            invddata_done;
64
//END
65
 
66
//RESP:
67
reg             wbinvddata_do;
68
wire            wbinvddata_done;
69
//END
70
 
71
// prefetch exported
72
reg [1:0]       prefetch_cpl;
73
reg [31:0]      prefetch_eip;
74
reg [63:0]      cs_cache;
75
 
76
// tlb exported
77
reg             cr0_pg;
78
reg             cr0_wp;
79
reg             cr0_am;
80
reg             cr0_cd;
81
reg             cr0_nw;
82
 
83
reg             acflag;
84
 
85
reg   [31:0]    cr3;
86
 
87
// prefetch_fifo exported
88
reg             prefetchfifo_accept_do;
89
wire [67:0]     prefetchfifo_accept_data;
90
wire            prefetchfifo_accept_empty;
91
 
92
reg             pipeline_after_read_empty;
93
reg             pipeline_after_prefetch_empty;
94
 
95
wire [15:0]     tlb_code_pf_error_code;
96
wire [15:0]     tlb_check_pf_error_code;
97
wire [15:0]     tlb_write_pf_error_code;
98
wire [15:0]     tlb_read_pf_error_code;
99
 
100
wire [31:0]     tlb_code_pf_cr2;
101
wire [31:0]     tlb_check_pf_cr2;
102
wire [31:0]     tlb_write_pf_cr2;
103
wire [31:0]     tlb_read_pf_cr2;
104
 
105
// reset exported
106
reg             pr_reset;
107
reg             rd_reset;
108
reg             exe_reset;
109
reg             wr_reset;
110
 
111
// avalon master
112
wire  [31:0]    avm_address;
113
wire  [31:0]    avm_writedata;
114
wire  [3:0]     avm_byteenable;
115
wire  [2:0]     avm_burstcount;
116
wire            avm_write;
117
wire            avm_read;
118
 
119
reg             avm_waitrequest;
120
reg             avm_readdatavalid;
121
reg   [31:0]    avm_readdata;
122
 
123
memory memory_inst(
124
    .clk                (clk),
125
    .rst_n              (rst_n),
126
 
127
    //REQ:
128
    .read_do                       (read_do),                       //input
129
    .read_done                     (read_done),                     //output
130
    .read_page_fault               (read_page_fault),               //output
131
    .read_ac_fault                 (read_ac_fault),                 //output
132
 
133
    .read_cpl                      (read_cpl),                      //input [1:0]
134
    .read_address                  (read_address),                  //input [31:0]
135
    .read_length                   (read_length),                   //input [3:0]
136
    .read_lock                     (read_lock),                     //input
137
    .read_rmw                      (read_rmw),                      //input
138
    .read_data                     (read_data),                     //output [63:0]
139
    //END
140
 
141
    //REQ:
142
    .write_do                      (write_do),                      //input
143
    .write_done                    (write_done),                    //output
144
    .write_page_fault              (write_page_fault),              //output
145
    .write_ac_fault                (write_ac_fault),                //output
146
 
147
    .write_cpl                     (write_cpl),                     //input [1:0]
148
    .write_address                 (write_address),                 //input [31:0]
149
    .write_length                  (write_length),                  //input [2:0]
150
    .write_lock                    (write_lock),                    //input
151
    .write_rmw                     (write_rmw),                     //input
152
    .write_data                    (write_data),                    //input [31:0]
153
    //END
154
 
155
    //REQ:
156
    .tlbcheck_do                   (tlbcheck_do),                   //input
157
    .tlbcheck_done                 (tlbcheck_done),                 //output
158
    .tlbcheck_page_fault           (tlbcheck_page_fault),           //output
159
 
160
    .tlbcheck_address              (tlbcheck_address),              //input [31:0]
161
    .tlbcheck_rw                   (tlbcheck_rw),                   //input
162
    //END
163
 
164
    //RESP:
165
    .tlbflushsingle_do             (tlbflushsingle_do),             //input
166
    .tlbflushsingle_done           (tlbflushsingle_done),           //output
167
    .tlbflushsingle_address        (tlbflushsingle_address),        //input [31:0]
168
    //END
169
 
170
    .tlbflushall_do                (tlbflushall_do),                //input
171
 
172
    .invdcode_do                   (invdcode_do),                   //input
173
    .invdcode_done                 (invdcode_done),                 //output
174
 
175
    .invddata_do                   (invddata_do),                   //input
176
    .invddata_done                 (invddata_done),                 //output
177
 
178
    .wbinvddata_do                 (wbinvddata_do),                 //input
179
    .wbinvddata_done               (wbinvddata_done),               //output
180
 
181
    // prefetch exported
182
    .prefetch_cpl                  (prefetch_cpl),                  //input [1:0]
183
    .prefetch_eip                  (prefetch_eip),                  //input [31:0]
184
    .cs_cache                      (cs_cache),                      //input [63:0]
185
//---    
186
    .cr0_pg                        (cr0_pg),                        //input
187
    .cr0_wp                        (cr0_wp),                        //input
188
    .cr0_am                        (cr0_am),                        //input
189
    .cr0_cd                        (cr0_cd),                        //input
190
    .cr0_nw                        (cr0_nw),                        //input
191
 
192
    .acflag                        (acflag),                        //input
193
 
194
    .cr3                           (cr3),                           //input [31:0]
195
 
196
    // prefetch_fifo exported
197
    .prefetchfifo_accept_do        (prefetchfifo_accept_do),        //input
198
    .prefetchfifo_accept_data      (prefetchfifo_accept_data),      //output [67:0]
199
    .prefetchfifo_accept_empty     (prefetchfifo_accept_empty),     //output
200
 
201
    // pipeline state
202
    .pipeline_after_read_empty     (pipeline_after_read_empty),     //input
203
    .pipeline_after_prefetch_empty (pipeline_after_prefetch_empty), //input
204
 
205
    .tlb_code_pf_error_code        (tlb_code_pf_error_code),        //output [15:0]
206
    .tlb_check_pf_error_code       (tlb_check_pf_error_code),       //output [15:0]
207
    .tlb_write_pf_error_code       (tlb_write_pf_error_code),       //output [15:0]
208
    .tlb_read_pf_error_code        (tlb_read_pf_error_code),        //output [15:0]
209
 
210
    .tlb_code_pf_cr2               (tlb_code_pf_cr2),               //output [31:0]
211
    .tlb_check_pf_cr2              (tlb_check_pf_cr2),              //output [31:0]
212
    .tlb_write_pf_cr2              (tlb_write_pf_cr2),              //output [31:0]
213
    .tlb_read_pf_cr2               (tlb_read_pf_cr2),               //output [31:0]
214
 
215
    // reset exported
216
    .pr_reset                      (pr_reset),                      //input
217
    .rd_reset                      (rd_reset),                      //input
218
    .exe_reset                     (exe_reset),                     //input
219
    .wr_reset                      (wr_reset),                      //input
220
 
221
    // avalon master
222
    .avm_address                   (avm_address),                   //output [31:0]
223
    .avm_writedata                 (avm_writedata),                 //output [31:0]
224
    .avm_byteenable                (avm_byteenable),                //output [3:0]
225
    .avm_burstcount                (avm_burstcount),                //output [2:0]
226
    .avm_write                     (avm_write),                     //output
227
    .avm_read                      (avm_read),                      //output
228
    .avm_waitrequest               (avm_waitrequest),               //input
229
    .avm_readdatavalid             (avm_readdatavalid),             //input
230
    .avm_readdata                  (avm_readdata)                   //input [31:0]
231
);
232
 
233
 
234
integer     fscanf_ret;
235
 
236
reg [255:0]  name;
237
reg [63:0]   value;
238
 
239
integer do_loop;
240
 
241
task input_state;
242
begin
243
    $fwrite(STDOUT, "request:", $time, "\n");
244
    $fflush(STDOUT);
245
 
246
    do_loop = 1;
247
 
248
    while(do_loop == 1) begin
249
 
250
        fscanf_ret = $fscanf(STDIN, "%s", name);
251
        fscanf_ret = $fscanf(STDIN, "%x", value);
252
 
253
        case(name)
254
            "quit:":     begin $dumpoff(); $finish_and_return(0); end
255
            "continue:": do_loop = 0;
256
 
257
            "rst_n:":                   rst_n           = value[0];
258
 
259
            "read_do:":                 read_do         = value[0];
260
            "read_cpl:":                read_cpl        = value[1:0];  //2
261
            "read_address:":            read_address    = value[31:0]; //32
262
            "read_length:":             read_length     = value[3:0];  //4
263
            "read_lock:":               read_lock       = value[0];
264
            "read_rmw:":                read_rmw        = value[0];
265
 
266
            "write_do:":                write_do        = value[0];
267
            "write_cpl:":               write_cpl       = value[1:0];  //2
268
            "write_address:":           write_address   = value[31:0]; //32
269
            "write_length:":            write_length    = value[2:0];  //3
270
            "write_lock:":              write_lock      = value[0];
271
            "write_rmw:":               write_rmw       = value[0];
272
            "write_data:":              write_data      = value[31:0]; //32
273
 
274
            "tlbcheck_do:":             tlbcheck_do     = value[0];
275
            "tlbcheck_address:":        tlbcheck_address= value[31:0]; //32
276
            "tlbcheck_rw:":             tlbcheck_rw     = value[0];
277
 
278
            "tlbflushsingle_do:":       tlbflushsingle_do      = value[0];
279
            "tlbflushsingle_address:":  tlbflushsingle_address = value[31:0]; //32
280
 
281
            "tlbflushall_do:":          tlbflushall_do  = value[0];
282
            "invdcode_do:":             invdcode_do     = value[0];
283
            "invddata_do:":             invddata_do     = value[0];
284
            "wbinvddata_do:":           wbinvddata_do   = value[0];
285
 
286
            "prefetch_cpl:":            prefetch_cpl    = value[1:0]; //2
287
            "prefetch_eip:":            prefetch_eip    = value[31:0]; //32
288
            "cs_cache:":                cs_cache        = value[63:0]; //64
289
 
290
            "prefetchfifo_accept_do:": prefetchfifo_accept_do = value[0];
291
 
292
            "cr0_pg:":                  cr0_pg = value[0];
293
            "cr0_wp:":                  cr0_wp = value[0];
294
            "cr0_am:":                  cr0_am = value[0];
295
            "cr0_cd:":                  cr0_cd = value[0];
296
            "cr0_nw:":                  cr0_nw = value[0];
297
 
298
            "acflag:":                  acflag = value[0];
299
 
300
            "cr3:":                     cr3    = value[31:0]; //32
301
 
302
            "pipeline_after_read_empty:":     pipeline_after_read_empty     = value[0];
303
            "pipeline_after_prefetch_empty:": pipeline_after_prefetch_empty = value[0];
304
 
305
            "pr_reset:":                pr_reset  = value[0];
306
            "rd_reset:":                rd_reset  = value[0];
307
            "exe_reset:":               exe_reset = value[0];
308
            "wr_reset:":                wr_reset  = value[0];
309
 
310
            "avm_waitrequest:":         avm_waitrequest   = value[0];
311
            "avm_readdatavalid:":       avm_readdatavalid = value[0];
312
            "avm_readdata:":            avm_readdata      = value[31:0]; //32
313
 
314
            default: begin $display("Unknown name: %s", name); $finish_and_return(-1); end
315
        endcase
316
    end
317
end
318
endtask
319
//46
320
 
321
task output_state;
322
begin
323
    $fwrite(STDOUT, "time:", $time, "\n");
324
 
325
    $fwrite(STDOUT, "read_done:        %x\n", read_done);
326
    $fwrite(STDOUT, "read_page_fault:  %x\n", read_page_fault);
327
    $fwrite(STDOUT, "read_ac_fault:    %x\n", read_ac_fault);
328
    $fwrite(STDOUT, "read_data:        %x\n", read_data); //64
329
 
330
    $fwrite(STDOUT, "write_done:       %x\n", write_done);
331
    $fwrite(STDOUT, "write_page_fault: %x\n", write_page_fault);
332
    $fwrite(STDOUT, "write_ac_fault:   %x\n", write_ac_fault);
333
 
334
    $fwrite(STDOUT, "tlbcheck_done:       %x\n", tlbcheck_done);
335
    $fwrite(STDOUT, "tlbcheck_page_fault: %x\n", tlbcheck_page_fault);
336
 
337
    $fwrite(STDOUT, "tlbflushsingle_done: %x\n", tlbflushsingle_done);
338
 
339
    $fwrite(STDOUT, "invdcode_done:   %x\n", invdcode_done);
340
    $fwrite(STDOUT, "invddata_done:   %x\n", invddata_done);
341
 
342
    $fwrite(STDOUT, "wbinvddata_done: %x\n", wbinvddata_done);
343
 
344
    $fwrite(STDOUT, "prefetchfifo_accept_data:  %x\n", (prefetchfifo_accept_empty)? 68'd0 : prefetchfifo_accept_data); //68
345
    $fwrite(STDOUT, "prefetchfifo_accept_empty: %x\n", prefetchfifo_accept_empty);
346
 
347
    $fwrite(STDOUT, "tlb_code_pf_cr2:         %x\n", tlb_code_pf_cr2); //32
348
    $fwrite(STDOUT, "tlb_code_pf_error_code:  %x\n", tlb_code_pf_error_code); //16
349
 
350
    $fwrite(STDOUT, "tlb_check_pf_cr2:        %x\n", tlb_check_pf_cr2); //32
351
    $fwrite(STDOUT, "tlb_check_pf_error_code: %x\n", tlb_check_pf_error_code); //16
352
 
353
    $fwrite(STDOUT, "tlb_write_pf_cr2:        %x\n", tlb_write_pf_cr2); //32
354
    $fwrite(STDOUT, "tlb_write_pf_error_code: %x\n", tlb_write_pf_error_code); //16
355
 
356
    $fwrite(STDOUT, "tlb_read_pf_cr2:         %x\n", tlb_read_pf_cr2); //32
357
    $fwrite(STDOUT, "tlb_read_pf_error_code:  %x\n", tlb_read_pf_error_code); //16
358
 
359
    $fwrite(STDOUT, "avm_address:    %x\n", avm_address);    //32
360
    $fwrite(STDOUT, "avm_writedata:  %x\n", avm_writedata);  //32
361
    $fwrite(STDOUT, "avm_byteenable: %x\n", avm_byteenable); //4
362
    $fwrite(STDOUT, "avm_burstcount: %x\n", avm_burstcount); //3
363
    $fwrite(STDOUT, "avm_write:      %x\n", avm_write);
364
    $fwrite(STDOUT, "avm_read:       %x\n", avm_read);
365
 
366
    $fwrite(STDOUT, "\n");
367
    $fflush(STDOUT);
368
end
369
endtask
370
//30
371
 
372
parameter STDIN  = 32'h8000_0000;
373
parameter STDOUT = 32'h8000_0001;
374
 
375
`define FALSE 1'b0
376
`define TRUE  1'b1
377
 
378
/*
379
wire  [31:0]    avm_address;
380
wire  [31:0]    avm_writedata;
381
wire  [3:0]     avm_byteenable;
382
wire  [2:0]     avm_burstcount;
383
wire            avm_write;
384
wire            avm_read;
385
 
386
reg             avm_waitrequest;
387
reg             avm_readdatavalid;
388
reg   [31:0]    avm_readdata;
389
*/
390
 
391
reg [255:0] dumpfile_name;
392
initial begin
393
    if( $value$plusargs("dumpfile=%s", dumpfile_name) == 0 ) begin
394
        dumpfile_name = "default.vcd";
395
    end
396
 
397
    $dumpfile(dumpfile_name);
398
    $dumpvars(0);
399
    $dumpon();
400
 
401
    $display("START");
402
 
403
    //--------------------------------------------------------------------------
404
 
405
    clk = 1'b0;
406
 
407
    forever begin
408
        if(clk == 1'b0) input_state();
409
 
410
        #5 clk = ~clk;
411
 
412
        $dumpflush();
413
 
414
        if(clk == 1'b1) output_state();
415
 
416
        //$display("clk: ", clk, " time: ", $time);
417
 
418
    end
419
end
420
 
421
endmodule

powered by: WebSVN 2.1.0

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