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

Subversion Repositories pci

[/] [pci/] [tags/] [working_demo/] [old_stuff/] [FIFOs/] [wb_tb.v] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mihad
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "wb_tb.v"                                            ////
4
////                                                              ////
5
////  This file is part of the "PCI bridge" project               ////
6
////  http://www.opencores.org/cores/pci/                         ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - mihad@opencores.org                                   ////
10
////      - Miha Dolenc                                           ////
11
////                                                              ////
12
////  All additional information is avaliable in the README.txt   ////
13
////  file.                                                       ////
14
////                                                              ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2000 Miha Dolenc, mihad@opencores.org          ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45
// $Log: not supported by cvs2svn $
46
// Revision 1.3  2001/06/12 11:15:10  mihad
47
// Changed module parameters
48
//
49
//
50
 
51
`include "constants.v"
52
`include "wbw_wbr_fifos.v"
53
 
54
// Common definitions for simulation purposes
55
`define Tpci 75 // Tp/2 = 7.5ns => Tp = 15ns => Fpci = 66MHz
56
`define Twb 25  // Tp/2 = 2.5ns =>   Tp = 5ns  => Fwb  = 200MHz
57
 
58
module WB_TB() ;
59
 
60
reg [31:0] wbw_data_in ;
61
wire [31:0] wbw_data_out;
62
reg [3:0]  wbw_cbe_in ;
63
wire [3:0] wbw_cbe_out ;
64
reg [3:0] wbw_control_in ;
65
wire [3:0] wbw_control_out ;
66
 
67
wire [31:0] wbr_data_out;
68
reg [31:0] wbr_data_in;
69
wire [3:0] wbr_be_out ;
70
reg [3:0] wbr_be_in ;
71
reg [3:0] wbr_control_in ;
72
wire [3:0] wbr_control_out ;
73
 
74
wire wbw_full;
75
wire wbw_empty ;
76
wire wbw_almost_full ;
77
wire wbw_almost_empty ;
78
reg wbw_wenable ;
79
reg wbw_renable ;
80
wire wbw_transaction_ready ;
81
 
82
wire wbr_full;
83
wire wbr_empty ;
84
wire wbr_almost_full ;
85
wire wbr_almost_empty ;
86
reg wbr_wenable ;
87
reg wbr_renable ;
88
wire wbr_transaction_ready ;
89
 
90
reg reset ;
91
reg pci_clock ;
92
reg wb_clock ;
93
 
94
reg wbr_flush ;
95
reg wbw_flush ;
96
 
97
`ifdef FPGA
98
    assign glbl.GSR = reset ;
99
`endif
100
 
101
// initial values
102
initial
103
begin
104
    reset <= 1'b1 ;
105
 
106
    pci_clock <= 1'b1 ;
107
    wb_clock <= 1'b0 ;
108
    wbw_data_in <= 32'h00000001 ;
109
    wbw_cbe_in  <= 4'h0 ;
110
    wbr_be_in  <= 4'h0 ;
111
    wbw_control_in <= 4'h1 ;
112
    wbw_wenable <= 1'b0;
113
    wbw_renable <= 1'b0 ;
114
    wbr_control_in <= 4'h1 ;
115
    wbr_wenable <= 1'b0;
116
    wbr_renable <= 1'b0 ;
117
    wbr_data_in <= 32'h00000001 ;
118
    wbr_flush <= 1'b0 ;
119
 
120
    #10 reset = 1'b0 ;
121
    run_tests ;
122
end
123
 
124
// clock generation
125
always
126
begin
127
   #`Tpci pci_clock = ~pci_clock ;
128
end
129
 
130
always
131
begin
132
   #`Twb wb_clock = ~wb_clock ;
133
end
134
 
135
task run_tests;
136
begin
137
    wbw_empty_nempty_transition ;
138
    $display("Empty/not empty transition test for WBW completed") ;
139
    wbw_full_empty ;
140
    $display("Full/empty status generation test for WBW completed") ;
141
 
