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

Subversion Repositories mem_ctrl

[/] [mem_ctrl/] [trunk/] [bench/] [richard/] [verilog/] [checkers.v] - Blame information for rev 28

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 rherveille
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  OpenCores Memory Controller Testbench                      ////
4
////  Additional checks                                          ////
5
////                                                             ////
6
////  Author: Richard Herveille                                  ////
7
////          richard@asics.ws                                   ////
8
////                                                             ////
9
////                                                             ////
10
////  Downloaded from: http://www.opencores.org/cores/mem_ctrl/  ////
11
////                                                             ////
12
/////////////////////////////////////////////////////////////////////
13
////                                                             ////
14
//// Copyright (C) 2001, 2002 Richard Herveille                  ////
15
////                          richard@asics.ws                   ////
16
////                                                             ////
17
//// This source file may be used and distributed without        ////
18
//// restriction provided that this copyright statement is not   ////
19
//// removed from the file and that any derivative work contains ////
20
//// the original copyright notice and the associated disclaimer.////
21
////                                                             ////
22
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
23
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
24
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
25
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
26
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
27
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
28
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
29
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
30
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
31
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
32
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
33
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
34
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
35
////                                                             ////
36
/////////////////////////////////////////////////////////////////////
37
 
38
//  CVS Log
39
//
40
//  $Id: checkers.v,v 1.1 2002-03-06 15:10:34 rherveille Exp $
41
//
42
//  $Date: 2002-03-06 15:10:34 $
43
//  $Revision: 1.1 $
44
//  $Author: rherveille $
45
//  $Locker:  $
46
//  $State: Exp $
47
//
48
// Change History:
49
//               $Log: not supported by cvs2svn $
50
//
51
 
52
`include "timescale.v"
53
 
54
//////////////////////////////
55
// external bus-master model
56
//
57
 
58
module bm_model(br, bg, chk);
59
 
60
        // parameters
61
        reg on_off;
62
 
63
        // inputs
64
        output br;
65
        reg br;
66
        input  bg;
67
        input chk;
68
 
69
        integer delay;
70
 
71
        initial
72
                begin
73
                        on_off = 0;
74
                        br = 1'b0;
75
                end
76
 
77
        always
78
        begin
79
                wait(on_off)
80
 
81
                delay = ($random >> 24) +10;
82
 
83
                // wait a random moment
84
                # delay;
85
 
86
                // assert bus_request
87
                br = 1'b1;
88
                $display("External bus-master requesting bus at time %t... ", $time);
89
 
90
                // wait for assertion of bus_grant
91
                wait(bg);
92
                $display("Bus granted at time %t.", $time);
93
 
94
                // check the memory controller output_enable signal, should be negated
95
                if (chk)
96
                        $display("Memory controller output signals not in tri-state.");
97
 
98
                delay = ($random >> 24) +10;
99
 
100
                // wait a random moment
101
                # delay;
102
 
103
                // negate bus_request                                   
104
                br = 1'b0;
105
                $display("External bus-master releasing bus at time %t ...", $time);
106
 
107
                // wait for negation of bus_grant
108
                wait(!bg);
109
                $display("Bus released at time %t.", $time);
110
 
111
        end
112
endmodule
113
 
114
 
115
//
116
// WISHBONE Bus Watchdog
117
//
118
module watch_dog(clk, cyc_i, ack_i, adr_i);
119
 
120
        // parameters
121
        parameter count = 1000;
122
 
123
        // inputs
124
        input clk;
125
        input cyc_i;
126
        input ack_i;
127
        input [31:0] adr_i;
128
 
129
        // variables
130
        integer cnt;
131
 
132
        // module body
133
        always@(posedge clk)
134
                if (!cyc_i || ack_i)
135
                        cnt <= #1 count;
136
                else
137
                        begin
138
                                cnt <= #1 cnt -1;
139
 
140
                                if (cnt == 0)
141
                                        begin
142
                                                $display("\n\n WATCHDOG TIMER EXPIRED \n\n");
143
                                                $display("Time: %t, address: %h", $time, adr_i);
144
                                                $stop;
145
                                        end
146
                        end
147
endmodule
148
 
149
 
150
//
151
// Check status of Wishbone ERR_O line
152
//
153
 
154
module err_check(err, sel_par);
155
 
156
        //
157
        // inputs
158
        //
159
        input err;
160
        input sel_par;
161
 
162
        //
163
        // module body
164
        //
165
        always@(err)
166
                case (err)
167
                        1'b1:
168
                                if(sel_par)
169
                                        begin
170
                                                $display("*");
171
                                                $display("* ERROR: WISHBONE ERR_O asserted at time %t", $time);
172
                                                $display("*");
173
                                        end
174
                                else
175
                                                $display("Wishbone ERR_O asserted (ok)");
176
 
177
                        1'bx:
178
                                begin
179
                                        $display("*");
180
                                        $display("* ERROR: WISHBONE ERR_O undefined at time %t", $time);
181
                                        $display("*");
182
                                end
183
                endcase
184
endmodule
185
 
186
//
187
// Check status of Wishbone ERR_O line
188
//
189
 
190
module cs_check(cs);
191
 
192
        //
193
        // inputs
194
        //
195
        input [7:0] cs;
196
 
197
        //
198
        // module body
199
        //
200
        always@(cs)
201
        begin
202
                if ((cs[7] == 1'bx) | (cs[6] == 1'bx) | (cs[5] == 1'bx) | (cs[4] == 1'bx) |
203
                    (cs[3] == 1'bx) | (cs[2] == 1'bx) | (cs[1] == 1'bx) | (cs[0] == 1'bx) )
204
                        begin
205
                                $display("*");
206
                                $display("* ERROR: CHIP SELECT SIGNAL UNDEFINED at time %t", $time);
207
                                $display("*");
208
                        end
209
 
210
                if ((!cs[7] & !(&cs[6:0])            ) |
211
                    (!cs[6] & !(&{cs[7]  , cs[5:0]}) ) |
212
                    (!cs[5] & !(&{cs[7:6], cs[4:0]}) ) |
213
                    (!cs[4] & !(&{cs[7:5], cs[3:0]}) ) |
214
                    (!cs[3] & !(&{cs[7:4], cs[2:0]}) ) |
215
                    (!cs[2] & !(&{cs[7:3], cs[1:0]}) ) |
216
                    (!cs[1] & !(&{cs[7:2], cs[0]}  ) ) |
217
                    (!cs[0] & !(&cs[7:1])          )   )
218
                        begin
219
                                $display("*");
220
                                $display("* ERROR: MULTIPLE CHIP SELECT SIGNALS ASSERTED at time %t", $time);
221
                                $display("*");
222
                        end
223
        end
224
 
225
endmodule
226
 

powered by: WebSVN 2.1.0

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