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

Subversion Repositories ethmac10g

[/] [ethmac10g/] [trunk/] [bench/] [management_tb.v] - Blame information for rev 72

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 45 fisher5090
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////
3
////                                                                                                                                                                    ////
4
//// MODULE NAME: testbech for management module                                        ////
5
////                                                                                                                                                                    ////
6
//// DESCRIPTION: Test Read & Write Internal Registers. Test MDIO ////
7
////              signals, including Read & Write                 ////
8
////                                                                                                                                                                    ////
9
//// This file is part of the 10 Gigabit Ethernet IP core project ////
10
////  http://www.opencores.org/projects/ethmac10g/                                              ////
11
////                                                                                                                                                                    ////
12
//// AUTHOR(S):                                                                                                                                 ////
13
//// Zheng Cao                                                               ////
14
////                                                                                                    ////
15
//////////////////////////////////////////////////////////////////////
16
////                                                                                                                                                                    ////
17
//// Copyright (c) 2005 AUTHORS.  All rights reserved.                     ////
18
////                                                                                                                                                                    ////
19
//// This source file may be used and distributed without         ////
20
//// restriction provided that this copyright statement is not    ////
21
//// removed from the file and that any derivative work contains  ////
22
//// the original copyright notice and the associated disclaimer. ////
23
////                                                              ////
24
//// This source file is free software; you can redistribute it   ////
25
//// and/or modify it under the terms of the GNU Lesser General   ////
26
//// Public License as published by the Free Software Foundation; ////
27
//// either version 2.1 of the License, or (at your option) any   ////
28
//// later version.                                               ////
29
////                                                              ////
30
//// This source is distributed in the hope that it will be       ////
31
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
32
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
33
//// PURPOSE.  See the GNU Lesser General Public License for more ////
34
//// details.                                                     ////
35
////                                                              ////
36
//// You should have received a copy of the GNU Lesser General    ////
37
//// Public License along with this source; if not, download it   ////
38
//// from http://www.opencores.org/lgpl.shtml                                                   ////
39
////                                                                                                                                                                    ////
40
//////////////////////////////////////////////////////////////////////
41
//
42
// CVS REVISION HISTORY:
43
//
44
// $Log: not supported by cvs2svn $
45
// Revision 1.1  2006/06/06 05:09:46  fisher5090
46
// no message
47
//
48
// Revision 1.1  2005/12/25 16:43:10  Zheng Cao
49
// 
50
// 
51
//
52
//////////////////////////////////////////////////////////////////////
53
 
54
module manage_tst_v;
55
 
56
        // Inputs
57
        reg mgmt_clk;
58
        reg rxclk;
59
        reg txclk;
60
        reg [1:0] mgmt_opcode;
61
        reg [9:0] mgmt_addr;
62
        reg [31:0] mgmt_wr_data;
63
        reg mgmt_miim_sel;
64
        reg mgmt_req;
65
        reg [18:0] rxStatRegPlus;
66
        reg [14:0] txStatRegPlus;
67
        reg reset;
68
 
69
        // Outputs
70
        wire [31:0] mgmt_rd_data;
71
        wire mgmt_miim_rdy;
72
        wire [52:0] cfgRxRegData;
73
        wire [9:0] cfgTxRegData;
74
        wire mdc;
75
        wire mdio;
76
 
77
        // Management configuration register address (0x340)
78
        reg [8:0] CONFIG_MANAGEMENT_ADD;
79
 
80
   // Flow control configuration register address (0x2C0)
81
   reg [8:0] CONFIG_FLOW_CTRL_ADD;
82
 
83
   // Reconciliation sublayer configuration register address (0x300)
84
        reg [8:0] CONFIG_RECONCILIATION_ADD;
85
 
86
   // Receiver configuration register address (0x200)
87
   reg [8:0] RECEIVER_ADD0;
88
 
89
   // Receiver configuration register address (0x240)
90
   reg [8:0] RECEIVER_ADD1;
91
 
92
   // Transmitter configuration register address        (0x280)
93
   reg [8:0] TRANSMITTER_ADD;
94
 
95
 
96
 
97
  // Set up constants values....
98
  initial
99
  begin
100
 
101
    // Management configuration register address (0x340)
