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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [bench/] [verilog/] [tb_eth_top.v] - Blame information for rev 23

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

Line No. Rev Author Line
1 22 mohor
///////////3///////////////////////////////////////////////////////////
2 15 mohor
////                                                              ////
3
////  tb_eth_top.v                                                ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/cores/ethmac/                      ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Igor Mohor (igorM@opencores.org)                      ////
10
////                                                              ////
11
////  All additional information is avaliable in the Readme.txt   ////
12
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16
//// Copyright (C) 2001 Authors                                   ////
17
////                                                              ////
18
//// This source file may be used and distributed without         ////
19
//// restriction provided that this copyright statement is not    ////
20
//// removed from the file and that any derivative work contains  ////
21
//// the original copyright notice and the associated disclaimer. ////
22
////                                                              ////
23
//// This source file is free software; you can redistribute it   ////
24
//// and/or modify it under the terms of the GNU Lesser General   ////
25
//// Public License as published by the Free Software Foundation; ////
26
//// either version 2.1 of the License, or (at your option) any   ////
27
//// later version.                                               ////
28
////                                                              ////
29
//// This source is distributed in the hope that it will be       ////
30
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
31
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
32
//// PURPOSE.  See the GNU Lesser General Public License for more ////
33
//// details.                                                     ////
34
////                                                              ////
35
//// You should have received a copy of the GNU Lesser General    ////
36
//// Public License along with this source; if not, download it   ////
37
//// from http://www.opencores.org/lgpl.shtml                     ////
38
////                                                              ////
39
//////////////////////////////////////////////////////////////////////
40
//
41
// CVS Revision History
42
//
43
// $Log: not supported by cvs2svn $
44 23 mohor
// Revision 1.4  2001/10/19 08:46:53  mohor
45
// eth_timescale.v changed to timescale.v This is done because of the
46
// simulation of the few cores in a one joined project.
47
//
48 22 mohor
// Revision 1.3  2001/09/24 14:55:49  mohor
49
// Defines changed (All precede with ETH_). Small changes because some
50
// tools generate warnings when two operands are together. Synchronization
51
// between two clocks domains in eth_wishbonedma.v is changed (due to ASIC
52
// demands).
53
//
54 19 mohor
// Revision 1.2  2001/08/15 14:04:30  mohor
55
// Signal names changed on the top level for easier pad insertion (ASIC).
56
//
57 17 mohor
// Revision 1.1  2001/08/06 14:41:09  mohor
58
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
59
// Include files fixed to contain no path.
60
// File names and module names changed ta have a eth_ prologue in the name.
61
// File eth_timescale.v is used to define timescale
62
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
63
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
64
// and Mdo_OE. The bidirectional signal must be created on the top level. This
65
// is done due to the ASIC tools.
66
//
67 15 mohor
// Revision 1.1  2001/07/30 21:46:09  mohor
68
// Directory structure changed. Files checked and joind together.
69
//
70
//
71
//
72
//
73
//
74
 
75
 
76
 
77
`include "eth_defines.v"
78 22 mohor
`include "timescale.v"
79 15 mohor
 
80
module tb_eth_top();
81
 
82
 
83
parameter Tp = 1;
84
 
85
 
86
reg           WB_CLK_I;
87
reg           WB_RST_I;
88
reg   [31:0]  WB_DAT_I;
89
 
90
reg   [31:0]  WB_ADR_I;
91
reg    [3:0]  WB_SEL_I;
92
reg           WB_WE_I;
93
reg           WB_CYC_I;
94
reg           WB_STB_I;
95
reg    [1:0]  WB_ACK_I;
96
 
97
wire  [31:0]  WB_DAT_O;
98
wire          WB_ACK_O;
99
wire          WB_ERR_O;
100
wire   [1:0]  WB_REQ_O;
101
wire   [1:0]  WB_ND_O;
102
wire          WB_RD_O;
103
 
