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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [sys/] [gen_elab_child_filelist] - Blame information for rev 135

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 134 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3
 
4 135 jt_eaton
#/****************************************************************************/
5
#/*                                                                          */
6
#/*   SOCGEN Design for Reuse toolset                                        */
7
#/*                                                                          */
8
#/*   Version 1.0.0                                                          */
9
#/*                                                                          */
10
#/*   Author(s):                                                             */
11
#/*      - John Eaton, z3qmtr45@gmail.com                                    */
12
#/*                                                                          */
13
#/****************************************************************************/
14
#/*                                                                          */
15
#/*                                                                          */
16
#/*             Copyright 2016 John T Eaton                                  */
17
#/*                                                                          */
18
#/* Licensed under the Apache License, Version 2.0 (the "License");          */
19
#/* you may not use this file except in compliance with the License.         */
20
#/* You may obtain a copy of the License at                                  */
21
#/*                                                                          */
22
#/*    http://www.apache.org/licenses/LICENSE-2.0                            */
23
#/*                                                                          */
24
#/* Unless required by applicable law or agreed to in writing, software      */
25
#/* distributed under the License is distributed on an "AS IS" BASIS,        */
26
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
27
#/* See the License for the specific language governing permissions and      */
28
#/* limitations under the License.                                           */
29
#/*                                                                          */
30
#/*                                                                          */
31
#/****************************************************************************/
32 134 jt_eaton
 
33
 
34
############################################################################
35
# General PERL config
36
############################################################################
37
use Getopt::Long;
38
use English;
39
use File::Basename;
40
use Cwd;
41
use XML::LibXML;
42
use lib './tools';
43
use sys::lib;
44
use yp::lib;
45
use BerkeleyDB;
46
 
47
 
48
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
49
 
50
 
51
############################################################################
52
### Process the options
53
############################################################################
54
Getopt::Long::config("require_order", "prefix=-");
55
GetOptions("h","help",
56
           "envidentifier=s" => \$envidentifier,
57
           "prefix=s" => \$prefix,
58
           "vendor=s" => \$vendor,
59
           "library=s" => \$library,
60
           "component=s" => \$component,
61
           "version=s" => \$version,
62
           "top_file=s" => \$top_file,
63
           "suffix=s" => \$suffix,
64
           "leader=s" => \$leader,
65
           "top","top_lib"
66
) || die "(use '$program_name -h' for help)";
67
 
68
 
69
 
70
##############################################################################
71
## Help option
72
##############################################################################
73
if ( $opt_h  or $opt_help)
74
  { print "\n gen_elab_child_filelist -prefix /work -envidentifier *simulation*  -vendor vendor_name  -library library_name  -component component_name -version version_name   ";
75
    print "\n";
76
    exit 1;
77
  }
78
 
79
 
80
##############################################################################
81
##
82
##############################################################################
83
 
84
$home = cwd();
85
my $variant;
86
my $view;
87
my $filesetref_name;
88
 
89
 
90
 
91
 
92
if($version)       {$variant   = "${component}_${version}";}
93
else               {$variant   = "${component}";}
94
 
95
my $parser = XML::LibXML->new();
96
my $spirit_component_file  = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
97
my $comp_xml_sep           = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
98
my $lib_comp_sep           = yp::lib::find_lib_comp_sep($vendor,$library,$component);
99 135 jt_eaton
my $child_dir              = yp::lib::get_child_dir;
100 134 jt_eaton
 
101
 
102
 
103
 
104
 print "\n---GEN_elab_child_filelist -prefix $prefix -envidentifier $envidentifier  -vendor $vendor  -library $library  -component $component -version $version  \n";
105
 
106 135 jt_eaton
foreach my $X_view ($spirit_component_file->findnodes('//ipxact:component/ipxact:model/ipxact:views/ipxact:view'))
107 134 jt_eaton
         {
108 135 jt_eaton
         my($Xview_name)            = $X_view->findnodes('./ipxact:name/text()')->to_literal ;
109
         my($Xview_envidentifier)   = $X_view->findnodes('./ipxact:envIdentifier/text()')->to_literal ;
110
         my($Xview_filesetref_name)  = $X_view->findnodes('./ipxact:fileSetRef/ipxact:localName/text()')->to_literal ;
111 134 jt_eaton
 
112
#print  "XXXXX   $Xview_name || $Xview_envidentifier || $Xview_filesetref_name  \n";
113
 
114
         if($envidentifier eq $Xview_envidentifier )
115
              {
116
              $view = $Xview_name;
117
              $filesetref_name = $Xview_filesetref_name;
118
              }
119
         }
120
 
121
#print  "XXXXZ   $view || $filesetref_name  \n";
122
 
123
 
124
if((defined $view  ) && defined $filesetref_name  )
125
 
