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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_elab_verilog] - 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 135 jt_eaton
#/****************************************************************************/
4
#/*                                                                          */
5
#/*   SOCGEN Design for Reuse toolset                                        */
6
#/*                                                                          */
7
#/*   Version 1.0.0                                                          */
8
#/*                                                                          */
9
#/*   Author(s):                                                             */
10
#/*      - John Eaton, z3qmtr45@gmail.com                                    */
11
#/*                                                                          */
12
#/****************************************************************************/
13
#/*                                                                          */
14
#/*                                                                          */
15
#/*             Copyright 2016 John T Eaton                                  */
16
#/*                                                                          */
17
#/* Licensed under the Apache License, Version 2.0 (the "License");          */
18
#/* you may not use this file except in compliance with the License.         */
19
#/* You may obtain a copy of the License at                                  */
20
#/*                                                                          */
21
#/*    http://www.apache.org/licenses/LICENSE-2.0                            */
22
#/*                                                                          */
23
#/* Unless required by applicable law or agreed to in writing, software      */
24
#/* distributed under the License is distributed on an "AS IS" BASIS,        */
25
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
26
#/* See the License for the specific language governing permissions and      */
27
#/* limitations under the License.                                           */
28
#/*                                                                          */
29
#/*                                                                          */
30
#/****************************************************************************/
31 134 jt_eaton
 
32
 
33
############################################################################
34
# General PERL config
35
############################################################################
36
use Getopt::Long;
37
use English;
38
use File::Basename;
39
use Cwd;
40
use Scalar::Util qw(looks_like_number);
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
           "version=s"        => \$version,
61
           "component=s"      => \$component,
62
           "configuration=s"  => \$configuration,
63
           "destination=s"    => \$destination,
64
           "local_parameters"
65
) || die "(use '$program_name -h' for help)";
66
 
67
 
68
##############################################################################
69
## Help option
70
##############################################################################
71
if ( $opt_h  or $opt_help  )
72
  { print "\n gen_verilog -envidentifier :*Simulation:*  -prefix /work/children -vendor vendor_name -library library_name  -component component_name  -version version_name -destination destination -configuration configuration -local_parameters  \n";
73
    exit 1;
74
  }
75
 
76
 
77
 
78
#############################################################################
79
##
80
##
81
#############################################################################
82
 
83
$home = cwd();
84
 
85
 
86
my $variant;
87
my $view;
88
 
89
if($version)       {$variant   = "${component}_${version}";}
90
else               {$variant   = "${component}";}
91
 
92
my $dest_dir = "../verilog";
93
 
94
 
95
unless (defined $destination && length $destination > 0)
96
{$destination = $variant;}
97
 
98
if(defined $configuration && length $configuration > 0)
99
{
100
#print "QQQQQQQQQQQQW  Configuration  $vendor $library $component $version  $configuration \n";
101
}
102
else
103
{ $configuration = "default";}
104
 
105
 
106
if($opt_local_parameters)
107
{
108
#print "QQQQQQQQQQQQW  Local_Parameters  $vendor $library $component $version   \n";
109
}
110
 
111
 
112
 
113
 
114
 
115
 
116
print "\n---GEN_elab_verilog    -envidentifier $envidentifier -prefix  $prefix -vendor $vendor -library $library -component $component -version $version -configuration $configuration -dest_dir     $dest_dir -destination  $destination   \n";
117
 
118
my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;
119
my $lib_comp_sep     = yp::lib::find_lib_comp_sep($vendor,$library,$component);
120
my $comp_xml_sep     = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
121
 
122
my $parser = XML::LibXML->new();
123
 
124
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
125
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
126
 
127
my $sim_library_path ;
128
 
129
my $sim_comp_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:comp_path/text()")->to_literal;
130
 
131
if ($sim_comp_path)  {$sim_library_path  ="${lib_comp_sep}${sim_comp_path}";}
132
else                 {$sim_library_path  = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;}
133
 
134
 
135 135 jt_eaton
foreach my $X_view ($spirit_component_file->findnodes("//ipxact:component/ipxact:model/ipxact:views/ipxact:view/ipxact:envIdentifier[text() = '$envidentifier']"))
136 134 jt_eaton
         {
137 135 jt_eaton
         $view   = $X_view->findnodes('../ipxact:name/text()')->to_literal ;
138 134 jt_eaton
         }
139
 
140
my $path  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}";
141
mkdir $path,0755             unless( -e $path );
142
 
143
my $path  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}";
144
mkdir $path,0755             unless( -e $path );
145
 
146
 
147
my   @instantiations    =       ();
148
my   @parameters        =       ();
149
my   %parameter_values  =       ();
150
my   %parameter_descriptions  = ();
151
 
152
unless ($socgen_file)      { print "No socgen ip file   \n";};
153
 
154
#/******************************************************************************************/
155
#/*                                                                                        */
156
#/* get parameters                                                                         */
157
#/*                                                                                        */
158
#/******************************************************************************************/
159
 
160
 
161
my @Pams = yp::lib::get_parameters($vendor,$library,$component,$version,$configuration);
162
 