104
reg           MTxClk;
105
wire   [3:0]  MTxD;
106
wire          MTxEn;
107
wire          MTxErr;
108
 
109
reg           MRxClk;
110
reg    [3:0]  MRxD;
111
reg           MRxDV;
112
reg           MRxErr;
113
reg           MColl;
114
reg           MCrs;
115
 
116
reg           Mdi_I;
117
wire          Mdo_O;
118
wire          Mdo_OE;
119
wire          Mdc_O;
120
 
121
 
122
 
123
reg GSR;
124
 
125
reg WishboneBusy;
126
reg StartTB;
127
reg [9:0] TxBDIndex;
128
reg [9:0] RxBDIndex;
129
 
130
 
131
 
132
// Connecting Ethernet top module
133
 
134
eth_top ethtop
135
(
136
  // WISHBONE common
137 17 mohor
  .wb_clk_i(WB_CLK_I), .wb_rst_i(WB_RST_I), .wb_dat_i(WB_DAT_I), .wb_dat_o(WB_DAT_O),
138 15 mohor
 
139
  // WISHBONE slave
140 23 mohor
        .wb_adr_i(WB_ADR_I[11:2]), .wb_sel_i(WB_SEL_I), .wb_we_i(WB_WE_I),   .wb_cyc_i(WB_CYC_I),
141 17 mohor
        .wb_stb_i(WB_STB_I), .wb_ack_o(WB_ACK_O), .wb_err_o(WB_ERR_O), .wb_req_o(WB_REQ_O),
142
        .wb_ack_i(WB_ACK_I), .wb_nd_o(WB_ND_O),   .wb_rd_o(WB_RD_O),
143 15 mohor
 
144
  //TX
145 19 mohor
  .mtx_clk_pad_i(MTxClk), .mtxd_pad_o(MTxD), .mtxen_pad_o(MTxEn), .mtxerr_pad_o(MTxErr),
146 15 mohor
 
147
  //RX
148 19 mohor
  .mrx_clk_pad_i(MRxClk), .mrxd_pad_i(MRxD), .mrxdv_pad_i(MRxDV), .mrxerr_pad_i(MRxErr),
149 17 mohor
  .mcoll_pad_i(MColl), .mcrs_pad_i(MCrs),
150 15 mohor
 
151
  // MIIM
152 22 mohor
  .mdc_pad_o(Mdc_O), .md_pad_i(Mdi_I), .md_pad_o(Mdo_O), .md_padoen_o(Mdo_OE),
153
 
154
  .int_o()
155 15 mohor
);
156
 
157
 
158
 
159
 
160
 
161
 
162
 
163
initial
164
begin
165
  WB_CLK_I  =  1'b0;
166 19 mohor
  WB_DAT_I  = 32'h0;
167
  WB_ADR_I  = 32'h0;
168
  WB_SEL_I  =  4'h0;
169
  WB_WE_I   =  1'b0;
170 15 mohor
  WB_CYC_I  =  1'b0;
171
  WB_STB_I  =  1'b0;
172
  WB_ACK_I  =  2'h0;
173
  MTxClk    =  1'b0;
174
  MRxClk    =  1'b0;
175
  MRxD      =  4'h0;
176
  MRxDV     =  1'b0;
177
  MRxErr    =  1'b0;
178
  MColl     =  1'b0;
179
  MCrs      =  1'b0;
180
  Mdi_I     =  1'b0;
181
 
182
  WishboneBusy = 1'b0;
183
  TxBDIndex = 10'h0;
184
  RxBDIndex = 10'h0;
185
end
186
 
187
 
188
// Reset pulse
189
initial
190
begin
191 19 mohor
  GSR           =  1'b1;
192
  WB_RST_I      =  1'b1;
193 15 mohor
  #100 WB_RST_I =  1'b1;
194
  GSR           =  1'b1;
195
  #100 WB_RST_I =  1'b0;
196
  GSR           =  1'b0;
