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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_elab_verilogLib] - Blame information for rev 134

Go to most recent revision | 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
#/*                                                                    */
5
#/*             -------                                                */
6
#/*            /   SOC  \                                              */
7
#/*           /    GEN   \                                             */
8
#/*          /    TOOL    \                                            */
9
#/*          ==============                                            */
10
#/*          |            |                                            */
11
#/*          |____________|                                            */
12
#/*                                                                    */
13
#/*                                                                    */
14
#/*                                                                    */
15
#/*  Author(s):                                                        */
16
#/*      - John Eaton, jt_eaton@opencores.org                          */
17
#/*                                                                    */
18
#/**********************************************************************/
19
#/*                                                                    */
20
#/*    Copyright (C) <2010-2012>                */
21
#/*                                                                    */
22
#/*  This source file may be used and distributed without              */
23
#/*  restriction provided that this copyright statement is not         */
24
#/*  removed from the file and that any derivative work contains       */
25
#/*  the original copyright notice and the associated disclaimer.      */
26
#/*                                                                    */
27
#/*  This source file is free software; you can redistribute it        */
28
#/*  and/or modify it under the terms of the GNU Lesser General        */
29
#/*  Public License as published by the Free Software Foundation;      */
30
#/*  either version 2.1 of the License, or (at your option) any        */
31
#/*  later version.                                                    */
32
#/*                                                                    */
33
#/*  This source is distributed in the hope that it will be            */
34
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
35
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
36
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
37
#/*  details.                                                          */
38
#/*                                                                    */
39
#/*  You should have received a copy of the GNU Lesser General         */
40
#/*  Public License along with this source; if not, download it        */
41
#/*  from http://www.opencores.org/lgpl.shtml                          */
42
#/*                                                                    */
43
#/**********************************************************************/
44
 
45
 
46
 
47
############################################################################
48
# General PERL config
49
############################################################################
50
use Getopt::Long;
51
use English;
52
use File::Basename;
53
use Cwd;
54
use XML::LibXML;
55
use lib './tools';
56
use sys::lib;
57
use yp::lib;
58
 
59
 
60
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
61
 
62
 
63
############################################################################
64
### Process the options
65
############################################################################
66
 
67
Getopt::Long::config("require_order", "prefix=-");
68
GetOptions("h","help",
69
           "envidentifier=s" => \$envidentifier,
70
           "prefix=s" => \$prefix,
71
           "vendor=s" => \$vendor,
72
           "library=s" => \$library,
73
           "component=s" => \$component,
74
           "version=s" => \$version,
75
           "configuration=s" => \$configuration,
76
           "dest_dir=s" => \$dest_dir,
77
           "view=s" => \$view
78
) || die "(use '$program_name -h' for help)";
79
 
80
 
81
##############################################################################
82
## Help option
83
##############################################################################
84
if ( $opt_h  or ($opt_help) )
85
   {
86
   print "\n gen_elab_verilogLib -envidentifier *simulation* -prefix /work  -vendor vendor_name -library  library_name  -component component_name -version version_name -dest_dir dest_dir";
87
   print "\n";
88
   exit 1;
89
   }
90
 
91
 
92
##############################################################################
93
##
94
##############################################################################
95
 
96
my $parser = XML::LibXML->new();
97
 
98
my $socgen_file               = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
99
my $ip_name_base_macro       = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:ip_name_base_macro/text()")->to_literal;
100
 
101
 
102
 
103
 
104
$home = cwd();
105
my @search_paths = ();
106
my $variant;
107
 
108
 
109
 
110
 
111
 
112
 
113
 
114
 
115
 
116
 
117
my @configs  = yp::lib::get_component_configs($vendor,$library,$component,$version);
118
 
119
 
120
   print "\n ---GEN_elab_verilogLib -envidentifier  $envidentifier -prefix $prefix  -vendor $vendor -library  $library  -component $component -version $version -dest_dir $dest_dir -configuration  $configuration  \n";
121
 
122
foreach my $config (@configs)
123
 
124
{
125
 
126
 
127
 
128
 
129
print "+++GEN_verilogLib  Configuration  $config  \n";
130
 
131
}
132
 
133
 
134
 
135
 
136
 
137
 
138
 
139
 if($version)       {$variant   = "${component}_${version}";}
140
 else               {$variant   = "${component}";}
141
 
142
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$library,$component);
143
my $comp_xml_sep    = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
144
my $module_name     = yp::lib::get_module_name($vendor,$library,$component,$version);
145
 
146
 
147
 
148
 
149
 
150
 
151
 
152
 
153
my $parser = XML::LibXML->new();
154
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
155
 
