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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [regtool/] [gen_registers] - Blame information for rev 123

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

Line No. Rev Author Line
1 119 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3
 
4
#/**********************************************************************/
5
#/*                                                                    */
6
#/*             -------                                                */
7
#/*            /   SOC  \                                              */
8
#/*           /    GEN   \                                             */
9
#/*          /    TOOL    \                                            */
10
#/*          ==============                                            */
11
#/*          |            |                                            */
12
#/*          |____________|                                            */
13
#/*                                                                    */
14
#/*                                                                    */
15
#/*                                                                    */
16
#/*  Author(s):                                                        */
17
#/*      - John Eaton, jt_eaton@opencores.org                          */
18
#/*                                                                    */
19
#/**********************************************************************/
20
#/*                                                                    */
21
#/*    Copyright (C) <2010-2011>                */
22
#/*                                                                    */
23
#/*  This source file may be used and distributed without              */
24
#/*  restriction provided that this copyright statement is not         */
25
#/*  removed from the file and that any derivative work contains       */
26
#/*  the original copyright notice and the associated disclaimer.      */
27
#/*                                                                    */
28
#/*  This source file is free software; you can redistribute it        */
29
#/*  and/or modify it under the terms of the GNU Lesser General        */
30
#/*  Public License as published by the Free Software Foundation;      */
31
#/*  either version 2.1 of the License, or (at your option) any        */
32
#/*  later version.                                                    */
33
#/*                                                                    */
34
#/*  This source is distributed in the hope that it will be            */
35
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
36
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
37
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
38
#/*  details.                                                          */
39
#/*                                                                    */
40
#/*  You should have received a copy of the GNU Lesser General         */
41
#/*  Public License along with this source; if not, download it        */
42
#/*  from http://www.opencores.org/lgpl.shtml                          */
43
#/*                                                                    */
44
#/**********************************************************************/
45
 
46
 
47
 
48
############################################################################
49
# General PERL config
50
############################################################################
51
use Getopt::Long;
52
use English;
53
use File::Basename;
54
use Cwd;
55
use XML::LibXML;
56
use lib './tools';
57
use sys::lib;
58
use yp::lib;
59
 
60
 
61
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
62
 
63
 
64
############################################################################
65
### Process the options
66
############################################################################
67
 
68
Getopt::Long::config("require_order", "prefix=-");
69
GetOptions("h",
70
           "view=s" => \$view,
71
           "prefix=s" => \$prefix,
72
           "vendor=s" => \$vendor,
73
           "project=s" => \$project,
74
           "version=s" => \$version,
75
           "component=s" => \$component,
76
           "dest_dir=s" => \$dest_dir,
77
           "bus_intf=s" => \$bus_intf
78
) || die "(use '$program_name -h' for help)";
79
 
80
 
81
##############################################################################
82
## Help option
83
##############################################################################
84
if (  $opt_h )
85
   {
86
   print "\n build_registers  -view {sim|syn} -prefix /work -project project_name   -component comp_name  -version version_name  -bus_intf bus_interface  -dest_dir dest_dir";
87
   print "\n";
88
   exit 1;
89
   }
90
 
91
 
92
##############################################################################
93
##
94
##############################################################################
95
 
96
 
97
 
98
$home = cwd();
99
 
100
my $variant;
101
 if($version)       {$variant   = "${component}_${version}";}
102
 else               {$variant   = "${component}";}
103
 
104
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$project);
105
my $comp_xml_sep    = yp::lib::find_ipxact_component_path("spirit:component",$vendor,$project,$component,$version);
106
 
107
#############################################################################
108
##
109
##
110
#############################################################################
111
 
112
print "  Building $view  RTL Registers  for  $prefix $vendor $project  $component  $variant in $dest_dir\n" ;
113
 
114
 
115
 
116
my $path  = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}";
117
mkdir $path,0755             unless( -e $path );
118
 
119
my $path  = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${view}";
120
mkdir $path,0755             unless( -e $path );
121
 
122
 
123
 
124
my $name;
125
my $library;
126
my $memmap_name;
127
my $memmap_base;
128
my $addblk_name;
129
my $addblk_range;
130
my $addblk_numrange;
131
my $addblk_numaddbits;
132
my $addblk_width;
133
my $byte_size;
134
my $reg_dim;
135
my $memMap;
136
 
137
 
138
my $memmap_name;
139
my $memmap_base;
140
my $memmap_numbase;
141
my $memmap_size;
142
my $memmap_type;
143
my $parmap_name;
144
 
145
my $reg_offset;
146
my $reg_numoffset;
147
my $reg_dimbits;
148
my $reg_create;
149
my $reg_has_read;
150
my $reg_has_write;
151
my $opt_bigendian;
152
 
153
my  $reg_numdim;
154
 
155
my $max_dim = 1;
156
my $max_has_read = 0;
157
my $max_has_write = 0;
158
my $max_has_create = 0;
159
 
160
my $pad;
161
my $sys_byte_lanes;
162
 
163
 
164
@registers = ();
165
 
166
#/**********************************************************************/
167
#/*                                                                    */
168
#/* Parse register block info from ip-xact file                        */
169
#/*                                                                    */
170
#/*                                                                    */
171
#/**********************************************************************/
172
 
173
 
174
 
175
my $parser = XML::LibXML->new();
176
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
177
 
178
   $name     = $spirit_component_file->findnodes('//spirit:component/spirit:name/text()')->to_literal ;
179
   $version  = $spirit_component_file->findnodes('//spirit:component/spirit:version/text()')->to_literal ;
180
   $vendor   = $spirit_component_file->findnodes('//spirit:component/spirit:vendor/text()')->to_literal ;
181
   $library  = $spirit_component_file->findnodes('//spirit:component/spirit:library/text()')->to_literal ;
182
 
183
foreach my $bus_iface ($spirit_component_file->findnodes("//spirit:busInterface[spirit:name/text() = '$bus_intf']/spirit:slave"))
184
   {
185
   $BI_name         = $bus_iface->findnodes('../spirit:name/text()')->to_literal ;
186
   $BI_endian       = $bus_iface->findnodes('../spirit:endianness/text()')->to_literal ;
187
   $BI_width        = $bus_iface->findnodes('../spirit:bitsInLau/text()')->to_literal ;
188
   $BI_xname        = $bus_iface->findnodes('../spirit:abstractionType/@spirit:name')->to_literal ;
189
   $memMap          = $bus_iface->findnodes('../spirit:slave/spirit:memoryMapRef/@spirit:memoryMapRef')->to_literal ;
190
   }
191
 
192
unless($BI_endian) {$BI_endian = "little";}
193
$byte_size         = int($BI_width) ;
194
 
195
 
196
 
197
 
198
 
199
 
200
 