197
  #100 StartTB  =  1'b1;
198
end
199
 
200
 
201
assign glbl.GSR = GSR;
202
 
203
 
204
 
205
// Generating WB_CLK_I clock
206
always
207
begin
208 19 mohor
//  forever #5 WB_CLK_I = ~WB_CLK_I;  // 2*5 ns -> 100.0 MHz    
209 15 mohor
//  forever #10 WB_CLK_I = ~WB_CLK_I;  // 2*10 ns -> 50.0 MHz    
210
  forever #15 WB_CLK_I = ~WB_CLK_I;  // 2*10 ns -> 33.3 MHz    
211
//  forever #18 WB_CLK_I = ~WB_CLK_I;  // 2*18 ns -> 27.7 MHz    
212
//  forever #100 WB_CLK_I = ~WB_CLK_I;
213
end
214
 
215
// Generating MTxClk clock
216
always
217
begin
218
  #3 forever #20 MTxClk = ~MTxClk;   // 2*20 ns -> 25 MHz
219
//  #3 forever #200 MTxClk = ~MTxClk;
220
end
221
 
222
// Generating MRxClk clock
223
always
224
begin
225
  #16 forever #20 MRxClk = ~MRxClk;   // 2*20 ns -> 25 MHz
226
//  #16 forever #250 MRxClk = ~MRxClk;
227
end
228
 
229
 
230
 
231
initial
232
begin
233
  wait(StartTB);  // Start of testbench
234
 
235 22 mohor
  WishboneWrite(32'h00000800, {26'h0, `ETH_MODER_ADR<<2});     // r_Rst = 1
236
  WishboneWrite(32'h00000000, {26'h0, `ETH_MODER_ADR<<2});     // r_Rst = 0
237
  WishboneWrite(32'h00000080, {26'h0, `ETH_RX_BD_ADR_ADR<<2}); // r_RxBDAddress = 0x80
238
  WishboneWrite(32'h0002A443, {26'h0, `ETH_MODER_ADR<<2});     // RxEn, Txen, FullD, CrcEn, Pad, DmaEn, r_IFG
239
  WishboneWrite(32'h00000004, {26'h0, `ETH_CTRLMODER_ADR<<2}); //r_TxFlow = 1
240 15 mohor
 
241
 
242
 
243
 
244
  SendPacket(16'h0015, 1'b0);
245
  SendPacket(16'h0043, 1'b1);   // Control frame
246
  SendPacket(16'h0025, 1'b0);
247
  SendPacket(16'h0045, 1'b0);
248
  SendPacket(16'h0025, 1'b0);
249
 
250
 
251
  ReceivePacket(16'h0012, 1'b1);    // Initializes RxBD and then Sends a control packet on the MRxD[3:0] signals.
252
  ReceivePacket(16'h0011, 1'b0);    // Initializes RxBD and then generates traffic on the MRxD[3:0] signals.
253
  ReceivePacket(16'h0016, 1'b0);    // Initializes RxBD and then generates traffic on the MRxD[3:0] signals.
254
  ReceivePacket(16'h0017, 1'b0);    // Initializes RxBD and then generates traffic on the MRxD[3:0] signals.
255
  ReceivePacket(16'h0018, 1'b0);    // Initializes RxBD and then generates traffic on the MRxD[3:0] signals.
256
 
257
 
258 22 mohor
  WishboneRead({26'h0, `ETH_MODER_ADR});   // Read from MODER register
259 15 mohor
 
260 23 mohor
  WishboneRead({24'h04, (8'h0<<2)});       // Read from TxBD register
261
  WishboneRead({24'h04, (8'h1<<2)});       // Read from TxBD register
262
  WishboneRead({24'h04, (8'h2<<2)});       // Read from TxBD register
263
  WishboneRead({24'h04, (8'h3<<2)});       // Read from TxBD register
264
  WishboneRead({24'h04, (8'h4<<2)});       // Read from TxBD register