126
{
127
 
128
unless($suffix) { $suffix = $view };
129
 
130
 
131
my $path ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/../filelists";
132
mkdir $path,0755          unless( -e $path );
133
 
134
 
135
 
136
 
137
 
138
my @configs  = yp::lib::get_component_configs($vendor,$library,$component,$version);
139
 
140
 
141
 
142
foreach my $config (@configs)
143
 
144
{
145
#print "Config  $config \n";
146
 
147
my @simfilelist = ();
148
 
149
 
150
my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/../filelists/${variant}_${config}.${suffix}\n";
151
#print "OUTFILE  $outfile";
152
open SIMFILE,">$outfile" or die "unable to open $outfile";
153
if($top_file)
154
 
155
{
156
#print SIMFILE  "$top_file  \n";
157
push @simfilelist,"$top_file  \n" ;
158
}
159
 
160
 
161
 
162
my $top_filename = find_filename( $filesetref_name, $vendor, $library,$component,$version);
163
#print SIMFILE "${home}${prefix}/${top_filename}_${config}.v \n";
164
push @simfilelist,"${home}${prefix}/${top_filename}_${config}.v \n";
165
 
166
 
167
 my $elab_db_filename = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,$config);
168
 
169
 my $elab_db  = new BerkeleyDB::Hash( -Filename => "$elab_db_filename", -Flags => DB_CREATE ) or die "Cannot open $elab_db_filename: $!";
170
 
171
 my $key;
172
 my $value;
173
 
174
 $cursor = $elab_db ->db_cursor() ;
175
 while ($cursor->c_get($key, $value, DB_NEXT) == 0)
176
   {
177
 
178
   my $VLNV;
179
   my $vlnv;
180
   ( ${VLNV},${vlnv}) = split( /___root./ , $key);
181
   if($VLNV eq "component")
182
     {
183
 
184
     if($vlnv)
185
       {
186
#       print "$key $vlnv   $value\n";
187
#       print SIMFILE "OUT  $value  \n";
188
       my $ven;
189
       my $lib;
190
       my $cmp;
191
       my $ver;
192
       my $cfg;
193
 
194
       ( ${ven},${lib},${cmp},${ver},${cfg}) = split( /:/ , $value);
195
 
196
#       print "FIND  ${ven} ${lib} ${cmp} ${ver} ${cfg} $view \n";
197
       my $filename = find_filename( $filesetref_name, $ven, $lib,$cmp,$ver);
198 135 jt_eaton
#       print SIMFILE "${home}/${child_dir}/${filename}_${cfg}.v \n";
199
       push @simfilelist,"${home}/${child_dir}/${filename}_${cfg}.v \n";
200 134 jt_eaton
 
201
       }
202
     }
203
    }
204
 
205
@simfilelist      = sys::lib::trim_sort(@simfilelist);
206
 
207
foreach my $simfile (@simfilelist)
208
{
209
       print SIMFILE "${simfile}";
210
}
211
 
212
 
213
 
214
 
215
my $status = $cursor->c_close() ;
216
$elab_db->db_close();
217
 
218
}
219
 
220
}
221
 
222
 
223
 
224
 
225
 
226
 
227
 
228
 
229
 
230
 
231
 
232
 
233
 
234
 
235
 
236
 
237
 
238
 
239
 
240
 
241
 
242
 
243
 
244
 
245
 
246
 
247
 
248
 
249
 
250
 
251
 
252
 
253
 
254
 
255
 
256
 
257
 
258
 
259
 
260
 
261
 
262
#/*********************************************************************************************/
263
#/                                                                                            */
264
#/  Create filelists for simulation, synthesis and linting                                    */
265
#/                                                                                            */
266
#/                                                                                            */
267
#/*********************************************************************************************/
268
 
269
 
270
 
271
 
272
 
273
 
274
 
275
 
276
 
277
 
278
#/*********************************************************************************************/
279
#/  find filename                                                                             */
280
#/                                                                                            */
281
#/  returns gloabal  name of the file                                                         */
282
#/                                                                                            */
283
#/                                                                                            */
284
#/*********************************************************************************************/
285
 
286
sub find_filename
287
   {
288
   my @params             = @_;
289
   my $version            = pop(@params);
290
   my $component          = pop(@params);
291
   my $library            = pop(@params);
292
   my $vendor             = pop(@params);
293
   my $filesetref_name    = pop(@params);
294
 
295
   my $variant;
296
   if($version)       {$variant   = "${component}_${version}";}
297
   else               {$variant   = "${component}";}
298
 
299
   my  @filelist =       yp::lib::parse_component_brothers("$vendor","$library","$component","$version");
300
   my $comp_xml_sep    = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
301
   my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$library,$component);
302
   my $library_path    = "${lib_comp_sep}${component}${comp_xml_sep}";
303
 
304
 
305
 
306
foreach $line (@filelist)
307
   {
308
   $_ = $line;
309
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
310
     {
311
     $new_library        = $2;
312
     $new_component      = $3;
313
     $new_vendor         = $1;
314
     $new_version        = $4;
315
 
316
     my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_library,$new_component,$new_version));
317
 
318
 
319 135 jt_eaton
           foreach  my   $i_name ($spirit_component_file->findnodes("//ipxact:fileSets/ipxact:fileSet/ipxact:file/ipxact:name"))
320 134 jt_eaton
              {
321
              my($file_name)      = $i_name ->findnodes('./text()')->to_literal ;
322 135 jt_eaton
              my($file_type)      = $i_name ->findnodes('../ipxact:userFileType/text()')->to_literal ;
323
              my($logical_name)   = $i_name ->findnodes('../ipxact:logicalName/text()')->to_literal ;
324
              my($view_file)      = $i_name ->findnodes('../../ipxact:name/text()')->to_literal ;
325 134 jt_eaton
              if(($file_type eq "libraryDir") &&  ($logical_name eq "dest_dir")  )
326
                 {
327
 
328
                 if( $view_file eq  $filesetref_name )
329
                   {
330
                   return ("${vendor}__${library}${library_path}/${file_name}${variant}");
331
                   };
332
                 }
333
              }
334
    }
335
}
336
}
337
 
338
 
339
1
340
 

powered by: WebSVN 2.1.0

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