102
    CONFIG_MANAGEMENT_ADD = 9'b101000000;
103
 
104
         // Reconciliation sublayer configuration register address (0x300)
105
    CONFIG_RECONCILIATION_ADD = 9'b100000000;
106
 
107
    // Flow control configuration register address (0x2C0)
108
    CONFIG_FLOW_CTRL_ADD  = 9'b011000000;
109
 
110
    // Receiver configuration register address (0x200)
111
         RECEIVER_ADD0 = 9'b000000000;
112
    // Receiver configuration register address  (0x240)
113
    RECEIVER_ADD1 = 9'b001000000;
114
 
115
    // Transmitter configuration register address       (0x280)
116
    TRANSMITTER_ADD = 9'b010000000;
117
 
118
  end
119
 
120
        management_top uut (
121
                .mgmt_clk(mgmt_clk),
122
                .rxclk(rxclk),
123
                .txclk(txclk),
124
                .mgmt_opcode(mgmt_opcode),
125
                .mgmt_addr(mgmt_addr),
126
                .mgmt_wr_data(mgmt_wr_data),
127
                .mgmt_rd_data(mgmt_rd_data),
128
                .mgmt_miim_sel(mgmt_miim_sel),
129
                .mgmt_req(mgmt_req),
130
                .mgmt_miim_rdy(mgmt_miim_rdy),
131
                .rxStatRegPlus(rxStatRegPlus),
132
                .txStatRegPlus(txStatRegPlus),
133
                .cfgRxRegData(cfgRxRegData),
134
                .cfgTxRegData(cfgTxRegData),
135
                .mdc(mdc),
136
                .mdio(mdio),
137
                .reset(reset)
138
        );
139
 
140
        initial begin
141
                // Initialize Inputs
142
                rxclk = 0;
143
                txclk = 0;
144
                rxStatRegPlus = 0;
145
                txStatRegPlus = 0;
146
                reset = 1;
147
 
148
                // Wait 100 ns for global reset to finish
149
                #100;
150
      reset = 0;
151
                // Add stimulus here
152
 
153
        end
154
 
155
  initial                 // drives mgmt_clk
156
  begin
157
    mgmt_clk <= 1'b0;
158
        #2000;
159
    forever
160
    begin
161
      mgmt_clk <= 1'b0;
162
      #12000;
163
      mgmt_clk <= 1'b1;
164
      #12000;
165
    end
166
  end
167
 
168
  initial
169
  begin : p_management
170
    integer I;
171
    mgmt_req       <= 1'b0;
172
    mgmt_miim_sel  <= 1'b0;
173
    mgmt_opcode    <= 2'b11;
174
    mgmt_addr      <= 32'h0;
175
    mgmt_wr_data   <= 32'h0;
176
 
177
    // reset the core
178
    $display("** Note: Resetting core...");
179
 
180
    reset <= 1'b1;
181
    #210000
182
    reset <= 1'b0;
183
    #500000
184
 
185
    //------------------------------------------------------------------
186
    // set up MDC frequency. Write 2E to Management configuration  
187
    // (register Add=340). This will enable MDIO and set MDC to 2.3 MHz
188
    //------------------------------------------------------------------
189
    $display("** Note: Setting MDC Frequency to 2.3MHZ....");
190
 
191
    // set CLOCK_DIVIDE value to 9 dec. for 41.66. MHz mgmt_CLK and enable MDIO
192
    @(negedge mgmt_clk)
193
    mgmt_addr[9]   <= 1'b1;
194
    mgmt_addr[8:0] <= CONFIG_MANAGEMENT_ADD;
195
    mgmt_miim_sel  <= 1'b0;
196
    mgmt_opcode    <= 2'b01;
197
    mgmt_wr_data   <= 32'b00000000000000000000000000101001;
198
 
199
    //------------------------------------------------------------------
200
    // Reading Management Configuration Register (Add=340).  
201
    //------------------------------------------------------------------
202
    $display("** Note: Reading Management Configuration  Register....");
203
 
204
    // Read from management configuration register
205
    @(negedge mgmt_clk)
206
    mgmt_addr[9]   <= 1'b1;
207
    mgmt_addr[8:0] <= CONFIG_MANAGEMENT_ADD;
208
    mgmt_miim_sel  <= 1'b0;
