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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [simulation/] [build_lint_filelists] - Blame information for rev 124

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

Line No. Rev Author Line
1 124 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
############################################################################
50
# General PERL config
51
############################################################################
52
use Getopt::Long;
53
use English;
54
use File::Basename;
55
use Cwd;
56
use XML::LibXML;
57
use lib './tools';
58
use sys::lib;
59
use yp::lib;
60
 
61
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
62
 
63
 
64
############################################################################
65
### Process the options
66
############################################################################
67
Getopt::Long::config("require_order", "prefix=-");
68
GetOptions("h","help",
69
           "work_site=s" => \$work_site,
70
           "vendor=s" => \$vendor,
71
           "project=s" => \$project,
72
           "component=s" => \$component,
73
           "version=s" => \$version
74
) || die "(use '$program_name -h' for help)";
75
 
76
 
77
 
78
##############################################################################
79
## Help option
80
##############################################################################
81
if ( $opt_h  or $opt_help)
82
  { print "\n build_lint_filelists -work_site /work  -vendor vendor_name  -project project_name  -component component_name   ";
83
    print "\n";
84
    exit 1;
85
  }
86
 
87
 
88
##############################################################################
89
##
90
##############################################################################
91
 
92
 
93
 
94
$home = cwd();
95
 
96
my $variant = "";
97
if($version) {$variant = "${component}_${version}"}
98
else         {$variant = "${component}"}
99
 
100
#############################################################################
101
##
102
##
103
#############################################################################
104
 
105
my $parser = XML::LibXML->new();
106
 
107
 
108
 
109
#/*********************************************************************************************/
110
#/                                                                                            */
111
#/  Create filelists for simulation  and  linting                                             */
112
#/                                                                                            */
113
#/                                                                                            */
114
#/*********************************************************************************************/
115
 
116
@filelist_sim = (  );
117
@filelist_ver = (  );
118
 
119
my @filelist_hier = (  );
120
 
121
 
122
push(@filelist_hier,"::${vendor}::${project}::${component}::${version}::");
123
my  @filelist =       parse_component_file("$vendor","$project","$component","$version");
124
@filelist     =       sys::lib::trim_sort(@filelist);
125
 
126
 
127
 
128
foreach $line (@filelist)
129
   {
130
   $_ = $line;
131
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
132
     {
133
     $new_proj      = $2;
134
     $new_comp      = $3;
135
     $new_vendor    = $1;
136
     $new_version   = $4;
137
     }
138
 
139
 
140
 
141
   #############################################################################
142
   ## Read destination from source xml file
143
   ##
144
   #############################################################################
145
 
146
 
147
 
148
   my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version));
149
 
150
 
151
 
152
 
153
   if($new_version){$new_variant   = "${new_comp}_${new_version}"}
154
   else             {$new_variant   = $new_comp}
155
 
156
 
157
 
158
 
159
   if($new_proj eq $project )
160
        {
161
 
162
           foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
163
              {
164
              my($file_name)      = $i_name ->findnodes('./text()')->to_literal ;
165
              my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
166
              my($logical_name)   = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
167
              my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
168
              my $component_path  = yp::lib::find_ipxact_component_path("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version);
169
 
170
              if( ($file_type eq "libraryDir") &&  ($view_file eq "fs-lint")  &&  ($logical_name eq "dest_dir")                    )
171
                 {
172
                 push(@filelist_sim,"../../../../${new_comp}${component_path}/${file_name}${new_variant}.v\n");
173
                 push(@filelist_ver,"    ../../../../${new_comp}${component_path}/${file_name}${new_variant}.v\n");
174
                 };
175
 
176
              }
177
        }
178
   else
179
        {
180
 
181
           foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
182
              {
183
              my($file_name)      = $i_name ->findnodes('./text()')->to_literal ;
184
              my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
185
              my($logical_name)   = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
186
              my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
187
              my $library_path    = yp::lib::find_ipxact_library_path("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version);
188
 
189
 
190
 
191
              if(($file_type eq "libraryDir")&& (($view_file eq "fs-lint") ) &&  ($logical_name eq "dest_dir")  )
192
                 {
193
                 push(@filelist_sim,"../../../../../children/${new_vendor}__${new_proj}${library_path}/${file_name}${new_variant}.v\n");
194
                 push(@filelist_ver,"   ../../../../../children/${new_vendor}__${new_proj}${library_path}/${file_name}${new_variant}.v\n");
195
                 };
196
              }
197
 
198
        }
199
 
200
   }
201
 
202
 
203
 
204
 
205
 
206
 
207
#############################################################################
208
##
209
##
210
#############################################################################
211
 
212
print "Building rtl_check  filelists for  $work_site  $vendor $project   $component $version $variant \n" ;
213
 
214
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
215
my $sogen_file               = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));
216
 
