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

Subversion Repositories ethmac

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

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

Line No. Rev Author Line
1 15 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
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
// Revision 1.1  2001/07/30 21:46:09  mohor
45
// Directory structure changed. Files checked and joind together.
46
//
47
//
48
//
49
//
50
//
51
 
52
 
53
 
54
`include "eth_defines.v"
55
`include "eth_timescale.v"
56
 
57
module tb_eth_top();
58
 
59
 
60
parameter Tp = 1;
61
 
62
 
63
reg           WB_CLK_I;
64
reg           WB_RST_I;
65
reg   [31:0]  WB_DAT_I;
66
 
67
reg   [31:0]  WB_ADR_I;
68
reg    [3:0]  WB_SEL_I;
69
reg           WB_WE_I;
70
reg           WB_CYC_I;
71
reg           WB_STB_I;
72
reg    [1:0]  WB_ACK_I;
73
 
74
wire  [31:0]  WB_DAT_O;
75
wire          WB_ACK_O;
76
wire          WB_ERR_O;
77
wire   [1:0]  WB_REQ_O;
78
wire   [1:0]  WB_ND_O;
79
wire          WB_RD_O;
80
 
81
reg           MTxClk;
82
wire   [3:0]  MTxD;
83
wire          MTxEn;
84
wire          MTxErr;
85
 
86
reg           MRxClk;
87
reg    [3:0]  MRxD;
88
reg           MRxDV;
89
reg           MRxErr;
90
reg           MColl;
91
reg           MCrs;
92
 
93
reg           Mdi_I;
94
wire          Mdo_O;
95
wire          Mdo_OE;
96
wire          Mdc_O;
97
 
98
 
99
 
100
reg GSR;
101
 
102
reg WishboneBusy;
103
reg StartTB;
104
reg [9:0] TxBDIndex;
105
reg [9:0] RxBDIndex;
106
 
107
 
108
 
109
// Connecting Ethernet top module
110
 
111
eth_top ethtop
112
(
113
  // WISHBONE common
114
  .WB_CLK_I(WB_CLK_I), .WB_RST_I(WB_RST_I), .WB_DAT_I(WB_DAT_I), .WB_DAT_O(WB_DAT_O),
115
 
116
  // WISHBONE slave
117
        .WB_ADR_I(WB_ADR_I), .WB_SEL_I(WB_SEL_I), .WB_WE_I(WB_WE_I),   .WB_CYC_I(WB_CYC_I),
118
        .WB_STB_I(WB_STB_I), .WB_ACK_O(WB_ACK_O), .WB_ERR_O(WB_ERR_O), .WB_REQ_O(WB_REQ_O),
119
        .WB_ACK_I(WB_ACK_I), .WB_ND_O(WB_ND_O),   .WB_RD_O(WB_RD_O),
120
 
121
  //TX
122
  .MTxClk_I(MTxClk), .MTxD_O(MTxD), .MTxEn_O(MTxEn), .MTxErr_O(MTxErr),
123
 
124
  //RX
125
  .MRxClk_I(MRxClk), .MRxD_I(MRxD), .MRxDV_I(MRxDV), .MRxErr_I(MRxErr), .MColl_I(MColl), .MCrs_I(MCrs),
126
 
127
  // MIIM
128
  .Mdc_O(Mdc_O), .Mdi_I(Mdi_I), .Mdo_O(Mdo_O), .Mdo_OE(Mdo_OE)
129
);
130
 
131
 
132
 
133
 
134
 
135
 
136
 
137
initial
138
begin
139
  WB_CLK_I  =  1'b0;
140
  WB_DAT_I  = 32'hx;
141
  WB_ADR_I  = 32'hx;
142
  WB_SEL_I  =  4'hx;
143
  WB_WE_I   =  1'bx;
144
  WB_CYC_I  =  1'b0;
145
  WB_STB_I  =  1'b0;
146
  WB_ACK_I  =  2'h0;
147
  MTxClk    =  1'b0;
148
  MRxClk    =  1'b0;
149
  MRxD      =  4'h0;
150
  MRxDV     =  1'b0;
151
  MRxErr    =  1'b0;