201
foreach my $comp_view ($spirit_component_file->findnodes("//spirit:memoryMap[spirit:name/text() = '$memMap']"))
202
   {
203
   $memmap_name  = $comp_view->findnodes('./spirit:bank/spirit:name/text()')->to_literal ;
204
   $memmap_base  = $comp_view->findnodes('./spirit:bank/spirit:baseAddress/text()')->to_literal ;
205
   $memmap_size  = $comp_view->findnodes('./spirit:addressUnitBits/text()')->to_literal ;
206
   $memmap_type  = $comp_view->findnodes('./spirit:bank/@spirit:bankAlignment')->to_literal ;
207
   $parmap_name  = $comp_view->findnodes('./spirit:name/text()')->to_literal ;
208
 
209
 
210
 
211
   $memmap_numbase = hex($memmap_base);
212
 
213
   #/**********************************************************************/
214
   #/*                                                                    */
215
   #/* Print header, module name and start parameters                     */
216
   #/*                                                                    */
217
   #/*                                                                    */
218
   #/**********************************************************************/
219
 
220
   my $outfile ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${name}_${version}_${memmap_name}";
221
   open   OUTFILE,">$outfile" or die "unable to open $outfile";
222
 
223
   print  OUTFILE " /*********************************************/  \n";
224
   print  OUTFILE sprintf(" /* Vendor:       %24s    */  \n",$vendor);
225
   print  OUTFILE sprintf(" /* Library:      %24s    */  \n",$library);
226
   print  OUTFILE sprintf(" /* Component:    %24s    */  \n",$name);
227
   print  OUTFILE sprintf(" /* Version:      %24s    */  \n",$version);
228
   print  OUTFILE sprintf(" /* MemMap:       %24s    */  \n",$memmap_name);
229
   print  OUTFILE sprintf(" /* Base:         %24s    */  \n",$memmap_base);
230
   print  OUTFILE sprintf(" /* Type:         %24s    */  \n",$memmap_type);
231
 
232
 
233
 
234
 
235
   if($BI_endian eq "big" )
236
   {
237
   $opt_bigendian = 1;
238
   print  OUTFILE   " /* Endian:                            Big    */  \n";
239
   }
240
   else
241
 
242
   {
243
   print  OUTFILE   " /* Endian:                         Little    */  \n";
244
   $opt_bigendian = 0;
245
   }
246
 
247
   print  OUTFILE sprintf(" /*********************************************/  \n");
248
 
249
 
250
   foreach my $comp_view ($spirit_component_file->findnodes("//spirit:memoryMap[spirit:name/text() = '$memMap']/spirit:bank/spirit:addressBlock/spirit:name"))
251
   {
252
   $addblk_name    = $comp_view->findnodes('../spirit:name/text()')->to_literal;
253
   $addblk_range   = $comp_view->findnodes('../spirit:range/text()')->to_literal;
254
   $addblk_width   = $comp_view->findnodes('../spirit:width/text()')->to_literal;
255
 
256
 
257
 
258
   $addblk_numrange = hex($addblk_range);
259
   $addblk_numaddbits = log($addblk_numrange)/log(2);
260
 
261
   $sys_byte_lanes  = int( $addblk_width) / $byte_size ;
262
 
263
   if    ($sys_byte_lanes == 4 ) { $adr_base = 2;}
264
   elsif ($sys_byte_lanes == 2 ) { $adr_base = 1;}
265
   else                          { $adr_base = 0;}
266
 
267
 
268
   print  OUTFILE sprintf(" /* AddressBlock: %24s    */  \n",$addblk_name);
269
   print  OUTFILE sprintf(" /* NumBase:      %24s    */  \n",$memmap_numbase);
270
   print  OUTFILE sprintf(" /* Range:        %24s    */  \n",$addblk_range);
271
   print  OUTFILE sprintf(" /* NumRange:     %24s    */  \n",$addblk_numrange);
272
   print  OUTFILE sprintf(" /* NumAddBits:   %24s    */  \n",$addblk_numaddbits);
273
   print  OUTFILE sprintf(" /* Width:        %24s    */  \n",$addblk_width);
274
   print  OUTFILE sprintf(" /* Byte_lanes:   %24s    */  \n",$sys_byte_lanes);
275
   print  OUTFILE sprintf(" /* Byte_size:    %24s    */  \n",$byte_size);
276
   print  OUTFILE sprintf(" /*********************************************/  \n");
277
 
278
 
279
   foreach my $reg_view ($spirit_component_file->findnodes("//spirit:memoryMap[spirit:name/text() = '$memMap']/spirit:bank/spirit:addressBlock[spirit:name/text() = '$addblk_name']/spirit:register/spirit:name "))
280
 
281
        {
282
        $reg_name    = $reg_view->findnodes('./text()')->to_literal ;
283
        $reg_offset  = $reg_view->findnodes('../spirit:addressOffset/text()')->to_literal ;
284
        $reg_dim     = $reg_view->findnodes('../spirit:dim/text()')->to_literal ;
285
        $reg_size    = $reg_view->findnodes('../spirit:size/text()')->to_literal ;
286
        $reg_access  = $reg_view->findnodes('../spirit:access/text()')->to_literal ;
287
        $reg_numoffset = hex($reg_offset) + $memmap_numbase;
288
        unless($reg_dim) {$reg_dim     = "0x1" ;}
289
        $reg_numdim         = hex($reg_dim);
290
 
291
        if($reg_numdim > $max_dim )  {$max_dim = $reg_numdim;}
292
 
293
        if($reg_numdim)
294
          {
295
          $reg_dimbits      = log($reg_numdim)/log(2);
296
          }
297
        else
298
          {
299
          $reg_dimbits    = 1;
300
          }
301
 
302
        if($reg_access eq "read-write")
303
         {
304
          $reg_has_read   = 1;
305
          $reg_has_write  = 1;
306
          if($reg_numdim)
307
            {
308
            if($reg_dimbits)     {$reg_create     = 0;}
309
            else                 {$reg_create     = 1;}
310
            }
311
          else
312
            {
313
            $reg_create     = 0;
314
            }
315
         }
316
 
317
 
318
 
319
 
320
 
321
 
322
        if($reg_access eq "read-only")
323
         {
324
          $reg_has_read   = 1;
325
          $reg_has_write  = 0;
326
          if($reg_numdim)
327
            {
328
            if($reg_dimbits)     {$reg_create     = 0;}
329
            else                 {$reg_create     = 1;}
330
            }
331
          else
332
            {
333
            $reg_create     = 0;
334
            }
335
 
336
         }
337
 
338
 
339
        if($reg_access eq "write-only")
340
         {
341
          $reg_has_read   = 0;
342
          $reg_has_write  = 1;
343
          if($reg_numdim)
344
            {
345
            if($reg_dimbits)     {$reg_create     = 0;}
346
            else                 {$reg_create     = 1;}
347
            }
348
          else
349
            {
350
            $reg_create     = 0;
351
            }
352
 
353
         }
354
 
355
 
356
        if($reg_access eq "write-strobe")
357
         {
358
          $reg_has_read   = 0;
359
          $reg_has_write  = 1;
360
          $reg_create     = 0;
361
         }
362
 
363
     if($reg_has_read){$max_has_read = 1;}
364
     if($reg_has_write){$max_has_write = 1;}
365
     if($reg_create)   {$max_has_create = 1;}
366
 
367
 
368
 
369
 
370
 
371
 
372
          print  OUTFILE sprintf(" /* Reg Name:       %22s    */  \n",$reg_name);
373
          print  OUTFILE sprintf(" /* Reg Offset:     %22s    */  \n",$reg_offset);
374
          print  OUTFILE sprintf(" /* Reg numOffset:  %22s    */  \n",$reg_numoffset);
375
          print  OUTFILE sprintf(" /* Reg size:       %22s    */  \n",$reg_size);
376
          print  OUTFILE sprintf(" /* Reg Dim:        %22s    */  \n",$reg_dim);
377
          print  OUTFILE sprintf(" /* Reg numDim:     %22s    */  \n",$reg_numdim);
378
          print  OUTFILE sprintf(" /* Reg DimBits:    %22s    */  \n",$reg_dimbits);
379
          print  OUTFILE sprintf(" /* Reg Create:     %22s    */  \n",$reg_create);
380
          print  OUTFILE sprintf(" /* Reg access:     %22s    */  \n",$reg_access);
381
          print  OUTFILE sprintf(" /* Reg has_read:   %22s    */  \n",$reg_has_read);
382
          print  OUTFILE sprintf(" /* Reg has_write:  %22s    */  \n",$reg_has_write);
383
          print  OUTFILE sprintf(" /*********************************************/  \n");
384
 
385
          push @registers , ":::${reg_name}:::${reg_numoffset}:::${reg_size}:::${reg_numdim}:::${reg_dimbits}:::${reg_create}:::${reg_access}:::${reg_has_read}:::${reg_has_write}:::";
386
 
387
        }
388
   }
389
 
390
   if($memmap_type eq "serial")    {     $memmap_numbase = $memmap_numbase + $addblk_numrange;     }
391
 
392
 
393
 
394
 
395
   }
396
 
397
 
398
 
399
 
400
          $num_add = log($max_dim)/log(2);
401
          print  OUTFILE sprintf(" /*********************************************/  \n");
402
          print  OUTFILE sprintf(" /* Max_dim:        %22s    */  \n",$max_dim);
403
          print  OUTFILE sprintf(" /* num_add:        %22s    */  \n",$num_add);
404
          print  OUTFILE sprintf(" /* mas_has_read:   %22s    */  \n",$max_has_read);
405
          print  OUTFILE sprintf(" /* mas_has_write:  %22s    */  \n",$max_has_write);
406
          print  OUTFILE sprintf(" /* mas_has_create: %22s    */  \n",$max_has_create);
407
          print  OUTFILE sprintf(" /*********************************************/  \n");
408
 
409
 
410
 
411
 
412
 
413
 
414
 
415
 
416
 
417
 
418
   print  OUTFILE     " /*********************************************/  \n";
419
   print  OUTFILE "\n\nmodule `VARIANT`";
420
   print  OUTFILE  uc(${memmap_name});
421
   print  OUTFILE "\n";
422
   print  OUTFILE "#(  parameter UNSELECTED = {${addblk_width}{1'b1}},\n";
423
   print  OUTFILE "    parameter UNMAPPED   = {${addblk_width}{1'b0}}";
424
 
425
 
426
 
427
 
428
 
429
 
430
 
431
 
432
     foreach $line (@registers)
433
        {
434
 
435
        $_ = $line;
436
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
437
          {
438
          my $t_name                = $1;
439
          my $t_numoffset           = $2;
440
          my $t_size                = $3;
441
          my $t_numdim              = $4;
442
          my $t_dimbits             = $5;
443
          my $t_create              = $6;
444
          my $t_access              = $7;
445
          my $t_has_read            = $8;
446
          my $t_has_write           = $9;
447
 
448
          if( $t_has_write eq "1" and   $t_create eq "1")
449
            {
450
            print  OUTFILE ",\n    parameter ";
451
            print  OUTFILE uc(${t_name});
452
            print  OUTFILE "_RST = ${t_size}'b0";
453
            }
454
 
455
         $pad = $byte_size -( int(${t_size}) % $byte_size )  ;
456
         if ( $pad == $byte_size ) { $pad = 0;}
457
 
458
 
459
 
460
        if($pad)
461
          {
462
          if( $t_has_read eq "1")
463
            {
464
            print  OUTFILE ",\n    parameter ";
465
            print  OUTFILE uc(${t_name});
466
            print  OUTFILE "_PAD = ${pad}'b0";
467
            }
468
 
469
       }
470
 
471
         }
472
       }
473
 
474
   print  OUTFILE ")\n ";
475
 
476
 
477
 
478
 
479
 
480
 
481
 
482
   #/**********************************************************************/
483
   #/*                                                                    */
484
   #/* Print io ports                                                     */
485
   #/*                                                                    */
486
   #/*                                                                    */
487
   #/**********************************************************************/
488
 
489
   print  OUTFILE "(\n";
490
   print  OUTFILE " input  wire             clk,\n";
491
   print  OUTFILE " input  wire             reset,\n";
492
   print  OUTFILE " input  wire             enable,\n";
493
   print  OUTFILE " input  wire             cs,\n";
494
   if($max_has_write){   print  OUTFILE " input  wire             wr,\n";}
495
   if($max_has_read) {print  OUTFILE " input  wire             rd,\n";}
496
   if($max_has_write) {print  OUTFILE " input  wire  [${addblk_width}-1:0]    wdata,\n";}
497
   if($max_has_read) {print  OUTFILE " output  reg  [${addblk_width}-1:0]    rdata,\n";}
498
   print  OUTFILE " input  wire  [${sys_byte_lanes}-1:0]    byte_lanes,\n";
499
   print  OUTFILE " input  wire  [${addblk_numaddbits}-1:${adr_base}]    addr";
500
 
501
   if($max_dim gt "1" )
502
     {
503
     print  OUTFILE " ,\n output  wire  [${num_add}-1:0]    addr_out";
504
     }
505
 
506
 
507
 
508
 
509
 
510
 
511
 
512
 
513
 
514
 
515
     foreach $line (@registers)