265 15 mohor
 
266 23 mohor
  WishboneRead({22'h01, (10'h80<<2)});       // Read from RxBD register
267
  WishboneRead({22'h01, (10'h81<<2)});       // Read from RxBD register
268
  WishboneRead({22'h01, (10'h82<<2)});       // Read from RxBD register
269
  WishboneRead({22'h01, (10'h83<<2)});       // Read from RxBD register
270
  WishboneRead({22'h01, (10'h84<<2)});       // Read from RxBD register
271 15 mohor
 
272
  #10000 $stop;
273
end
274
 
275
 
276
 
277
 
278
 
279
 
280
 
281
task WishboneWrite;
282
  input [31:0] Data;
283
  input [31:0] Address;
284
  integer ii;
285
 
286
  begin
287
    wait (~WishboneBusy);
288
    WishboneBusy = 1;
289
    @ (posedge WB_CLK_I);
290
    #1;
291
    WB_ADR_I = Address;
292
    WB_DAT_I = Data;
293
    WB_WE_I  = 1'b1;
294
    WB_CYC_I = 1'b1;
295
    WB_STB_I = 1'b1;
296
    WB_SEL_I = 4'hf;
297
 
298 19 mohor
//    for(ii=0; (ii<20 & ~WB_ACK_O); ii=ii+1)   // Response on the WISHBONE is limited to 20 WB_CLK_I cycles
299
//    begin
300
//      @ (posedge WB_CLK_I);
301
//    end
302 15 mohor
 
303 19 mohor
//    if(ii==20)
304
//      begin
305
//        $display("\nERROR: Task WishboneWrite(Data=0x%0h, Address=0x%0h): Too late or no appeariance of the WB_ACK_O signal, (Time=%0t)", 
306
//          Data, Address, $time);
307
//        #50 $stop;
308
//      end
309 15 mohor
 
310 19 mohor
    wait(WB_ACK_O);   // waiting for acknowledge response
311
 
312
    // Writing information about the access to the screen
313 15 mohor
    @ (posedge WB_CLK_I);
314 23 mohor
      if(~Address[11] & ~Address[10])
315 22 mohor
        $write("\nWrite to register (Data: 0x%x, Reg. Addr: 0x%0x)", Data, Address);
316 15 mohor
      else
317 23 mohor
      if(~Address[11] & Address[10])
318 15 mohor
        if(Address[9:2] < tb_eth_top.ethtop.r_RxBDAddress)
319
          begin
320 22 mohor
            $write("\nWrite to TxBD (Data: 0x%x, TxBD Addr: 0x%0x)\n", Data, Address);
321 23 mohor
            if(Data[9])
322 15 mohor
              $write("Send Control packet (PAUSE = 0x%0h)\n", Data[31:16]);
323
          end
324
        else
325 22 mohor
          $write("\nWrite to RxBD (Data: 0x%x, RxBD Addr: 0x%0x)", Data, Address);
326 15 mohor
      else
327 22 mohor
        $write("\nWB write ??????????????     Data: 0x%x      Addr: 0x%0x", Data, Address);
328 15 mohor
    #1;
329
    WB_ADR_I = 32'hx;
330
    WB_DAT_I = 32'hx;
331
    WB_WE_I  = 1'bx;
332
    WB_CYC_I = 1'b0;
333
    WB_STB_I = 1'b0;
334
    WB_SEL_I = 4'hx;
335
    #5 WishboneBusy = 0;
336
  end
337
endtask
338
 
339
 
340
task WishboneRead;
341
  input [31:0] Address;
342
  reg   [31:0] Data;
343
  integer ii;
344
 
345
  begin
346
    wait (~WishboneBusy);
347
    WishboneBusy = 1;
348
    @ (posedge WB_CLK_I);
349
    #1;
350
    WB_ADR_I = Address;
351
    WB_WE_I  = 1'b0;
352
    WB_CYC_I = 1'b1;