152
  MColl     =  1'b0;
153
  MCrs      =  1'b0;
154
  Mdi_I     =  1'b0;
155
 
156
  WishboneBusy = 1'b0;
157
  TxBDIndex = 10'h0;
158
  RxBDIndex = 10'h0;
159
end
160
 
161
 
162
// Reset pulse
163
initial
164
begin
165
  GSR           =  1'b0;
166
  WB_RST_I      =  1'b0;
167
  #100 WB_RST_I =  1'b1;
168
  GSR           =  1'b1;
169
  #100 WB_RST_I =  1'b0;
170
  GSR           =  1'b0;
171
  #100 StartTB  =  1'b1;
172
end
173
 
174
 
175
assign glbl.GSR = GSR;
176
 
177
 
178
 
179
// Generating WB_CLK_I clock
180
always
181
begin
182
//  forever #10 WB_CLK_I = ~WB_CLK_I;  // 2*10 ns -> 50.0 MHz    
183
  forever #15 WB_CLK_I = ~WB_CLK_I;  // 2*10 ns -> 33.3 MHz    
184
//  forever #18 WB_CLK_I = ~WB_CLK_I;  // 2*18 ns -> 27.7 MHz    
185
//  forever #100 WB_CLK_I = ~WB_CLK_I;
186
end
187
 
188
// Generating MTxClk clock
189
always
190
begin
191
  #3 forever #20 MTxClk = ~MTxClk;   // 2*20 ns -> 25 MHz
192
//  #3 forever #200 MTxClk = ~MTxClk;
193
end
194
 
195
// Generating MRxClk clock
196
always
197
begin
198
  #16 forever #20 MRxClk = ~MRxClk;   // 2*20 ns -> 25 MHz
199
//  #16 forever #250 MRxClk = ~MRxClk;
200
end
201
 
202
 
203
 
204
initial
205
begin
206
  wait(StartTB);  // Start of testbench
207
 
208
  WishboneWrite(32'h00000800, {`ETHERNET_SPACE, `REG_SPACE, 6'h0, `MODER_ADR<<2});    // r_Rst = 1
209
  WishboneWrite(32'h00000000, {`ETHERNET_SPACE, `REG_SPACE, 6'h0, `MODER_ADR<<2});    // r_Rst = 0
210
  WishboneWrite(32'h00000080, {`ETHERNET_SPACE, `REG_SPACE, 6'h0, `RX_BD_ADR_ADR<<2});// r_RxBDAddress = 0x80
211
  WishboneWrite(32'h0002A443, {`ETHERNET_SPACE, `REG_SPACE, 6'h0, `MODER_ADR<<2});    // RxEn, Txen, FullD, CrcEn, Pad, DmaEn, r_IFG
212
  WishboneWrite(32'h00000004, {`ETHERNET_SPACE, `REG_SPACE, 6'h0, `CTRLMODER_ADR<<2});//r_TxFlow = 1
213
 
214
 
215
 
216
 
217
  SendPacket(16'h0015, 1'b0);
218
  SendPacket(16'h0043, 1'b1);   // Control frame
219
  SendPacket(16'h0025, 1'b0);
220
  SendPacket(16'h0045, 1'b0);
221
  SendPacket(16'h0025, 1'b0);
222
 
223
 
224
  ReceivePacket(16'h0012, 1'b1);    // Initializes RxBD and then Sends a control packet on the MRxD[3:0] signals.
225
  ReceivePacket(16'h0011, 1'b0);    // Initializes RxBD and then generates traffic on the MRxD[3:0] signals.
226
  ReceivePacket(16'h0016, 1'b0);    // Initializes RxBD and then generates traffic on the MRxD[3:0] signals.
227
  ReceivePacket(16'h0017, 1'b0);    // Initializes RxBD and then generates traffic on the MRxD[3:0] signals.
228
  ReceivePacket(16'h0018, 1'b0);    // Initializes RxBD and then generates traffic on the MRxD[3:0] signals.
229
 
230
 
231
  WishboneRead({`ETHERNET_SPACE, `REG_SPACE, 6'h0, `MODER_ADR<<2});   // Read from MODER register