156
 
157
if($dest_dir ne "../views")
158
{
159
print "XXXXXXXXXXXXXXXXXXX   Building $view   $library  $component $verison  $variant  $dest_dir    Dest_dir not ./views  \n" ;
160
}
161
 
162
 
163
#print "VVVVVVVV   Building $view  Verilog Lib RTL for  $prefix $library  $component $verison  $variant  $dest_dir  \n" ;
164
 
165
 
166
 
167
 
168
my $path  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}";
169
mkdir $path,0755             unless( -e $path );
170
 
171
 
172
my $path  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../defines";
173
mkdir $path,0755             unless( -e $path );
174
 
175
my $path  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists";
176
mkdir $path,0755             unless( -e $path );
177
 
178
 
179
my $path  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}";
180
mkdir $path,0755             unless( -e $path );
181
 
182
 
183
 
184
    #/**********************************************************************/
185
    #/*                                                                    */
186
    #/* build a `define file for module names                              */
187
    #/*                                                                    */
188
    #/*                                                                    */
189
    #/*                                                                    */
190
    #/*                                                                    */
191
    #/**********************************************************************/
192
 
193
    my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../defines/${variant}.v";
194
    open DEFLIST,">$outfile" or die "unable to open $outfile";
195
 
196
        if(defined $configuration && length $configuration >0 )
197
          {
198
          print  DEFLIST "   \`define $ip_name_base_macro     ${module_name}_${configuration}  \n";
199
    my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}_${configuration}.MOD";
200
    open FILELIST,">$outfile" or die "unable to open $outfile";
201
          }
202
        else
203
          {
204
          print  DEFLIST "   \`define $ip_name_base_macro     ${module_name}  \n";
205
    my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.MOD";
206
    open FILELIST,">$outfile" or die "unable to open $outfile";
207
 
208
    }
209
 
210
 
211
 
212
 
213
 
214
    my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.INC";
215
    open INCLIST,">$outfile" or die "unable to open $outfile";
216
 
217
    print INCLIST  "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../defines/${variant}.v\n";
218
 
219
 
220
 
221
 
222
 
223
 
224
    foreach my $comp_view ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:envIdentifier[./text() = '$envidentifier']"))
225
      {
226
      my($view_name)     = $comp_view->findnodes('../spirit:name/text()')->to_literal ;
227
      my($view_fileset)  = $comp_view->findnodes('../spirit:fileSetRef/spirit:localName/text()')->to_literal ;
228
   #   print "    VVVVVVVVVVVVVL    Found $view  --  $view_name  $view_fileset  $dest_dir  $configuration   \n" ;
229
 
230
if($view ne $view_name)
231
{
232
print "XXXXXXXXXXXXXXXXXXXXX   Building $view   $view_name not equal   $vendor, $library, $component, $version    \n" ;
233
}
234
 
235
 
236
 
237
 
238
   my @includes = yp::lib::get_files($vendor,$library,$component,$version,$view_fileset,"include") ;
239
 
240
#      print "     VVVVVVVK  $vendor,$library,$component,$version,$view_fileset  include   $view_name \n";
241
 
242
      foreach my $include (@includes)
243
        {
244
#        print "       VVVVVVVJ  |${include}| \n";
245
       print INCLIST  "${home}${prefix}/${include}\n";
246
        }
247
 
248
   my @modules   = yp::lib::get_files($vendor,$library,$component,$version,$view_fileset,"module") ;
249
 
250
      foreach my $module (@modules)
251
        {
252
#        print "       VVVVVVVI  |${module}|  $configuration   \n";
253
        #  need to tag the top module but no others
254
 
255
        if(defined $configuration && length $configuration >0 )
256
          {
257
          $_ = $module;
258
          if(/(\S+)${component}_${version}/)
259
            {
260
            $_ = $module;
261
          if(/(\S+)${component}_${version}(\S+)/)
262
            {
263
#            print "No_TAG    $module \n";
264
            print FILELIST  "${home}${prefix}/${module}\n";
265
            }
266
            else
267
              {
268
#              print "   TAG    $module \n";
269
              print FILELIST  "${home}${prefix}/${module}_${configuration}\n";
270
              }
271
            }
272
          else
273
            {
274
#            print "No_TAG    $module \n";
275
            print FILELIST  "${home}${prefix}/${module}\n";
276
            }
277
          }
278
        else
279
          {
280
          print FILELIST  "${home}${prefix}/${module}\n";
281
          }
282
        }
283
 
284
   my @libraryDirs   = yp::lib::get_files($vendor,$library,$component,$version,$view_fileset,"libraryDir") ;
285
 
286
      foreach my $libraryDir (@libraryDirs)
287
        {
288
#        print "       VVVVVVVM  |${libraryDir}| \n";
289
        }
290
 
291
      }
