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

Subversion Repositories xgate

[/] [xgate/] [trunk/] [bench/] [verilog/] [wb_master_model.v] - Blame information for rev 66

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

Line No. Rev Author Line
1 2 rehayes
///////////////////////////////////////////////////////////////////////
2
////                                                               ////
3
////  WISHBONE rev.B2 Wishbone Master model                        ////
4
////                                                               ////
5
////                                                               ////
6
////  Author: Richard Herveille                                    ////
7
////          richard@asics.ws                                     ////
8
////          www.asics.ws                                         ////
9
////                                                               ////
10
////  Downloaded from: http://www.opencores.org/projects/mem_ctrl  ////
11
////                                                               ////
12
///////////////////////////////////////////////////////////////////////
13
////                                                               ////
14
//// Copyright (C) 2001 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 27 rehayes
//  $Id$
41 2 rehayes
//
42 27 rehayes
//  $Date$
43
//  $Revision$
44
//  $Author$
45
//  $Locker$
46
//  $State$
47 2 rehayes
//
48
// Change History:
49
//
50
`include "timescale.v"
51
 
52
module wb_master_model  #(parameter dwidth = 32,
53
                          parameter awidth = 32)
54 20 rehayes
(
55
output reg                 cyc,
56
output reg                 stb,
57
output reg                 we,
58
output reg [dwidth/8 -1:0] sel,
59
output reg [awidth   -1:0] adr,
60
output reg [dwidth   -1:0] dout,
61
input      [dwidth   -1:0] din,
62
input                      clk,
63
input                      ack,
64
input                      rst,  // No Connect
65
input                      err,  // No Connect
66
input                      rty   // No Connect
67
);
68 2 rehayes
 
69
////////////////////////////////////////////////////////////////////
70
//
71
// Local Wires
72
//
73
 
74
reg [dwidth   -1:0] q;
75
 
76
event test_command_start;
77
event test_command_mid;
78
event test_command_end;
79
 
80 20 rehayes
event cmp_error_detect;
81
 
82 2 rehayes
////////////////////////////////////////////////////////////////////
83
//
84
// Memory Logic
85
//
86
 
87
initial
88
        begin
89
                adr  = {awidth{1'bx}};
90
                dout = {dwidth{1'bx}};
91
                cyc  = 1'b0;
92
                stb  = 1'bx;
93
                we   = 1'hx;
94
                sel  = {dwidth/8{1'bx}};
95
                #1;
96
                $display("\nINFO: WISHBONE MASTER MODEL INSTANTIATED (%m)");
97
        end
98
 
99 20 rehayes
 
100 2 rehayes
////////////////////////////////////////////////////////////////////
101
//
102
// Wishbone write cycle
103
//
104
 
105
task wb_write;
106
        input   delay;
107
        integer delay;
108
 
109 35 rehayes
        input   [awidth   -1:0] a;
110
        input   [dwidth   -1:0] d;
111
        input   [dwidth/8 -1:0] s;
112 2 rehayes
 
113
        begin
114
                -> test_command_start;
115
                // wait initial delay
116
                repeat(delay) @(posedge clk);
117
 
118
                // assert wishbone signal
119
                #1;
120
                adr  = a;
121
                dout = d;
122
                cyc  = 1'b1;
123
                stb  = 1'b1;
124
                we   = 1'b1;
125 35 rehayes
                sel  = s;
126 2 rehayes
                @(posedge clk);
127
                -> test_command_mid;
128
 
129
                // wait for acknowledge from slave
130
                while(~ack)     @(posedge clk);
131
                -> test_command_mid;
132
 
133
                // negate wishbone signals
134
                #1;
135
                cyc  = 1'b0;
136
                stb  = 1'bx;
137
                adr  = {awidth{1'bx}};
138
                dout = {dwidth{1'bx}};
139
                we   = 1'hx;
140
                sel  = {dwidth/8{1'bx}};
141
                -> test_command_end;
142
 
143
        end
144
endtask
145
 
146
////////////////////////////////////////////////////////////////////
147
//
148
// Wishbone read cycle
149
//
150
 
151
task wb_read;
152
        input   delay;
153
        integer delay;
154
 
155 35 rehayes
        input   [awidth   -1:0] a;
156
        output  [dwidth   -1:0] d;
157
        input   [dwidth/8 -1:0] s;
158 2 rehayes
 
159
        begin
160
 
161
                // wait initial delay
162
                repeat(delay) @(posedge clk);
163
 
164
                // assert wishbone signals
165
                #1;
166
                adr  = a;
167
                dout = {dwidth{1'bx}};
168
                cyc  = 1'b1;
169
                stb  = 1'b1;
170
                we   = 1'b0;
171 35 rehayes
                sel  = s;
172 2 rehayes
                @(posedge clk);
173
 
174
                // wait for acknowledge from slave
175
                while(~ack)     @(posedge clk);
176
 
177
                // negate wishbone signals
178
                d    = din; // Grab the data on the posedge of clock
179
                #1;         // Delay the clearing (hold time of the control signals
180
                cyc  = 1'b0;
181
                stb  = 1'bx;
182
                adr  = {awidth{1'bx}};
183
                dout = {dwidth{1'bx}};
184
                we   = 1'hx;
185
                sel  = {dwidth/8{1'bx}};
186
 
187
        end
188
endtask
189
 
190
////////////////////////////////////////////////////////////////////
191
//
192
// Wishbone compare cycle (read data from location and compare with expected data)
193
//
194
 
195
task wb_cmp;
196
        input   delay;
197
        integer delay;
198
 
199 35 rehayes
        input [awidth   -1:0] a;
200
        input [dwidth   -1:0] d_exp;
201
        input [dwidth/8 -1:0] s;
202 2 rehayes
 
203
        begin
204 35 rehayes
                wb_read (delay, a, q, s);
205 2 rehayes
 
206
                if (d_exp !== q)
207 20 rehayes
                  begin
208
                        -> cmp_error_detect;
209 2 rehayes
                        $display("Data compare error at address %h. Received %h, expected %h at time %t", a, q, d_exp, $time);
210 20 rehayes
                  end
211 2 rehayes
        end
212
endtask
213
 
214
endmodule
215
 
216
 

powered by: WebSVN 2.1.0

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