232
 
233
  WishboneRead({`ETHERNET_SPACE, `BD_SPACE, 2'h0, (10'h0<<2)});       // Read from TxBD register
234
  WishboneRead({`ETHERNET_SPACE, `BD_SPACE, 2'h0, (10'h1<<2)});       // Read from TxBD register
235
  WishboneRead({`ETHERNET_SPACE, `BD_SPACE, 2'h0, (10'h2<<2)});       // Read from TxBD register
236
  WishboneRead({`ETHERNET_SPACE, `BD_SPACE, 2'h0, (10'h3<<2)});       // Read from TxBD register
237
  WishboneRead({`ETHERNET_SPACE, `BD_SPACE, 2'h0, (10'h4<<2)});       // Read from TxBD register
238
 
239
  WishboneRead({`ETHERNET_SPACE, `BD_SPACE, 2'h0, (10'h80<<2)});       // Read from RxBD register
240
  WishboneRead({`ETHERNET_SPACE, `BD_SPACE, 2'h0, (10'h81<<2)});       // Read from RxBD register
241
  WishboneRead({`ETHERNET_SPACE, `BD_SPACE, 2'h0, (10'h82<<2)});       // Read from RxBD register
242
  WishboneRead({`ETHERNET_SPACE, `BD_SPACE, 2'h0, (10'h83<<2)});       // Read from RxBD register
243
  WishboneRead({`ETHERNET_SPACE, `BD_SPACE, 2'h0, (10'h84<<2)});       // Read from RxBD register
244
 
245
  #10000 $stop;
246
end
247
 
248
 
249
 
250
 
251
 
252
 
253
 
254
task WishboneWrite;
255
  input [31:0] Data;
256
  input [31:0] Address;
257
  integer ii;
258
 
259
  begin
260
    wait (~WishboneBusy);
261
    WishboneBusy = 1;
262
    @ (posedge WB_CLK_I);
263
    #1;
264
    WB_ADR_I = Address;
265
    WB_DAT_I = Data;
266
    WB_WE_I  = 1'b1;
267
    WB_CYC_I = 1'b1;
268
    WB_STB_I = 1'b1;
269
    WB_SEL_I = 4'hf;
270
 
271
    for(ii=0; (ii<20 & ~WB_ACK_O); ii=ii+1)   // Response on the WISHBONE is limited to 20 WB_CLK_I cycles
272
    begin
273
      @ (posedge WB_CLK_I);
274
    end
275
 
276
    if(ii==20)
277
      begin
278
        $display("\nERROR: Task WishboneWrite(Data=0x%0h, Address=0x%0h): Too late or no appeariance of the WB_ACK_O signal, (Time=%0t)",
279
          Data, Address, $time);
280
        #50 $stop;
281
      end
282
 
283
    @ (posedge WB_CLK_I);
284
    if(Address[31:16] == `ETHERNET_SPACE)
285
      if(Address[15:12] == `REG_SPACE)
286
        $write("\nWrite to register (Data: 0x%x, Reg. Addr: 0x%0x)", Data, Address[9:2]);
287
      else