516
        {
517
        $_ = $line;
518
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
519
          {
520
          my $t_name                = $1;
521
          my $t_numoffset           = $2;
522
          my $t_size                = $3;
523
          my $t_numdim              = $4;
524
          my $t_dimbits             = $5;
525
          my $t_create              = $6;
526
          my $t_access              = $7;
527
          my $t_has_read            = $8;
528
          my $t_has_write           = $9;
529
 
530
        print  OUTFILE ",\n output  wire  ${t_name}_cs  ";
531
        print  OUTFILE ",\n output   reg  ${t_name}_dec  ";
532
 
533
        if($t_size == 1)
534
          {
535
          if( $t_has_read eq "1")
536
            {
537
            print  OUTFILE ",\n input  wire                     ${t_name}_rdata  ";
538
            }
539
 
540
          if( $t_has_write eq "1")
541
            {
542
            print  OUTFILE ",\n output   reg  ${t_name}_wr_0  ";
543
            if( $t_create eq "1")
544
              {
545
              print  OUTFILE ",\n output  reg                     $t_name  ";
546
              print  OUTFILE ",\n input  wire                     next_${t_name}  ";
547
              }
548
            else
549
              {
550
              print  OUTFILE ",\n output  reg                     ${t_name}_wdata  ";
551
              }
552
            }
553
          }
554
 
555
       else
556
          {
557
          if( $t_has_read eq "1")
558
            {
559
            print  OUTFILE ",\n input  wire  [${t_size}-1:0]    ${t_name}_rdata  ";
560
            }
561
 
562
          if( $t_has_write eq "1")
563
            {
564
            print  OUTFILE ",\n output   reg  ${t_name}_wr_0  ";
565
            if( $t_create eq "1")
566
              {
567
              print  OUTFILE ",\n output  reg  [${t_size}-1:0]    $t_name  ";
568
              print  OUTFILE ",\n input  wire  [${t_size}-1:0]    next_${t_name}  ";
569
              }
570
            else
571
              {
572
              print  OUTFILE ",\n output  reg  [${t_size}-1:0]    ${t_name}_wdata  ";
573
              }
574
            }
575
          }
576
 
577
 
578
        if( $t_has_write eq "1")
579
          {
580
          if($t_size > ${byte_size})        { print  OUTFILE ",\n output   reg  ${t_name}_wr_1  ";  }
581
          if($t_size > (${byte_size}*2))    { print  OUTFILE ",\n output   reg  ${t_name}_wr_2  ";  }
582
          if($t_size > (${byte_size}*3))    { print  OUTFILE ",\n output   reg  ${t_name}_wr_3  ";  }
583
          }
584
       }
585
     }
586
 
587
   print  OUTFILE "\n);\n\n\n";
588
 
589
 
590
 
591
 
592
 
593
 
594
 
595
 
596
 
597
 
598
 
599
 
600
 
601
 
602
 
603
 
604
 
605
 
606
 
607
 
608
 
609
 
610
 
611
 
612
 
613
 
614
 
615
 
616
 
617
 
618
   #/**********************************************************************/
619
   #/*                                                                    */
620
   #/* Print parameters for register addresses                            */
621
   #/*                                                                    */
622
   #/*                                                                    */
623
   #/**********************************************************************/
624
 
625
 
626
     foreach $line (@registers)
627
        {
628
        $_ = $line;
629
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
630
          {
631
          my $t_name                = $1;
632
          my $t_numoffset           = $2;
633
          my $t_size                = $3;
634
          my $t_numdim              = $4;
635
          my $t_dimbits             = $5;
636
          my $t_create              = $6;
637
          my $t_access              = $7;
638
          my $t_has_read            = $8;
639
          my $t_has_write           = $9;
640
 
641
          print  OUTFILE "parameter ";
642
          print  OUTFILE uc(${t_name});
643
          print  OUTFILE " = ${addblk_numaddbits}'d${t_numoffset};\n";
644
          my $register_addressOffset_end = $t_numoffset + $t_numdim;
645
          print  OUTFILE "parameter ";
646
          print  OUTFILE uc(${t_name});
647
          print  OUTFILE "_END = ${addblk_numaddbits}'d${register_addressOffset_end};\n";
648
 
649
          }
650
 
651
        }
652
 
653
 
654
 
655
 
656
 
657
   #/**********************************************************************/
658
   #/*                                                                    */
659
   #/* write data register creation                                       */
660
   #/*                                                                    */
661
   #/*                                                                    */
662
   #/**********************************************************************/
663
 
664
 
665
 
666
   print  OUTFILE "\n\n";
667
   print  OUTFILE " reg  [${addblk_width}-1:0]    rdata_i;\n";
668
 
669
 
670
 
671
     foreach $line (@registers)
672
        {
673
        $_ = $line;
674
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
675
          {
676
          my $t_name                = $1;
677
          my $t_numoffset           = $2;
678
          my $t_size                = $3;
679
          my $t_numdim              = $4;
680
          my $t_dimbits             = $5;
681
          my $t_create              = $6;
682
          my $t_access              = $7;
683
          my $t_has_read            = $8;
684
          my $t_has_write           = $9;
685
 
686
          if(( $t_has_write eq "1") and ( $t_create eq "1"))
687
            {
688
            if($t_size eq 1){ print  OUTFILE "reg   ${t_name}_wdata;\n";}
689
            else            { print  OUTFILE "reg  [${t_size}-1:0]    ${t_name}_wdata;\n";}
690
            }
691
          }
692
        }
693
 
694
 
695
 
696
 
697
 
698
 
699
 
700
 
701
 
702
 
703
 
704
 
705
 
706
 
707
 
708
 
709
 
710
 
711
 
712
   #/**********************************************************************/
713
   #/*                                                                    */
714
   #/* Set up for block width and endian                                  */
715
   #/* seperate pass for each byte lane                                   */
716
   #/*                                                                    */
717
   #/**********************************************************************/
718
 
719
 
720
 
721
 
722
 
723
 
724
   for ($log_byte_lane =0; $log_byte_lane < $sys_byte_lanes;  $log_byte_lane++)
725
       {
726
       if($adr_base == 2)
727
         {
728
         if ($opt_bigendian)
729
          {
730
          if    ( $log_byte_lane == 0) {$phy_byte_lane = 3;}
731
          elsif ( $log_byte_lane == 1) {$phy_byte_lane = 2;}
732
          elsif ( $log_byte_lane == 2) {$phy_byte_lane = 1;}
733
          else             {$phy_byte_lane = 0;}
734
          }
735
         else
736
           {$phy_byte_lane = $log_byte_lane}
737
        }
738
 
739
       elsif($adr_base == 1)
740
         {
741
         if ($opt_bigendian)
742
          {
743
          if    ( $log_byte_lane == 0) {$phy_byte_lane = 1;}
744
          else             {$phy_byte_lane = 0;}
745
          }
746
         else
747
           {$phy_byte_lane = $log_byte_lane}
748
        }
749
         else
750
           {$phy_byte_lane = $log_byte_lane}
751
 
752
 
753
 
754
    #/**********************************************************************/
755
    #/*                                                                    */
756
    #/* Debug                                                              */
757
    #/*                                                                    */
758
    #/*                                                                    */
759
    #/**********************************************************************/
760
 
761
 
762
     print  OUTFILE "/*QQQ        Reg_Name     Reg_Access sys_byte_lanes  reg_byte_lanes reg_size  reg_add   ar_base log_byte_lane phy_byte_lane  reg_lane   pad_size        padding     bigend    */  \n";
763
 
764
 
765
 
766
     foreach $line (@registers)
767
        {
768
        $_ = $line;
769
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
770
          {
771
          my $t_name                = $1;
772
          my $t_numoffset           = $2;
773
          my $t_size                = $3;
774
          my $t_numdim              = $4;
775
          my $t_dimbits             = $5;
776
          my $t_create              = $6;
777
          my $t_access              = $7;
778
          my $t_has_read            = $8;
779
          my $t_has_write           = $9;
780
 
781
 
782
          my $reg_byte_lane           =     $t_numoffset   % $sys_byte_lanes  ;
783
          my $reg_byte_lanes          =     $t_size   / ${byte_size}  ;
784
          my $pad_size                =     $t_size  % $byte_size    ;
785
 
786
 
787
 
788
       if($pad_size)  {$padding = $byte_size - $pad_size;}
789
       else
790
         {
791
         $padding = 0;
792
         $pad_size = ${byte_size};
793
         }
794
 
795
          $reg_byte_lanes   = ($padding +  $t_size)/ $byte_size;
796
          my $strng = sprintf( "/*QQQ %16s  %12s %11s  %6s          %6s   %6s   %6s   %6s            %6s      %6s          %2s       %6s     %6s       */  \n",${t_name},${t_access},${sys_byte_lanes},${reg_byte_lanes},${t_size},${t_numoffset},${adr_base},${log_byte_lane},${phy_byte_lane},${reg_byte_lane},${pad_size},${padding},${opt_bigendian});
797
 
798
         print  OUTFILE  $strng;
799
 
800
 
801
 
802
          }
803
        }
804
 
805
         print  OUTFILE "\n\n\n";
806
 
807
 
808
 
809
 
810
 
811
 
812
    #/**********************************************************************/
813
    #/*                                                                    */
814
    #/* Read Data Muxing                                                   */
815
    #/*                                                                    */
816
    #/*                                                                    */
817
    #/**********************************************************************/
818
 
819
 
820
    if($max_has_read == "1" and $max_has_create == "1")
821
     {
822
     print  OUTFILE "always@(*)\n";
823
     print  OUTFILE "  if(rd && cs)\n";
824
     print  OUTFILE "    begin\n";
825
     print  OUTFILE "  if(byte_lanes[ $phy_byte_lane ])\n";
826
     print  OUTFILE "   rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] =  rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}];         \n";
827
     print  OUTFILE "  else\n";
828
     print  OUTFILE "                rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = UNMAPPED;\n";
829
     print  OUTFILE "    end\n";
830
     print  OUTFILE "  else          rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = UNSELECTED;\n\n\n";
831
 
832
     print  OUTFILE "always@(*)\n";
833
     print  OUTFILE "    case(addr[$addblk_numaddbits-1:${adr_base}])\n";
834
 
835
 
836
 
837
 
838
 
839
 
840
 
841
 
842
     foreach $line (@registers)
843
        {
844
        $_ = $line;
845
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
846
          {
847
          my $t_name                = $1;
848
          my $t_numoffset           = $2;
849
          my $t_size                = $3;
850
          my $t_numdim              = $4;
851
          my $t_dimbits             = $5;
852
          my $t_create              = $6;
853
          my $t_access              = $7;
854
          my $t_has_read            = $8;
855
          my $t_has_write           = $9;
856
 
857
 
858
 
859
 
860
          my $reg_byte_lane           =     $t_numoffset   % $sys_byte_lanes  ;
861
          my $reg_byte_lanes          =     $t_size   / ${byte_size}  ;
862
          my $pad_size                =     $t_size  % $byte_size    ;
863
 
864
 
865
 
866
       if($pad_size)  {$padding = $byte_size - $pad_size;}
867
       else
868
         {
869
         $padding = 0;
870
         $pad_size = ${byte_size};
871
         }
872
 
873
          $reg_byte_lanes   = ($padding +  $t_size)/ $byte_size;
874
 
875
 
876
       my $REG_NAME =  uc($t_name);
877
 
878
 
879
 
880
       if(  $t_has_read eq "1" )
881
         {
882
 
883
         if(( $sys_byte_lanes eq "1" ) and ( $reg_byte_lanes  eq "1") )
884
            {
885
             if(   $reg_byte_lanes - 1  eq       $phy_byte_lane )
886
              {
887
              print  OUTFILE "${REG_NAME}[$addblk_numaddbits-1:${adr_base}]:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
888
              if($padding)
889
                {
890
                if($pad_size eq "1")
891
                  {                print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata };//QQQQ\n";}
892
                else
893
                  {                print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:$phy_byte_lane*${byte_size}] };//QQQQ\n";}
894
                }
895
              else         { print  OUTFILE " ${t_name}_rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] ;//QQQQ\n";}
896
              }
897
 
898
 
899
            }
900
 
901
         elsif( $sys_byte_lanes eq  $reg_byte_lanes )
902
            {
903
             if(   $reg_byte_lanes - 1  eq       $phy_byte_lane )
904
              {
905
              print  OUTFILE "${REG_NAME}[$addblk_numaddbits-1:${adr_base}]:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
906
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:$phy_byte_lane*${byte_size}] };//QQQQ\n"; }
907
              else         { print  OUTFILE " ${t_name}_rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] ;//QQQQ\n";}
908
              }
909
            else
910
              {
911
              print  OUTFILE "${REG_NAME}[$addblk_numaddbits-1:${adr_base}]:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
912
              print  OUTFILE " ${t_name}_rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] ;//QQQQ\n";
913
              }
914
            }
915
         elsif (  ($sys_byte_lanes eq "1") and  ( $reg_byte_lanes eq "2"))
916
            {
917
            if($opt_bigendian)
918
              {
919
              print  OUTFILE "{";
920
              print  OUTFILE "${REG_NAME}[$addblk_numaddbits-1:1],1'b1}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
921
              print  OUTFILE " ${t_name}_rdata[${byte_size}-1:0] ;//QQQQ\n";
922
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:1],1'b0}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
923
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:${byte_size}] };//QQQQ\n"; }
924
              else         { print  OUTFILE " ${t_name}_rdata[$(byte_size}-1:${byte_size}] ;//QQQQ\n";}
925
              }