217
 
218
 
219
 
220
 
221
#/*********************************************************************************************/
222
#/                                                                                            */
223
#/                                                                                            */
224
#/  Read each variants parameters and defaults into an array and their order into an array    */
225
#/  order must be preservered so that parameters can use the values of other parameters       */
226
#/                                                                                            */
227
#/*********************************************************************************************/
228
 
229
my %default_parameters = ();
230
my @parameter_order    = ();
231
 
232
 
233
foreach  my   $i_name ($sogen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$variant']/socgen:parameters/socgen:parameter"))
234
      {
235
      my($parameter_name)     = $i_name ->findnodes('socgen:name/text()')->to_literal ;
236
      my($parameter_default)  = $i_name ->findnodes('socgen:value/text()')->to_literal ;
237
      $default_parameters{$parameter_name}  = $parameter_default;
238
      push  @parameter_order ,$parameter_name ;
239
 #     print "XXXXY $parameter_name     $parameter_default       \n";
240
      }
241
 
242
 
243
 
244
 
245
 
246
 
247
 
248
 
249
 
250
foreach my $comp ($spirit_component_file->findnodes('//spirit:component'))
251
   {
252
   my($vendor)   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
253
   my($library)  = $comp->findnodes('./spirit:library/text()')->to_literal ;
254
   my($name)     = $comp->findnodes('./spirit:name/text()')->to_literal ;
255
   my($version)  = $comp->findnodes('./spirit:version/text()')->to_literal ;
256
   my $variant = "";
257
   if($version) {$variant = "${name}_${version}"}
258
   else         {$variant = "${name}"}
259
   print "rtl/gen directories  for    $project - $component         VLNV        $vendor - $library -  $name -  $variant \n";
260
   }
261
 
262
 
263
 
264
 
265
 
266
 
267
 
268
 
269
 
270
 
271
 
272
   push(@filelist_sim,"    ./TestBench\n");
273
 
274
   print "CREATING componentRef filelists for   $project   $component  $name $variant \n";
275
 
276
 
277
 
278
 
279
        @filelist_ver =       sys::lib::trim_sort(@filelist_ver);
280
        @filelist_sim =       sys::lib::trim_sort(@filelist_sim);
281
 
282
 
283
 
284
 
285
 
286
 
287
 
288
 
289
 
290
   #/*********************************************************************************************/
291
   #/                                                                                            */
292
   #/                                                                                            */
293
   #/                                                                                            */
294
   #/                                                                                            */
295
   #/                                                                                            */
296
   #/                                                                                            */
297
   #/*********************************************************************************************/
298
 
299
 
300
 
301
   @wire_inst = (  );
302
 
303
   foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:ports/spirit:port/name"))
304
      {
305
      my($port_name)  = $i_name ->findnodes('./text()')->to_literal ;
306
      my($left)       = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
307
      my($right)      = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
308
      if($left)  {      push(@wire_inst,"wire    [${left}:${right}]      ${port_name};\n");}
309
      else       {      push(@wire_inst,"wire                  ${port_name};\n");}
310
      }
311
 
312
   push(@wire_inst,"\n\n\n  $variant \n ");
313
 
314
   my $first = 1;
315
 
316
   foreach  my  $parameter_name  (@parameter_order)
317
      {
318
      if($first)
319
        {
320
         push(@wire_inst,"       #(.${parameter_name}(${parameter_name})");
321
         $first=0;
322
        }
323
      else
324
        {
325
        push(@wire_inst,",\n        .${parameter_name}(${parameter_name})");
326
        }
327
      }
328
 
329
   if($first == 0){push(@wire_inst,")\n");}
330
   push(@wire_inst," test \n (   \n");
331
 
332
   $first = 1;
333
   foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:ports/spirit:port/name"))
334
      {
335
      my($port_name)  = $i_name ->findnodes('./text()')->to_literal ;
336
      if($first)
337
        {
338
        push(@wire_inst,"        .${port_name}      (${port_name})");
339
        $first=0;
340
        }
341
      else
342
        {
343
        push(@wire_inst,",\n        .${port_name}   (${port_name})");
344
        }
345
      }
346
 
347
   push(@wire_inst,"\n  );\n\n\n\n");
348
 
349
 
350
 
351
 
352
 
353
 
354
   #/*********************************************************************************************/
355
   #/                                                                                            */
356
   #/ Make simulation file set                                                                   */
357
   #/                                                                                            */
358
   #/                                                                                            */
359
   #/                                                                                            */
360
   #/                                                                                            */
361
   #/*********************************************************************************************/
362
 
363
   print "CREATING sim files for   $project  $component   $chip   $name  $variant \n";
364
 
365
 
366
 
367
 
368
   my $sogen_file     = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));