163
foreach my $Pam (@Pams)
164
{
165
my $param_name;
166
my $param_value;
167
 
168
( $param_name,$param_value) = split( /\::/ , $Pam);
169
unless(defined $parameter_values{$param_name}) {push ( @parameters,  "$param_name");};
170
$parameter_values{$param_name} = $param_value;
171
}
172
 
173
 
174
 
175
 
176
my @signals = yp::lib::get_signals($vendor,$library,$component,$version);
177
 
178
 
179
 
180
#/**********************************************************************/
181
#/*                                                                    */
182
#/* Every hier cell is constructed from the ipxact file with seperate  */
183
#/* version  for each view                                             */
184
#/*                                                                    */
185
#/* Start by opening the output file                                   */
186
#/* get fileset name                                                   */
187
#/* check that requested view exists                                   */
188
#/*                                                                    */
189
#/**********************************************************************/
190
 
191 135 jt_eaton
foreach my $comp_view ($spirit_component_file->findnodes("//ipxact:component/ipxact:model/ipxact:views/ipxact:view/ipxact:name[text() = '$view']"             ))
192 134 jt_eaton
   {
193 135 jt_eaton
   my($view_fileset_name)  = $comp_view->findnodes('../ipxact:fileSetRef/ipxact:localName/text()')->to_literal ;
194 134 jt_eaton
 
195 135 jt_eaton
 
196
 
197 134 jt_eaton
   if($configuration eq "default")
198
   {
199
   $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}/${destination}";
200
   }
201
   else
202
   {
203
   $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}/${destination}_${configuration}";
204
   }
205
 
206
 
207
   open DEST_FILE,">$outfile" or die "unable to open $outfile";
208
 
209
   if($configuration eq "default")
210
   {
211
   print DEST_FILE  "\n module \n\n  $main_module_name \n ";
212
   }
213
   else
214
   {
215
   print DEST_FILE  "\n module \n\n  ${main_module_name}_${configuration} \n ";
216
   }
217
 
218
 
219
   my @I_names = yp::lib::get_instance_names($vendor,$library,$component,$version,$configuration);
220
 
221
   foreach my $I_name (@I_names)
222
        {
223
        my $foo_ven;
224
        my $foo_lib;
225
        my $foo_cmp;
226
        my $foo_ver;
227
        my $foo_cfg;
228
 
229
        my $vlnvc  = yp::lib::get_instance_vlnvc($vendor,$library,$component,$version,$I_name,$configuration );
230
 
231
          ( $foo_ven,$foo_lib,$foo_cmp,$foo_ver,$foo_cfg) = split( /\:/ , $vlnvc);
232
 
233
 
234
        push @instantiations  , "/*  ${vlnvc}  */ \n";
235
        my $module_name  = yp::lib::get_instance_module_name($vendor,$library,$component,$version,$I_name,$configuration);
236
        if(defined $foo_cfg && length $foo_cfg > 0)
237
          {
238
          push @instantiations  ,          "${module_name}_${foo_cfg}\n";
239
          }
240
        else
241
          {
242
          push @instantiations  ,          "${module_name}\n";
243
          $first = 1;
244
          my @Pams = yp::lib::get_Parameters($vendor,$library,$component,$version,"root.${I_name}",$configuration);
245
          foreach my $pam (@Pams)
246
            {
247
            ( $foo_name,$foo_value) = split( /\::/ , $pam);
248
            if($first)
249
              {
250
              push @instantiations  , "#( .${foo_name} (${foo_value})";
251
              $first = 0;
252
              }
253
            else  {push @instantiations  , ",\n   .${foo_name} (${foo_value})";}
254
            }
255
 
256
          if($first == 0)  { push @instantiations  , ")\n";}
257
          }
258
 
259
 
260
 
261
 
262
 
263
 
264
          push @instantiations  , "$I_name \n   (\n ";
265
          $first = 1;
266
 
267
          my @Inst_conns = yp::lib::get_instance_adhoc_conns($vendor,$library,$component,$version,$I_name);
268
          my @Buss_conns = yp::lib::get_instance_conns($vendor,$library,$component,$version,$I_name);
269
          foreach my $Buss_conn (@Buss_conns)
270
             {
271
             if($first)
272
               {
273
               push @instantiations  ,          "  $Buss_conn";
274
               $first =0;
275
               }
276
             else
277
               {
278
               push @instantiations  , ",\n   $Buss_conn";
279
               }
280
             }
281
          foreach my $Inst_conn (@Inst_conns)
282
             {
283
             if($first)
284
               {
285
               push @instantiations  ,          "  $Inst_conn";
286
               $first =0;
287
               }
288
             else
289
               {
290
               push @instantiations  , ",\n   $Inst_conn";
291
               }
292
             }
293
        push @instantiations  , ");\n\n";
294
        }
295
 
296
 
297
 
298
 
299
 
300
 
301
 
302
 
303
   #/**********************************************************************/
304
   #/*                                                                    */
305
   #/* Add any and all global parameters with their default values        */
306
   #/*                                                                    */
307
   #/**********************************************************************/
308
 
309
   unless ($opt_local_parameters)