142
    wbr_empty_nempty_transition ;
143
    $display("Empty/not empty transition test for WBR completed") ;
144
    wbr_full_empty ;
145
    $display("Full/empty status generation test for WBR completed") ;
146
 
147
    simultaneous_operation ;
148
    $stop ;
149
end
150
endtask
151
 
152
task wbw_empty_nempty_transition ;
153
    integer index ;
154
    integer read_data ;
155
begin
156
    read_data = 1 ;
157
    fork
158
    begin:write_wbw_once
159
        // repeat the test several times, so clock to clock transition time changes
160
        for(index = 2; index <= 101; index = index + 1)
161
        begin
162
            // wait for WBW to become empty
163
            wait(wbw_empty);
164
            // sample empty on posedge of clock
165
            @(posedge wb_clock)
166
                wbw_wenable <= #`FF_DELAY 1'b1;
167
 
168
            // data gets written at clock edge following the one empty was asserted
169
            @(posedge wb_clock)
170
            begin
171
                // prepare data for next write
172
                wbw_wenable <= #`FF_DELAY 1'b0 ;
173
                wbw_data_in <= #`FF_DELAY index ;
174
                wbw_control_in <= #`FF_DELAY index[3:0] ;
175
                wbw_cbe_in <= #`FF_DELAY index[7:4] ;
176
                // wait for WBW to be empty again
177
                wait(~wbw_empty) ;
178
            end
179
        end
180
    end
181
 
182
    begin:read_wbw
183
        // repeat test several times
184
        while(read_data <= 100)
185
        begin
186
            wait (~wbw_empty) ;
187
            @(posedge pci_clock)
188
                // at first clock edge empty is deasserted assert read enable, so read will be performed on the next clk edge
189
                wbw_renable <= #`FF_DELAY 1'b1 ;
190
            @(posedge pci_clock)
191
            begin
192
                // sample read data
193
                if ((wbw_data_out != read_data) || (read_data[3:0] != wbw_control_out) || (read_data[7:4] != wbw_cbe_out))
194
                begin
195
                    $display("Empty/not empty transition test failed for WBW fifo! On read number %d !", index) ;
196
                    $stop ;
197
                end
198
                // prepare data for next read sampling
199
                read_data <= read_data + 32'd1 ;
200
                wbw_renable <= #`FF_DELAY 1'b0 ;
201
                @(posedge pci_clock) ;
202
            end
203
        end
204
    end
205
    join
206
end
207
endtask
208
 
209
task wbw_full_empty;
210
    integer windex ;
211
    integer rindex ;
212
begin
213
    // task fills FIFO until it is full and monitors status outputs if they are asserted correctly
214
    windex = 1 ;
215
    wbw_data_in <= #`FF_DELAY 32'h00000001 ;
216
    wbw_control_in <= #`FF_DELAY 4'h1 ;
217
    wbw_cbe_in <= #`FF_DELAY 4'h0 ;
218
    begin:fill_FIFO
219
        @(posedge wb_clock)
220
            wbw_wenable <= #`FF_DELAY 1'b1 ;