926
            else
927
              {
928
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:1],1'b0}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
929
              print  OUTFILE "${t_name}_rdata[${byte_size}-1:0] ;//QQQQ\n";
930
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:1],1'b1}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
931
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:${byte_size}] };//QQQQ\n";}
932
              else         { print  OUTFILE " ${t_name}_rdata[$(byte_size}-1:${byte_size}] ;//QQQQ\n"; }
933
              }
934
            }
935
 
936
         elsif (  ($sys_byte_lanes eq "1") and  ( $reg_byte_lanes eq "3"))
937
            {
938
            if($opt_bigendian)
939
              {
940
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b11}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
941
              print  OUTFILE " ${t_name}_rdata[${byte_size}-1:0] ;//QQQQ\n";
942
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b10}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
943
              print  OUTFILE " ${t_name}_rdata[$(byte_size}-1:${byte_size}] ;//QQQQ\n";
944
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b01}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
945
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:(${byte_size}*2)] };//QQQQ\n"; }
946
              else         { print  OUTFILE " ${t_name}_rdata[(${byte_size}*3)-1:(${byte_size}*2)] ;//QQQQ\n"; }
947
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b00}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
948
              print  OUTFILE " ${byte_size}'h0 ;//QQQQ\n";
949
              }
950
            else
951
              {
952
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b00}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
953
              print  OUTFILE " ${t_name}_rdata[${byte_size}-1:0] ;//QQQQ\n";
954
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b01}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
955
              print  OUTFILE " ${t_name}_rdata[$(byte_size}-1:${byte_size}] ;//QQQQ\n";
956
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b10}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
957
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:(${byte_size}*2)] };//QQQQ\n"; }
958
              else         { print  OUTFILE " ${t_name}_rdata[(${byte_size}*3)-1:(${byte_size}*2)] ;//QQQQ\n";}
959
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b11}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
960
              print  OUTFILE " ${byte_size}'h0 ;//QQQQ\n";
961
              }
962
           }
963
 
964
         elsif (  ($sys_byte_lanes eq "1") and  ( $reg_byte_lanes eq "4"))
965
            {
966
            if($opt_bigendian)
967
              {
968
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b11}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
969
              print  OUTFILE " ${t_name}_rdata[${byte_size}-1:0] ;//QQQQ\n";
970
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b10}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
971
              print  OUTFILE " ${t_name}_rdata[$(byte_size}-1:${byte_size}] ;//QQQQ\n";
972
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b01}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
973
              print  OUTFILE " ${t_name}_rdata[(${byte_size}*3)-1:(${byte_size}*2)] ;//QQQQ\n";
974
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b00}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
975
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:(${byte_size}*3)] };//QQQQ\n";}
976
              else         { print  OUTFILE " ${t_name}_rdata[(${byte_size}*4)-1:(${byte_size}*3)] ;//QQQQ\n";}
977
              }
978
            else
979
              {
980
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b00}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
981
              print  OUTFILE " ${t_name}_rdata[${byte_size}-1:0] ;//QQQQ\n";
982
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b01}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
983
              print  OUTFILE " ${t_name}_rdata[(${byte_size}*2)-1:${byte_size}] ;//QQQQ\n";
984
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b10}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
985
              print  OUTFILE " ${t_name}_rdata[(${byte_size}*3)-1:(${byte_size}*2)] ;//QQQQ\n";
986
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],2'b11}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
987
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:(${byte_size}*3)] };//QQQQ\n"; }
988
              else         { print  OUTFILE " ${t_name}_rdata[(${byte_size}*4)-1:(${byte_size}*3)] ;//QQQQ\n";}
989
              }
990
            }
991
 
992
 
993
 
994
         elsif (  ($sys_byte_lanes eq "2") and  ( $reg_byte_lanes eq "3") )
995
            {
996
            if($opt_bigendian)
997
              {
998
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],1'b1}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
999
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:$phy_byte_lane*${byte_size}]   };//QQQQ\n"; }
1000
              else         { print  OUTFILE " ${t_name}_rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]      ;//QQQQ\n"; }
1001
              }
1002
            else
1003
              {
1004
 
1005
 
1006
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],1'b0}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1007
              print  OUTFILE " ${t_name}_rdata[$log_byte_lane*${byte_size}+${byte_size}-1:$log_byte_lane*${byte_size}]      ;//QQQQ\n";
1008
 
1009
              unless ($log_byte_lane){
1010
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],1'b1}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1011
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:(${byte_size}*2)]   };//QQQQ\n"; }
1012
              else         { print  OUTFILE " ${t_name}_rdata[(${byte_size}*3)-1:(${byte_size}*2)]      ;//QQQQ\n";}
1013
              }
1014
 
1015
 
1016
 
1017
              }
1018
            }
1019
 
1020
         elsif (  ($sys_byte_lanes eq "2") and  ( $reg_byte_lanes eq "4") )
1021
            {
1022
            if($opt_bigendian)
1023
              {
1024
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],1'b1}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1025
              print  OUTFILE " ${t_name}_rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] ;//QQQQ\n";
1026
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],1'b0}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1027
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:$phy_byte_lane*${byte_size}+(${byte_size}*2)]   };//QQQQ\n"; }
1028
              else         { print  OUTFILE " ${t_name}_rdata[$phy_byte_lane*${byte_size}+${byte_size}-1+(${byte_size}*2):$phy_byte_lane*${byte_size}+(${byte_size}*2)]      ;//QQQQ\n"; }
1029
              }
1030
            else
1031
              {
1032
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],1'b0}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1033
              print  OUTFILE " ${t_name}_rdata[$log_byte_lane*${byte_size}+${byte_size}-1:$log_byte_lane*${byte_size}] ;//QQQQ\n";
1034
              print  OUTFILE "{${REG_NAME}[$addblk_numaddbits-1:2],1'b1}:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1035
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:$log_byte_lane*${byte_size}+(${byte_size}*2)]   };//QQQQ\n"; }
1036
              else         { print  OUTFILE " ${t_name}_rdata[$log_byte_lane*${byte_size}+${byte_size}-1+(${byte_size}*2):$log_byte_lane*${byte_size}+(${byte_size}*2)]      ;//QQQQ\n";}
1037
              }
1038
            }
1039
 
1040
         elsif(( $sys_byte_lanes eq "2") and  ( $reg_byte_lanes eq "1") and ($reg_byte_lane eq $log_byte_lane)  )
1041
            {
1042
             print  OUTFILE "${REG_NAME}[$addblk_numaddbits-1:${adr_base}]:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1043
             if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata };//QQQQ\n"; }
1044
             else         { print  OUTFILE " ${t_name}_rdata ;//QQQQ\n"; }
1045
            }
1046
 
1047
 
1048
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "1") and ($reg_byte_lane eq $log_byte_lane)  )
1049
            {
1050
            print  OUTFILE "${REG_NAME}[$addblk_numaddbits-1:${adr_base}]:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1051
            if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata };//QQQQ\n";}
1052
            else         { print  OUTFILE " ${t_name}_rdata ;//QQQQ\n"; }
1053
            }
1054
 
1055
 
1056
 
1057
 
1058
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "2") and ($reg_byte_lane eq $log_byte_lane)  )
1059
            {
1060
            print  OUTFILE "${REG_NAME}[$addblk_numaddbits-1:${adr_base}]:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1061
            print  OUTFILE " ${t_name}_rdata[${byte_size}-1:0] ;//QQQQ\n";
1062
            }
1063
 
1064
 
1065
 
1066
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "2") and ($reg_byte_lane ==    ${log_byte_lane}-1 ))
1067
            {
1068
            print  OUTFILE "${REG_NAME}[$addblk_numaddbits-1:${adr_base}]:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1069
            if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:${byte_size}] };//QQQQ\n";}