353
    WB_STB_I = 1'b1;
354
    WB_SEL_I = 4'hf;
355
 
356
    for(ii=0; (ii<20 & ~WB_ACK_O); ii=ii+1)   // Response on the WISHBONE is limited to 20 WB_CLK_I cycles
357
    begin
358
      @ (posedge WB_CLK_I);
359
      Data = WB_DAT_O;
360
    end
361
 
362
    if(ii==20)
363
      begin
364
        $display("\nERROR: Task WishboneRead(Address=0x%0h): Too late or no appeariance of the WB_ACK_O signal, (Time=%0t)",
365
          Address, $time);
366
        #50 $stop;
367
      end
368
 
369
    @ (posedge WB_CLK_I);
370 23 mohor
      if(~Address[11] & ~Address[10])
371 22 mohor
        $write("\nRead from register (Data: 0x%x, Reg. Addr: 0x%0x)", Data, Address);
372 15 mohor
      else
373 23 mohor
      if(~Address[11] & Address[10])
374 15 mohor
        if(Address[9:2] < tb_eth_top.ethtop.r_RxBDAddress)
375
          begin
376 22 mohor
            $write("\nRead from TxBD (Data: 0x%x, TxBD Addr: 0x%0x)", Data, Address);
377 15 mohor
          end
378
        else
379 22 mohor
          $write("\nRead from RxBD (Data: 0x%x, RxBD Addr: 0x%0x)", Data, Address);
380 15 mohor
      else
381 22 mohor
        $write("\nWB read  ?????????    Data: 0x%x      Addr: 0x%0x", Data, Address);
382 15 mohor
    #1;
383
    WB_ADR_I = 32'hx;
384
    WB_WE_I  = 1'bx;
385
    WB_CYC_I = 1'b0;
386
    WB_STB_I = 1'b0;
387
    WB_SEL_I = 4'hx;
388
    #5 WishboneBusy = 0;
389
  end
390
endtask
391
 
392
 
393
 
394
 
395
task SendPacket;
396
  input [15:0]  Length;
397
  input         ControlFrame;
398
  reg           Wrap;
399
  reg [31:0]    TempAddr;
400
  reg [31:0]    TempData;
401
 
402
  begin
403
    if(TxBDIndex == 3)    // Only 4 buffer descriptors are used
404
      Wrap = 1'b1;
405
    else
406
      Wrap = 1'b0;
407
 
