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

Subversion Repositories pit

[/] [pit/] [trunk/] [bench/] [verilog/] [wb_master_model.v] - Blame information for rev 16

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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