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

Subversion Repositories cryptosorter

[/] [cryptosorter/] [trunk/] [lib/] [bsv/] [BRAMFIFO/] [mkTestBench.bsv] - Blame information for rev 5

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

Line No. Rev Author Line
1 5 kfleming
//----------------------------------------------------------------------//
2
// The MIT License
3
//
4
// Copyright (c) 2008 Kermin Fleming, kfleming@mit.edu
5
//
6
// Permission is hereby granted, free of charge, to any person
7
// obtaining a copy of this software and associated documentation
8
// files (the "Software"), to deal in the Software without
9
// restriction, including without limitation the rights to use,
10
// copy, modify, merge, publish, distribute, sublicense, and/or sell
11
// copies of the Software, and to permit persons to whom the
12
// Software is furnished to do so, subject to the following conditions:
13
//
14
// The above copyright notice and this permission notice shall be
15
// included in all copies or substantial portions of the Software.
16
//
17
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
// OTHER DEALINGS IN THE SOFTWARE.
25
//----------------------------------------------------------------------//
26
 
27
import BRAMFIFO::*;
28
import FIFOF::*;
29
import FIFO::*;
30
 
31
/***
32
 *
33
 * This module is a test harness for the BRAMFIFO verilog module.
34
 * The module compares the behavior of a BRAM based sized FIFO and a
35
 * standard sized fifo.  If their behavior differs at any point during the
36
 * long pseudo-random test bench, then a failure message is displayed.
37
 *
38
 ***/
39
 
40
 
41
(* synthesize *)
42
module mkTest (FIFOF#(Bit#(32)));
43
  FIFOF#(Bit#(32)) gold <- mkBRAMFIFOF(250);
44
  FIFO#(Bit#(32)) p <- mkSizedFIFO(6);
45
  return gold;
46
endmodule
47
 
48
 
49
module mkTestBench ();
50
  Reg#(Bit#(32)) test_counter <- mkReg(0);
51
 
52
  rule test_counter_rl;
53
    test_counter <= test_counter + 1;
54
    if(test_counter > 1000000)
55
      begin
56
        $display("PASS");
57
        $finish;
58
      end
59
  endrule
60
 
61
  for(Integer i = 2; i < 4; i = i + 1)
62
     begin
63
       FIFO#(Bit#(32)) gold <- mkSizedFIFO(i);
64
       FIFO#(Bit#(32)) test <- mkBRAMFIFO(i);
65
       Reg#(Bit#(32)) counter <- mkReg(0);
66
 
67
       rule count;
68
         counter <= counter + 1;
69
       endrule
70
 
71
       rule enq_a(counter % fromInteger(i) == 0);
72
         gold.enq(counter);
73
       endrule
74
 
75
       rule enq_b(counter % fromInteger(i) == 0);
76
         test.enq(counter);
77
       endrule
78
 
79
       for(Integer j = 2; j < 4; j = j+1)
80
          begin
81
            rule deq_check(zeroExtend(counter)%fromInteger(j) == 0);
82
              if(gold.first() != test.first())
83
                begin
84
                  $display("FAIL Not equal! g: %d t: %d i: %d j: %d", gold.first, test.first, i, j);
85
                end
86
              else
87
                begin
88
                  $display("Match: %d i:%d j:%d", gold.first, i,j);
89
                end
90
 
91
                gold.deq;
92
                test.deq;
93
 
94
             endrule
95
          end
96
     end
97
 
98
endmodule

powered by: WebSVN 2.1.0

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