369
 
370
    foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:rtl_check/socgen:lint[socgen:variant/text() = '$variant']"))
371
      {
372
      my($simulation)      = $i_name ->findnodes('socgen:name/text()')->to_literal ;
373
      my($configuration)   = $i_name ->findnodes('socgen:configuration/text()')->to_literal ;
374
 
375
      print " lint  files for   $project  $component   $variant  $simulation $configuration          \n";
376
 
377
 
378
 
379
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path"))
380
         {
381
         my($library_path)     = $i_name ->findnodes('./text()')->to_literal ;
382
 
383
         my $path  = "${home}${work_site}/${vendor}__${project}${library_path}/rtl_check";
384
 
385
         mkdir $path,0755 unless (-e $path) ;
386
 
387
         $path  = "${home}${work_site}/${vendor}__${project}${library_path}/rtl_check/${simulation}";
388
         mkdir $path,0755   unless (-e $path);
389
 
390
         my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/rtl_check/${simulation}/Makefile";
391
         open  MAKSIMFILE,">$outfile" or die "unable to open $outfile";
392
 
393
 
394
 
395
         }
396
 
397
 
398
      print MAKSIMFILE  "include ../../../../../bin/Makefile.root\n";
399
      print MAKSIMFILE  "comp=${variant}\n";
400
      print MAKSIMFILE  "test=${simulation}\n";
401
 
402
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path"))
403
        {
404
        my($library_path)     = $i_name ->findnodes('./text()')->to_literal ;
405
        my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/rtl_check/${simulation}/filelist.ver";
406
        open SIMFILE,">$outfile" or die "unable to open $outfile";
407
        }
408
 
409
      foreach  my   $i_line (@filelist_sim){ print SIMFILE  "$i_line";}
410
 
411
 
412
 
413
      my %local_parameters =  %default_parameters;
414
      my @local_order      =  @parameter_order;
415
 
416
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$configuration']/./socgen:parameters/socgen:parameter/socgen:name"))
417
         {
418
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
419
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
420
         if($local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
421
         $local_parameters{$par_name} = $par_value;
422
         }
423
 
424
 
425
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:rtl_check/socgen:lint[socgen:name/text() = '$simulation']/./socgen:parameters/socgen:parameter/socgen:name"))
426
         {
427
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
428
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
429
         if  ( $local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
430
         $local_parameters{$par_name} = $par_value;
431
         }
432
 
433
       foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path"))
434
         {
435
         my($library_path)     = $i_name ->findnodes('./text()')->to_literal ;
436
         my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/rtl_check/${simulation}/TestBench";
437
         open SIM_PARM_FILE,">$outfile" or die "unable to open $outfile";
438
         }
439
      print SIM_PARM_FILE  "//  Testbench  for  $project    $component    $variant   $configuration    $simulation\n";
440
      print SIM_PARM_FILE  "                                \n";
441
      print SIM_PARM_FILE  "                                \n";
442
      print SIM_PARM_FILE  "module TB();                                \n";
443
      print SIM_PARM_FILE  "                                \n";
444
      print SIM_PARM_FILE  "     $variant   \n";
445
 
446
      my $first =1;
447
 
448
      foreach  my  $parameter_name  (@local_order)
449
         {
450
         my($parameter_default)  =    $local_parameters{$parameter_name};
451
         if($first)
452
           {
453
           print SIM_PARM_FILE  "   #(  .${parameter_name}(${parameter_default})";
454
           $first = 0;
455
           }
456
         else
457
           {
458
           print SIM_PARM_FILE  ",\n       .${parameter_name}(${parameter_default})";
459
           }
460
         }
461
 
462
         if($first)       { print SIM_PARM_FILE  "  ";}
463
         else             { print SIM_PARM_FILE  ") ";}
464
 
465
      print SIM_PARM_FILE  "  test \n (); \n\n\n\n endmodule \n  ";
466
 
467
 
468
 
469
      }
470
 
471
 
472
 
473
 
474
 
475
 
476
 
477
#/*********************************************************************************************/
478
#/                                                                                            */
479
#/                                                                                            */
480
#/                                                                                            */
481
#/                                                                                            */
482
#/                                                                                            */
483
#/                                                                                            */
484
#/*********************************************************************************************/
485
 
486
 
487
 
488
 
489
sub parse_component_file
490
   {
491
   my @params     = @_;
492
   my $version    = pop(@params);
493
   my $component  = pop(@params);
494
   my $library    = pop(@params);
495
   my $vendor     = pop(@params);
496
   my $spirit_component_file         = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$library,$component,$version ));
497
 
498
 
499
 
500
 
501
foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef"))
502
   {
503
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
504
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
505
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
506
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
507
            my $hier_ref_type      = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
508
 
509
     if($hier_ref_type eq "spirit:component")
510
     {
511
     my  @filelist_sub = parse_component_file($new_vendor,$new_library,$new_name,$new_version);
512
        foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
513
     }
514
 
515
 
516
     elsif($hier_ref_type eq "spirit:designConfiguration")
517
     {
518
 
519
        my $spirit_designCfg_file
520
         = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version ));
521
 
522
        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration'))
523
           {
524
           $new_vendor         = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
525
           $new_library        = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
526
           $new_name           = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
527
           $new_version        = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
528
           $hier_ref_type                ="spirit:design";
529
           }
530
     }