1070
            else         { print  OUTFILE " ${t_name}_rdata[$(byte_size}-1:${byte_size}] ;//QQQQ\n"; }
1071
            }
1072
 
1073
 
1074
 
1075
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "3") and ($phy_byte_lane) ne "3"  )
1076
            {
1077
             if(   $reg_byte_lanes - 1  eq       $phy_byte_lane )
1078
              {
1079
              print  OUTFILE "${REG_NAME}[$addblk_numaddbits-1:${adr_base}]:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1080
              if($padding) { print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata[${t_size}-1:$phy_byte_lane*${byte_size}] };//QQQQ\n"; }
1081
              else         { print  OUTFILE " ${t_name}_rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] ;//QQQQ\n";}
1082
              }
1083
            else
1084
              {
1085
              print  OUTFILE "${REG_NAME}[$addblk_numaddbits-1:${adr_base}]:      rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = ";
1086
              print  OUTFILE " ${t_name}_rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] ;//QQQQ\n";
1087
              }
1088
            }
1089
 
1090
         }
1091
      }
1092
 
1093
   }
1094
 
1095
         print  OUTFILE "\n\n\n";
1096
         print  OUTFILE "    default:    rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = UNMAPPED;\n";
1097
         print  OUTFILE "    endcase\n\n";
1098
 
1099
 
1100
 
1101
 
1102
     }
1103
 
1104
 
1105
 
1106
 
1107
 
1108
 
1109
 
1110
 
1111
 
1112
 
1113
 
1114
 
1115
 
1116
 
1117
    #/**********************************************************************/
1118
    #/*                                                                    */
1119
    #/* Read Data Muxing                                                   */
1120
    #/*                                                                    */
1121
    #/*                                                                    */
1122
    #/**********************************************************************/
1123
 
1124
 
1125
    if($max_has_read == "1" and $max_has_create == "0" )
1126
     {
1127
     print  OUTFILE "always@(*)\n";
1128
     print  OUTFILE "  if(rd && cs)\n";
1129
     print  OUTFILE "    begin\n";
1130
     print  OUTFILE "  if(byte_lanes[ $phy_byte_lane ])\n";
1131
     print  OUTFILE "   rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] =  rdata_i[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}];         \n";
1132
     print  OUTFILE "  else\n";
1133
     print  OUTFILE "                rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = UNMAPPED;\n";
1134
     print  OUTFILE "    end\n";
1135
     print  OUTFILE "  else          rdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}] = UNSELECTED;\n\n\n";
1136
 
1137
     print  OUTFILE "always@(*)\n";
1138
     print  OUTFILE "    begin\n";
1139
     print  OUTFILE "        rdata_i  = UNMAPPED;\n";
1140
 
1141
 
1142
     foreach $line (@registers)
1143
        {
1144
        $_ = $line;
1145
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1146
          {
1147
          my $t_name                = $1;
1148
          my $t_numoffset           = $2;
1149
          my $t_size                = $3;
1150
          my $t_numdim              = $4;
1151
          my $t_dimbits             = $5;
1152
          my $t_create              = $6;
1153
          my $t_access              = $7;
1154
          my $t_has_read            = $8;
1155
          my $t_has_write           = $9;
1156
          my $reg_byte_lane           =     $t_numoffset   % $sys_byte_lanes  ;
1157
          my $reg_byte_lanes          =     $t_size   / ${byte_size}  ;
1158
          my $pad_size                =     $t_size  % $byte_size    ;
1159
 
1160
 
1161
       if($pad_size)  {$padding = $byte_size - $pad_size;}
1162
       else
1163
         {
1164
         $padding = 0;
1165
         $pad_size = ${byte_size};
1166
         }
1167
 
1168
 
1169
         my $REG_NAME =  uc($t_name);
1170
 
1171
 
1172
 
1173
 
1174
 
1175
         if(  $t_has_read eq "1" )
1176
           {
1177
           print  OUTFILE "if( ${t_name}_cs )     rdata_i = ";
1178
                if($padding) {   print  OUTFILE "{${REG_NAME}_PAD , ${t_name}_rdata };//QQQQ\n";}
1179
                else         {   print  OUTFILE " ${t_name}_rdata ;//QQQQ\n";}
1180
           }
1181
 
1182
 
1183
 
1184
 
1185
 
1186
         print  OUTFILE "\n";
1187
 
1188
 
1189
 
1190
     }
1191
 
1192
 
1193
}
1194
 
1195
         print  OUTFILE "    end\n\n";
1196
 
1197
 
1198
}
1199
 
1200
 
1201
 
1202
 
1203
 
1204
 
1205
 
1206
 
1207
 
1208
 
1209
 
1210
 
1211
 
1212
 
1213
 
1214
 
1215
 
1216
 
1217
 
1218
 
1219
 
1220
 
1221
 
1222
 
1223
 
1224
 
1225
 
1226
 
1227
 
1228
 
1229
 
1230
 
1231
 
1232
 
1233
 
1234
 
1235
 
1236
 
1237
 
1238
    #/**********************************************************************/
1239
    #/*                                                                    */
1240
    #/* Write Data Selection                                               */
1241
    #/*                                                                    */
1242
    #/*                                                                    */
1243
    #/**********************************************************************/
1244
 
1245
 
1246
 
1247
    if($max_has_write)
1248
     {
1249
 
1250
     print  OUTFILE "always@(*)\n";
1251
     print  OUTFILE "    begin\n";
1252
 
1253
     foreach $line (@registers)
1254
        {
1255
        $_ = $line;
1256
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1257
          {
1258
          my $t_name                = $1;
1259
          my $t_numoffset           = $2;
1260
          my $t_size                = $3;
1261
          my $t_numdim              = $4;
1262
          my $t_dimbits             = $5;
1263
          my $t_create              = $6;
1264
          my $t_access              = $7;
1265
          my $t_has_read            = $8;
1266
          my $t_has_write           = $9;
1267
          my $reg_byte_lane           =     $t_numoffset   % $sys_byte_lanes  ;
1268
          my $reg_byte_lanes          =     $t_size   / ${byte_size}  ;
1269
          my $pad_size                =     $t_size  % $byte_size    ;
1270
 
1271
 
1272
       if($pad_size)  {$padding = $byte_size - $pad_size;}
1273
       else
1274
         {
1275
         $padding = 0;
1276
         $pad_size = ${byte_size};
1277
         }
1278
 
1279
 
1280
       my $REG_NAME =  uc($t_name);
1281
 
1282
 
1283
         $reg_byte_lanes   = ($padding + $t_size)/ $byte_size;
1284
 
1285
 
1286
 
1287
 
1288
       if( $t_has_write eq "1" )
1289
         {
1290
         if (  ($sys_byte_lanes eq "1") and  ( $reg_byte_lanes eq "1"))
1291
            {
1292
            print  OUTFILE "${t_name}_wdata      =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:0];//    1\n";
1293
            }
1294
 
1295
        elsif( $sys_byte_lanes eq  $reg_byte_lanes )
1296
            {
1297
             if(   $reg_byte_lanes - 1  eq       $phy_byte_lane )
1298
              {
1299
              print  OUTFILE "${t_name}_wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:$phy_byte_lane*${byte_size}]     =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:$phy_byte_lane*${byte_size}];// 2\n";
1300
 
1301
              }
1302
            else
1303
              {
1304
 
1305
              print  OUTFILE "${t_name}_wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]     =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //    3 \n";
1306
              }
1307
            }
1308
         elsif (  ($sys_byte_lanes eq "1") and  ( $reg_byte_lanes eq "2"))
1309
            {
1310
            if($opt_bigendian)
1311
              {
1312
              print  OUTFILE "${t_name}_wdata[${byte_size}-1:0]            =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:0]; //   4  \n";
1313
 
1314
 
1315
              print  OUTFILE "${t_name}_wdata[${pad_size}+${byte_size}-1:${byte_size}]            =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:0]; //  5   \n";
1316
 
1317
              }
1318
            else
1319
              {
1320
              print  OUTFILE "${t_name}_wdata[${byte_size}-1:0]            =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //   6  \n";
1321
 
1322
 
1323
              print  OUTFILE "${t_name}_wdata[${pad_size}+${byte_size}-1:${byte_size}]            =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:0]; //  ${byte_size}-1   \n";
1324
 
1325
              }
1326
            }
1327
 
1328
         elsif (  ($sys_byte_lanes eq "1") and  ( $reg_byte_lanes eq "3"))
1329
            {
1330
            if($opt_bigendian)
1331
              {
1332
              print  OUTFILE "${t_name}_wdata[${byte_size}-1:0]             =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //   8  \n";
1333
              print  OUTFILE "${t_name}_wdata[$(byte_size}-1:${byte_size}]             =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //  9   \n";
1334
              print  OUTFILE "${t_name}_wdata[${pad_size}+$(byte_size}-1:(${byte_size}*2)]             =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:0]; // 10    \n";
1335
              }
1336
            else
1337
              {
1338
              print  OUTFILE "${t_name}_wdata[${byte_size}-1:0]                  =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //  11   \n";
1339
              print  OUTFILE "${t_name}_wdata[$(byte_size}-1:${byte_size}]                 =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //  12   \n";
1340
              print  OUTFILE "${t_name}_wdata[${pad_size}+$(byte_size}-1:(${byte_size}*2)]    =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:0]; // 13    \n";
1341
              }
1342
           }
1343
 
1344
         elsif (  ($sys_byte_lanes eq "1") and  ( $reg_byte_lanes eq "4"))
1345
            {
1346
            if($opt_bigendian)
1347
              {
1348
              print  OUTFILE "${t_name}_wdata[${byte_size}-1:0]             =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //   14  \n";
1349
              print  OUTFILE "${t_name}_wdata[$(byte_size}-1:${byte_size}]             =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //  15   \n";
1350
              print  OUTFILE "${t_name}_wdata[(${byte_size}*3)-1:(${byte_size}*2)]             =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; // 16    \n";
1351
              print  OUTFILE "${t_name}_wdata[${pad_size}+(${byte_size}*3)-1:(${byte_size}*3)]             =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:0]; // 17    \n";
1352
 
1353
              }
1354
            else
1355
              {
1356
              print  OUTFILE "${t_name}_wdata[${byte_size}-1:0]             =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //   18  \n";
1357
              print  OUTFILE "${t_name}_wdata[$(byte_size}-1:${byte_size}]             =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //  19   \n";
1358
              print  OUTFILE "${t_name}_wdata[(${byte_size}*3)-1:(${byte_size}*2)]             =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; // 20    \n";
1359
              print  OUTFILE "${t_name}_wdata[${pad_size}+(${byte_size}*3)-1:(${byte_size}*3)]             =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:0]; // 21    \n";
1360
              }
1361
            }
1362
 
1363
         elsif (  ($sys_byte_lanes eq "2") and  ( $reg_byte_lanes eq "3") )
1364
            {
1365
            if($opt_bigendian)
1366
              {
1367
              print  OUTFILE "${t_name}_wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]            =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //  22   \n";
1368
              }
1369
            else
1370
              {
1371
              print  OUTFILE "${t_name}_wdata[$log_byte_lane*${byte_size}+${byte_size}-1:$log_byte_lane*${byte_size}]            =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //    \n";
1372
              if($log_byte_lane == 0)
1373
              {
1374
              print  OUTFILE "${t_name}_wdata[$log_byte_lane*${byte_size}+${pad_size}+$(byte_size}-1:$log_byte_lane*${byte_size}+(${byte_size}*2)]            =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //     \n";
1375
              }
1376
              }
1377
            }
1378
 
1379
         elsif (  ($sys_byte_lanes eq "2") and  ( $reg_byte_lanes eq "4") )
1380
            {
1381
            if($opt_bigendian)
1382
              {
1383
              print  OUTFILE "${t_name}_wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]            =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //  24   \n";
1384
              print  OUTFILE "${t_name}_wdata[$phy_byte_lane*${byte_size}+${byte_size}-1+$(byte_size}-1:$phy_byte_lane*${byte_size}+(${byte_size}*2)]           =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //  25   \n";
1385
              }
1386
            else
1387
              {
1388
              print  OUTFILE "${t_name}_wdata[$log_byte_lane*${byte_size}+${byte_size}-1:$log_byte_lane*${byte_size}]            =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; // 26    \n";
1389
             if($log_byte_lane)
1390
               {
1391
 
1392
              print  OUTFILE "${t_name}_wdata[$log_byte_lane*${byte_size}+${pad_size}+$(byte_size}-1:$log_byte_lane*${byte_size}+(${byte_size}*2)]            =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:$phy_byte_lane*${byte_size}]; //  27   \n";
1393
               }
1394
             else
1395
                      {
1396
 
1397
              print  OUTFILE "${t_name}_wdata[$log_byte_lane*${byte_size}+${byte_size}-1+(${byte_size}*2):$log_byte_lane*${byte_size}+(${byte_size}*2)]            =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //  27   \n";
1398
               }
1399
 
1400
             }
1401
            }
1402
 
1403
         elsif(( $sys_byte_lanes eq "2") and  ( $reg_byte_lanes eq "1") and ($reg_byte_lane eq $log_byte_lane)  )
1404
            {
1405
             print  OUTFILE "${t_name}_wdata     =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:$phy_byte_lane*${byte_size}]; //  28   \n";
1406
            }
1407
 
1408
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "1") and ($reg_byte_lane eq $log_byte_lane)  )
1409
            {
1410
            print  OUTFILE "${t_name}_wdata     =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:$phy_byte_lane*${byte_size}]; //  29   \n";
1411
            }
1412
 
1413
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "2") and ($reg_byte_lane eq $log_byte_lane)  )
1414
            {
1415
            print  OUTFILE "${t_name}_wdata[${byte_size}-1:0]     =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //  30   \n";
1416
            }