209
    mgmt_opcode    <= 2'b11;
210
 
211
    //------------------------------------------------------------------
212
    // Disable Flow Control. Set top 3 bits of the flow control 
213
    // configuration register (Add=2C0) to zero therefore disabling tx 
214
    // and rx flow control. 
215
    //------------------------------------------------------------------
216
    $display("** Note: Disabling tx and rx flow control...");
217
 
218
    // Turn off flow control by writing relevant bits into the register    
219
    @(negedge mgmt_clk)
220
    mgmt_addr[9]   <= 1'b1;
221
    mgmt_addr[8:0] <= CONFIG_FLOW_CTRL_ADD;
222
    mgmt_miim_sel  <= 1'b0;
223
    mgmt_opcode    <= 2'b01;
224
    mgmt_wr_data   <= 32'b00000000000000000000001100000000;
225
 
226
    //------------------------------------------------------------------
227
    // Reading Flow Control Configuration Register (Add=2C0).  
228
    //------------------------------------------------------------------
229
    $display("** Note: Reading Flow Control Configuration  Register....");
230
 
231
    // Read from flow control register
232
    @(negedge mgmt_clk)
233
    mgmt_addr[9]   <= 1'b1;
234
    mgmt_addr[8:0] <= CONFIG_RECONCILIATION_ADD;
235
    mgmt_miim_sel  <= 1'b0;
236
    mgmt_opcode    <= 2'b11;
237
 
238
         // Read from statistics register 0
239
    @(negedge mgmt_clk)
240
         mgmt_req <= 1'b1;
241
    mgmt_addr[9]   <= 1'b0;
242
    mgmt_addr[8:0] <= 0;
243
    mgmt_miim_sel  <= 1'b0;
244
    mgmt_opcode    <= 2'b11;
245
 
246
 
247
         @(negedge mgmt_clk)
248
         mgmt_req <= 1'b0;
249
    mgmt_addr[9]   <= 1'b0;
250
    mgmt_addr[8:0] <= 1;
251
    mgmt_miim_sel  <= 1'b0;
252
    mgmt_opcode    <= 2'b11;
253
 
254
         // Read from statistics register 1
255
         @(negedge mgmt_clk)
256
         mgmt_req <= 1'b1;
257
    mgmt_addr[9]   <= 1'b0;
258
    mgmt_addr[8:0] <= 1;
259
    mgmt_miim_sel  <= 1'b0;
260
    mgmt_opcode    <= 2'b11;
261
 
262
         @(negedge mgmt_clk)
263
         mgmt_req <= 1'b0;
264
    mgmt_addr[9]   <= 1'b0;
265
    mgmt_addr[8:0] <= 1;
266
    mgmt_miim_sel  <= 1'b0;
267
    mgmt_opcode    <= 2'b11;
268
 
269
         // MDIO WRITE
270
    @(negedge mgmt_clk)
271
         mgmt_req <= 1'b1;
272
    mgmt_addr[9]   <= 1'b1;
273
    mgmt_addr[8:0] <= CONFIG_FLOW_CTRL_ADD;
274
    mgmt_miim_sel  <= 1'b1;
275
    mgmt_opcode    <= 2'b01;
276
         mgmt_wr_data   <= 32'b00000000000000000000001100110000;
277
         #50000
278
         @(negedge mgmt_clk)
279
         mgmt_req <= 1'b0;
280
    wait (mgmt_miim_rdy ==1'b1);
281
         #50000
282
 
283
    // MDIO READ
284
    @(negedge mgmt_clk)
285
         mgmt_req <= 1'b1;
286
    mgmt_addr[9]   <= 1'b1;
287
    mgmt_addr[8:0] <= CONFIG_FLOW_CTRL_ADD;
288
    mgmt_miim_sel  <= 1'b1;
289
    mgmt_opcode    <= 2'b10;
290
         mgmt_wr_data   <= 32'b00000000000000000000001100110000;
291
 
292
         @(negedge mgmt_clk)
293
         mgmt_req <= 1'b0;
294
 
295
    #100000
296
    // test process here is done
297
    $display("** failure: Simulation Stopped");
298
    $stop;
299
 
300
  end
301
 
302
 
303
endmodule
304
 

powered by: WebSVN 2.1.0

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