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

Subversion Repositories socgen

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

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
 
118 125 jt_eaton
my  @filelist =       yp::lib::parse_component_file("$vendor","$project","$component","$version");
119 124 jt_eaton
 
120
 
121
 
122
 
123
foreach $line (@filelist)
124
   {
125
   $_ = $line;
126
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
127
     {
128
     $new_proj      = $2;
129
     $new_comp      = $3;
130
     $new_vendor    = $1;
131
     $new_version   = $4;
132
     }
133
 
134
 
135
 
136
   #############################################################################
137
   ## Read destination from source xml file
138
   ##
139
   #############################################################################
140
 
141
 
142
 
143
   my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version));
144
 
145
 
146
 
147
 
148
   if($new_version){$new_variant   = "${new_comp}_${new_version}"}
149
   else             {$new_variant   = $new_comp}
150
 
151
 
152
 
153 127 jt_eaton
if(($new_vendor eq $vendor ) &&  ($new_proj eq $project ) &&  ($new_comp eq $component )  &&  ($new_version eq $version )        )
154
 
155 124 jt_eaton
        {
156
 
157
           foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
158
              {
159
              my($file_name)      = $i_name ->findnodes('./text()')->to_literal ;
160
              my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
161
              my($logical_name)   = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
162
              my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
163
              my $component_path  = yp::lib::find_ipxact_component_path("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version);
164
 
165
              if( ($file_type eq "libraryDir") &&  ($view_file eq "fs-lint")  &&  ($logical_name eq "dest_dir")                    )
166
                 {
167
                 push(@filelist_sim,"../../../../${new_comp}${component_path}/${file_name}${new_variant}.v\n");
168
                 };
169
 
170
              }
171
        }
172
   else
173
        {
174
 
175
           foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
176
              {
177
              my($file_name)      = $i_name ->findnodes('./text()')->to_literal ;
178
              my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
179
              my($logical_name)   = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
180
              my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
181
              my $library_path    = yp::lib::find_ipxact_library_path("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version);
182
 
183
 
184
 
185
              if(($file_type eq "libraryDir")&& (($view_file eq "fs-lint") ) &&  ($logical_name eq "dest_dir")  )
186
                 {
187
                 push(@filelist_sim,"../../../../../children/${new_vendor}__${new_proj}${library_path}/${file_name}${new_variant}.v\n");
188
                 };
189
              }
190
 
191
        }
192
 
193
   }
194
 
195
 
196
 
197
 
198
 
199
 
200
#############################################################################
201
##
202
##
203
#############################################################################
204
 
205
print "Building rtl_check  filelists for  $work_site  $vendor $project   $component $version $variant \n" ;
206
 
207
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
208
my $sogen_file               = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));
209
 
210
 
211
 
212
 
213
 
214
#/*********************************************************************************************/
215
#/                                                                                            */
216
#/                                                                                            */
217
#/  Read each variants parameters and defaults into an array and their order into an array    */
218
#/  order must be preservered so that parameters can use the values of other parameters       */
219
#/                                                                                            */
220
#/*********************************************************************************************/
221
 
222
my %default_parameters = ();
223
my @parameter_order    = ();
224
 
225
 
226 128 jt_eaton
foreach  my   $i_name ($sogen_file->findnodes("//socgen:testbenches/socgen:testbench[socgen:variant/text() = '$variant']/socgen:parameters/socgen:parameter"))
227 124 jt_eaton
      {
228
      my($parameter_name)     = $i_name ->findnodes('socgen:name/text()')->to_literal ;
229
      my($parameter_default)  = $i_name ->findnodes('socgen:value/text()')->to_literal ;
230
      $default_parameters{$parameter_name}  = $parameter_default;
231
      push  @parameter_order ,$parameter_name ;
232
 #     print "XXXXY $parameter_name     $parameter_default       \n";
233
      }
234
 
235
 
236
 
237
 
238
 
239
 
240
 
241
 
242
foreach my $comp ($spirit_component_file->findnodes('//spirit:component'))
243
   {
244
   my($vendor)   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
245
   my($library)  = $comp->findnodes('./spirit:library/text()')->to_literal ;
246
   my($name)     = $comp->findnodes('./spirit:name/text()')->to_literal ;
247
   my($version)  = $comp->findnodes('./spirit:version/text()')->to_literal ;
248
   my $variant = "";
249
   if($version) {$variant = "${name}_${version}"}
250
   else         {$variant = "${name}"}
251
   print "rtl/gen directories  for    $project - $component         VLNV        $vendor - $library -  $name -  $variant \n";
252
   }
253
 
254
 
255
 
256
 
257
 
258
 
259
 
260
 
261
 
262
 
263
 
264
   push(@filelist_sim,"    ./TestBench\n");
265
 
266
   print "CREATING componentRef filelists for   $project   $component  $name $variant \n";
267
 
268 128 jt_eaton
   @filelist_sim =       sys::lib::trim_sort(@filelist_sim);
269 124 jt_eaton
 