1417
 
1418
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "2") and ($reg_byte_lane == ${log_byte_lane}-1 ))
1419
            {
1420
            print  OUTFILE "${t_name}_wdata[${pad_size}+${byte_size}-1:${byte_size}]     =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:$phy_byte_lane*${byte_size}]; //    \n";
1421
            }
1422
 
1423
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "3") and ($phy_byte_lane) ne "3"  )
1424
            {
1425
             if(   $reg_byte_lanes - 1  eq       $phy_byte_lane )
1426
              {
1427
              print  OUTFILE "${t_name}_wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:$phy_byte_lane*${byte_size}]     =  wdata[$phy_byte_lane*${byte_size}+${pad_size}-1:$phy_byte_lane*${byte_size}]; //  32   \n";
1428
              }
1429
            else
1430
              {
1431
              print  OUTFILE "${t_name}_wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]     =  wdata[$phy_byte_lane*${byte_size}+${byte_size}-1:$phy_byte_lane*${byte_size}]; //  33   \n";
1432
              }
1433
            }
1434
 
1435
         }
1436
      }
1437
 
1438
   }
1439
 
1440
         print  OUTFILE "\n\n\n";
1441
         print  OUTFILE "    end\n\n";
1442
 
1443
 
1444
 
1445
 
1446
 
1447
    #/**********************************************************************/
1448
    #/*                                                                    */
1449
    #/* Write strobe Creation                                              */
1450
    #/*                                                                    */
1451
    #/*                                                                    */
1452
    #/**********************************************************************/
1453
 
1454
 
1455
 
1456
     print  OUTFILE "always@(*)\n";
1457
     print  OUTFILE "    begin\n";
1458
 
1459
 
1460
 
1461
     foreach $line (@registers)
1462
        {
1463
        $_ = $line;
1464
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1465
          {
1466
          my $t_name                = $1;
1467
          my $t_numoffset           = $2;
1468
          my $t_size                = $3;
1469
          my $t_numdim              = $4;
1470
          my $t_dimbits             = $5;
1471
          my $t_create              = $6;
1472
          my $t_access              = $7;
1473
          my $t_has_read            = $8;
1474
          my $t_has_write           = $9;
1475
 
1476
 
1477
          my $reg_byte_lane           =     $t_numoffset   % $sys_byte_lanes  ;
1478
          my $reg_byte_lanes          =     $t_size   / ${byte_size}  ;
1479
          my $pad_size                =     $t_size  % $byte_size    ;
1480
 
1481
 
1482
 
1483
       if($pad_size)  {$padding = $byte_size - $pad_size;}
1484
       else
1485
         {
1486
         $padding = 0;
1487
         $pad_size = ${byte_size};
1488
         }
1489
 
1490
          $reg_byte_lanes   = ($padding +  $t_size)/ $byte_size;
1491
 
1492
 
1493
 
1494
       my $REG_NAME =  uc($t_name);
1495
 
1496
 
1497
 
1498
 
1499
 
1500
 
1501
 
1502
 
1503
       if( $t_has_write eq "1" )
1504
         {
1505
         if ( $sys_byte_lanes eq  $reg_byte_lanes )
1506
            {
1507
            print  OUTFILE "${t_name}_wr_${phy_byte_lane} = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:${adr_base}]== ${REG_NAME}[$addblk_numaddbits-1:${adr_base}] ); //     \n";
1508
            }
1509
 
1510
         elsif (  ($sys_byte_lanes eq "1") and  ( $reg_byte_lanes eq "2"))
1511
            {
1512
            if($opt_bigendian)
1513
              {
1514
              print  OUTFILE "${t_name}_wr_0 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:1],1'b1} ); //     \n";
1515
              print  OUTFILE "${t_name}_wr_1 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:1],1'b0} ); //     \n";
1516
 
1517
              }
1518
            else
1519
              {
1520
              print  OUTFILE "${t_name}_wr_0 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:1],1'b0} ); //     \n";
1521
              print  OUTFILE "${t_name}_wr_1 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:1],1'b1} ); //     \n";
1522
              }
1523
            }
1524
 
1525
         elsif (  ($sys_byte_lanes eq "1") and  ( $reg_byte_lanes eq "3"))
1526
            {
1527
            if($opt_bigendian)
1528
              {
1529
              print  OUTFILE "${t_name}_wr_0 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b11} ); //     \n";
1530
              print  OUTFILE "${t_name}_wr_1 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b10} ); //     \n";
1531
              print  OUTFILE "${t_name}_wr_2 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b01} ); //     \n";
1532
              }
1533
            else
1534
              {
1535
              print  OUTFILE "${t_name}_wr_0 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b00} ); //     \n";
1536
              print  OUTFILE "${t_name}_wr_1 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b01} ); //     \n";
1537
              print  OUTFILE "${t_name}_wr_2 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b10} ); //     \n";
1538
              }
1539
           }
1540
 
1541
         elsif (  ($sys_byte_lanes eq "1") and  ( $reg_byte_lanes eq "4"))
1542
            {
1543
            if($opt_bigendian)
1544
              {
1545
              print  OUTFILE "${t_name}_wr_0 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b11} ); //     \n";
1546
              print  OUTFILE "${t_name}_wr_1 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b10} ); //     \n";
1547
              print  OUTFILE "${t_name}_wr_2 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b01} ); //     \n";
1548
              print  OUTFILE "${t_name}_wr_3 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b00} ); //     \n";
1549
              }
1550
            else
1551
              {
1552
              print  OUTFILE "${t_name}_wr_0 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b00} ); //     \n";
1553
              print  OUTFILE "${t_name}_wr_1 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b01} ); //     \n";
1554
              print  OUTFILE "${t_name}_wr_2 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b10} ); //     \n";
1555
              print  OUTFILE "${t_name}_wr_3 = cs && wr && enable && byte_lanes[ 0 ] && ( addr[$addblk_numaddbits-1:0]== {${REG_NAME}[$addblk_numaddbits-1:2],2'b11} ); //     \n";
1556
 
1557
              }
1558
            }
1559
 
1560
         elsif (  ($sys_byte_lanes eq "2") and  ( $reg_byte_lanes eq "3") )
1561
            {
1562
              if ($log_byte_lane == 0 )
1563
                 {
1564
                 print  OUTFILE "${t_name}_wr_0 = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:1]== {${REG_NAME}[$addblk_numaddbits-1:2],1'b0} ); //     \n";
1565
                 print  OUTFILE "${t_name}_wr_2 = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:1]== {${REG_NAME}[$addblk_numaddbits-1:2],1'b1} ); //     \n";
1566
                 }
1567
              elsif ($log_byte_lane == 1 )
1568
                 {
1569
                 print  OUTFILE "${t_name}_wr_1 = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:1]== {${REG_NAME}[$addblk_numaddbits-1:2],1'b0} ); //     \n";
1570
                 }
1571
            }
1572
 
1573
 
1574
 
1575
         elsif (  ($sys_byte_lanes eq "2") and  ( $reg_byte_lanes eq "4") )
1576
            {
1577
              if ($log_byte_lane == 0 )
1578
                 {
1579
                 print  OUTFILE "${t_name}_wr_0 = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:1]== {${REG_NAME}[$addblk_numaddbits-1:2],1'b0} ); //     \n";
1580
                 print  OUTFILE "${t_name}_wr_2 = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:1]== {${REG_NAME}[$addblk_numaddbits-1:2],1'b1} ); //     \n";
1581
                 }
1582
              elsif ($log_byte_lane == 1 )
1583
                 {
1584
                 print  OUTFILE "${t_name}_wr_1 = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:1]== {${REG_NAME}[$addblk_numaddbits-1:2],1'b0} ); //     \n";
1585
                 print  OUTFILE "${t_name}_wr_3 = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:1]== {${REG_NAME}[$addblk_numaddbits-1:2],1'b1} ); //     \n";
1586
                 }
1587
            }
1588
 
1589
 
1590
 
1591
 
1592
 
1593
 
1594
         elsif(( $sys_byte_lanes eq "2") and  ( $reg_byte_lanes eq "1") and ($reg_byte_lane eq $log_byte_lane)  )
1595
            {
1596
            print  OUTFILE "${t_name}_wr_0 = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:${adr_base}]== ${REG_NAME}[$addblk_numaddbits-1:${adr_base}] );\n";
1597
            }
1598
 
1599
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "1") and ($reg_byte_lane eq $log_byte_lane)  )
1600
            {
1601
            print  OUTFILE "${t_name}_wr_0 = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:${adr_base}]== ${REG_NAME}[$addblk_numaddbits-1:${adr_base}] );\n";
1602
            }
1603
 
1604
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "2") and ($reg_byte_lane eq $log_byte_lane)  )
1605
            {
1606
            print  OUTFILE "${t_name}_wr_0 = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:${adr_base}]== ${REG_NAME}[$addblk_numaddbits-1:${adr_base}] );\n";
1607
            }
