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

Subversion Repositories usb_fpga_2_14

[/] [usb_fpga_2_14/] [trunk/] [examples/] [memfifo/] [fpga-2.04b/] [ipcore_dir/] [mem0/] [user_design/] [sim/] [sp6_data_gen.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
//*****************************************************************************
2
// (c) Copyright 2008-2009 Xilinx, Inc. All rights reserved.
3
//
4
// This file contains confidential and proprietary information
5
// of Xilinx, Inc. and is protected under U.S. and
6
// international copyright and other intellectual property
7
// laws.
8
//
9
// DISCLAIMER
10
// This disclaimer is not a license and does not grant any
11
// rights to the materials distributed herewith. Except as
12
// otherwise provided in a valid license issued to you by
13
// Xilinx, and to the maximum extent permitted by applicable
14
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
15
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
16
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
17
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
18
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
19
// (2) Xilinx shall not be liable (whether in contract or tort,
20
// including negligence, or under any other theory of
21
// liability) for any loss or damage of any kind or nature
22
// related to, arising under or in connection with these
23
// materials, including for any direct, or any indirect,
24
// special, incidental, or consequential loss or damage
25
// (including loss of data, profits, goodwill, or any type of
26
// loss or damage suffered as a result of any action brought
27
// by a third party) even if such damage or loss was
28
// reasonably foreseeable or Xilinx had been advised of the
29
// possibility of the same.
30
//
31
// CRITICAL APPLICATIONS
32
// Xilinx products are not designed or intended to be fail-
33
// safe, or for use in any application requiring fail-safe
34
// performance, such as life-support or safety devices or
35
// systems, Class III medical devices, nuclear facilities,
36
// applications related to the deployment of airbags, or any
37
// other applications that could lead to death, personal
38
// injury, or severe property or environmental damage
39
// (individually and collectively, "Critical
40
// Applications"). Customer assumes the sole risk and
41
// liability of any use of Xilinx products in Critical
42
// Applications, subject only to applicable laws and
43
// regulations governing limitations on product liability.
44
//
45
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
46
// PART OF THIS FILE AT ALL TIMES.
47
//
48
//*****************************************************************************
49
//   ____  ____
50
//  /   /\/   /
51
// /___/  \  /    Vendor: Xilinx
52
// \   \   \/     Version: %version
53
//  \   \         Application: MIG
54
//  /   /         Filename: data_gen.v
55
// /___/   /\     Date Last Modified: 
56
// \   \  /  \    Date Created: 
57
//  \___\/\___\
58
//
59
//Device: Spartan6
60
//Design Name: DDR/DDR2/DDR3/LPDDR 
61
//Purpose: This module generates different data pattern as described in 
62
//         parameter DATA_PATTERN and is set up for Spartan 6 family.
63
//Reference:
64
//Revision History:
65
//*****************************************************************************
66
 
67
`timescale 1ps/1ps
68
 
69
module sp6_data_gen #
70
 
71
(
72
   parameter TCQ           = 100,
73
   parameter ADDR_WIDTH = 32,
74
   parameter BL_WIDTH = 6,
75
   parameter DWIDTH = 32,
76
   parameter DATA_PATTERN = "DGEN_ALL", //"DGEN__HAMMER", "DGEN_WALING1","DGEN_WALING0","DGEN_ADDR","DGEN_NEIGHBOR","DGEN_PRBS","DGEN_ALL"  
77
   parameter NUM_DQ_PINS   = 8,
78
   parameter COLUMN_WIDTH = 10
79
 
80
 )
81
 (
82
   input   clk_i,                 //
83
   input   rst_i,
84
   input [31:0] prbs_fseed_i,
85
 
86
   input [3:0]  data_mode_i,   // "00" = bram; 
87
   input        data_rdy_i,
88
   input   cmd_startA,
89
   input   cmd_startB,
90
   input   cmd_startC,
91
   input   cmd_startD,
92
   input   cmd_startE,
93
   input [DWIDTH-1:0]     fixed_data_i,
94
 
95
   input [ADDR_WIDTH-1:0]  addr_i,          // generated address used to determine data pattern.
96
   input [6:0]    user_burst_cnt,   // generated burst length for control the burst data
97
 
98
   input   fifo_rdy_i,           // connect from mcb_wr_full when used as wr_data_gen
99
                                 // connect from mcb_rd_empty when used as rd_data_gen
100
                                 // When both data_rdy and data_valid is asserted, the ouput data is valid.
101
   output  [DWIDTH-1:0] data_o   // generated data pattern   
102
);
103
// 
104
wire [31:0]       prbs_data;
105
 
106
reg [31:0]         adata;
107
reg [DWIDTH-1:0]   hdata;
108
reg [DWIDTH-1:0]   ndata;
109
reg [DWIDTH - 1:0] w1data;
110
reg [DWIDTH-1:0] data;
111
reg burst_count_reached2;
112
 
113
reg               data_valid;
114
reg [2:0] walk_cnt;
115
reg [ADDR_WIDTH-1:0] user_address;
116
 
117
 
118
integer i,j;
119
reg [BL_WIDTH-1:0] user_bl;
120
reg [7:0] BLANK;
121
 
122
reg [7:0] SHIFT_0;
123
reg [7:0] SHIFT_1;
124
reg [7:0] SHIFT_2;
125
reg [7:0] SHIFT_3;
126
reg [7:0] SHIFT_4;
127
reg [7:0] SHIFT_5;
128
reg [7:0] SHIFT_6;
129
reg [7:0] SHIFT_7;
130
reg [31:0] SHIFTB_0 ;
131
reg [31:0] SHIFTB_1;
132
reg [31:0] SHIFTB_2;
133
reg [31:0] SHIFTB_3;
134
reg [31:0] SHIFTB_4;
135
reg [31:0] SHIFTB_5;
136
reg [31:0] SHIFTB_6;
137
reg [31:0] SHIFTB_7;
138
reg [3:0] TSTB;
139
//*********************************************************************************************
140
 
141
 
142
 
143
 
144
 
145
assign data_o = data;
146
 
147
generate
148
 
149
if (DWIDTH==32) begin: data_out32
150
always @ (adata,hdata,ndata,w1data,prbs_data,data_mode_i,fixed_data_i)
151
begin
152
   case(data_mode_i)
153
       //  4'b0000: data = 32'b0;       //reserved
154
         4'b0001: data = fixed_data_i;       // fixed
155
         4'b0010: data = adata;  // address as data
156
         4'b0011: data = hdata;  // DGEN_HAMMER
157
         4'b0100: data = ndata;  // DGEN_NEIGHBOUR
158
         4'b0101: data = w1data; // DGEN_WALKING1
159
         4'b0110: data = w1data; // DGEN_WALKING0
160
         4'b0111: data = prbs_data;
161
         default : data = 'b0;
162
   endcase
163
end
164
end
165
 
166
endgenerate
167
 
168
generate
169
if (DWIDTH==64) begin: data_out64
170
always @ (adata,hdata,ndata,w1data,prbs_data,data_mode_i,fixed_data_i)
171
begin
172
   case(data_mode_i)
173
         4'b0000: data = 'b0;                 //reserved
174
         4'b0001: data = fixed_data_i;                 // fixed
175
         4'b0010: data = {adata,adata};       // address as data
176
         4'b0011: data = hdata;       // DGEN_HAMMER
177
         4'b0100: data = ndata;       // DGEN_NEIGHBOUR
178
         4'b0101: data = w1data;     // DGEN_WALKING1
179
         4'b0110: data = w1data;     // DGEN_WALKING0
180
         4'b0111: data = {prbs_data,prbs_data};
181
         default : data = 'b0;
182
   endcase
183
end
184
end
185
endgenerate
186
 
187
generate
188
if (DWIDTH==128) begin: data_out128
189
always @ (adata,hdata,ndata,w1data,prbs_data,data_mode_i,fixed_data_i)
190
begin
191
   case(data_mode_i)
192
         4'b0000: data = 'b0;       //reserved
193
         4'b0001: data = fixed_data_i;       // fixed
194
         4'b0010: data = {adata,adata,adata,adata};       // address as data
195
         4'b0011: data = hdata;       // DGEN_HAMMER
196
         4'b0100: data = ndata;       // DGEN_NEIGHBOUR
197
         4'b0101: data = w1data;   // DGEN_WALKING1
198
         4'b0110: data = w1data;   // DGEN_WALKING0
199
         4'b0111: data = {prbs_data,prbs_data,prbs_data,prbs_data};
200
         default : data = 'b0;
201
   endcase
202
end
203
end
204
endgenerate
205
 
206
 
207
// WALKING ONES:
208
 
209
generate
210
if ((DWIDTH == 64) ||(DWIDTH == 128))  begin: SHIFT_VALUE
211
 
212
always @ (data_mode_i) begin
213
  if (data_mode_i == 3'b101 || data_mode_i == 3'b100) begin // WALKING ONE
214
    BLANK   = 8'h00;
215
    SHIFT_0 = 8'h01;
216
    SHIFT_1 = 8'h02;
217
    SHIFT_2 = 8'h04;
218
    SHIFT_3 = 8'h08;
219
    SHIFT_4 = 8'h10;
220
    SHIFT_5 = 8'h20;
221
    SHIFT_6 = 8'h40;
222
    SHIFT_7 = 8'h80;
223
 
224
    end
225
    else if (data_mode_i == 3'b100)begin // NEIGHBOR ONE
226
    BLANK   = 8'h00;
227
    SHIFT_0 = 8'h01;
228
    SHIFT_1 = 8'h02;
229
    SHIFT_2 = 8'h04;
230
    SHIFT_3 = 8'h08;
231
    SHIFT_4 = 8'h10;
232
    SHIFT_5 = 8'h20;
233
    SHIFT_6 = 8'h40;
234
    SHIFT_7 = 8'h80;
235
    end
236
 
237
 
238
 
239
    else if (data_mode_i == 3'b110) begin  // WALKING ZERO
240
    BLANK   = 8'hff;
241
    SHIFT_0 = 8'hfe;
242
    SHIFT_1 = 8'hfd;
243
    SHIFT_2 = 8'hfb;
244
    SHIFT_3 = 8'hf7;
245
    SHIFT_4 = 8'hef;
246
    SHIFT_5 = 8'hdf;
247
    SHIFT_6 = 8'hbf;
248
    SHIFT_7 = 8'h7f;
249
    end
250
    else begin
251
    BLANK   = 8'hff;
252
    SHIFT_0 = 8'hfe;
253
    SHIFT_1 = 8'hfd;
254
    SHIFT_2 = 8'hfb;
255
    SHIFT_3 = 8'hf7;
256
    SHIFT_4 = 8'hef;
257
    SHIFT_5 = 8'hdf;
258
    SHIFT_6 = 8'hbf;
259
    SHIFT_7 = 8'h7f;
260
    end
261
 
262
end
263
end
264
endgenerate
265
 
266
always @ (data_mode_i) begin
267
 
268
if (data_mode_i == 3'b101 ) begin // WALKING ONE
269
 
270
    SHIFTB_0 = 32'h0002_0001;
271
    SHIFTB_1 = 32'h0008_0004;
272
    SHIFTB_2 = 32'h0020_0010;
273
    SHIFTB_3 = 32'h0080_0040;
274
    SHIFTB_4 = 32'h0200_0100;
275
    SHIFTB_5 = 32'h0800_0400;
276
    SHIFTB_6 = 32'h2000_1000;
277
    SHIFTB_7 = 32'h8000_4000;
278
    end
279
else if (data_mode_i == 3'b100)begin // NEIGHBOR ONE
280
 
281
    SHIFTB_0 = 32'h0000_0001;
282
    SHIFTB_1 = 32'h0000_0002;
283
    SHIFTB_2 = 32'h0000_0004;
284
    SHIFTB_3 = 32'h0000_0008;
285
    SHIFTB_4 = 32'h0000_0010;
286
    SHIFTB_5 = 32'h0000_0020;
287
    SHIFTB_6 = 32'h0000_0040;
288
    SHIFTB_7 = 32'h0000_0080;
289
    end
290
 
291
else begin  // WALKING ZERO
292
    SHIFTB_0 = 32'hfffd_fffe;
293
    SHIFTB_1 = 32'hfff7_fffb;
294
    SHIFTB_2 = 32'hffdf_ffef;
295
    SHIFTB_3 = 32'hff7f_ffbf;
296
    SHIFTB_4 = 32'hfdff_feff;
297
    SHIFTB_5 = 32'hf7ff_fbff;
298
    SHIFTB_6 = 32'hdfff_efff;
299
    SHIFTB_7 = 32'h7fff_bfff;
300
    end
301
 
302
end
303
 
304
 
305
 
306
 
307
 
308
reg [DWIDTH-1:0] tmpdata ;
309
reg ndata_rising;
310
reg shift_en;
311
generate
312
if (DWIDTH == 32 && (DATA_PATTERN == "DGEN_WALKING0" || DATA_PATTERN == "DGEN_WALKING1" ||
313
    DATA_PATTERN == "DGEN_ALL"))  begin : WALKING_ONE_32_PATTERN
314
 
315
  always @ (posedge clk_i)
316
  begin
317
   if (rst_i) begin
318
        w1data <= #TCQ  'b0;
319
        ndata_rising <= #TCQ  1'b1;
320
        shift_en <= #TCQ  1'b0;
321
        end
322
   else if((fifo_rdy_i && user_burst_cnt != 6'd0) || cmd_startC )
323
      if (NUM_DQ_PINS == 16)
324
      begin
325
         if(cmd_startC)
326
           begin
327
                      case (addr_i[4:2])
328
                      0: w1data <= #TCQ    SHIFTB_0;
329
                      1: w1data <= #TCQ    SHIFTB_1;
330
                      2: w1data <= #TCQ    SHIFTB_2;
331
                      3: w1data <= #TCQ    SHIFTB_3;
332
                      4: w1data <= #TCQ    SHIFTB_4;
333
                      5: w1data <= #TCQ    SHIFTB_5;
334
                      6: w1data <= #TCQ    SHIFTB_6;
335
                      7: w1data <= #TCQ    SHIFTB_7;
336
 
337
                      default :w1data <= #TCQ    SHIFTB_0;
338
                      endcase
339
 
340
                      ndata_rising <= #TCQ  1'b0;
341
           end  //(NUM_DQ_PINS == 16) (cmd_startC)  
342
         else //shifting
343
            if (data_mode_i == 3'b100)
344
              w1data <= #TCQ    {16'h0000,w1data[14:0],w1data[15]};
345
            else
346
              w1data <= #TCQ    {w1data[29:16],w1data[31:30],w1data[13:0],w1data[15:14]};
347
 
348
 
349
      end  //(DQ_PINS == 16 
350
      else if (NUM_DQ_PINS == 8) begin
351
         if(cmd_startC)  // loading data pattern according the incoming address
352
            begin
353
                       case (addr_i[2])
354
                        0: w1data <= #TCQ    SHIFTB_0;
355
                        1: w1data <= #TCQ    SHIFTB_1;
356
                        default :w1data <= #TCQ    SHIFTB_0;
357
                       endcase
358
            end // (cmd_startC)   
359
        else  // Shifting
360
          // need neigbour pattern ********************
361
                w1data <= #TCQ    {w1data[27:24],w1data[31:28],w1data[19:16],w1data[23:20],
362
                                w1data[11:8] ,w1data[15:12],w1data[3:0]  ,w1data[7:4]};
363
 
364
      end //(NUM_DQ_PINS == 8)
365
      else if (NUM_DQ_PINS == 4) begin   // NUM_DQ_PINS == 4   
366
          // need neigbour pattern ********************      
367
             if (data_mode_i == 3'b100)
368
               w1data <= #TCQ    32'h0804_0201;
369
             else
370
               w1data <= #TCQ    32'h8421_8421;
371
      end // (NUM_DQ_PINS_4    
372
 
373
  end
374
end
375
endgenerate // DWIDTH == 32
376
 
377
generate
378
if (DWIDTH == 64 && (DATA_PATTERN == "DGEN_WALKING0" || DATA_PATTERN == "DGEN_WALKING1"
379
    || DATA_PATTERN == "DGEN_ALL"))  begin : WALKING_ONE_64_PATTERN
380
 
381
  always @ (posedge clk_i)
382
  begin
383
   if (rst_i)
384
        w1data <= #TCQ  'b0;
385
 
386
   else if((fifo_rdy_i && user_burst_cnt != 6'd0) || cmd_startC )
387
 
388
 
389
 
390
      if (NUM_DQ_PINS == 16)
391
      begin
392
         if(cmd_startC)
393
           begin
394
 
395
             case (addr_i[4:3])
396
 
397
 
398
                 0: begin
399
                    //  7:0
400
                    w1data[2*DWIDTH/4-1:0*DWIDTH/4]    <= #TCQ    SHIFTB_0;
401
                    w1data[4*DWIDTH/4-1:2*DWIDTH/4]    <= #TCQ    SHIFTB_1;
402
 
403
                    end
404
                 1:  begin
405
                    w1data[2*DWIDTH/4-1:0*DWIDTH/4]    <= #TCQ    SHIFTB_2;
406
                    w1data[4*DWIDTH/4-1:2*DWIDTH/4]    <= #TCQ    SHIFTB_3;
407
                    end
408
 
409
                 2: begin
410
                    w1data[2*DWIDTH/4-1:0*DWIDTH/4]    <= #TCQ    SHIFTB_4;
411
                    w1data[4*DWIDTH/4-1:2*DWIDTH/4]    <= #TCQ    SHIFTB_5;
412
                    end
413
                 3:  begin
414
                    w1data[2*DWIDTH/4-1:0*DWIDTH/4]    <= #TCQ    SHIFTB_6;
415
                    w1data[4*DWIDTH/4-1:2*DWIDTH/4]    <= #TCQ    SHIFTB_7;
416
 
417
                    end
418
 
419
 
420
               default :begin
421
                    w1data <= #TCQ  BLANK;    //15:8 
422
                    end
423
 
424
             endcase
425
 
426
 
427
           end  //(NUM_DQ_PINS == 16) (cmd_startC)      
428
         else begin  //shifting
429
             if (data_mode_i == 3'b100)
430
               begin
431
                 w1data[63:48] <= #TCQ    {16'h0000};
432
                 w1data[47:32] <= #TCQ    {w1data[45:32],w1data[47:46]};
433
                 w1data[31:16] <= #TCQ    {16'h0000};
434
                 w1data[15:0]  <= #TCQ    {w1data[13:0],w1data[15:14]};
435
 
436
               end
437
            else
438
 
439
              w1data[DWIDTH - 1:0] <= #TCQ    {
440
                                          w1data[4*DWIDTH/4 - 5:4*DWIDTH/4 - 16],
441
                                          w1data[4*DWIDTH/4 - 1 :4*DWIDTH/4 - 4],
442
 
443
                                          w1data[3*DWIDTH/4 - 5:3*DWIDTH/4 - 16],
444
                                          w1data[3*DWIDTH/4 - 1 :3*DWIDTH/4 - 4],
445
 
446
                                          w1data[2*DWIDTH/4 - 5:2*DWIDTH/4 - 16],
447
                                          w1data[2*DWIDTH/4 - 1 :2*DWIDTH/4 - 4],
448
 
449
                                          w1data[1*DWIDTH/4 - 5:1*DWIDTH/4 - 16],
450
                                          w1data[1*DWIDTH/4 - 1 :1*DWIDTH/4 - 4]
451
 
452
                                          };
453
 
454
 
455
         end
456
 
457
      end  //(DQ_PINS == 16 
458
      else if (NUM_DQ_PINS == 8) begin
459
         if(cmd_startC)  // loading data pattern according the incoming address
460
 
461
                 if (data_mode_i == 3'b100)
462
 
463
                   case (addr_i[3])
464
 
465
 
466
                       0:  w1data <= #TCQ    {
467
                                   BLANK,SHIFT_3,BLANK,SHIFT_2,
468
                                   BLANK,SHIFT_1,BLANK,SHIFT_0
469
                                   };
470
 
471
                       1:  w1data <= #TCQ    {
472
                                   BLANK,SHIFT_7,BLANK,SHIFT_6,
473
                                   BLANK,SHIFT_5,BLANK,SHIFT_4
474
                                   };
475
 
476
                       default :begin
477
                         w1data <= #TCQ    'b0;    //15:8 
478
                    end
479
 
480
                    endcase
481
 
482
                  else
483
                  w1data <= #TCQ    {32'h8040_2010,32'h0804_0201};  //**** checked
484
         else  // Shifting
485
                 if (data_mode_i == 3'b100)
486
 
487
               begin
488
                 w1data[63:56] <= #TCQ    {8'h00};
489
                 w1data[55:48] <= #TCQ    {w1data[51:48],w1data[55:52]};
490
 
491
                 w1data[47:40] <= #TCQ    {8'h00};
492
                 w1data[39:32] <= #TCQ    {w1data[35:32],w1data[39:36]};
493
 
494
                 w1data[31:24] <= #TCQ    {8'h00};
495
                 w1data[23:16] <= #TCQ    {w1data[19:16],w1data[23:20]};
496
 
497
                 w1data[15:8]  <= #TCQ    {8'h00};
498
                 w1data[7:0]  <= #TCQ    {w1data[3:0],w1data[7:4]};
499
 
500
               end
501
                 else
502
                      w1data <= #TCQ    w1data;
503
      end //(NUM_DQ_PINS == 8)
504
      else if (NUM_DQ_PINS == 4) // NUM_DQ_PINS == 4   
505
            if (data_mode_i == 3'b100)
506
               w1data <= #TCQ    64'h0804_0201_0804_0201;
507
            else
508
               w1data <= #TCQ    64'h8421_8421_8421_8421;
509
 
510
  end
511
end
512
endgenerate
513
 
514
generate
515
 
516
if (DWIDTH == 128 && (DATA_PATTERN == "DGEN_WALKING0" || DATA_PATTERN == "DGEN_WALKING1" || DATA_PATTERN == "DGEN_ALL"))  begin : WALKING_ONE_128_PATTERN
517
 
518
  always @ (posedge clk_i)
519
  begin
520
   if (rst_i)
521
        w1data <= #TCQ  'b0;
522
 
523
   else if((fifo_rdy_i && user_burst_cnt != 6'd0) || cmd_startC )
524
 
525
 
526
 
527
      if (NUM_DQ_PINS == 16)
528
      begin
529
         if(cmd_startC)
530
           begin
531
             case (addr_i[4])
532
 
533
 
534
                 0: begin
535
 
536
                    w1data[1*DWIDTH/4-1:0*DWIDTH/4]    <= #TCQ  SHIFTB_0;
537
                    w1data[2*DWIDTH/4-1:1*DWIDTH/4]    <= #TCQ  SHIFTB_1;   //  32                                       
538
                    w1data[3*DWIDTH/4-1:2*DWIDTH/4]    <= #TCQ  SHIFTB_2;
539
                    w1data[4*DWIDTH/4-1:3*DWIDTH/4]    <= #TCQ  SHIFTB_3;
540
 
541
 
542
                    end
543
                 1:  begin
544
 
545
                    w1data[1*DWIDTH/4-1:0*DWIDTH/4]    <= #TCQ  SHIFTB_4;
546
                    w1data[2*DWIDTH/4-1:1*DWIDTH/4]    <= #TCQ  SHIFTB_5;   //  32                                       
547
                    w1data[3*DWIDTH/4-1:2*DWIDTH/4]    <= #TCQ  SHIFTB_6;
548
                    w1data[4*DWIDTH/4-1:3*DWIDTH/4]    <= #TCQ  SHIFTB_7;
549
 
550
                    end
551
 
552
              default :begin
553
                    w1data <= #TCQ  BLANK;    //15:8 
554
 
555
                    end
556
 
557
             endcase
558
 
559
           end  //(NUM_DQ_PINS == 16) (cmd_startC)      
560
         else begin  //shifting
561
              if (data_mode_i == 3'b100)
562
               begin
563
                 w1data[127:112] <= #TCQ    {16'h0000};
564
                 w1data[111:96] <= #TCQ    {w1data[107:96],w1data[111:108]};
565
                 w1data[95:80] <= #TCQ    {16'h0000};
566
                 w1data[79:64] <= #TCQ    {w1data[75:64],w1data[79:76]};
567
 
568
 
569
                 w1data[63:48] <= #TCQ    {16'h0000};
570
                 w1data[47:32] <= #TCQ    {w1data[43:32],w1data[47:44]};
571
                 w1data[31:16] <= #TCQ    {16'h0000};
572
                 w1data[15:0] <= #TCQ    {w1data[11:0],w1data[15:12]};
573
 
574
               end
575
              else begin
576
              w1data[DWIDTH - 1:0]             <= #TCQ  {
577
                                                    w1data[4*DWIDTH/4 - 9:4*DWIDTH/4 - 16],
578
                                                    w1data[4*DWIDTH/4 - 1 :4*DWIDTH/4 - 8],
579
                                                    w1data[4*DWIDTH/4 - 25:4*DWIDTH/4 -32],
580
                                                    w1data[4*DWIDTH/4 - 17:4*DWIDTH/4 -24],
581
 
582
                                                    w1data[3*DWIDTH/4 - 9:3*DWIDTH/4 - 16],
583
                                                    w1data[3*DWIDTH/4 - 1 :3*DWIDTH/4 - 8],
584
                                                    w1data[3*DWIDTH/4 - 25:3*DWIDTH/4 - 32],
585
                                                    w1data[3*DWIDTH/4 - 17:3*DWIDTH/4 - 24],
586
 
587
                                                    w1data[2*DWIDTH/4 - 9:2*DWIDTH/4 - 16],
588
                                                    w1data[2*DWIDTH/4 - 1 :2*DWIDTH/4 - 8],
589
                                                    w1data[2*DWIDTH/4 - 25:2*DWIDTH/4 - 32],
590
                                                    w1data[2*DWIDTH/4 - 17:2*DWIDTH/4 - 24],
591
 
592
 
593
                                                    w1data[1*DWIDTH/4 - 9:1*DWIDTH/4 - 16],
594
                                                    w1data[1*DWIDTH/4 - 1 :1*DWIDTH/4 - 8],
595
                                                    w1data[1*DWIDTH/4 - 25:1*DWIDTH/4 - 32],
596
                                                    w1data[1*DWIDTH/4 - 17 :1*DWIDTH/4 - 24]
597
                                                    };
598
             end
599
 
600
         end
601
 
602
      end  //(DQ_PINS == 16 
603
      else if (NUM_DQ_PINS == 8) begin
604
         if(cmd_startC)  // loading data pattern according the incoming address
605
            begin
606
                        if (data_mode_i == 3'b100)
607
                         w1data <= #TCQ    {
608
                                          BLANK,SHIFT_7,BLANK,SHIFT_6,
609
                                          BLANK,SHIFT_5,BLANK,SHIFT_4,
610
                                          BLANK,SHIFT_3,BLANK,SHIFT_2,
611
                                          BLANK,SHIFT_1,BLANK,SHIFT_0
612
                                          };
613
                        else
614
                       //  w1data <= #TCQ    {32'h8040_2010,32'h0804_0201,32'h8040_2010,32'h0804_0201};
615
                         w1data <= #TCQ    {
616
                                          SHIFT_7,SHIFT_6,SHIFT_5,SHIFT_4,
617
                                          SHIFT_3,SHIFT_2,SHIFT_1,SHIFT_0,
618
                                          SHIFT_7,SHIFT_6,SHIFT_5,SHIFT_4,
619
                                          SHIFT_3,SHIFT_2,SHIFT_1,SHIFT_0
620
                                          };
621
 
622
 
623
            end // (cmd_startC)   
624
        else  // Shifting
625
 
626
                 begin
627
 
628
                      w1data <= #TCQ    w1data;//{w1data[96:64], w1data[127:97],w1data[31:0], w1data[63:32]}; 
629
                 end // else
630
      end //(NUM_DQ_PINS == 8)
631
      else
632
         if (data_mode_i == 3'b100)
633
          w1data <= #TCQ    128'h0804_0201_0804_0201_0804_0201_0804_0201;
634
         else
635
          w1data <= #TCQ    128'h8421_8421_8421_8421_8421_8421_8421_8421;
636
 
637
  end
638
end
639
endgenerate
640
 
641
// HAMMER_PATTERN: Alternating 1s and 0s on DQ pins 
642
//                 => the rsing data pattern will be    32'b11111111_11111111_11111111_11111111
643
//                 => the falling data pattern will be  32'b00000000_00000000_00000000_00000000
644
generate
645
if ( DWIDTH == 32 &&( DATA_PATTERN == "DGEN_HAMMER" || DATA_PATTERN == "DGEN_ALL"))  begin : HAMMER_PATTERN_32
646
  always @ (posedge clk_i)
647
  begin
648
    if (rst_i)
649
      hdata <= #TCQ    'd0;
650
    else if((fifo_rdy_i && user_burst_cnt != 6'd0) || cmd_startC ) begin
651
      if (NUM_DQ_PINS == 16)
652
           hdata <= #TCQ    32'h0000_FFFF;
653
      else if (NUM_DQ_PINS == 8)
654
           hdata <= #TCQ    32'h00FF_00FF;
655
      else if (NUM_DQ_PINS == 4)     // NUM_DQ_PINS == 4    
656
           hdata <= #TCQ    32'h0F0F_0F0F;
657
    end
658
  end
659
end
660
endgenerate
661
 
662
 
663
generate
664
if ( DWIDTH == 64 && (DATA_PATTERN == "DGEN_HAMMER" || DATA_PATTERN == "DGEN_ALL"))  begin : HAMMER_PATTERN_64
665
  always @ (posedge clk_i)
666
  begin
667
    if (rst_i)
668
      hdata <= #TCQ    'd0;
669
    else if((fifo_rdy_i && user_burst_cnt != 6'd0) || cmd_startC )
670
      if (NUM_DQ_PINS == 16)
671
           hdata <= #TCQ    64'h0000FFFF_0000FFFF;
672
      else if (NUM_DQ_PINS == 8)
673
           hdata <= #TCQ    64'h00FF00FF_00FF00FF;
674
      else if (NUM_DQ_PINS == 4)     // NUM_DQ_PINS == 4    
675
           hdata <= #TCQ    64'h0F0F_0F0F_0F0F_0F0F;
676
 
677
  end
678
end
679
endgenerate
680
 
681
 
682
generate
683
if ( DWIDTH == 128 && (DATA_PATTERN == "DGEN_HAMMER" || DATA_PATTERN == "DGEN_ALL"))  begin : HAMMER_PATTERN_128
684
  always @ (posedge clk_i)
685
  begin
686
    if (rst_i)
687
      hdata <= #TCQ    'd0;
688
    else if((fifo_rdy_i && user_burst_cnt != 6'd0) || cmd_startC )
689
      if (NUM_DQ_PINS == 16)
690
           hdata <= #TCQ    128'h0000FFFF_0000FFFF_0000FFFF_0000FFFF;
691
      else if (NUM_DQ_PINS == 8)
692
           hdata <= #TCQ    128'h00FF00FF_00FF00FF_00FF00FF_00FF00FF;
693
      else if (NUM_DQ_PINS == 4)     // NUM_DQ_PINS == 4    
694
           hdata <= #TCQ    128'h0F0F_0F0F_0F0F_0F0F_0F0F_0F0F_0F0F_0F0F;
695
 
696
  end
697
end
698
endgenerate
699
 
700
 
701
always @ (w1data,hdata)
702
begin
703
for (i=0; i <= DWIDTH - 1; i= i+1)
704
   ndata[i] = hdata[i] ^ w1data[i];
705
 
706
         end
707
 
708
 
709
 
710
 
711
// HAMMER_PATTERN_MINUS: generate walking HAMMER  data pattern except 1 bit for the whole burst. The incoming addr_i[5:2] determine 
712
// the position of the pin driving oppsite polarity
713
//  addr_i[6:2] = 5'h0f ; 32 bit data port
714
//                 => the rsing data pattern will be    32'b11111111_11111111_01111111_11111111
715
//                 => the falling data pattern will be  32'b00000000_00000000_00000000_00000000
716
 
717
// ADDRESS_PATTERN: use the address as the 1st data pattern for the whole burst. For example
718
// Dataport 32 bit width with starting addr_i  = 30'h12345678, user burst length 4
719
//                 => the 1st data pattern :     32'h12345678
720
//                 => the 2nd data pattern :     32'h12345679
721
//                 => the 3rd data pattern :     32'h1234567a
722
//                 => the 4th data pattern :     32'h1234567b
723
generate
724
 
725
//data_rdy_i
726
 
727
if (DATA_PATTERN == "DGEN_ADDR"  || DATA_PATTERN == "DGEN_ALL")  begin : ADDRESS_PATTERN
728
//data_o logic
729
always @ (posedge clk_i)
730
begin
731
  if (cmd_startD)
732
    adata <= #TCQ    addr_i;
733
  else if(fifo_rdy_i && data_rdy_i && user_burst_cnt > 6'd1)
734
         if (DWIDTH == 128)
735
                 adata <= #TCQ    adata + 16;
736
         else if (DWIDTH == 64)
737
                 adata <= #TCQ    adata + 8;
738
         else     // DWIDTH == 32   
739
                 adata <= #TCQ    adata + 4;
740
end
741
end
742
endgenerate
743
 
744
 
745
// PRBS_PATTERN: use the address as the PRBS seed data pattern for the whole burst. For example
746
// Dataport 32 bit width with starting addr_i = 30'h12345678, user burst length 4
747
//                
748
 
749
generate
750
if (DATA_PATTERN == "DGEN_PRBS"  || DATA_PATTERN == "DGEN_ALL")  begin : PRBS_PATTERN
751
 
752
//   PRBS DATA GENERATION
753
// xor all the tap positions before feedback to 1st stage.
754
 
755
 
756
 
757
assign data_clk_en = fifo_rdy_i && data_rdy_i && user_burst_cnt > 6'd1;
758
 
759
 
760
data_prbs_gen #
761
  (
762
    .TCQ        (TCQ),
763
    .PRBS_WIDTH (32),
764
    .SEED_WIDTH (32)
765
   )
766
   data_prbs_gen
767
  (
768
   .clk_i            (clk_i),
769
   .clk_en           (data_clk_en),
770
   .rst_i            (rst_i),
771
   .prbs_fseed_i     (prbs_fseed_i),
772
   .prbs_seed_init   (cmd_startE),
773
   .prbs_seed_i      (addr_i[31:0]),
774
   .prbs_o           (prbs_data)
775
 
776
  );
777
end
778
endgenerate
779
 
780
 
781
endmodule

powered by: WebSVN 2.1.0

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