221
        while (windex < `WBW_DEPTH)
222
        begin
223
            @(posedge wb_clock)
224
            begin
225
                windex = windex + 1 ;
226
                wbw_data_in <= #`FF_DELAY windex ;
227
                wbw_control_in <= #`FF_DELAY windex[3:0] ;
228
                wbw_cbe_in <= #`FF_DELAY windex[7:4] ;
229
 
230
                if (windex == (`WBW_DEPTH))
231
                begin
232
                    if (~wbw_almost_full)
233
                    begin
234
                        $display("Almost full status generation test for WBW failed") ;
235
                        $stop ;
236
                    end
237
                end
238
            end
239
        end
240
 
241
        wbw_wenable <= #`FF_DELAY 1'b0 ;
242
        @(posedge wb_clock)
243
        begin
244
            if (~wbw_full)
245
            begin
246
                $display("Full status generation test for WBW failed") ;
247
                $stop ;
248
            end
249
        end
250
    end
251
 
252
    // statements read from FIFO, monitor data output and status outputs on proper clock edge
253
    begin:empty_FIFO
254
        rindex = 0 ;
255
        wait (wbw_full) ;
256
        @(posedge pci_clock)
257
            wbw_renable <= #`FF_DELAY 1'b1 ;
258
        while(rindex < (`WBW_DEPTH - 1))
259
        begin
260
            rindex = rindex + 1 ;
261
            @(posedge pci_clock)
262
            begin
263
                if ((wbw_data_out != rindex) || (rindex[3:0] != wbw_control_out) || (rindex[7:4] != wbw_cbe_out))
264
                begin
265
                    $display("Full/Empty status generation test failed for WBW fifo!");
266
                    $stop ;
267
                end
268
                if (rindex == `WBW_DEPTH - 1)
269
                begin
270
                    if (~wbw_almost_empty)
271
                    begin
272
                        $display("Almost empty status generation test for WBW failed") ;
273
                        $stop ;
274
                    end
275
                end
276
            end
277
        end
278
 
279
        wbw_renable <= #`FF_DELAY 1'b0 ;
280
        @(posedge pci_clock)
281
        begin
282
            if (~wbw_empty)
283
            begin
284
                $display("Empty status generation test for WBW failed") ;
285
                $stop ;
286
            end
287
        end
288
    end
289
end
290
endtask
291
 
292
 
293
task wbr_empty_nempty_transition ;
294
    integer index ;
295
    integer read_data ;
296
begin
297
    read_data = 1 ;
298
    fork
299
    begin:write_wbr_once
300
        for(index = 2; index <= 101; index = index + 1)
301
        begin
302
            wait(wbr_empty);
303
            @(posedge pci_clock)
304
                wbr_wenable <= #`FF_DELAY 1'b1;
305
 
306
            // data gets written at next rising clock edge
307
            @(posedge pci_clock)
308
            begin
309
                wbr_wenable <= #`FF_DELAY 1'b0 ;
310
                wbr_data_in <= #`FF_DELAY index ;
311
                wbr_control_in <= #`FF_DELAY index[3:0] ;
312
                wbr_be_in <= #`FF_DELAY index[7:4] ;
313
                wait(~wbr_empty) ;
314
            end
315
        end
316
    end
317
 
318
    begin:read_wbr
319
        while(read_data <= 100)
320
        begin
321
            wait (~wbr_empty) ;
322
            @(posedge wb_clock)
323
                wbr_renable <= #`FF_DELAY 1'b1 ;
324
            @(posedge wb_clock)
325
            begin
326
                if ((wbr_data_out != read_data) || (read_data[3:0] != wbr_control_out) || (read_data[7:4] != wbr_be_out))
327
                begin
328
                    $display("Empty/not empty transition test failed for WBR fifo! On read number %d !", index) ;
329
                    $stop ;
330
                end
331
                read_data <= read_data + 32'd1 ;
332
                wbr_renable <= #`FF_DELAY 1'b0 ;
333
                @(posedge wb_clock) ;
334
            end
335
        end
336
    end
337
    join
338
end
339
endtask
340
 
341
task wbr_full_empty;
342
    integer windex ;
343
    integer rindex ;
344
begin
345
    windex = 1 ;
346
    wbr_data_in <= #`FF_DELAY 32'h00000001 ;
347
    wbr_control_in <= #`FF_DELAY 4'h1 ;
348
    wbr_be_in <= #`FF_DELAY 4'h0 ;
349
    begin:fill_FIFO
350
        @(posedge pci_clock)
351
            wbr_wenable <= #`FF_DELAY 1'b1 ;
352
        while (windex < `WBR_DEPTH)
353
        begin
354
            @(posedge pci_clock)
355
            begin
356
                windex = windex + 1 ;
357
                wbr_data_in <= #`FF_DELAY windex ;
358
                wbr_control_in <= #`FF_DELAY windex[3:0] ;
359
                wbr_be_in <= #`FF_DELAY windex[7:4] ;
360
 
361
                if (windex == (`WBR_DEPTH))
362
                begin
363
                    if (~wbr_almost_full)
364
                    begin
365
                        $display("Almost full status generation test for WBR failed") ;
366
                        $stop ;
367
                    end
368
                end
369
            end
370
        end
371
 
372
        wbr_wenable <= #`FF_DELAY 1'b0 ;
373
        @(posedge pci_clock)
374
        begin
375
            if (~wbr_full)
376
            begin
377
                $display("Full status generation test for WBR failed") ;
378
                $stop ;
379
            end
380
        end
381
    end
382
 
383
    begin:empty_FIFO
384
        rindex = 0 ;
385
        wait (wbr_full) ;
386
        @(posedge wb_clock)
387
            wbr_renable <= #`FF_DELAY 1'b1 ;
388
        while(rindex < (`WBR_DEPTH - 1))
389
        begin
390
            rindex = rindex + 1 ;
391
            @(posedge wb_clock)
392
            begin
393
                if ((wbr_data_out != rindex) || (rindex[3:0] != wbr_control_out) || (rindex[7:4] != wbr_be_out))
394
                begin
395
                    $display("Full/Empty status generation test failed for WBR fifo!");
396
                    $stop ;
397
                end
398
                if (rindex == `WBR_DEPTH - 1)
399
                begin
400
                    if (~wbr_almost_empty)
401
                    begin
402
                        $display("Almost empty status generation test for WBR failed") ;
403
                        $stop ;
404
                    end
405
                end
406
            end
407
        end
408
 
409
        wbr_renable <= #`FF_DELAY 1'b0 ;
410
        @(posedge wb_clock)
411
        begin
412
            if (~wbr_empty)
413
            begin
414
                $display("Empty status generation test for WBR failed") ;
415
                $stop ;
416
            end
417
        end
418
    end
419
end
420
endtask
421
 
422
task simultaneous_operation;
423
    integer i ;
424
    integer wbw_data_incoming ;
425
    reg[(`WBW_ADDR_LENGTH - 1):0] wb_num_of_writes ;
426
    reg[(`WBR_ADDR_LENGTH - 1):0] wb_num_of_reads ;
427
    reg[(`WBR_ADDR_LENGTH - 1):0] pci_num_of_writes ;
428
    reg[3:0] wbw_cbe_outgoing ;
429
    reg[31:0] wbw_data_outgoing ;
430
    reg[3:0] wbr_be_outgoing ;
431
    reg[31:0] wbr_data_outgoing ;
432
    integer decision ;
433
    reg read_request ;
434
begin
435
    // initialize data
436
    wbw_data_in <= 32'd0 ;
437
    wbw_control_in <= 4'h0 ;
438
    wbw_cbe_in <= 4'he ;
439
    wbw_data_outgoing <= 32'd1;
440
    wbw_cbe_outgoing <= 4'hf;
441
 
442
    read_request <= 1'b0 ;
443
    wbr_be_outgoing <= 4'hf ;
444
    wbr_data_outgoing <= 32'd1 ;
445
    wbr_data_in <= 32'd0 ;
446
    wbr_control_in <= 4'h1 ;
447
    wbr_be_in <= 4'he ;
448
 
449
fork
450
begin:wb_requests
451
    forever
452
    begin
453
        // random decision on whether current request is a read or a write
454
        decision = $random(wbw_data_incoming) ;
455
        if (decision <= 32'd2_147_000_000)
456
        begin
457
            // write operation
458
            if(~wbw_full && ~wbw_almost_full && ~read_request)
459
            begin
460
                // WBW fifo is not full or almost full, so it can accomodate one transaction at least
461
                // get random transaction length
462
                wb_num_of_writes = $random ;
463
                @(posedge wb_clock)
464
                begin
465
                    wbw_wenable <= #`FF_DELAY 1'b1 ; //assert write enable and assign control to address
466
                    wbw_data_in <= #`FF_DELAY wbw_data_in + 1 ;
467
                    wbw_cbe_in <= #`FF_DELAY wbw_cbe_in + 1 ;
468
                    wbw_control_in <= #`FF_DELAY `ADDRESS ;
469
                end
470
 
471
                @(posedge wb_clock) ; // address is written on the first clock edge
472
                @(negedge wb_clock) ; // wait 1/2 clock to see if after address was written fifo is almost empty
473
                while ((wb_num_of_writes > 1) && (~wbw_almost_full))
474
                begin
475
                    // prepare new data
476
                    wbw_data_in <= #`FF_DELAY wbw_data_in + 1 ;
477
                    wbw_control_in <= #`FF_DELAY 4'h1 ;
478
                    wbw_cbe_in <= #`FF_DELAY wbw_cbe_in + 1 ;
479
                    @(posedge wb_clock)  // write new data
480
                        wb_num_of_writes <= wb_num_of_writes - 1 ;
481
                    @(negedge wb_clock) ; // combinatorial monitoring of almost full avoided by waiting half a cycle
482
                end //while
483
                // prepare last data
484
                wbw_data_in <= #`FF_DELAY wbw_data_in + 1 ;
485
                wbw_control_in <= #`FF_DELAY `LAST ;
486
                wbw_cbe_in <= #`FF_DELAY wbw_cbe_in + 1 ;
487
                @(posedge wb_clock) //last data of transaction written
488
                    wbw_wenable <= #`FF_DELAY 1'b0 ;
489
                @(negedge wb_clock) ;
490
 
491
            end //if
492
            else
493
                // since it was a write request and FIFO cannot accommodate another transaction, wait one cycle
494
                @(posedge wb_clock) ;
495
        end
496
        else
497
        begin
498
            // it's a read request
499
 
500
            // only accept read request if no other is pending           
501
            if (~read_request)
502
            begin
503
            @(posedge wb_clock)
504
            // initiate read request
505
                read_request <= #`FF_DELAY 1'b1 ;
506
 
507
            // wait for FIFO to be filled and transaction be ready 
508
            wait(~wbr_empty && wbr_transaction_ready) ;
509
 
510
            // random number of reads wb is prepared to do
511
            wb_num_of_reads = $random ;
512
 
513
            // first posedge of wb clock when transaction is ready - assert read enable
514
            @(posedge wb_clock)
515
                wbr_renable <= #`FF_DELAY 1'b1 ;
516
            // until whole transaction or random number of reads is performed do a read
517
            @(negedge wb_clock) ; //wait if maybe first transaction is the last
518
 
519
           while((wb_num_of_reads > 1) && (~wbr_almost_empty) && (wbr_control_out != `LAST))
520
           begin
521
               @(posedge wb_clock)
522
               begin
523
                   if ((wbr_data_out != wbr_data_outgoing) || (wbr_be_out != wbr_be_outgoing))
524
                   begin
525
                       $display("Operational test for WBR FIFO failed") ;
526
                       $stop ;
527
                   end
528
 
529
                   // prepare new set of outgoing data for comparison  
530
                   wbr_data_outgoing <= #`FF_DELAY wbr_data_outgoing + 1;
531
                   wbr_be_outgoing   <= #`FF_DELAY wbr_be_outgoing + 1 ;
532
                   wb_num_of_reads   <= wb_num_of_reads - 1 ;
533
 
534
                   @(negedge wb_clock) ; // avoiding combinatorial logic for monitoring almost full or control out by waiting 1/2 cycle
535
               end
536
           end
537
 
538
            // read last data entry
539
            @(posedge wb_clock)
540
            begin
541
                if ((wbr_data_out != wbr_data_outgoing) || (wbr_be_out != wbr_be_outgoing))
542
                begin
543
                    $display("Operational test for WBR FIFO failed") ;
544
                    $stop ;
545
                end
546
                wbr_renable <= #`FF_DELAY 1'b0 ;
547
            end
548
 
549
            // after last intended data is read, flush wbr_fifo
550
            @(posedge wb_clock)
551
            begin
552
                if(~wbr_empty)
553
                begin
554
                    wbr_flush <= #`FF_DELAY 1'b1 ;
555
                    @(posedge wb_clock)
556
                        wbr_flush <= #`FF_DELAY 1'b0 ;
557
                end //if
558
            end // posedge
559
        end
560
        else
561
            @(posedge wb_clock) ;
562
        end //else
563
    end //forever
564
end //wb_requests
565
 
566
begin:pci_completions
567
    // wait until read request is present or at least one write is posted
568
    forever
569
    begin
570
    wait ((~wbw_empty && wbw_transaction_ready) || (read_request && wbr_empty)) ;
571
 
572
    // all the writes must finish before a read can be processed
573
    if (~wbw_empty && wbw_transaction_ready)
574
    begin
575
        // first posedge of pci clock when transaction is ready - assert read enable
576
        @(posedge pci_clock)
577
            wbw_renable <= #`FF_DELAY 1'b1 ;
578
 
579
        // first entry must be address
580
        @(posedge pci_clock)
581
        begin
582
            if ((wbw_data_out != wbw_data_outgoing) || (wbw_cbe_out != wbw_cbe_outgoing) || (wbw_control_out != `ADDRESS))
583
            begin
584
                 $display("Operational test for WBW FIFO failed") ;
585
                 $stop ;
586
            end //if
587
 
588
            wbw_data_outgoing <= #`FF_DELAY wbw_data_outgoing + 1 ;
589
            wbw_cbe_outgoing  <= #`FF_DELAY wbw_cbe_outgoing + 1 ;
590
        end //posedge
591
 
592
        // wait for negedge - maybe first data is also last
593
        @(negedge pci_clock) ;
594
 
595
        while ((wbw_control_out != `LAST) && (~wbw_almost_empty))
596
        begin
597
            @(posedge pci_clock)
598
            begin
599
                if ((wbw_data_out != wbw_data_outgoing) || (wbw_cbe_out != wbw_cbe_outgoing))
600
                begin
601
                    $display("Operational test for WBW FIFO failed") ;
602
                    $stop ;
603
                end
604
 
605
                // prepare new set of outgoing data for comparison  
606
                wbw_data_outgoing <= #`FF_DELAY wbw_data_outgoing + 1;
607
                wbw_cbe_outgoing   <= #`FF_DELAY wbw_cbe_outgoing + 1 ;
608
 
609
                @(negedge pci_clock) ; // avoiding combinatorial logic for monitoring almost full or control out by waiting 1/2 cycle
610
            end
611
        end
612
 
613
        // read last data entry
614
        @(posedge pci_clock)
615
        begin
616
            if ((wbw_data_out != wbw_data_outgoing) || (wbw_cbe_out != wbw_cbe_outgoing) || (wbw_control_out != `LAST))
617
            begin
618
                $display("Operational test for WBW FIFO failed") ;
619
                $stop ;
620
            end
621
            wbw_renable <= #`FF_DELAY 1'b0 ;
622
            // prepare new set of outgoing data for comparison  
623
            wbw_data_outgoing <= #`FF_DELAY wbw_data_outgoing + 1;
624
            wbw_cbe_outgoing   <= #`FF_DELAY wbw_cbe_outgoing + 1 ;
625
 
626
        end //posedge
627
 
628
        // turnaround cycle
629
        @(posedge pci_clock) ;
630
 
631
    end // if
632
    else if (read_request && wbr_empty)
633
    begin
634
        // read request is present - fill the FIFO
635
        pci_num_of_writes = $random ; // reads are of random length
636
        @(posedge pci_clock)
637
        begin
638
            if (pci_num_of_writes < `WBR_DEPTH'h2)
639
                wbr_control_in <= #`FF_DELAY `LAST ;
640
            else
641
                wbr_control_in <= #`FF_DELAY 4'h1 ;
642
 
643
            wbr_wenable <= #`FF_DELAY 1'b1 ;
644
            wbr_data_in <= #`FF_DELAY wbr_data_in + 1 ;
645
            wbr_be_in   <= #`FF_DELAY wbr_be_in + 1 ;
646
 
647
            // set wbr outgoing to new value
648
            wbr_data_outgoing <= wbr_data_in + 1 ;
649
            wbr_be_outgoing   <= wbr_be_in  + 1;
650
        end // posedge
651
 
652
        @(negedge pci_clock) ;
653
 
654
        if (wbr_control_in != `LAST)
655
        begin
656
            while ((pci_num_of_writes > 1) && (~wbr_almost_full))
657
            begin
658
                @(posedge pci_clock)
659
                begin
660
                    // prepare data for next write
661
                    wbr_data_in <= #`FF_DELAY wbr_data_in + 1 ;
662
                    wbr_be_in   <= #`FF_DELAY wbr_be_in + 1 ;
663
                    pci_num_of_writes <= pci_num_of_writes - 1 ;
664
                end // posedge
665
                @(negedge pci_clock) ; // avoid combinatorial logic for almost full monitoring
666
            end //while
667
 
668
            // write last data phase
669
            wbr_control_in <= #`FF_DELAY `LAST ;
670
            @(posedge pci_clock)
671
            begin
672
                // last data is written
673
                wbr_wenable <= #`FF_DELAY 1'b0 ;
674
                read_request <= #`FF_DELAY 1'b0 ;
675
            end //posedge
676
        end //if
677
        else
678
        begin
679
            // first is also the last data - wait for posedge and finish
680
            @(posedge pci_clock)
681
            begin
682
                wbr_wenable <= #`FF_DELAY 1'b0 ;
683
                read_request <= #`FF_DELAY 1'b0 ;
684
            end //posedge
685
        end //else
686
        @(posedge pci_clock) ; // turnaround
687
    end //else if
688
    else
689
        @(posedge pci_clock) ;
690
    end //forever
691
end //pci_completions
692
 
693
begin:timing
694
    #1000000 $stop ;
695
end //timing
696
join
697
end
698
 
699
endtask
700
 
701
WBW_WBR_FIFOS #(`WBW_DEPTH, `WBW_ADDR_LENGTH, `WBR_DEPTH, `WBR_ADDR_LENGTH) wbw_wbr
702
                     (.wb_clock_in(wb_clock), .pci_clock_in(pci_clock), .reset_in(reset),
703
                      .wbw_wenable_in(wbw_wenable), .wbw_addr_data_in(wbw_data_in),
704
                      .wbw_cbe_in(wbw_cbe_in), .wbw_control_in(wbw_control_in),
705
                      .wbw_renable_in(wbw_renable), .wbw_addr_data_out(wbw_data_out),
706
                      .wbw_cbe_out(wbw_cbe_out), .wbw_control_out(wbw_control_out),
707
                      .wbw_flush_in(1'b0), .wbw_almost_full_out(wbw_almost_full), .wbw_full_out(wbw_full),
708
                      .wbw_almost_empty_out(wbw_almost_empty), .wbw_empty_out(wbw_empty), .wbw_transaction_ready_out(wbw_transaction_ready),
709
                      .wbr_wenable_in(wbr_wenable), .wbr_data_in(wbr_data_in),
710
                      .wbr_be_in(wbr_be_in), .wbr_control_in(wbr_control_in),
711
                      .wbr_renable_in(wbr_renable), .wbr_data_out(wbr_data_out),
712
                      .wbr_be_out(wbr_be_out), .wbr_control_out(wbr_control_out),
713
                      .wbr_flush_in(wbr_flush), .wbr_almost_full_out(wbr_almost_full), .wbr_full_out(wbr_full),
714
                      .wbr_almost_empty_out(wbr_almost_empty), .wbr_empty_out(wbr_empty), .wbr_transaction_ready_out(wbr_transaction_ready)) ;
715
 
716
endmodule
717
 
718
 
719
 
720
 

powered by: WebSVN 2.1.0

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