288
      if(Address[15:12] == `BD_SPACE)
289
        if(Address[9:2] < tb_eth_top.ethtop.r_RxBDAddress)
290
          begin
291
            $write("\nWrite to TxBD (Data: 0x%x, TxBD Addr: 0x%0x)\n", Data, Address[9:2]);
292
            if(Data[13])
293
              $write("Send Control packet (PAUSE = 0x%0h)\n", Data[31:16]);
294
          end
295
        else
296
          $write("\nWrite to RxBD (Data: 0x%x, RxBD Addr: 0x%0x)", Data, Address[9:2]);
297
      else
298
        $write("\nWB write      Data: 0x%x      Addr: 0x%0x", Data, Address);
299
    else
300
      $write("\nWARNING !!! WB write to non-ethernet space (Data: 0x%x, Addr: 0x%0x)", Data, Address);
301
    #1;
302
    WB_ADR_I = 32'hx;
303
    WB_DAT_I = 32'hx;
304
    WB_WE_I  = 1'bx;
305
    WB_CYC_I = 1'b0;
306
    WB_STB_I = 1'b0;
307
    WB_SEL_I = 4'hx;
308
    #5 WishboneBusy = 0;
309
  end
310
endtask
311
 
312
 
313
task WishboneRead;
314
  input [31:0] Address;
315
  reg   [31:0] Data;
316
  integer ii;
317
 
318
  begin
319
    wait (~WishboneBusy);
320
    WishboneBusy = 1;
321
    @ (posedge WB_CLK_I);
322
    #1;
323
    WB_ADR_I = Address;
324
    WB_WE_I  = 1'b0;
325
    WB_CYC_I = 1'b1;
326
    WB_STB_I = 1'b1;
327
    WB_SEL_I = 4'hf;
328
 
329
    for(ii=0; (ii<20 & ~WB_ACK_O); ii=ii+1)   // Response on the WISHBONE is limited to 20 WB_CLK_I cycles
330
    begin
331
      @ (posedge WB_CLK_I);
332
      Data = WB_DAT_O;
333
    end
334
 
335
    if(ii==20)
336
      begin
337
        $display("\nERROR: Task WishboneRead(Address=0x%0h): Too late or no appeariance of the WB_ACK_O signal, (Time=%0t)",
338
          Address, $time);
339
        #50 $stop;
340
      end
341
 
342
    @ (posedge WB_CLK_I);
343
    if(Address[31:16] == `ETHERNET_SPACE)
344
      if(Address[15:12] == `REG_SPACE)
345
        $write("\nRead from register (Data: 0x%x, Reg. Addr: 0x%0x)", Data, Address[9:2]);
346
      else
347
      if(Address[15:12] == `BD_SPACE)
348
        if(Address[9:2] < tb_eth_top.ethtop.r_RxBDAddress)
349
          begin
350
            $write("\nRead from TxBD (Data: 0x%x, TxBD Addr: 0x%0x)", Data, Address[9:2]);
351
          end
352
        else
353
          $write("\nRead from RxBD (Data: 0x%x, RxBD Addr: 0x%0x)", Data, Address[9:2]);
354
      else
355
        $write("\nWB read      Data: 0x%x      Addr: 0x%0x", Data, Address);
356
    else
357
      $write("\nWARNING !!! WB read to non-ethernet space (Data: 0x%x, Addr: 0x%0x)", Data, Address);
358
    #1;
359
    WB_ADR_I = 32'hx;
360
    WB_WE_I  = 1'bx;
361
    WB_CYC_I = 1'b0;
362
    WB_STB_I = 1'b0;
363
    WB_SEL_I = 4'hx;
364
    #5 WishboneBusy = 0;
365
  end
366
endtask
367
 
368
 
369
 
370
 
371
task SendPacket;
372
  input [15:0]  Length;
373
  input         ControlFrame;
374
  reg           Wrap;
375
  reg [31:0]    TempAddr;
376
  reg [31:0]    TempData;
377
 
378
  begin
379
    if(TxBDIndex == 3)    // Only 4 buffer descriptors are used
380
      Wrap = 1'b1;
381
    else
382
      Wrap = 1'b0;
383
 