292
 
293
 
294
 
295
 
296
 
297
 
298
 
299
 
300
 
301
#print " VVVVVVVV   $envidentifier  $view  \n" ;
302
 
303
 
304
my  @filelist =       yp::lib::parse_component_brothers("$vendor","$library","$component","$version");
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
#     print "  VVVVVVVVVVVVVVVVVVVVV  Brother      $new_vendor  $new_library  $new_component $new_version \n" ;
317
 
318
    my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_library,$new_component,$new_version));
319
 
320
    foreach my $comp_view ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:envIdentifier[./text() = '$envidentifier']"))
321
      {
322
      my($view_name)     = $comp_view->findnodes('../spirit:name/text()')->to_literal ;
323
      my($view_fileset)  = $comp_view->findnodes('../spirit:fileSetRef/spirit:localName/text()')->to_literal ;
324
#      print "    VVVVVVVVVVVVVV    Found  $view_name  $view_fileset    \n" ;
325
 
326
    #/**********************************************************************/
327
    #/*                                                                    */
328
    #/* build a fileset in the following order                             */
329
    #/*                                                                    */
330
    #/* deflist for module names                                           */
331
    #/* all include files                                                  */
332
    #/* all module files                                                   */
333
    #/*                                                                    */
334
    #/*                                                                    */
335
    #/**********************************************************************/
336
 
337
 
338
 
339
 
340
    foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
341
       {
342
       my($file_name)          = $i_name ->findnodes('./text()')->to_literal ;
343
       my($file_logicalname)   = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
344
       my($file_type)          = $i_name ->findnodes('../spirit:fileType/text()')->to_literal ;
345
       my($file_usertype)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
346
       my($view_file)          = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
347
 
348
 
349
 
350
       if(($file_usertype eq "libraryDir")&& ($view_file eq $view_fileset)  &&   ($file_type eq "verilogSource")        )
351
         {
352
#          print "       VVVVVMVV   ${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}\n";
353
        push @search_paths,  "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}";
354
         };
355
 
356
 
357
       if(($file_usertype eq "module") && ($view_file eq $view_fileset) &&   ($file_type eq "verilogSource")                     )
358
         {
359
 
360
#          print "       VVVVVIVV   ${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}\n";
361
#         print FILELIST  "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}\n";
362
         if($file_logicalname )
363
            {
364
            print  DEFLIST   sprintf( "\`define %s   _%s\n",   uc($file_logicalname) ,  $file_logicalname );
365
            }
366
         };
367
       }
368
      }
369
     }
370
   }
371
      #/**********************************************************************/
372
      #/*                                                                    */
373
      #/* Every leaf cell is processed through a the verilog preprocessor    */
374
      #/* to customize the module names,remove all verilog tic(`) statements */
375
      #/* and to create seperate versions for simulation and synthesys       */
376
      #/*                                                                    */
377
      #/*                                                                    */
378
      #/**********************************************************************/
379
 
380
 
381
 
382
        if(defined $configuration && length $configuration >0 )
383
             {
384
             $file_out  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}/${variant}_${configuration}.v";
385
             }
386
        else
387
             {
388
             $file_out  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}/${variant}.v";
389
             }
390
 
391
        if( -e $file_out )
392
        {
393
        $cmd ="rm  $file_out \n";
394
        if (system($cmd)) {}
395
        };
396
 
397
        my $cmd_path;
398
 
399
        foreach $search_path (@search_paths)
400
              {
401
               $cmd_path = " $cmd_path -I${search_path} " ;
402
              }
403
 
404
 
405
 
406
 
407
        if(defined $configuration && length $configuration >0 )
408
             {
409
        $cmd ="vppreproc --noline --noblank  $cmd_path  -f  ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.INC  -f  ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}_${configuration}.MOD    >>  $file_out \n";
410
             }
411
        else
412
             {
413
        $cmd ="vppreproc --noline --noblank  $cmd_path  -f  ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.INC  -f  ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.MOD    >>  $file_out \n";
414
             }
415
 
416
 
417
 
418
 
419
 
420
 
421
 
422
        if (system($cmd)) {}
423
 
424
 
425
 
426
 
427
 
428
 
429
 
430
 
431
 
432
 
433
1
434
 
435
 
436
 
437
 
438
 
439
 
440
 
441
 
442
 
443
 
444
 
445
 
446
 
447
 
448
 

powered by: WebSVN 2.1.0

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