310
     {
311
     my $first = 1;
312
     foreach my $parameter_name (@parameters)
313
        {
314
        my $parameter_value = $parameter_values{$parameter_name};
315
        if($first)
316
          {
317
          print DEST_FILE  "   #( parameter \n      ${parameter_name}=${parameter_value}";
318
          $first=0;
319
          }
320
        else  { print DEST_FILE  ",\n      ${parameter_name}=${parameter_value}";}
321
        }
322
 
323
     if    ($first == 0)   { print DEST_FILE  ")\n"; }
324
       }
325
 
326
 
327
 
328
  foreach my $Pam (@Pams)
329
      {
330
#      print DEST_FILE  "//*** $Pam  ***/ \n";
331
      }
332
 
333
 
334
 
335
   #/**********************************************************************/
336
   #/*                                                                    */
337
   #/* sort all  ports  with their type, size and direction               */
338
   #/*                                                                    */
339
   #/**********************************************************************/
340
 
341
   my @port_list  = ();
342
   my @wire_nodes = ();
343
   my $key;
344
   my $value;
345
 
346
   foreach my $signal (@signals)
347
         {
348
         ( ${port_name},${direction},${type},${vector},${left},${right}) = split ':', $signal;
349
 
350
            if(  $direction ne "node"   )
351
              {
352
              my $q_width  = "     ";
353
              if( ${vector} eq "vector" )  { $q_width = "[ ${left} :  ${right}]";             }
354
              push (@port_list,  "${direction}   ${type}    $q_width        ${port_name}");
355
              }
356
            else
357
              {
358
              my $q_width  = "     ";
359
              if( ${vector} eq "vector" )   { $q_width = "[ $left :  $right]";}
360 135 jt_eaton
              push @wire_nodes,     "$type     $q_width              ${port_name};";
361 134 jt_eaton
              }
362
         }
363
 
364
   @port_list      = sys::lib::trim_sort(@port_list);
365
 
366
   #/**********************************************************************/
367
   #/*                                                                    */
368
   #/* Now add all ports  with their type, size and direction             */
369
   #/*                                                                    */
370
   #/**********************************************************************/
371
 
372
   print DEST_FILE  "\n    ";
373
   $first = 1;
374
 
375
   foreach $port_line (@port_list)
376
        {
377
          if($first)
378
            {
379
            print DEST_FILE  " (\n ${port_line}";
380
            $first=0;
381
            }
382
          else
383
            {
384
            print DEST_FILE  ",\n ${port_line}";
385
            }
386
 
387
        }
388
 
389
   if    ($first == 0)   { print DEST_FILE  ");\n\n\n\n"; }
390
   else                  { print DEST_FILE  "();\n\n\n\n";}
391
 
392
 
393
   #/**********************************************************************/
394
   #/*                                                                    */
395
   #/* Add any and all local parameters with their default values         */
396
   #/*                                                                    */
397
   #/**********************************************************************/
398
 
399
   if ($opt_local_parameters)
400
     {
401
     foreach my $parameter_name (@parameters)
402
        {
403
        my $parameter_value = $parameter_values{${parameter_name}};
404
        print DEST_FILE  "parameter     ${parameter_name} = ${parameter_value};\n";
405
        }
406
     }
407
 
408
   @wire_nodes      = sys::lib::trim_sort(@wire_nodes);
409
 
410
   foreach my $wire_node (@wire_nodes)
411
       {
412
       print DEST_FILE  "${wire_node}\n";
413
       }
414
 
415
 
416
     #/**********************************************************************/
417
     #/*                                                                    */
418
     #/* Dump everything from the ip-xact files into component              */
419
     #/*                                                                    */
420
     #/**********************************************************************/
421
 
422
     print DEST_FILE  "\n\n\n";
423
     while(   my $line_out      = shift(@instantiations))             {  print DEST_FILE  "$line_out";}
424
 
425
 
426
     #/**********************************************************************/
427
     #/*                                                                    */
428
     #/* After all the data from the ip-xact file has been entered we now   */
429
     #/* insert any and all verilog fragments at the end before closing     */
430
     #/* the module                                                         */
431
     #/*                                                                    */
432
     #/**********************************************************************/
433
 
434 135 jt_eaton
      if(defined $view_fileset_name & length  $view_fileset_name > 0)
435
        {
436
        my @fragments = yp::lib::get_files($vendor,$library,$component,$version,$view_fileset_name,"fragment") ;
437 134 jt_eaton
 
438 135 jt_eaton
        foreach my $fragment(@fragments)
439
          {
440 134 jt_eaton
          $SRCFILE ="${home}${prefix}/${fragment}";
441
          open(SRCFILE) or die("Could not open src file.  $SRCFILE ");
442
          foreach $line ()
443
             {
444
             chomp($line);
445
             print DEST_FILE  "${line}\n";
446 135 jt_eaton
             }
447
          }
448
       }
449 134 jt_eaton
 
450
   print DEST_FILE  "\n\n\n  endmodule\n\n";
451
   }
452
 
453
1
454
 

powered by: WebSVN 2.1.0

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