1608
 
1609
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "2") and ($reg_byte_lane == ${log_byte_lane}-1 ))
1610
            {
1611
            print  OUTFILE "${t_name}_wr_1 = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:${adr_base}]== ${REG_NAME}[$addblk_numaddbits-1:${adr_base}] );\n";
1612
            }
1613
 
1614
         elsif(( $sys_byte_lanes eq "4") and  ( $reg_byte_lanes eq "3") and ($log_byte_lane  ne "3")  )
1615
            {
1616
             if(   ${reg_byte_lanes}-1   ==       $log_byte_lane )
1617
              {
1618
            print  OUTFILE "${t_name}_wr_${log_byte_lane} = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:${adr_base}]== ${REG_NAME}[$addblk_numaddbits-1:${adr_base}] ); //     \n";
1619
              }
1620
            else
1621
              {
1622
            print  OUTFILE "${t_name}_wr_${log_byte_lane} = cs && wr && enable && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:${adr_base}]== ${REG_NAME}[$addblk_numaddbits-1:${adr_base}] ); //     \n";
1623
              }
1624
            }
1625
 
1626
         }
1627
      }
1628
 
1629
 
1630
}
1631
         print  OUTFILE "\n\n\n";
1632
         print  OUTFILE "    end\n\n";
1633
 
1634
 
1635
}
1636
 
1637
 
1638
 
1639
 
1640
 
1641
 
1642
 
1643
 
1644
 
1645
 
1646
 
1647
 
1648
 
1649
 
1650
 
1651
 
1652
 
1653
 
1654
    #/**********************************************************************/
1655
    #/*                                                                    */
1656
    #/* Print read strobes                                                 */
1657
    #/*                                                                    */
1658
    #/*                                                                    */
1659
    #/**********************************************************************/
1660
 
1661
 
1662
 
1663
 
1664
 
1665
     foreach $line (@registers)
1666
        {
1667
        $_ = $line;
1668
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1669
          {
1670
          my $t_name                = $1;
1671
          my $t_numoffset           = $2;
1672
          my $t_size                = $3;
1673
          my $t_numdim              = $4;
1674
          my $t_dimbits             = $5;
1675
          my $t_create              = $6;
1676
          my $t_access              = $7;
1677
          my $t_has_read            = $8;
1678
          my $t_has_write           = $9;
1679
          my $reg_byte_lane           =     $t_numoffset   % $sys_byte_lanes  ;
1680
          my $reg_byte_lanes          =     $t_size   / ${byte_size}  ;
1681
          my $pad_size                =     $t_size  % $byte_size    ;
1682
 
1683
 
1684
       if($pad_size)  {$padding = $byte_size - $pad_size;}
1685
       else
1686
         {
1687
         $padding = 0;
1688
         $pad_size = ${byte_size};
1689
         }
1690
 
1691
 
1692
         my $REG_NAME =  uc($t_name);
1693
 
1694
 
1695
 
1696
 
1697
          $reg_byte_lanes   = ($padding + int($t_size))/ $byte_size;
1698
 
1699
 
1700
 
1701
 
1702
 
1703
 
1704
            if(( $sys_byte_lanes == 1) and ($reg_byte_lanes == 1))
1705
              {
1706
 
1707
              }
1708
 
1709
            elsif(( $sys_byte_lanes == 1) and ($reg_byte_lanes == 2))
1710
              {
1711
 
1712
              }
1713
 
1714
            elsif(( $sys_byte_lanes == 1) and ($reg_byte_lanes == 3))
1715
              {
1716
 
1717
              }
1718
            elsif(( $sys_byte_lanes == 1) and ($reg_byte_lanes == 4))
1719
              {
1720
 
1721
              }
1722
            elsif (  ( $sys_byte_lanes == 2) and ($reg_byte_lanes == 1) and       ( $log_byte_lane == $reg_byte_lane)  )
1723
               {
1724
               push  @add_decs, "        ${t_name}_dec = cs && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:${adr_base}]== ${REG_NAME}[$addblk_numaddbits-1:${adr_base}] );//. $sys_byte_lanes. $reg_byte_lanes.   5\n"
1725
               }
1726
              elsif (  ( $sys_byte_lanes == 4) and ($reg_byte_lanes == 1) and       ( $log_byte_lane == $reg_byte_lane)  )
1727
               {
1728
               push  @add_decs, "        ${t_name}_dec = cs && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:${adr_base}]== ${REG_NAME}[$addblk_numaddbits-1:${adr_base}] );//. $sys_byte_lanes. $reg_byte_lanes.   5\n"
1729
               }
1730
            elsif (  ( $sys_byte_lanes == 4) and ($reg_byte_lanes == 2) and       ( $log_byte_lane == $reg_byte_lane)  )
1731
               {
1732
               push  @add_decs, "        ${t_name}_dec = cs && byte_lanes[ $phy_byte_lane ] && ( addr[$addblk_numaddbits-1:${adr_base}]== ${REG_NAME}[$addblk_numaddbits-1:${adr_base}] );//. $sys_byte_lanes. $reg_byte_lanes.   5\n"
1733
               }
1734
          }
1735
       }
1736
 
1737
}
1738
 
1739
 
1740
 
1741
 
1742
 
1743
 
1744
 
1745
 
1746
 
1747
 
1748
     foreach $line (@registers)
1749
        {
1750
        $_ = $line;
1751
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1752
          {
1753
          my $t_name                = $1;
1754
          my $t_numoffset           = $2;
1755
          my $t_size                = $3;
1756
          my $t_numdim              = $4;
1757
          my $t_dimbits             = $5;
1758
          my $t_create              = $6;
1759
          my $t_access              = $7;
1760
          my $t_has_read            = $8;
1761
          my $t_has_write           = $9;
1762
          my $reg_byte_lane           =     $t_numoffset   % $sys_byte_lanes  ;
1763
          my $reg_byte_lanes          =     $t_size   / ${byte_size}  ;
1764
          my $pad_size                =     $t_size  % $byte_size    ;
1765
 
1766
 
1767
       if($pad_size)  {$padding = $byte_size - $pad_size;}
1768
       else
1769
         {
1770
         $padding = 0;
1771
         $pad_size = ${byte_size};
1772
         }
1773
       my $REG_NAME =  uc($t_name);
1774
 
1775
 
1776
          $reg_byte_lanes   = ($padding + int($t_size))/ $byte_size;
1777
 
1778
 
1779
 
1780
 
1781
 
1782
 
1783
            if(( $sys_byte_lanes == 1) and ($reg_byte_lanes == 1))
1784
              {
1785
               push  @add_decs, "        ${t_name}_dec = cs && ( addr[$addblk_numaddbits-1:0]== ${REG_NAME}[$addblk_numaddbits-1:0] );//  1\n"
1786
              }
1787
 
1788
            elsif(( $sys_byte_lanes == 1) and ($reg_byte_lanes == 2))
1789
              {
1790
               push  @add_decs, "        ${t_name}_dec = cs && ( addr[$addblk_numaddbits-1:1]== ${REG_NAME}[$addblk_numaddbits-1:1] );//  2\n"
1791
              }
1792
 
1793
            elsif(( $sys_byte_lanes == 1) and ($reg_byte_lanes == 3))
1794
              {
1795
               push  @add_decs, "        ${t_name}_dec = cs && ( addr[$addblk_numaddbits-1:2]== ${REG_NAME}[$addblk_numaddbits-1:2] );//  3\n"
1796
              }
1797
            elsif(( $sys_byte_lanes == 1) and ($reg_byte_lanes == 4))
1798
              {
1799
               push  @add_decs, "        ${t_name}_dec = cs && ( addr[$addblk_numaddbits-1:2]== ${REG_NAME}[$addblk_numaddbits-1:2] );//  4\n"
1800
              }
1801
            elsif(( $sys_byte_lanes == 2) and ($reg_byte_lanes == 2))
1802
              {
1803
               push  @add_decs, "        ${t_name}_dec = cs && ( addr[$addblk_numaddbits-1:1]== ${REG_NAME}[$addblk_numaddbits-1:1] );//  4\n"
1804
              }
1805
 
1806
            elsif(( $sys_byte_lanes == 2) and ($reg_byte_lanes == 3))
1807
              {
1808
               push  @add_decs, "        ${t_name}_dec = cs && ( addr[$addblk_numaddbits-1:2]== ${REG_NAME}[$addblk_numaddbits-1:2] );//  4\n"
1809
              }
1810
 
1811
            elsif(( $sys_byte_lanes == 2) and ($reg_byte_lanes == 4))
1812
              {
1813
               push  @add_decs, "        ${t_name}_dec = cs && ( addr[$addblk_numaddbits-1:2]== ${REG_NAME}[$addblk_numaddbits-1:2] );//  4\n"
1814
              }
1815
 
1816
 
1817
            elsif(( $sys_byte_lanes == 4) and ($reg_byte_lanes == 3))
1818
              {
1819
               push  @add_decs, "        ${t_name}_dec = cs && ( addr[$addblk_numaddbits-1:2]== ${REG_NAME}[$addblk_numaddbits-1:2] );//  4\n"
1820
              }
1821
 
1822
            elsif(( $sys_byte_lanes == 4) and ($reg_byte_lanes == 4))
1823
              {
1824
               push  @add_decs, "        ${t_name}_dec = cs && ( addr[$addblk_numaddbits-1:2]== ${REG_NAME}[$addblk_numaddbits-1:2] );//  4\n"
1825
              }
1826
 
1827
 
1828
 
1829
 
1830
          }
1831
 
1832
}
1833
 