408 23 mohor
    TempAddr = {22'h01, (TxBDIndex<<2)};
409 22 mohor
    TempData = {Length[15:0], 1'b1, 1'b0, Wrap, 3'h0, ControlFrame, 1'b0, TxBDIndex[7:0]};  // Ready and Wrap = 1
410 15 mohor
 
411
    #1;
412
    if(TxBDIndex == 3)    // Only 4 buffer descriptors are used
413
      TxBDIndex = 0;
414
    else
415
      TxBDIndex = TxBDIndex + 1;
416
 
417
    fork
418
      begin
419
        WishboneWrite(TempData, TempAddr); // Writing status to TxBD
420
      end
421
 
422
      begin
423
        if(~ControlFrame)
424
        WaitingForTxDMARequest(4'h1, Length); // Delay, DMALength
425
      end
426
    join
427
  end
428
endtask
429
 
430
 
431
 
432
task ReceivePacket;    // Initializes RxBD and then generates traffic on the MRxD[3:0] signals.
433
  input [15:0] LengthRx;
434
  input        RxControlFrame;
435
  reg        WrapRx;
436
  reg [31:0] TempRxAddr;
437
  reg [31:0] TempRxData;
438
  reg abc;
439
  begin
440
    if(RxBDIndex == 3)    // Only 4 buffer descriptors are used
441
      WrapRx = 1'b1;
442
    else
443
      WrapRx = 1'b0;
444
 
445 23 mohor
    TempRxAddr = {22'h01, ((tb_eth_top.ethtop.r_RxBDAddress + RxBDIndex)<<2)};
446 15 mohor
 
447 22 mohor
    TempRxData = {LengthRx[15:0], 1'b1, 1'b0, WrapRx, 5'h0, RxBDIndex[7:0]};  // Ready and WrapRx = 1 or 0
448 15 mohor
 
449
    #1;
450
    if(RxBDIndex == 3)    // Only 4 buffer descriptors are used
451
      RxBDIndex = 0;
452
    else
453
      RxBDIndex = RxBDIndex + 1;
454
 
455
    abc=1;
456
    WishboneWrite(TempRxData, TempRxAddr); // Writing status to RxBD
457
    abc=0;
458
    fork
459
      begin
460
        #200;
461
        if(RxControlFrame)
462
          GetControlDataOnMRxD(LengthRx); // LengthRx = PAUSE timer value.
463
        else
464
          GetDataOnMRxD(LengthRx); // LengthRx bytes is comming on MRxD[3:0] signals
465
      end
466
 
467
      begin
468
        if(RxControlFrame)
469
          WaitingForRxDMARequest(4'h1, 16'h40); // Delay, DMALength = 64 bytes.
470
        else
471
          WaitingForRxDMARequest(4'h1, LengthRx); // Delay, DMALength
472
      end
473
    join
474
  end
475
endtask
476
 
477
 
478
 
479
task WaitingForTxDMARequest;
480
  input [3:0] Delay;
481
  input [15:0] DMALength;
482
  integer pp;
483
  reg [7:0]a, b, c, d;
484
 
485
  for(pp=0; pp*4<DMALength; pp=pp+1)
486
  begin
487
    a = 4*pp[7:0]+3;
488
    b = 4*pp[7:0]+2;
489
    c = 4*pp[7:0]+1;
490
    d = 4*pp[7:0]  ;
491
    @ (posedge WB_REQ_O[0]);
492
    repeat(Delay) @(posedge WB_CLK_I);
493
 
494
    wait (~WishboneBusy);
495
    WishboneBusy = 1;
496
    #1;
497
    WB_DAT_I = {a, b, c, d};
498 23 mohor
//    WB_ADR_I = {20'h20, pp[11:0]};
499
    WB_ADR_I = {22'h02, pp[9:0]};
500 15 mohor
    $display("task WaitingForTxDMARequest: pp=%0d, WB_ADR_I=0x%0h, WB_DAT_I=0x%0h", pp, WB_ADR_I, WB_DAT_I);
501
 
502
    WB_WE_I  = 1'b1;
503
    WB_CYC_I = 1'b1;
504
    WB_STB_I = 1'b1;
505
    WB_SEL_I = 4'hf;
506
    WB_ACK_I[0] = 1'b1;
507
 
508
    @ (posedge WB_CLK_I);
509
    #1;
510
    WB_ADR_I = 32'hx;
511
    WB_DAT_I = 32'hx;
512
    WB_WE_I  = 1'bx;
513
    WB_CYC_I = 1'b0;
514
    WB_STB_I = 1'b0;
515
    WB_SEL_I = 4'hx;
516
    WB_ACK_I[0] = 1'b0;
517
    #5 WishboneBusy = 0;
518
  end
519
endtask
520
 
521
 
522
task WaitingForRxDMARequest;
523
  input [3:0] Delay;
524
  input [15:0] DMALengthRx;
525
  integer rr;
526
 
527
  for(rr=0; rr*4<DMALengthRx; rr=rr+1)
528
  begin
529
    @ (posedge WB_REQ_O[1]);
530
    repeat(Delay) @(posedge WB_CLK_I);
531
 
532
    wait (~WishboneBusy);
533
    WishboneBusy = 1;
534
    #1;
535 23 mohor
//    WB_ADR_I = {20'h20, rr[11:0]};
536
    WB_ADR_I = {22'h02, rr[9:0]};
537 15 mohor
    $display("task WaitingForRxDMARequest: rr=%0d, WB_ADR_I=0x%0h, WB_DAT_O=0x%0h", rr, WB_ADR_I, WB_DAT_O);
538
 
539
    WB_WE_I  = 1'b1;
540
    WB_CYC_I = 1'b1;
541
    WB_STB_I = 1'b1;
542
    WB_SEL_I = 4'hf;
543
    WB_ACK_I[1] = 1'b1;
544
 
545
    @ (posedge WB_CLK_I);
546
    #1;
547
    WB_ADR_I = 32'hx;
548
    WB_WE_I  = 1'bx;
549
    WB_CYC_I = 1'b0;
550
    WB_STB_I = 1'b0;
551
    WB_SEL_I = 4'hx;
552
    WB_ACK_I[1] = 1'b0;
553
    #5 WishboneBusy = 0;
554
  end
555
endtask
556
 
557
 
558
 
559
task GetDataOnMRxD;
560
  input [15:0] Len;
561
  integer tt;
562
 
563
  begin
564
    @ (posedge MRxClk);
565
    MRxDV=1'b1;
566
 
567
    for(tt=0; tt<15; tt=tt+1)
568
    begin
569
      MRxD=4'h5;              // preamble
570
      @ (posedge MRxClk);
571
    end
572
    MRxD=4'hd;                // SFD
573
 
574
    for(tt=0; tt<Len; tt=tt+1)
575
    begin
576
      @ (posedge MRxClk);
577
      MRxD=tt[3:0];
578
      @ (posedge MRxClk);
579
      MRxD=tt[7:4];
580
    end
581
    @ (posedge MRxClk);
582
    MRxDV=1'b0;
583
  end
584
endtask
585
 
586
 
587
task GetControlDataOnMRxD;
588
  input [15:0] Timer;
589
  reg [127:0] Packet;
590
  reg [127:0] Data;
591
  reg [31:0] Crc;
592
  integer tt;
593
 
594
  begin
595
  Packet = 128'h10082C000010_deadbeef0013_8880_0010; // 0180c2000001 + 8808 + 0001
596
  Crc = 32'h6014fe08; // not a correct value
597
 
598
    @ (posedge MRxClk);
599
    MRxDV=1'b1;
600
 
601
    for(tt=0; tt<15; tt=tt+1)
602
    begin
603
      MRxD=4'h5;              // preamble
604
      @ (posedge MRxClk);
605
    end
606
    MRxD=4'hd;                // SFD
607
 
608
    for(tt=0; tt<32; tt=tt+1)
609
    begin
610
      Data = Packet << (tt*4);
611
      @ (posedge MRxClk);
612
      MRxD=Data[127:124];
613
    end
614
 
615
    for(tt=0; tt<2; tt=tt+1)    // timer
616
    begin
617
      Data[15:0] = Timer << (tt*8);
618
      @ (posedge MRxClk);
619
      MRxD=Data[11:8];
620
      @ (posedge MRxClk);
621
      MRxD=Data[15:12];
622
    end
623
 
624
    for(tt=0; tt<42; tt=tt+1)   // padding
625
    begin
626
      Data[7:0] = 8'h0;
627
      @ (posedge MRxClk);
628
      MRxD=Data[3:0];
629
      @ (posedge MRxClk);
630
      MRxD=Data[3:0];
631
    end
632
 
633
    for(tt=0; tt<4; tt=tt+1)    // crc
634
    begin
635
      Data[31:0] = Crc << (tt*8);
636
      @ (posedge MRxClk);
637
      MRxD=Data[27:24];
638
      @ (posedge MRxClk);
639
      MRxD=Data[31:28];
640
    end
641
 
642
 
643
 
644
    @ (posedge MRxClk);
645
    MRxDV=1'b0;
646
  end
647
endtask
648
 
649
 
650
 
651
endmodule

powered by: WebSVN 2.1.0

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