531
 
532
     if($hier_ref_type eq "spirit:design")
533
     {
534
     my  @filelist_sub = parse_design_file($new_vendor,$new_library,$new_name,$new_version);
535
     foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
536
     }
537
  }
538
 
539
   @filelist_hier     =       sys::lib::trim_sort(@filelist_hier);
540
   return(@filelist_hier);
541
 
542
}
543
 
544
#/*********************************************************************************************/
545
#/                                                                                            */
546
#/                                                                                            */
547
#/                                                                                            */
548
#/                                                                                            */
549
#/                                                                                            */
550
#/                                                                                            */
551
#/*********************************************************************************************/
552
 
553
sub parse_design_file
554
   {
555
   my @params     = @_;
556
   my $version    = pop(@params);
557
   my $component  = pop(@params);
558
   my $library    = pop(@params);
559
   my $vendor     = pop(@params);
560
 
561
   $home = cwd();
562
 
563
   my $spirit_design_file = $parser->parse_file(yp::lib::find_ipxact("spirit:design",$vendor,$library,$component,$version ));
564
   #/*********************************************************************************************/
565
   #/                                                                                            */
566
   #/  Create filelists for simulation ,  linting and synthesis                     */
567
   #/                                                                                            */
568
   #/                                                                                            */
569
   #/*********************************************************************************************/
570
 
571
   if($spirit_design_file)
572
    {
573
   foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:componentRef/\@spirit:vendor"))
574
        {
575
        my($vendor_name)         = $i_name  ->to_literal ;
576
        my($library_name)        = $i_name  ->findnodes('../@spirit:library')->to_literal ;
577
        my($component_name)      = $i_name  ->findnodes('../@spirit:name')->to_literal ;
578
        my($version_name)        = $i_name  ->findnodes('../@spirit:version')->to_literal ;
579
 
580
        push(@filelist_hier,"::${vendor_name}::${library_name}::${component_name}::${version_name}::");
581
        my  @filelist_sub = parse_component_file($vendor_name,$library_name,$component_name,$version_name);
582
           foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
583
        }
584
    }
585
   @filelist_hier     =       sys::lib::trim_sort(@filelist_hier);
586
   return(@filelist_hier);
587
   }
588
 
589
 
590
 

powered by: WebSVN 2.1.0

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