384
    TempAddr = {`ETHERNET_SPACE, `BD_SPACE, 2'h0, (TxBDIndex<<2)};
385
    TempData = {Length[15:0], 1'b1, Wrap, ControlFrame, 5'h0, TxBDIndex[7:0]};  // Ready and Wrap = 1
386
 
387
    #1;
388
    if(TxBDIndex == 3)    // Only 4 buffer descriptors are used
389
      TxBDIndex = 0;
390
    else
391
      TxBDIndex = TxBDIndex + 1;
392
 
393
    fork
394
      begin
395
        WishboneWrite(TempData, TempAddr); // Writing status to TxBD
396
      end
397
 
398
      begin
399
        if(~ControlFrame)
400
        WaitingForTxDMARequest(4'h1, Length); // Delay, DMALength
401
      end
402
    join
403
  end
404
endtask
405
 
406
 
407
 
408
task ReceivePacket;    // Initializes RxBD and then generates traffic on the MRxD[3:0] signals.
409
  input [15:0] LengthRx;
410
  input        RxControlFrame;
411
  reg        WrapRx;
412
  reg [31:0] TempRxAddr;
413
  reg [31:0] TempRxData;
414
  reg abc;
415
  begin
416
    if(RxBDIndex == 3)    // Only 4 buffer descriptors are used
417
      WrapRx = 1'b1;
418
    else
419
      WrapRx = 1'b0;
420
 
421
    TempRxAddr = {`ETHERNET_SPACE, `BD_SPACE, 2'h0, ((tb_eth_top.ethtop.r_RxBDAddress + RxBDIndex)<<2)};
422
 
423
    TempRxData = {LengthRx[15:0], 1'b1, WrapRx, 6'h0, RxBDIndex[7:0]};  // Ready and WrapRx = 1 or 0
424
 
425
    #1;
426
    if(RxBDIndex == 3)    // Only 4 buffer descriptors are used
427
      RxBDIndex = 0;
428
    else
429
      RxBDIndex = RxBDIndex + 1;
430
 
431
    abc=1;
432
    WishboneWrite(TempRxData, TempRxAddr); // Writing status to RxBD
433
    abc=0;
434
    fork
435
      begin
436
        #200;
437
        if(RxControlFrame)
438
          GetControlDataOnMRxD(LengthRx); // LengthRx = PAUSE timer value.
439
        else
440
          GetDataOnMRxD(LengthRx); // LengthRx bytes is comming on MRxD[3:0] signals
441
      end
442
 
443
      begin
444
        if(RxControlFrame)
445
          WaitingForRxDMARequest(4'h1, 16'h40); // Delay, DMALength = 64 bytes.
446
        else
447
          WaitingForRxDMARequest(4'h1, LengthRx); // Delay, DMALength
448
      end
449
    join
450
  end
451
endtask
452
 
453
 
454
 
455
task WaitingForTxDMARequest;
456
  input [3:0] Delay;
457
  input [15:0] DMALength;
458
  integer pp;
459
  reg [7:0]a, b, c, d;
460
 
461
  for(pp=0; pp*4<DMALength; pp=pp+1)
462
  begin
463
    a = 4*pp[7:0]+3;
464
    b = 4*pp[7:0]+2;
465
    c = 4*pp[7:0]+1;
466
    d = 4*pp[7:0]  ;
467
    @ (posedge WB_REQ_O[0]);
468
    repeat(Delay) @(posedge WB_CLK_I);
469
 
470
    wait (~WishboneBusy);
471
    WishboneBusy = 1;
472
    #1;
473
    WB_DAT_I = {a, b, c, d};
474
    WB_ADR_I = {`ETHERNET_SPACE, `TX_DATA, pp[11:0]};
475
    $display("task WaitingForTxDMARequest: pp=%0d, WB_ADR_I=0x%0h, WB_DAT_I=0x%0h", pp, WB_ADR_I, WB_DAT_I);
476
 
477
    WB_WE_I  = 1'b1;
478
    WB_CYC_I = 1'b1;
479
    WB_STB_I = 1'b1;
480
    WB_SEL_I = 4'hf;
481
    WB_ACK_I[0] = 1'b1;
482
 
483
    @ (posedge WB_CLK_I);
484
    #1;
485
    WB_ADR_I = 32'hx;
486
    WB_DAT_I = 32'hx;
487
    WB_WE_I  = 1'bx;
488
    WB_CYC_I = 1'b0;
489
    WB_STB_I = 1'b0;
490
    WB_SEL_I = 4'hx;
491
    WB_ACK_I[0] = 1'b0;
492
    #5 WishboneBusy = 0;
493
  end
494
endtask
495
 
496
 
497
task WaitingForRxDMARequest;
498
  input [3:0] Delay;
499
  input [15:0] DMALengthRx;
500
  integer rr;
501
 
502
  for(rr=0; rr*4<DMALengthRx; rr=rr+1)
503
  begin
504
    @ (posedge WB_REQ_O[1]);
505
    repeat(Delay) @(posedge WB_CLK_I);
506
 
507
    wait (~WishboneBusy);
508
    WishboneBusy = 1;
509
    #1;
510
    WB_ADR_I = {`ETHERNET_SPACE, `RX_DATA, rr[11:0]};
511
    $display("task WaitingForRxDMARequest: rr=%0d, WB_ADR_I=0x%0h, WB_DAT_O=0x%0h", rr, WB_ADR_I, WB_DAT_O);
512
 
513
    WB_WE_I  = 1'b1;
514
    WB_CYC_I = 1'b1;
515
    WB_STB_I = 1'b1;
516
    WB_SEL_I = 4'hf;
517
    WB_ACK_I[1] = 1'b1;
518
 
519
    @ (posedge WB_CLK_I);
520
    #1;
521
    WB_ADR_I = 32'hx;
522
    WB_WE_I  = 1'bx;
523
    WB_CYC_I = 1'b0;
524
    WB_STB_I = 1'b0;
525
    WB_SEL_I = 4'hx;
526
    WB_ACK_I[1] = 1'b0;
527
    #5 WishboneBusy = 0;
528
  end
529
endtask
530
 
531
 
532
 
533
task GetDataOnMRxD;
534
  input [15:0] Len;
535
  integer tt;
536
 
537
  begin
538
    @ (posedge MRxClk);
539
    MRxDV=1'b1;
540
 
541
    for(tt=0; tt<15; tt=tt+1)
542
    begin
543
      MRxD=4'h5;              // preamble
544
      @ (posedge MRxClk);
545
    end
546
    MRxD=4'hd;                // SFD
547
 
548
    for(tt=0; tt<Len; tt=tt+1)
549
    begin
550
      @ (posedge MRxClk);
551
      MRxD=tt[3:0];
552
      @ (posedge MRxClk);
553
      MRxD=tt[7:4];
554
    end
555
    @ (posedge MRxClk);
556
    MRxDV=1'b0;
557
  end
558
endtask
559
 
560
 
561
task GetControlDataOnMRxD;
562
  input [15:0] Timer;
563
  reg [127:0] Packet;
564
  reg [127:0] Data;
565
  reg [31:0] Crc;
566
  integer tt;
567
 
568
  begin
569
  Packet = 128'h10082C000010_deadbeef0013_8880_0010; // 0180c2000001 + 8808 + 0001
570
  Crc = 32'h6014fe08; // not a correct value
571
 
572
    @ (posedge MRxClk);
573
    MRxDV=1'b1;
574
 
575
    for(tt=0; tt<15; tt=tt+1)
576
    begin
577
      MRxD=4'h5;              // preamble
578
      @ (posedge MRxClk);
579
    end
580
    MRxD=4'hd;                // SFD
581
 
582
    for(tt=0; tt<32; tt=tt+1)
583
    begin
584
      Data = Packet << (tt*4);
585
      @ (posedge MRxClk);
586
      MRxD=Data[127:124];
587
    end
588
 
589
    for(tt=0; tt<2; tt=tt+1)    // timer
590
    begin
591
      Data[15:0] = Timer << (tt*8);
592
      @ (posedge MRxClk);
593
      MRxD=Data[11:8];
594
      @ (posedge MRxClk);
595
      MRxD=Data[15:12];
596
    end
597
 
598
    for(tt=0; tt<42; tt=tt+1)   // padding
599
    begin
600
      Data[7:0] = 8'h0;
601
      @ (posedge MRxClk);
602
      MRxD=Data[3:0];
603
      @ (posedge MRxClk);
604
      MRxD=Data[3:0];
605
    end
606
 
607
    for(tt=0; tt<4; tt=tt+1)    // crc
608
    begin
609
      Data[31:0] = Crc << (tt*8);
610
      @ (posedge MRxClk);
611
      MRxD=Data[27:24];
612
      @ (posedge MRxClk);
613
      MRxD=Data[31:28];
614
    end
615
 
616
 
617
 
618
    @ (posedge MRxClk);
619
    MRxDV=1'b0;
620
  end
621
endtask
622
 
623
 
624
 
625
endmodule

powered by: WebSVN 2.1.0

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