270
 
271
 
272
 
273
 
274
 
275
 
276
 
277
 
278
 
279
 
280
 
281
 
282
   #/*********************************************************************************************/
283
   #/                                                                                            */
284
   #/ Make simulation file set                                                                   */
285
   #/                                                                                            */
286
   #/                                                                                            */
287
   #/                                                                                            */
288
   #/                                                                                            */
289
   #/*********************************************************************************************/
290
 
291
   print "CREATING sim files for   $project  $component   $chip   $name  $variant \n";
292
 
293
 
294
 
295
 
296
   my $sogen_file     = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));
297
 
298
    foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:rtl_check/socgen:lint[socgen:variant/text() = '$variant']"))
299
      {
300
      my($simulation)      = $i_name ->findnodes('socgen:name/text()')->to_literal ;
301
      my($configuration)   = $i_name ->findnodes('socgen:configuration/text()')->to_literal ;
302
 
303
      print " lint  files for   $project  $component   $variant  $simulation $configuration          \n";
304 127 jt_eaton
      my $sim_library_path = $sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
305 124 jt_eaton
 
306 127 jt_eaton
      my $path  = "${home}${work_site}/${vendor}__${project}${sim_library_path}/rtl_check";
307 124 jt_eaton
 
308 125 jt_eaton
      mkdir $path,0755 unless (-e $path) ;
309 124 jt_eaton
 
310 127 jt_eaton
      $path  = "${home}${work_site}/${vendor}__${project}${sim_library_path}/rtl_check/${simulation}";
311 125 jt_eaton
      mkdir $path,0755   unless (-e $path);
312 124 jt_eaton
 
313 127 jt_eaton
      my $outfile ="${home}${work_site}/${vendor}__${project}${sim_library_path}/rtl_check/${simulation}/Makefile";
314 125 jt_eaton
      open  MAKSIMFILE,">$outfile" or die "unable to open $outfile";
315 124 jt_eaton
 
316
 
317
 
318 127 jt_eaton
      $outfile ="${home}${work_site}/${vendor}__${project}${sim_library_path}/rtl_check/${simulation}/TestBench";
319 125 jt_eaton
      open SIM_PARM_FILE,">$outfile" or die "unable to open $outfile";
320 124 jt_eaton
 
321
 
322 128 jt_eaton
      print MAKSIMFILE  "include ${home}/tools/bin/Makefile.root\n";
323 124 jt_eaton
      print MAKSIMFILE  "comp=${variant}\n";
324
      print MAKSIMFILE  "test=${simulation}\n";
325
 
326
 
327
 
328
      my %local_parameters =  %default_parameters;
329
      my @local_order      =  @parameter_order;
330
 
331
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$configuration']/./socgen:parameters/socgen:parameter/socgen:name"))
332
         {
333
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
334
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
335
         if($local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
336
         $local_parameters{$par_name} = $par_value;
337
         }
338
 
339
      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"))
340
         {
341
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
342
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
343
         if  ( $local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
344
         $local_parameters{$par_name} = $par_value;
345
         }
346
 
347 125 jt_eaton
 
348
 
349
      my $module_name = yp::lib::get_module_name($vendor,$project,$component,$version);
350
 
351 124 jt_eaton
      print SIM_PARM_FILE  "//  Testbench  for  $project    $component    $variant   $configuration    $simulation\n";
352
      print SIM_PARM_FILE  "                                \n";
353 125 jt_eaton
      print SIM_PARM_FILE  "module TB(input clk,input reset); \n";
354
      print SIM_PARM_FILE  "   \n\n";
355
      print SIM_PARM_FILE  "     $module_name   \n";
356 124 jt_eaton
 
357
      my $first =1;
358
 
359
      foreach  my  $parameter_name  (@local_order)
360
         {
361 128 jt_eaton
 
362 124 jt_eaton
         my($parameter_default)  =    $local_parameters{$parameter_name};
363 128 jt_eaton
 
364
       #  if a parameter is used to define a paramter then use its value instead. Only works for lookup- no alterations
365
         if($local_parameters{$parameter_default}) {   $parameter_default  =    $local_parameters{$parameter_default}      }
366
 
367 124 jt_eaton
         if($first)
368
           {
369
           print SIM_PARM_FILE  "   #(  .${parameter_name}(${parameter_default})";
370
           $first = 0;
371
           }
372
         else
373
           {
374
           print SIM_PARM_FILE  ",\n       .${parameter_name}(${parameter_default})";
375
           }
376
         }
377
 
378
         if($first)       { print SIM_PARM_FILE  "  ";}
379
         else             { print SIM_PARM_FILE  ") ";}
380
 
381 125 jt_eaton
      print SIM_PARM_FILE  "  test \n (.clk(clk),.reset(reset)); \n\n\n\n endmodule \n  ";
382 124 jt_eaton
 
383
 
384
 
385
      }
386
 
387
 
388
 
389
 
390
 

powered by: WebSVN 2.1.0

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