1834
         print  OUTFILE "\n\n always@(*)\n     begin\n";
1835
           foreach my $add_line (@add_decs)
1836
                {
1837
                 print  OUTFILE "${add_line}";
1838
                }
1839
 
1840
            print  OUTFILE "\n     end\n\n";
1841
 
1842
 
1843
 
1844
 
1845
 
1846
 
1847
 
1848
 
1849
 
1850
 
1851
 
1852
 
1853
 
1854
 
1855
 
1856
 
1857
 
1858
 
1859
 
1860
    #/**********************************************************************/
1861
    #/*                                                                    */
1862
    #/* Create Chip Selects                                                */
1863
    #/*                                                                    */
1864
    #/*                                                                    */
1865
    #/**********************************************************************/
1866
 
1867
   print  OUTFILE "\n  /* verilator lint_off UNSIGNED */           \n";
1868
 
1869
     foreach $line (@registers)
1870
        {
1871
        $_ = $line;
1872
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1873
          {
1874
          my $t_name                = $1;
1875
          my $t_numoffset           = $2;
1876
          my $t_size                = $3;
1877
          my $t_numdim              = $4;
1878
          my $t_dimbits             = $5;
1879
          my $t_create              = $6;
1880
          my $t_access              = $7;
1881
          my $t_has_read            = $8;
1882
          my $t_has_write           = $9;
1883
          my $REG_NAME              =  uc($t_name);
1884
          print  OUTFILE "assign   ${t_name}_cs = cs && ( addr >= ${REG_NAME} ) && ( addr < ${REG_NAME}_END );\n";
1885
          }
1886
        }
1887
 
1888
 
1889
   print  OUTFILE "\n  /* verilator lint_on UNSIGNED */           \n";
1890
 
1891
 
1892
 
1893
 
1894
 
1895
 
1896
    #/**********************************************************************/
1897
    #/*                                                                    */
1898
    #/* Create Registers                                                   */
1899
    #/*                                                                    */
1900
    #/*                                                                    */
1901
    #/**********************************************************************/
1902
 
1903
     foreach $line (@registers)
1904
        {
1905
        $_ = $line;
1906
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1907
          {
1908
          my $t_name                = $1;
1909
          my $t_numoffset           = $2;
1910
          my $t_size                = $3;
1911
          my $t_numdim              = $4;
1912
          my $t_dimbits             = $5;
1913
          my $t_create              = $6;
1914
          my $t_access              = $7;
1915
          my $t_has_read            = $8;
1916
          my $t_has_write           = $9;
1917
 
1918
 
1919
          my $reg_byte_lane           =     $t_numoffset   % $sys_byte_lanes  ;
1920
          my $reg_byte_lanes          =     $t_size   / ${byte_size}  ;
1921
          my $pad_size                =     $t_size  % $byte_size    ;
1922
 
1923
 
1924
 
1925
       if($pad_size)  {$padding = $byte_size - $pad_size;}
1926
       else
1927
         {
1928
         $padding = 0;
1929
         $pad_size = ${byte_size};
1930
         }
1931
 
1932
          $reg_byte_lanes   = ($padding +  $t_size)/ $byte_size;
1933
 
1934
 
1935
       if(( $t_has_write eq "1") and   ( $t_create eq "1")  )
1936
         {
1937
         print  OUTFILE "   always@(posedge clk)\n     if(reset)  $t_name <=  ";
1938
         print  OUTFILE uc($t_name);
1939
         print  OUTFILE "_RST;\n        else\n       begin\n";
1940
 
1941
         if($reg_byte_lanes == 1)
1942
          {
1943
          if($pad_size ==1)
1944
           {
1945
           print  OUTFILE "    if(${t_name}_wr_0)    ${t_name}   <=  ${t_name}_wdata   ;\n";
1946
           print  OUTFILE "    else    ${t_name}                        <=    next_${t_name};\n\n";
1947
           }
1948
         else
1949
           {
1950
           print  OUTFILE "    if(${t_name}_wr_0)    ${t_name}[${pad_size}-1:0]  <=  ${t_name}_wdata[${pad_size}-1:0]  ;\n";
1951
           print  OUTFILE "    else    ${t_name}[${pad_size}-1:0]   <=    next_${t_name}[${pad_size}-1:0];\n\n";
1952
           }
1953
 
1954
          }
1955
         elsif($reg_byte_lanes == 2)
1956
          {
1957
          print  OUTFILE "    if(${t_name}_wr_0)    ${t_name}[${byte_size}-1:0]  <=  ${t_name}_wdata[${byte_size}-1:0]  ;\n";
1958
          print  OUTFILE "    else    ${t_name}[${byte_size}-1:0]   <=    next_${t_name}[${byte_size}-1:0];\n\n";
1959
          print  OUTFILE "    if(${t_name}_wr_1)    ${t_name}[${pad_size}+${byte_size}-1:${byte_size}]  <=  ${t_name}_wdata[${pad_size}+${byte_size}-1:${byte_size}]  ;\n";
1960
          print  OUTFILE "    else    ${t_name}[${pad_size}+${byte_size}-1:${byte_size}]   <=    next_${t_name}[${pad_size}+${byte_size}-1:${byte_size}];\n\n";
1961
          }
1962
         elsif($reg_byte_lanes == 3)
1963
          {
1964
          print  OUTFILE "    if(${t_name}_wr_0)    ${t_name}[${byte_size}-1:0]  <=  ${t_name}_wdata[${byte_size}-1:0]  ;\n";
1965
          print  OUTFILE "    else    ${t_name}[${byte_size}-1:0]   <=    next_${t_name}[${byte_size}-1:0];\n\n";
1966
          print  OUTFILE "    if(${t_name}_wr_1)    ${t_name}[$(byte_size}-1:${byte_size}]  <=  ${t_name}_wdata[$(byte_size}-1:${byte_size}]  ;\n";
1967
          print  OUTFILE "    else    ${t_name}[$(byte_size}-1:${byte_size}]   <=    next_${t_name}[$(byte_size}-1:${byte_size}];\n\n";
1968
          print  OUTFILE "    if(${t_name}_wr_2)    ${t_name}[${pad_size}+$(byte_size}-1:(${byte_size}*2)]  <=  ${t_name}_wdata[${pad_size}+$(byte_size}-1:(${byte_size}*2)]  ;\n";
1969
          print  OUTFILE "    else    ${t_name}[${pad_size}+$(byte_size}-1:(${byte_size}*2)]   <=    next_${t_name}[${pad_size}+$(byte_size}-1:(${byte_size}*2)];\n\n";
1970
          }
1971
         elsif($reg_byte_lanes == 4)
1972
          {
1973
          print  OUTFILE "    if(${t_name}_wr_0)    ${t_name}[${byte_size}-1:0]  <=  ${t_name}_wdata[${byte_size}-1:0]  ;\n";
1974
          print  OUTFILE "    else    ${t_name}[${byte_size}-1:0]   <=    next_${t_name}[${byte_size}-1:0];\n\n";
1975
          print  OUTFILE "    if(${t_name}_wr_1)    ${t_name}[$(byte_size}-1:${byte_size}]  <=  ${t_name}_wdata[$(byte_size}-1:${byte_size}]  ;\n";
1976
          print  OUTFILE "    else    ${t_name}[$(byte_size}-1:${byte_size}]   <=    next_${t_name}[$(byte_size}-1:${byte_size}];\n\n";
1977
          print  OUTFILE "    if(${t_name}_wr_2)    ${t_name}[(${byte_size}*3)-1:(${byte_size}*2)]  <=  ${t_name}_wdata[(${byte_size}*3)-1:(${byte_size}*2)]  ;\n";
1978
          print  OUTFILE "    else    ${t_name}[(${byte_size}*3)-1:(${byte_size}*2)]   <=    next_${t_name}[(${byte_size}*3)-1:(${byte_size}*2)];\n\n";
1979
          print  OUTFILE "    if(${t_name}_wr_3)    ${t_name}[${pad_size}+(${byte_size}*3)-1:(${byte_size}*3)]  <=  ${t_name}_wdata[${pad_size}+(${byte_size}*3)-1:(${byte_size}*3)]  ;\n";
1980
          print  OUTFILE "    else    ${t_name}[${pad_size}+(${byte_size}*3)-1:(${byte_size}*3)]   <=    next_${t_name}[${pad_size}+(${byte_size}*3)-1:(${byte_size}*3)];\n\n";
1981
          }
1982
 
1983
       print  OUTFILE "\n     end\n\n";
1984
 
1985
 
1986
         }
1987
 
1988
 
1989
 
1990
 
1991
 
1992
 
1993
       }
1994
 
1995
}
1996
 
1997
 
1998
 
1999
 
2000
 
2001
 
2002
 
2003
 
2004
 
2005
 
2006
 
2007
 
2008
 
2009
 
2010
 
2011
 
2012
 
2013
 
2014
 
2015
   print  OUTFILE "\nendmodule \n";
2016
 
2017
 
2018
 
2019
 
2020
 
2021
 
2022
 
2023
close  OUTFILE ;
2024
 
2025
 
2026
1
2027
 
2028
 

powered by: WebSVN 2.1.0

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