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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_verilog] - Blame information for rev 127

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

Line No. Rev Author Line
1 119 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
#/*                                                                    */
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
# 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
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
60
 
61
 
62
############################################################################
63
### Process the options
64
############################################################################
65
Getopt::Long::config("require_order", "prefix=-");
66
GetOptions("h","help",
67
           "view=s" => \$view,
68
           "prefix=s" => \$prefix,
69
           "vendor=s" => \$vendor,
70
           "project=s" => \$project,
71
           "version=s" => \$version,
72
           "component=s" => \$component,
73
           "dest_dir=s" => \$dest_dir,
74
           "destination=s" => \$destination,
75
           "configuration=s" => \$configuration,
76 126 jt_eaton
           "fragment","no_port","local_parameters","tb","debug","verbose"
77 119 jt_eaton
) || die "(use '$program_name -h' for help)";
78
 
79
 
80
##############################################################################
81
## Help option
82
##############################################################################
83
if ( $opt_h  or $opt_help  )
84
  { print "\n gen_verilog -view {sim/syn}  -prefix /work -vendor vendor_name -project project_name  -component component_name  -version version_name -fragment -no_port -local_parameters -destination destination -configuration configuration -dest_dir  ../verilog";
85
    print "\n";
86
    exit 1;
87
  }
88
 
89 126 jt_eaton
#print "\n WARNING  GEN_verilog  $view  $prefix $vendor $project $component $version $configuration      $dest_dir  $destination   \n";
90 119 jt_eaton
 
91 122 jt_eaton
my $main_module_name = yp::lib::get_module_name($vendor,$project,$component,$version) ;
92 119 jt_eaton
 
93 125 jt_eaton
 
94
 
95
 
96 119 jt_eaton
#############################################################################
97
##
98
##
99
#############################################################################
100
 
101
 
102
$home = cwd();
103
my $variant;
104
 if($version)       {$variant   = "${component}_${version}";}
105
 else               {$variant   = "${component}";}
106
 
107
 
108 120 jt_eaton
 
109
 
110 127 jt_eaton
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$project,$component);
111 125 jt_eaton
my $comp_xml_sep    = yp::lib::find_ipxact_component_path("spirit:component",$vendor,$project,$component,$version);
112 121 jt_eaton
 
113 125 jt_eaton
 
114
 
115
 
116
my $parser = XML::LibXML->new();
117
 
118
 
119
my $path  = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}";
120
mkdir $path,0755             unless( -e $path );
121
 
122
my $path  = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${view}";
123
mkdir $path,0755             unless( -e $path );
124
 
125
my   @filelist_hier     =       ();
126
my   @instantiations    =       ();
127
my   @parameters        =       ();
128
my   %parameter_values  =       ();
129
 
130 126 jt_eaton
 
131
 
132
 
133 125 jt_eaton
my $sogen_file               = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));
134
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
135 127 jt_eaton
my $sim_library_path              = $sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
136 125 jt_eaton
 
137
 
138
 
139
 
140
 
141
 
142
 
143 127 jt_eaton
#if( ($prefix eq "/work")  && ($sim_library_path)         ){$opt_tb = 1;}
144 125 jt_eaton
 
145
 
146 121 jt_eaton
if($opt_tb )
147
{
148
   print "Creating testbench for   $vendor $project $component  $version \n";
149
 
150
 
151 127 jt_eaton
   my $path  ="${home}/projects/${vendor}/${project}${sim_library_path}";
152 121 jt_eaton
   mkdir $path,0755             unless( -e $path );
153
 
154 127 jt_eaton
   my $path  ="${home}/projects/${vendor}/${project}${sim_library_path}/testbenches";
155 121 jt_eaton
   mkdir $path,0755             unless( -e $path );
156
 
157 127 jt_eaton
      $path  ="${home}/projects/${vendor}/${project}${sim_library_path}/testbenches/xml";
158 124 jt_eaton
   mkdir $path,0755             unless( -e $path );
159 121 jt_eaton
 
160 124 jt_eaton
 
161
   $outfile ="${home}/projects/${vendor}/${project}/ip/${component}/sim/testbenches/xml/${variant}_dut.params.xml";
162 121 jt_eaton
   open TB_COMP_FILE,">$outfile" or die "unable to open $outfile";
163
 
164 124 jt_eaton
   $outfile ="${home}/projects/${vendor}/${project}/ip/${component}/sim/testbenches/xml/${variant}_dutg.design.xml";
165 121 jt_eaton
   open TB_DESIGN_FILE,">$outfile" or die "unable to open $outfile";
166
 
167 122 jt_eaton
 
168 121 jt_eaton
   print TB_COMP_FILE  "\n";
169 122 jt_eaton
   print TB_COMP_FILE  "                                                 \n";
176 121 jt_eaton
   print TB_COMP_FILE  "
177
   print TB_COMP_FILE  "xmlns:spirit=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\"\n";
178 125 jt_eaton
   print TB_COMP_FILE  "xmlns:socgen=\"http://opencores.org\"\n";
179 121 jt_eaton
   print TB_COMP_FILE  "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
180
   print TB_COMP_FILE  "xsi:schemaLocation=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\n";
181
   print TB_COMP_FILE  "http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009/index.xsd\">\n";
182
   print TB_COMP_FILE  "${vendor}\n";
183
   print TB_COMP_FILE  "${project}\n";
184
   print TB_COMP_FILE  "${component}\n";
185
   print TB_COMP_FILE  "${version}_dut.params\n";
186
 
187
 
188
   print TB_DESIGN_FILE  "\n";
189 122 jt_eaton
   print TB_DESIGN_FILE  "                                                 \n";
196 121 jt_eaton
   print TB_DESIGN_FILE  "
197
   print TB_DESIGN_FILE  "xmlns:spirit=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\"\n";
198 125 jt_eaton
   print TB_DESIGN_FILE  "xmlns:socgen=\"http://opencores.org\"\n";
199 121 jt_eaton
   print TB_DESIGN_FILE  "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
200
   print TB_DESIGN_FILE  "xsi:schemaLocation=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\n";
201
   print TB_DESIGN_FILE  "http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009/index.xsd\">\n";
202
   print TB_DESIGN_FILE  "${vendor}\n";
203
   print TB_DESIGN_FILE  "${project}\n";
204
   print TB_DESIGN_FILE  "${component}\n";
205
   print TB_DESIGN_FILE  "${version}_dutg.design\n";
206
 
207
}
208
 
209
 
210
     #/**********************************************************************/
211
     #/*                                                                    */
212 124 jt_eaton
     #/* if configuration set then read parameters from socgen:componentConfiguration file      */
213 121 jt_eaton
     #/*                                                                    */
214
     #/**********************************************************************/
215
 
216
    if($configuration)
217
      {
218
      # print "XXX Reading configuration   $configuration \n";
219 124 jt_eaton
      unless ($sogen_file)      { print "No socgen ip file \n";};
220 121 jt_eaton
 
221 124 jt_eaton
      foreach my $socgen_cfg ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:configurations/socgen:configuration/socgen:parameters/socgen:parameter/socgen:name"))
222 121 jt_eaton
                {
223
                my($param_name)         = $socgen_cfg->findnodes('./text()')->to_literal ;
224
                my($param_value)        = $socgen_cfg->findnodes('../socgen:value/text()')->to_literal ;
225
                my($config_name)        = $socgen_cfg->findnodes('../../../socgen:name/text()')->to_literal ;
226
                if($config_name eq $configuration  )
227
                  {
228
                  unless(defined $parameter_values{$param_name}) {push ( @parameters,  "$param_name");};
229
                  $parameter_values{$param_name} = ${param_value};
230
                  }
231
                }
232
 
233
      }
234
 
235
 
236
 
237
 
238 119 jt_eaton
#/**********************************************************************/
239
#/*                                                                    */
240
#/* Every hier cell is constructed from the ipxact file with seperate  */
241
#/* version  for each view                                             */
242
#/*                                                                    */
243
#/* Start by opening the output file                                   */
244
#/* get fileset name                                                   */
245
#/* check that requested view exists                                   */
246
#/*                                                                    */
247
#/**********************************************************************/
248
 
249 120 jt_eaton
foreach my $comp_view ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:name[text() = '$view']"             ))
250 119 jt_eaton
   {
251 120 jt_eaton
   my($view_fileset_name)  = $comp_view->findnodes('../spirit:fileSetRef/spirit:localName/text()')->to_literal ;
252
   $outfile ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${view}/${destination}";
253
   open DEST_FILE,">$outfile" or die "unable to open $outfile";
254 122 jt_eaton
   unless ($opt_fragment){     print DEST_FILE  "\n module \n\n  $main_module_name \n ";}
255 119 jt_eaton
 
256 120 jt_eaton
   #/*****************************************************************************/
257
   #/*  wire_decs array holds all port and signal declarations                   */
258
   #/*  :::name:::node_input_output:::wire_reg:::scaler_vector:::left:::right::: */
259
   #/*****************************************************************************/
260 119 jt_eaton
 
261 120 jt_eaton
   @wire_decs = (  );
262 119 jt_eaton
 
263
 
264 120 jt_eaton
   #/**********************************************************************/
265
   #/*  inst_conns holds all instance connections                         */
266
   #/**********************************************************************/
267 119 jt_eaton
 
268 120 jt_eaton
   @inst_conns = (  );
269 119 jt_eaton
 
270 120 jt_eaton
   my @decl_names  = ();
271
   my %decl_dirs  = ();
272
   my %decl_types  = ();
273
   my %decl_vector = ();
274
   my %decl_lefts  = ();
275
   my %decl_rights = ();
276 119 jt_eaton
 
277 120 jt_eaton
   #  component file
278 126 jt_eaton
 
279 120 jt_eaton
   parse_component_file($spirit_component_file);
280 126 jt_eaton
  if($opt_verbose){print "parse design files \n"; }
281 120 jt_eaton
   parse_design_files($spirit_component_file);
282 126 jt_eaton
  if($opt_verbose){print "process design files \n"; }
283 120 jt_eaton
   process_design_files($spirit_component_file);
284 126 jt_eaton
  if($opt_verbose){print "process wire_decs \n"; }
285 119 jt_eaton
 
286 120 jt_eaton
   #/**********************************************************************/
287
   #/*                                                                    */
288
   #/* pack ports and nodes into hashes                                   */
289
   #/*                                                                    */
290
   #/**********************************************************************/
291 119 jt_eaton
 
292
 
293 120 jt_eaton
   @wire_decs      = sys::lib::trim_sort(@wire_decs);
294
   foreach $line (@wire_decs)
295
     {
296
     $_ = $line;
297 119 jt_eaton
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
298
          {
299
          $q_index               = $1;
300
          $q_node_name           = $2;
301
          $q_direction           = $3;
302
          $q_type                = $4;
303
          $q_vector              = $5;
304
          $q_left                = $6;
305
          $q_right               = $7;
306
          $q_instance            = $8;
307
          $q_depth               = $9;
308
          $q_phy_name            = $10;
309
          $q_busref_name         = $11;
310
          $q_abslog_name         = $12;
311
 
312 126 jt_eaton
 
313
  if($opt_debug ){print  "XXXXX--    $line \n  ";}
314
 
315 119 jt_eaton
         push ( @decl_names,$q_index);
316
 
317
 
318
          if(  $decl_pnames{$q_index})
319
            {
320
            if(  $decl_pnames{$q_index} eq ${q_index})
321
              {
322
              $decl_pnames{$q_index}  = "${q_node_name}";
323
              }
324
            }
325
          else
326
            {
327
            $decl_pnames{$q_index}  = "${q_node_name}";
328
            }
329
 
330
 
331
          if(  $decl_dirs{$q_index})
332
            {
333
            if(  $decl_dirs{$q_index} eq "node")
334
              {
335
              $decl_dirs{$q_index}  = "${q_direction}";
336
              }
337
            }
338
          else
339
            {
340
            $decl_dirs{$q_index}  = "${q_direction}";
341
            }
342
 
343 126 jt_eaton
 
344
 
345
            if(  $decl_types{$q_index})
346
              {
347
              if(  $decl_types{$q_index} eq "wire")
348
                {
349
                $decl_types{$q_index}  = "${q_type}";
350
                }
351
              }
352
            else
353
              {
354
              $decl_types{$q_index}  = "${q_type}";
355
              }
356
 
357
 
358
 
359
 
360
 
361 119 jt_eaton
          if(  $decl_vector{$q_index})
362
            {  unless(  $decl_vector{$q_index} eq "vector"){ $decl_vector{$q_index}  = "${q_vector}";  }}
363
          else  { $decl_vector{$q_index}  = "${q_vector}"; }
364
 
365
          if( $q_vector eq "vector" )
366
            {
367
            if ( defined $decl_lefts{$q_index})
368
               {
369 126 jt_eaton
 
370
 
371
                $_ = $q_left;
372
                if(/(\D+)/)
373
                {
374
                $_ = $decl_lefts{$q_index};
375
                   if(/(\D+)/)
376
                   {
377
                   print "WARNING  $variant :: $q_node_name :    $q_left   is NOT  a number            $decl_lefts{$q_index}    is NOT  a number \n";
378
                   #if($decl_lefts{$q_index}   <= $q_left  ) {$decl_lefts{$q_index}   = $q_left;}
379
                   }
380
                   else
381
                   {
382
                   #print "WARNING  $variant :: $q_node_name :    $q_left   is NOT  a number            $decl_lefts{$q_index}    is a number \n";
383
                   #if($decl_lefts{$q_index}   <= $q_left  ) {$decl_lefts{$q_index}   = $q_left;}
384
                   $decl_lefts{$q_index}   = $q_left;
385
                   }
386
                }
387
                else
388
 
389
                {
390
 
391
                $_ = $decl_lefts{$q_index};
392
                   if(/(\D+)/)
393
                   {
394
                   #print "WARNING  $variant :: $q_node_name :    $q_left   is   a number            $decl_lefts{$q_index}    is NOT  a number \n";
395
                   #if($decl_lefts{$q_index}   <= $q_left  ) {$decl_lefts{$q_index}   = $q_left;}
396
                   }
397
                   else
398
                   {
399
                   #print "WARNING  $variant :: $q_node_name :    $q_left   is   a number            $decl_lefts{$q_index}    is   a number \n";
400
                   if($decl_lefts{$q_index}   <= $q_left  ) {$decl_lefts{$q_index}   = $q_left;}
401
                   }
402
                }
403
 
404
 
405 119 jt_eaton
               if($decl_rights{$q_index}  >= $q_right ) {$decl_rights{$q_index}  = $q_right;}
406
               }
407
            else
408
               {
409
               $decl_lefts{$q_index}   = $q_left;
410
               $decl_rights{$q_index}  = $q_right;
411
               }
412
            }
413
          }
414
        }
415
     @decl_names      = sys::lib::trim_sort(@decl_names);
416
 
417
 
418
 
419
 
420
 
421
     #/**********************************************************************/
422
     #/*                                                                    */
423 126 jt_eaton
     #/* All port and signal info is now loaded in hashes                   */
424
     #/* Resort on physical name                                            */
425 119 jt_eaton
     #/* Print out module header , parameters and ports                     */
426
     #/*                                                                    */
427
     #/**********************************************************************/
428
 
429
 
430
 
431
 
432 126 jt_eaton
   foreach my $decl_name (@decl_names)
433 120 jt_eaton
 
434 126 jt_eaton
     {
435 119 jt_eaton
 
436 126 jt_eaton
     my $phy_name = $decl_pnames{$decl_name};
437
 
438
     unless ($phy_name) {$phy_name =$decl_name }
439
 
440
     push ( @phy_names,$phy_name);
441
 
442
     if(  $phy_dirs{$phy_name})
443
            {
444
            if(  $phy_dirs{$phy_name} eq "node")
445
              {
446
              $phy_dirs{$phy_name}   = "$decl_dirs{$decl_name}";
447
              }
448
            }
449
          else
450
            {
451
            $phy_dirs{$phy_name}  = "$decl_dirs{$decl_name}";
452
            }
453
 
454
            if(  $phy_types{$phy_name})
455
              {
456
              if(  $phy_types{$phy_name} eq "wire")
457
                {
458
                $phy_types{$phy_name}  = "$decl_types{$decl_name}";
459
                }
460
              }
461
            else
462
              {
463
              $phy_types{$phy_name}  = "$decl_types{$decl_name}";
464
              }
465
 
466
          if(  $phy_vector{$phy_name})
467
            {  unless(  $phy_vector{$phy_name} eq "vector"){ $phy_vector{$phy_name}  = "$decl_vector{$decl_name}";  }}
468
          else  { $phy_vector{$phy_name}  = "$decl_vector{$decl_name}"; }
469
 
470
          if( $phy_vector{$phy_name} eq "vector" )
471
            {
472
            if ( defined $phy_lefts{$phy_name})
473
               {
474
                $_ = $phy_lefts{$phy_name};
475
                if(/(\D+)/)
476
                {
477
                $_ = $phy_lefts{$phy_name};
478
                   if(/(\D+)/)
479
                   {
480
                   }
481
                   else
482
                   {
483
                   $phy_lefts{$phy_name}   = $decl_lefts{$decl_name};
484
                   }
485
                }
486
                else
487
                {
488
                $_ = $phy_lefts{$phy_name};
489
                   if(/(\D+)/)
490
                   {
491
                   }
492
                   else
493
                   {
494
                   if($phy_lefts{$phy_name}   <= $decl_lefts{$decl_name}  ) {$phy_lefts{$phy_name}   = $decl_lefts{$decl_name};}
495
                   }
496
                }
497
 
498
               if($phy_rights{$phy_name}  >= $decl_rights{$decl_name} ) {$phy_rights{$phy_name}  = $decl_rights{$decl_name};}
499
               }
500
            else
501
               {
502
               $phy_lefts{$phy_name}   = $decl_lefts{$decl_name};
503
               $phy_rights{$phy_name}  = $decl_rights{$decl_name};
504
               }
505
            }
506
 
507
   }
508
 
509
 
510
 
511
 
512
     @phy_names      = sys::lib::trim_sort(@phy_names);
513
 
514
 
515
 
516
 
517
 
518
 
519
 
520 119 jt_eaton
     #/**********************************************************************/
521
     #/*                                                                    */
522
     #/* Add any and all global parameters with their default values        */
523
     #/*                                                                    */
524
     #/**********************************************************************/
525
 
526
     unless ($opt_local_parameters)
527
     {
528
     my $first = 1;
529
     foreach my $parameter_name (@parameters)
530
        {
531
        my $parameter_value = $parameter_values{$parameter_name};
532
        if($first)
533
          {
534
          print DEST_FILE  "   #( parameter \n      ${parameter_name}=${parameter_value}";
535
          $first=0;
536
          }
537
        else  { print DEST_FILE  ",\n      ${parameter_name}=${parameter_value}";}
538
        }
539
 
540
     if    ($first == 0)   { print DEST_FILE  ")\n"; }
541
       }
542
 
543
 
544
     #/**********************************************************************/
545
     #/*                                                                    */
546
     #/* sort all  ports  with their type, size and direction               */
547
     #/*                                                                    */
548
     #/**********************************************************************/
549
 
550
 
551
     my @port_list  = ();
552
 
553
 
554 126 jt_eaton
     foreach $x_name (@phy_names)
555 119 jt_eaton
        {
556
        my $q_width  = "     ";
557 126 jt_eaton
        if( $phy_vector{$x_name} eq "vector" )  { $q_width = "[ $phy_lefts{$x_name} :  $phy_rights{$x_name}]"}
558 119 jt_eaton
 
559 126 jt_eaton
        if( $phy_dirs{$x_name} ne "node" )
560 119 jt_eaton
          {
561 126 jt_eaton
          push (@port_list,  "$phy_dirs{$x_name}   $phy_types{$x_name}    $q_width        ${x_name}");
562 119 jt_eaton
          }
563
        }
564
 
565
     @port_list      = sys::lib::trim_sort(@port_list);
566
 
567
 
568
     #/**********************************************************************/
569
     #/*                                                                    */
570
     #/* Now add all ports  with their type, size and direction             */
571
     #/*                                                                    */
572
     #/**********************************************************************/
573
 
574
 
575
     print DEST_FILE  "\n    ";
576
     $first = 1;
577
 
578
     foreach $port_line (@port_list)
579
        {
580
          if($first)
581
            {
582
            print DEST_FILE  " (\n ${port_line}";
583
            $first=0;
584
            }
585
          else
586
            {
587
            print DEST_FILE  ",\n ${port_line}";
588
            }
589
 
590
        }
591
 
592
     if    ($first == 0)   { print DEST_FILE  ");\n\n\n\n"; }
593
     elsif ($opt_no_port)  { print DEST_FILE  "\n\n\n\n";  }
594
     else                  { print DEST_FILE  "();\n\n\n\n";}
595
 
596 121 jt_eaton
 
597
 
598
 
599
 
600 119 jt_eaton
     #/**********************************************************************/
601
     #/*                                                                    */
602 121 jt_eaton
     #/* print wire decs for testbench                                      */
603
     #/*                                                                    */
604
     #/**********************************************************************/
605
 
606
 
607 126 jt_eaton
     foreach $x_name (@phy_names)
608 121 jt_eaton
        {
609
 
610 126 jt_eaton
        if( $phy_dirs{$x_name} ne "node" )
611 121 jt_eaton
          {
612 126 jt_eaton
    if ( $phy_vector{$x_name} eq "vector" )
613 121 jt_eaton
             {
614 126 jt_eaton
             push (@tb_adhoc_list,  "\n${x_name}<\/spirit:name>\n\n\n<\/spirit:adHocConnection>\n"     );
615 121 jt_eaton
             }
616
             else
617
            {
618 126 jt_eaton
            push (@tb_adhoc_list,  "\n${x_name}<\/spirit:name>\n\n\n<\/spirit:adHocConnection>\n"     );
619 121 jt_eaton
             }
620
 
621 126 jt_eaton
         }
622 121 jt_eaton
 
623
        }
624
 
625
     @tb_adhoc_list      = sys::lib::trim_sort(@tb_adhoc_list);
626
     print TB_DESIGN_FILE  "\n\n";
627
 
628
     foreach $adhoc_line (@tb_adhoc_list)
629
        {
630
 
631
            print TB_DESIGN_FILE  "${adhoc_line}\n";
632
 
633
 
634
        }
635
 
636
     print TB_DESIGN_FILE  "\n\n";
637
 
638
 
639
 
640
 
641
 
642
 
643
     #/**********************************************************************/
644
     #/*                                                                    */
645
     #/* Add parameters  to dut      */
646
     #/*                                                                    */
647
     #/**********************************************************************/
648
print TB_DESIGN_FILE    "\n\n";
649
 
650
 
651
 
652
 
653
print TB_DESIGN_FILE    "\n";
654
print TB_DESIGN_FILE    "dut\n";
655
print TB_DESIGN_FILE    "\n";
656
print TB_DESIGN_FILE    "\n";
657
 
658
 
659
     foreach my $parameter_name (@parameters)
660
        {
661
        print TB_DESIGN_FILE  " ${parameter_name}<\/spirit:configurableElementValue>\n";
662
        }
663
 
664
print TB_DESIGN_FILE    "\n";
665
print TB_DESIGN_FILE    "\n";
666
print TB_DESIGN_FILE    "\n";
667
print TB_DESIGN_FILE    "\n";
668
 
669
 
670
 
671
 
672
     #/**********************************************************************/
673
     #/*                                                                    */
674
     #/* Add parameters  to comp      */
675
     #/*                                                                    */
676
     #/**********************************************************************/
677
print TB_COMP_FILE    "\n\n";
678 125 jt_eaton
print TB_COMP_FILE    "                                                  \n";
679
print TB_COMP_FILE    "                                   \n";
680
print TB_COMP_FILE    "                                                 \n";
681
print TB_COMP_FILE    "              Dut                                   \n";
682
print TB_COMP_FILE    "                                                 \n";
683
print TB_COMP_FILE    "              
684
print TB_COMP_FILE    "                                   spirit:library=\"${project}\"                                    \n";
685
print TB_COMP_FILE    "                                   spirit:name=\"${component}\"                                    \n";
686
print TB_COMP_FILE    "                                   spirit:version=\"${version}_dutg.design\"/>                                   \n";
687
print TB_COMP_FILE    "                                                 \n";
688
print TB_COMP_FILE    "                                         \n";
689 121 jt_eaton
print TB_COMP_FILE    "\n";
690
 
691
 
692
 
693
 
694
 
695
     foreach my $parameter_name (@parameters)
696
        {
697
        my $parameter_value = $parameter_values{$parameter_name};
698
        print TB_COMP_FILE  "    ${parameter_name}${parameter_value}\n";
699
        }
700
 
701
print TB_COMP_FILE    "\n";
702
print TB_COMP_FILE    "\n";
703
 
704
 
705
 
706
 
707
   print TB_COMP_FILE  "\n";
708
 
709
 
710
 
711
 
712
 
713
 
714
 
715
 
716
 
717
     #/**********************************************************************/
718
     #/*                                                                    */
719 119 jt_eaton
     #/* Add any and all local parameters with their default values         */
720
     #/*                                                                    */
721
     #/**********************************************************************/
722
 
723
     if ($opt_local_parameters)
724
     {
725
     foreach my $parameter_name (@parameters)
726
        {
727
        my $parameter_value = $parameter_values{${parameter_name}};
728
        print DEST_FILE  "parameter ${parameter_name} = ${parameter_value};\n";
729
        }
730
     }
731
 
732
     #/**********************************************************************/
733
     #/*                                                                    */
734
     #/* Add all internal wires and regs with their sizes                   */
735
     #/*                                                                    */
736
     #/**********************************************************************/
737 121 jt_eaton
 
738
     my @wire_nodes = ();
739 119 jt_eaton
 
740 121 jt_eaton
 
741 126 jt_eaton
     foreach $x_name (@phy_names)
742 119 jt_eaton
        {
743
        my $q_width  = "     ";
744 126 jt_eaton
        if( $phy_vector{$x_name} eq "vector" ){ $q_width = "[ $phy_lefts{$x_name} :  $phy_rights{$x_name}]"}
745
        if( $phy_dirs{$x_name} eq "node" )    { push @wire_nodes,     "$phy_types{$x_name}     $q_width              ${x_name};";}
746 119 jt_eaton
        }
747
 
748 121 jt_eaton
     @wire_nodes      = sys::lib::trim_sort(@wire_nodes);
749
 
750
     foreach my $wire_node (@wire_nodes)
751
     {
752
     print DEST_FILE  "${wire_node}\n";
753
     }
754
 
755 119 jt_eaton
     print DEST_FILE  "\n\n\n";
756 120 jt_eaton
 
757 119 jt_eaton
 
758 120 jt_eaton
     while(   my $line_out      = shift(@instantiations))             {  print DEST_FILE  "$line_out";}
759 119 jt_eaton
 
760
     #/**********************************************************************/
761
     #/*                                                                    */
762
     #/* After all the data from the ip-xact file has been entered we now   */
763
     #/* insert any and all verilog fragments at the end before closing     */
764
     #/* the module                                                         */
765
     #/*                                                                    */
766
     #/**********************************************************************/
767
 
768
 
769
     foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
770
        {
771
        my($rtl_file)       = $i_name ->findnodes('./text()')->to_literal;
772 120 jt_eaton
        my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal;
773 119 jt_eaton
        my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
774
 
775 120 jt_eaton
        if(($file_type eq "fragment")&& (($view_file eq $view_fileset_name)))
776 119 jt_eaton
          {
777
          $SRCFILE ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${rtl_file}";
778
          open(SRCFILE) or die("Could not open src file.  $SRCFILE ");
779
          foreach $line ()
780
             {
781
             chomp($line);
782
             print DEST_FILE  "${line}\n";
783
             }
784
          }
785
        }
786
     unless ($opt_fragment ) {print DEST_FILE  "\n\n\n  endmodule\n\n";}
787 120 jt_eaton
 
788 119 jt_eaton
   }
789
 
790
 
791
 
792
 
793
 
794
 
795
 
796
 
797
 
798
 
799 120 jt_eaton
 
800 119 jt_eaton
#/*********************************************************************************************/
801
#/                                                                                            */
802 125 jt_eaton
#/ this routine does not follow busses down into componentRef                                 */
803 119 jt_eaton
#/                                                                                            */
804
#/                                                                                            */
805
#/                                                                                            */
806
#/                                                                                            */
807
#/*********************************************************************************************/
808
 
809
 
810
 
811
 
812
sub parse_busInterface
813
   {
814
   my @params     = @_;
815
   my $depth      = pop(@params);
816
   my $busref     = pop(@params);
817
   my $version    = pop(@params);
818
   my $component  = pop(@params);
819
   my $project    = pop(@params);
820
   my $vendor     = pop(@params);
821
 
822
   my $home = cwd();
823
 
824
   my @out_stack  = ();
825
 
826 126 jt_eaton
  if($opt_verbose){print "parse_busInterface $vendor $project $component $version \n"; }
827 119 jt_eaton
 
828
   my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
829
 
830 120 jt_eaton
 
831 125 jt_eaton
 
832 119 jt_eaton
   my $busInterfaceTest = 0;
833
 
834
   my @mas_slave;
835
     push @mas_slave  , "master";
836
     push @mas_slave  , "slave";
837
 
838
     foreach my $seek_type (@mas_slave)
839
        {
840
 
841
 
842
     foreach my $bus_iface ($spirit_component_file->findnodes("//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:${seek_type}"))
843
        {
844
        my($fff_cname)         = $bus_iface->findnodes('../spirit:name/text()')->to_literal ;
845
        my($fff_vendor)        = $bus_iface->findnodes('../spirit:abstractionType/@spirit:vendor')->to_literal ;
846
        my($fff_library)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:library')->to_literal ;
847
        my($fff_name)          = $bus_iface->findnodes('../spirit:abstractionType/@spirit:name')->to_literal ;
848
        my($fff_version)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:version')->to_literal ;
849
 
850
 
851
        foreach my $port_face ($spirit_component_file->findnodes('//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:portMaps/spirit:portMap/spirit:logicalPort'))
852
           {
853
 
854
           my($fff_xxx_name)      = $port_face->findnodes('../../../spirit:name/text()')->to_literal ;
855
 
856
           my($fff_log_name)      = $port_face->findnodes('./spirit:name/text()')->to_literal ;
857
           my($fff_phy_name)      = $port_face->findnodes('../spirit:physicalPort/spirit:name/text()')->to_literal ;
858
           my($fff_type_name)     = $port_face->findnodes('../spirit:physicalPort/spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
859
           my($fff_int_name)      = $port_face->findnodes('../../../spirit:name/text()')->to_literal ;
860
 
861
           my($fff_left_value)    = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
862
           my($fff_right_value)   = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
863
 
864
           unless ($fff_type_name)  {$fff_type_name = "wire";};
865
 
866
           if(  ( $fff_xxx_name  eq  $busref) && (  $busref eq   $fff_cname  )       )
867
             {
868
             $busInterfaceTest = 1;
869
             my $busdef_parser = XML::LibXML->new();
870 125 jt_eaton
 
871
 
872
             my $spirit_abstractor_filename     = yp::lib::find_ipxact("spirit:abstractionDefinition",$fff_vendor,$fff_library,$fff_name,$fff_version);
873
 
874
             unless($spirit_abstractor_filename){
875 126 jt_eaton
              #print "  $fff_vendor $fff_library $fff_name $fff_version  \n";
876 125 jt_eaton
 
877
            }
878
 
879
 
880 122 jt_eaton
             my $spirit_abstractor_file     = ($parser->parse_file(yp::lib::find_ipxact("spirit:abstractionDefinition",$fff_vendor,$fff_library,$fff_name,$fff_version))
881 119 jt_eaton
 
882
 
883 122 jt_eaton
                ) || die "(OOPs $fff_vendor $fff_library $fff_name $fff_version )";
884 119 jt_eaton
 
885
 
886
 
887
             foreach my $abstr_view ($spirit_abstractor_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$fff_log_name']"))
888
                {
889
                my($sss_m_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onMaster/spirit:direction/text()')->to_literal ;
890
                my($sss_s_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onSlave/spirit:direction/text()')->to_literal ;
891
 
892
                    if    ($sss_m_dir eq "in")  { $sss_m_dir = "input";}
893
                    elsif ($sss_m_dir eq "out") { $sss_m_dir = "output";}
894
 
895
                    if    ($sss_s_dir eq "in")  { $sss_s_dir = "input";}
896
                    elsif ($sss_s_dir eq "out") { $sss_s_dir = "output";}
897
 
898
 
899
                my $fff_direction = "";
900
 
901
 
902
                  if    ( $seek_type eq "master")  { $fff_direction = $sss_m_dir;     }
903
                  elsif ( $seek_type eq "slave" )  { $fff_direction = $sss_s_dir;     }
904
 
905
                  my $fff_dir = "";
906
                  if   ($fff_direction  eq "in" )  {$fff_dir = "input" ;}
907
                  elsif($fff_direction  eq "out" ) {$fff_dir = "output" ;}
908
                  else                             {$fff_dir = $fff_direction;     }
909
 
910 122 jt_eaton
                  if($fff_left_value ne "") { push @out_stack, ":::${depth}:::${fff_log_name}:::${fff_phy_name}:::${fff_dir}:::${fff_type_name}:::vector:::${fff_left_value}:::${$fff_right_value}:::"; }
911 119 jt_eaton
                  else                { push @out_stack, ":::${depth}:::${fff_log_name}:::${fff_phy_name}:::${fff_dir}:::${fff_type_name}:::scaler:::none:::none:::";    }
912
 
913
 
914
                }
915
             }
916
 
917
           }
918
       }
919
 
920
}
921
 
922
 
923
 
924
 
925
 
926
       if ( $busInterfaceTest){
927
                              @out_stack      = sys::lib::trim_sort(@out_stack);
928
                              return(@out_stack);
929
                              }
930
 
931
 
932 125 jt_eaton
     my @spirit_design_files       = yp::lib::find_ipxact_design_files($vendor,$project,$component,$version);
933 120 jt_eaton
 
934
     foreach  my   $sd_file (@spirit_design_files)
935 119 jt_eaton
     {
936
 
937 125 jt_eaton
     $_ = $sd_file;
938
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::/)
939
          {
940
          $q_vendor            = $1;
941
          $q_library           = $2;
942
          $q_design            = $3;
943
          $q_version           = $4;
944
          $sd_file             = $parser->parse_file(yp::lib::find_ipxact("spirit:design",$q_vendor,$q_library,$q_design,$q_version));
945
          }
946 120 jt_eaton
 
947
     foreach  my   $x_name ($sd_file->findnodes('//spirit:hierConnections/spirit:hierConnection/@spirit:interfaceRef'))
948 119 jt_eaton
        {
949
        my($hierConn_name)                   = $x_name ->to_literal ;
950
        my($hierConn_comref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:componentRef')->to_literal ;
951
        my($hierConn_busref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:busRef')->to_literal ;
952
        if($busref eq  $hierConn_name)
953
          {
954 120 jt_eaton
          foreach  my   $x_name ($sd_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName[text() = '$hierConn_comref_name']"))
955 119 jt_eaton
            {
956
            #/**********************************************************************/
957
            #/*                                                                    */
958
            #/* Lookup VLNV for each instantiated component                        */
959
            #/*                                                                    */
960
            #/**********************************************************************/
961
 
962
            my($vendor_name)         = $x_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
963
            my($library_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
964
            my($component_name)      = $x_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
965
            my($version_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
966
            $depth = $depth +1;
967
            @out_stack = parse_busInterface ($vendor_name, $library_name,$component_name,$version_name,$hierConn_busref_name,$depth );
968
            }
969
          }
970
        }
971 120 jt_eaton
 
972
     }
973
 
974 119 jt_eaton
        @out_stack      = sys::lib::trim_sort(@out_stack);
975
        return(@out_stack);
976 120 jt_eaton
 
977 119 jt_eaton
 
978
   }
979
 
980
 
981
 
982
 
983 120 jt_eaton
 
984
 
985
 
986
 
987
 
988
 
989
 
990
 
991
 
992
 
993 119 jt_eaton
#/*********************************************************************************************/
994
#/                                                                                            */
995
#/                                                                                            */
996
#/                                                                                            */
997
#/                                                                                            */
998
#/                                                                                            */
999
#/                                                                                            */
1000
#/*********************************************************************************************/
1001
 
1002
 
1003
 
1004
 
1005 120 jt_eaton
sub parse_design_files
1006
   {
1007
   my @params     = @_;
1008
   my $spirit_component_file      = pop(@params);
1009
 
1010 126 jt_eaton
   #print "\n";
1011 125 jt_eaton
 
1012
 
1013
 
1014
 
1015
 
1016
 
1017
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef"))
1018 120 jt_eaton
    {
1019 125 jt_eaton
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
1020
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
1021
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
1022
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
1023
            parse_design_files($parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_library,$new_name,$new_version )) );
1024
   }
1025 120 jt_eaton
 
1026
 
1027 125 jt_eaton
 
1028
 
1029 120 jt_eaton
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef"))
1030
    {
1031
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
1032
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
1033
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
1034
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
1035 125 jt_eaton
            my $hier_ref_type = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
1036 120 jt_eaton
 
1037
 
1038
 
1039 125 jt_eaton
     if($hier_ref_type eq "spirit:component")
1040
     {
1041 120 jt_eaton
 
1042
     }
1043
 
1044
 
1045 125 jt_eaton
     elsif($hier_ref_type eq "spirit:designConfiguration")
1046 120 jt_eaton
     {
1047
 
1048
        my $spirit_designCfg_file
1049
         = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version ));
1050
 
1051
        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration'))
1052
           {
1053 125 jt_eaton
            $new_vendor          = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
1054
            $new_library         = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
1055
            $new_name            = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
1056
            $new_version         = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
1057
            $hier_ref_type       = "spirit:design" ;
1058 120 jt_eaton
           }
1059
     }
1060
 
1061 125 jt_eaton
 
1062
    if($hier_ref_type eq "spirit:design")
1063
     {
1064
        parse_design_file($parser->parse_file(yp::lib::find_ipxact("spirit:design",$new_vendor,$new_library,$new_name,$new_version )) );
1065
      }
1066
 
1067
 
1068
 
1069
 
1070
 
1071 120 jt_eaton
  }
1072
 
1073
}
1074
 
1075
 
1076
 
1077
 
1078
 
1079
 
1080
 
1081
#/*********************************************************************************************/
1082
#/                                                                                            */
1083
#/                                                                                            */
1084
#/                                                                                            */
1085
#/                                                                                            */
1086
#/                                                                                            */
1087
#/                                                                                            */
1088
#/*********************************************************************************************/
1089
 
1090
 
1091
 
1092
 
1093
sub process_design_files
1094
   {
1095
   my @params     = @_;
1096
   my $spirit_component_file      = pop(@params);
1097
 
1098 126 jt_eaton
   #print "\n";
1099 125 jt_eaton
 
1100
 
1101
 
1102
 
1103
 
1104
 
1105
 
1106
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef"))
1107 120 jt_eaton
    {
1108 125 jt_eaton
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
1109
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
1110
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
1111
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
1112
            process_design_files($parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_library,$new_name,$new_version )) );
1113 120 jt_eaton
    }
1114
 
1115
 
1116 125 jt_eaton
 
1117
 
1118
 
1119
 
1120 120 jt_eaton
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef"))
1121
    {
1122
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
1123
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
1124
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
1125
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
1126 125 jt_eaton
            my $hier_ref_type = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
1127 120 jt_eaton
 
1128
 
1129 125 jt_eaton
     if($hier_ref_type eq "spirit:component")
1130 120 jt_eaton
     {
1131
     }
1132
 
1133
 
1134
 
1135 125 jt_eaton
     elsif($hier_ref_type eq "spirit:designConfiguration")
1136 120 jt_eaton
     {
1137
 
1138
        my $spirit_designCfg_file
1139
         = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version ));
1140
 
1141
        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration'))
1142
           {
1143 125 jt_eaton
           ($new_vendor)         = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
1144
           ($new_library)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
1145
           ($new_name)           = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
1146
           ($new_version)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
1147
           $hier_ref_type = "spirit:design";
1148
 
1149 120 jt_eaton
           }
1150
     }
1151
 
1152 125 jt_eaton
 
1153
     if($hier_ref_type eq "spirit:design")
1154
     {
1155 126 jt_eaton
     if($opt_verbose){print "process_design_file  $new_vendor $new_library $new_name $new_version  \n"; }
1156 125 jt_eaton
        process_design_file($parser->parse_file(yp::lib::find_ipxact("spirit:design",$new_vendor,$new_library,$new_name,$new_version )) );
1157 126 jt_eaton
     }
1158 120 jt_eaton
  }
1159
 
1160
}
1161
 
1162
 
1163
 
1164
 
1165
 
1166
 
1167
 
1168
 
1169
 
1170
 
1171
#/*********************************************************************************************/
1172
#/                                                                                            */
1173
#/                                                                                            */
1174
#/                                                                                            */
1175
#/                                                                                            */
1176
#/                                                                                            */
1177
#/                                                                                            */
1178
#/*********************************************************************************************/
1179
 
1180
 
1181
 
1182
 
1183 119 jt_eaton
sub parse_design_file
1184
   {
1185
   my @params     = @_;
1186
   my $spirit_design_file      = pop(@params);
1187
 
1188
 
1189
 
1190
 
1191 120 jt_eaton
 
1192 126 jt_eaton
#print "\n";
1193 120 jt_eaton
foreach my $new_comp ($spirit_design_file->findnodes("//spirit:design/spirit:vendor"))
1194
   {
1195
   my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
1196
   my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
1197
   my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
1198
   my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
1199 126 jt_eaton
   #print "WARNING  $new_vendor $new_library $new_name $new_version  DESIGN \n";
1200 120 jt_eaton
   }
1201
 
1202
 
1203
 
1204
 
1205 126 jt_eaton
     #/**********************************************************************/
1206
     #/*                                                                    */
1207
     #/* Add all internal wires and regs with their sizes                   */
1208
     #/*                                                                    */
1209
     #/**********************************************************************/
1210
 
1211
     foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:vendorExtensions/socgen:nodes/socgen:node/spirit:name"))
1212
        {
1213
        my($node_name)       = $i_name ->findnodes('./text()')->to_literal ;
1214
        my($node_busdef)     = $i_name ->findnodes('../socgen:busDef/text()')->to_literal ;
1215
        my($node_left)       = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
1216
        my($node_right)      = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
1217
        my($node_type)       = $i_name ->findnodes('../spirit:typeName/text()')->to_literal ;
1218
 
1219
        unless($node_busdef){   $node_busdef =    $node_name;     }
1220 120 jt_eaton
 
1221 126 jt_eaton
        if(  $node_left ne "" ) { push @wire_decs , ":::${node_busdef}:::${node_name}:::node:::${node_type}:::vector:::${node_left}:::${$node_right}:::none:::0:::${node_name}:::XXX:::${node_name}:::"; }
1222
        else                     { push @wire_decs , ":::${node_busdef}:::${node_name}:::node:::${node_type}:::scaler:::none:::none:::none:::0:::${node_name}:::XXX:::${node_name}:::";   }
1223 120 jt_eaton
 
1224 126 jt_eaton
        }
1225
 
1226
 
1227
 
1228
 
1229
 
1230
 
1231
 
1232
 
1233 119 jt_eaton
     #/**********************************************************************/
1234
     #/*                                                                    */
1235
     #/* Read each hierConnection and enter signals into wire_decs          */
1236
     #/*                                                                    */
1237
     #/**********************************************************************/
1238
     foreach  my   $x_name ($spirit_design_file->findnodes('//spirit:hierConnections/spirit:hierConnection/@spirit:interfaceRef'))
1239
        {
1240
        my($hierConn_name)                   = $x_name ->to_literal ;
1241
        my($hierConn_comref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:componentRef')->to_literal ;
1242
        my($hierConn_busref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:busRef')->to_literal ;
1243
 
1244
        foreach  my   $x_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
1245
           {
1246
           #/**********************************************************************/
1247
           #/*                                                                    */
1248
           #/* Lookup VLNV for each instantiated component                        */
1249
           #/*                                                                    */
1250
           #/**********************************************************************/
1251
 
1252
           my($instance_name)       = $x_name ->findnodes('./text()')->to_literal ;
1253
          my($vendor_name)         = $x_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
1254
         my($library_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
1255
         my($component_name)      = $x_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
1256
         my($version_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
1257
 
1258
           if( "$instance_name" eq  "$hierConn_comref_name"     )
1259
             {
1260
             my  @filelist_sub = parse_busInterface($vendor_name, $library_name,$component_name,$version_name,$hierConn_busref_name,"1" );
1261
           #/**********************************************************************/
1262
           #/*                                                                    */
1263
           #/* follow bus all the way to it's source                              */
1264
           #/*                                                                    */
1265
           #/**********************************************************************/
1266
 
1267
             foreach $xxline (@filelist_sub)
1268
                {
1269
                $_ = $xxline;
1270
                if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1271
                  {
1272
                  $k_depth               = $1;
1273
                  $k_log_name            = $2;
1274
                  $k_phy_name            = $3;
1275
                  $k_direction           = $4;
1276
                  $k_type                = $5;
1277
                  $k_vector              = $6;
1278
                  $k_left                = $7;
1279
                  $k_right               = $8;
1280
                  push  @wire_decs,":::${hierConn_name}_${k_log_name}:::${hierConn_name}_${k_log_name}:::${k_direction}:::wire:::${k_vector}:::${k_left}:::${k_right}:::${hierConn_comref_name}:::${k_depth}:::${k_phy_name}:::${hierConn_busref_name}:::${k_log_name}:::";
1281
                  }
1282
                }
1283
             }
1284
           }
1285
        }
1286
 
1287
 
1288
 
1289
 
1290
 
1291
     #/**************************************************************************/
1292
     #/*                                                                        */
1293
     #/* Read each  interconnection and enter sub signals into wire_decs        */
1294
     #/*                                                                        */
1295
     #/**************************************************************************/
1296
 
1297
 
1298
 
1299
 
1300
     foreach  my   $x_name ($spirit_design_file->findnodes('//spirit:interconnections/spirit:interconnection/spirit:activeInterface/@spirit:componentRef'))
1301
        {
1302
        my($hierConn_comref_name)            = $x_name ->to_literal;
1303
        my($hierConn_busref_name)            = $x_name ->findnodes('../@spirit:busRef')->to_literal ;
1304
        my($hierConn_name)                   = $x_name ->findnodes('../../spirit:name/text()')->to_literal ;
1305
 
1306
        foreach  my   $x_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
1307
           {
1308
           #/**********************************************************************/
1309
           #/*                                                                    */
1310
           #/* Lookup VLNV for each instantiated component                        */
1311
           #/*                                                                    */
1312
           #/**********************************************************************/
1313
 
1314
           my($instance_name)       = $x_name ->findnodes('./text()')->to_literal ;
1315
           my($vendor_name)         = $x_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
1316
           my($library_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
1317
           my($component_name)      = $x_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
1318
           my($version_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
1319
 
1320
 
1321
 
1322
           if( "$instance_name" eq  "$hierConn_comref_name"     )
1323
             {
1324
 
1325
 
1326
 
1327
           #/**********************************************************************/
1328
           #/*                                                                    */
1329
           #/* follow bus all the way to it's source                              */
1330
           #/*                                                                    */
1331
           #/**********************************************************************/
1332
 
1333
 
1334
             my  @filelist_sub = parse_busInterface($vendor_name, $library_name,$component_name,$version_name,$hierConn_busref_name,"1" );
1335
             foreach $xxline (@filelist_sub)
1336
                {
1337
 
1338
 
1339
                $_ = $xxline;
1340
                if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1341
                  {
1342
                  $k_depth               = $1;
1343
                  $k_log_name            = $2;
1344
                  $k_phy_name            = $3;
1345
                  $k_direction           = $4;
1346
                  $k_type                = $5;
1347
                  $k_vector              = $6;
1348
                  $k_left                = $7;
1349
                  $k_right               = $8;
1350
 
1351
 
1352
                  push  @wire_decs,":::${hierConn_name}_${k_log_name}:::${hierConn_name}_${k_log_name}:::node:::wire:::${k_vector}:::${k_left}:::${k_right}:::${hierConn_comref_name}:::${k_depth}:::${k_phy_name}:::${hierConn_busref_name}:::${k_log_name}:::";
1353
                  }
1354
                }
1355
             }
1356
           }
1357
        }
1358
 
1359
 
1360
 
1361
     #/*******************************************************************************/
1362
     #/*                                                                             */
1363
     #/* Read each  interconnection and enter modified signals into wire_decs        */
1364
     #/*                                                                             */
1365
     #/*******************************************************************************/
1366
 
1367
 
1368
 
1369
 
1370
 
1371
        foreach  my  $k_name ($spirit_design_file->findnodes('//spirit:interconnections/spirit:interconnection/spirit:activeInterface/spirit:portMaps/spirit:portMap/spirit:logicalPort/spirit:name'))
1372
           {
1373
           my($lp_name)                = $k_name ->to_literal;
1374
           my($lp_pname)               = $k_name ->findnodes('../../spirit:physicalPort/spirit:name/text()')->to_literal ;
1375
           my($lp_left)                = $k_name ->findnodes('../../spirit:physicalPort/spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
1376
           my($lp_right)               = $k_name ->findnodes('../../spirit:physicalPort/spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
1377
           my($lp_componentref_name)   = $k_name ->findnodes('../../../../@spirit:componentRef')->to_literal ;
1378
           my($lp_busref_name)         = $k_name ->findnodes('../../../../@spirit:busRef')->to_literal ;
1379
           my($lp_interconnect_name)   = $k_name ->findnodes('../../../../../spirit:name/text()')->to_literal ;
1380
 
1381
 
1382
           if ( $lp_pname eq '' ) { $lp_pname ="${lp_interconnect_name}_${lp_name}";}
1383
           if ( $lp_left  eq '' ) { $lp_left ="none";}
1384
           if ( $lp_right eq '' ) { $lp_right ="none";}
1385
 
1386
 
1387
 
1388
          if ( $lp_left  eq 'none' )
1389
          {
1390
           push  @wire_decs,":::${lp_interconnect_name}_${lp_name}:::${lp_pname}:::node:::wire:::scaler:::none:::none:::${lp_componentref_name}:::0:::${lp_interconnect_name}_${lp_name}:::${lp_busref_name}:::${lp_pname}:::";
1391
          }
1392
          else
1393
          {
1394
           push  @wire_decs,":::${lp_interconnect_name}_${lp_name}:::${lp_pname}:::node:::wire:::vector:::${lp_left}:::${lp_right}:::${lp_componentref_name}:::0:::${lp_interconnect_name}_${lp_name}:::${lp_busref_name}:::${lp_pname}:::";
1395
          }
1396
           }
1397
 
1398
 
1399
 
1400
 
1401
 
1402
 
1403
 
1404
 
1405
     #/**********************************************************************/
1406
     #/*                                                                    */
1407
     #/* Read all adHocConnections and load instance connect info into array*/
1408
     #/*                                                                    */
1409
     #/**********************************************************************/
1410
 
1411
 
1412
     foreach  my   $i_xame ($spirit_design_file->findnodes('//spirit:adHocConnections/spirit:adHocConnection/spirit:internalPortReference/@spirit:componentRef'))
1413
        {
1414
        my($comp_name)    = $i_xame ->to_literal;
1415
        my($int_value)    = $i_xame ->findnodes('../../spirit:name/text()')->to_literal ;
1416 126 jt_eaton
        my($tied_value)   = $i_xame ->findnodes('../../@spirit:tiedValue')->to_literal ;
1417 119 jt_eaton
        my($int_name)     = $i_xame ->findnodes('../@spirit:portRef')->to_literal ;
1418 126 jt_eaton
        my($vec_name)     = $i_xame ->findnodes('../../spirit:externalPortReference/@spirit:portRef')->to_literal ;
1419
        my($vec_left)     = $i_xame ->findnodes('../../spirit:externalPortReference/@spirit:left')->to_literal ;
1420
        my($vec_right)    = $i_xame ->findnodes('../../spirit:externalPortReference/@spirit:right')->to_literal ;
1421 124 jt_eaton
 
1422
 
1423 126 jt_eaton
# print "XXXXXX  $comp_name  $int_name  ( $int_value  $tied_value  )   $vec_name $vec_left $vec_right  \n";
1424 124 jt_eaton
 
1425 126 jt_eaton
 
1426
        unless ($int_value)
1427
         {$int_value = "_DUMMY_";
1428
         }
1429
 
1430
 
1431
        if($tied_value )
1432
          {
1433
          push @inst_conns , ":::${comp_name}:::adhoc:::${int_name}:::${tied_value}:::scaler:::none:::none:::";
1434
          }
1435
        elsif($vec_left ne "")
1436 119 jt_eaton
          {
1437
          push @inst_conns , ":::${comp_name}:::adhoc:::${int_name}:::${int_value}:::vector:::${vec_left}:::${vec_right}:::";
1438 126 jt_eaton
          push @wire_decs  , ":::${vec_name}:::${int_value}:::node:::wire:::vector:::${vec_left}:::${$vec_right}:::none:::0:::${int_value}:::XXX:::${vec_name}:::";
1439 119 jt_eaton
          }
1440
        else
1441
          {
1442
          push @inst_conns , ":::${comp_name}:::adhoc:::${int_name}:::${int_value}:::scaler:::none:::none:::";
1443 126 jt_eaton
          push @wire_decs  , ":::${vec_name}:::${int_value}:::node:::wire:::scaler:::none:::none:::none:::0:::${int_value}:::XXX:::${vec_name}:::";
1444 119 jt_eaton
          }
1445 126 jt_eaton
 
1446
 
1447 119 jt_eaton
        }
1448
 
1449
 
1450
 
1451
 
1452
 
1453
 
1454
 
1455
 
1456
 
1457
 
1458 126 jt_eaton
 
1459
 
1460 119 jt_eaton
 
1461
 
1462
 
1463
 
1464
 
1465
 
1466
 
1467
     #/**********************************************************************/
1468
     #/*                                                                    */
1469
     #/* extract bus instance connections from wire_decs                    */
1470
     #/*                                                                    */
1471
     #/**********************************************************************/
1472
 
1473 126 jt_eaton
     #print "+-+";
1474 119 jt_eaton
 
1475
 
1476
 
1477
     my @inst_names  = ();
1478
     my @inst_Inames  = ();
1479
     my %inst_ports  = ();
1480
     my %inst_sigs   = ();
1481
     my %inst_vector = ();
1482
     my %inst_left   = ();
1483
     my %inst_right  = ();
1484
 
1485
 
1486
     foreach $line (@wire_decs)
1487
        {
1488
        $_ = $line;
1489
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1490
          {
1491
          my $t_index               = $1;
1492
          my $t_node_name           = $2;
1493
          my $t_direction           = $3;
1494
          my $t_type                = $4;
1495
          my $t_vector              = $5;
1496
          my $t_left                = $6;
1497
          my $t_right               = $7;
1498
          my $t_instance            = $8;
1499
          my $t_depth               = $9;
1500
          my $t_phy_name            = $10;
1501
          my $t_busref_name         = $11;
1502
          my $t_abslog_name         = $12;
1503
 
1504
        if( 1)
1505
          {
1506
 
1507
         push ( @inst_names, "${t_instance}_${t_busref_name}_${t_index}");
1508
 
1509
         $inst_Inames{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_instance}";
1510
 
1511
         if(  $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"})
1512
            {
1513
            if(  $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"} eq ${t_index})
1514
              {
1515
              $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_node_name}";
1516
              }
1517
            }
1518
         else
1519
            {
1520
            $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_node_name}";
1521
            }
1522
 
1523
         if   ($t_depth >= 2 )      { $inst_ports{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_busref_name}_${t_abslog_name}" ;}
1524
         elsif($t_depth == 1 )      { $inst_ports{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_phy_name}";}
1525
 
1526
         if(  $inst_vector{"${t_instance}_${t_busref_name}_${t_index}"})
1527
            {
1528
            if(  $inst_vector{"${t_instance}_${t_busref_name}_${t_index}"} eq "scaler")
1529
              {$inst_vector{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_vector}";}
1530
            }
1531
         else
1532
            {$inst_vector{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_vector}";}
1533
 
1534
         unless(  $inst_left{"${t_instance}_${t_busref_name}_${t_index}"} eq '')
1535
            {
1536
            if(  $inst_left{"${t_instance}_${t_busref_name}_${t_index}"} eq "none")
1537
              {
1538
              $inst_left{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_left}";
1539
              }
1540
            elsif(  $inst_left{"${t_instance}_${t_busref_name}_${t_index}"} < ${t_left})
1541
              {
1542
              $inst_left{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_left}";
1543
              }
1544
            }
1545
          else
1546
            {
1547
            $inst_left{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_left}";
1548
            }
1549
 
1550
          unless(  $inst_right{"${t_instance}_${t_busref_name}_${t_index}"} eq '')
1551
            {
1552
            if(  $inst_right{"${t_instance}_${t_busref_name}_${t_index}"} eq "none")
1553
              {
1554
              $inst_right{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_right}";
1555
              }
1556
            elsif(  $inst_right{"${t_instance}_${t_busref_name}_${t_index}"} < ${t_right})
1557
              {
1558
              $inst_right{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_right}";
1559
              }
1560
            }
1561
          else {$inst_right{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_right}";}
1562
 
1563
        }
1564
      }
1565
     }
1566
     @inst_names = sys::lib::trim_sort(@inst_names);
1567
     foreach $i_name (@inst_names)
1568
         {
1569
        unless($inst_Inames{$i_name} eq "none")
1570
         {
1571
         if($inst_vector{$i_name} eq "vector"  )
1572
           {
1573 126 jt_eaton
          push @inst_conns ,":::$inst_Inames{$i_name}:::adhoc:::$inst_ports{$i_name}:::$inst_sigs{$i_name}:::vector:::$inst_left{$i_name}:::$inst_right{$i_name}:::";
1574 119 jt_eaton
          }
1575
        else
1576
          {
1577 126 jt_eaton
          push @inst_conns ,":::$inst_Inames{$i_name}:::adhoc:::$inst_ports{$i_name}:::$inst_sigs{$i_name}:::scaler:::none:::none:::";
1578 119 jt_eaton
 
1579
           }
1580
         }
1581
         }
1582 120 jt_eaton
     }
1583 119 jt_eaton
 
1584
 
1585
 
1586
 
1587
 
1588
 
1589
 
1590
 
1591
 
1592 120 jt_eaton
#/*********************************************************************************************/
1593
#/                                                                                            */
1594
#/                                                                                            */
1595
#/                                                                                            */
1596
#/                                                                                            */
1597
#/                                                                                            */
1598
#/                                                                                            */
1599
#/*********************************************************************************************/
1600 119 jt_eaton
 
1601
 
1602
 
1603
 
1604 120 jt_eaton
sub process_design_file
1605
   {
1606
   my @params     = @_;
1607
   my $spirit_design_file      = pop(@params);
1608 119 jt_eaton
 
1609
 
1610
 
1611
 
1612
 
1613 126 jt_eaton
#print "\n";
1614 120 jt_eaton
foreach my $new_comp ($spirit_design_file->findnodes("//spirit:design/spirit:vendor"))
1615
   {
1616
   my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
1617
   my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
1618
   my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
1619
   my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
1620
#   print "XXXXXX-  $new_vendor $new_library $new_name $new_version  DESIGN \n";
1621
   }
1622 119 jt_eaton
 
1623
 
1624
 
1625 126 jt_eaton
 
1626
 
1627 119 jt_eaton
     #/**********************************************************************/
1628
     #/*                                                                    */
1629
     #/* Instantiate each component with parameters and port connections    */
1630
     #/*                                                                    */
1631
     #/* If the component doesn't have a instance name then this is skipped */
1632
     #/*                                                                    */
1633
     #/**********************************************************************/
1634
 
1635 126 jt_eaton
     #print "+-+";
1636 119 jt_eaton
 
1637
     push @instantiations  , "////////////////////////////////////////////////////////////////\n";
1638
 
1639 126 jt_eaton
 
1640
     @inst_conns = sys::lib::trim_sort(@inst_conns);
1641
 
1642
 
1643
 
1644
 
1645
 
1646
 
1647 119 jt_eaton
     foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
1648
        {
1649
        my($instance_name)       = $i_name ->findnodes('./text()')->to_literal ;
1650 122 jt_eaton
        my($vendor_name)         = $i_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
1651
        my($library_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
1652 119 jt_eaton
        my($component_name)      = $i_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
1653
        my($version_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
1654
 
1655 122 jt_eaton
        my $module_name = yp::lib::get_module_name($vendor_name,$library_name,$component_name,$version_name) ;
1656
 
1657
 
1658 126 jt_eaton
 
1659
 
1660
 
1661
 
1662
 
1663 119 jt_eaton
        if($instance_name)
1664
          {
1665 122 jt_eaton
          push @instantiations  , "$module_name\n";
1666 119 jt_eaton
          $first = 1;
1667
 
1668
          foreach  my   $i_parameter ($spirit_design_file->findnodes("//spirit:componentInstance[spirit:instanceName/text() = '$instance_name']/spirit:configurableElementValues/spirit:configurableElementValue/\@spirit:referenceId"))
1669
             {
1670
             my($foo_name)       = $i_parameter ->to_literal ;
1671
             my($foo_value)      = $i_parameter ->findnodes('../text()')->to_literal ;
1672 124 jt_eaton
 
1673
 
1674
 
1675
 
1676 119 jt_eaton
             if($first)
1677
               {
1678
               push @instantiations  , "#( .${foo_name} (${foo_value})";
1679
               $first = 0;
1680
               }
1681
             else  {push @instantiations  , ",\n   .${foo_name} (${foo_value})";}
1682
             }
1683
 
1684
             if($first == 0)  { push @instantiations  , ")\n";}
1685
             push @instantiations  , "$instance_name \n   (\n ";
1686
             $first = 1;
1687
 
1688 126 jt_eaton
 
1689
 
1690
 
1691
             foreach $line (@inst_conns)
1692 119 jt_eaton
                {
1693
                $_ = $line;
1694
 
1695
                if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1696
                  {
1697
                  my $z_instance_name           = $1;
1698
                  my $z_busRef_name   = $2;
1699
                  my $z_port_name           = $3;
1700
                  my $z_signal_name           = $4;
1701
                  my $z_vecscal           = $5;
1702
                  my $z_left           = $6;
1703
                  my $z_right           = $7;
1704 126 jt_eaton
 
1705
                  if($opt_debug ){print  "YYYYYY--    $line  \n";}
1706
 
1707 119 jt_eaton
                  if($z_vecscal eq "vector")
1708
                    {
1709
                    if($z_left eq $z_right){$z_signal_name =  "${z_signal_name}[${z_left}]" ;}
1710
                    else    {$z_signal_name =  "${z_signal_name}[${z_left}:${z_right}]" ;}
1711
                    }
1712 124 jt_eaton
 
1713
                  if ($z_signal_name eq "_DUMMY_")  {$z_signal_name = "      ";}
1714
 
1715 119 jt_eaton
                  if($instance_name eq  $z_instance_name )
1716
                    {
1717
                    if($first)
1718
                      {
1719
                      push @instantiations  ,          "  .${z_port_name}         (${z_signal_name})";
1720
                      $first =0;
1721
                      }
1722
                    else   {           push @instantiations  , ",\n   .${z_port_name}         (${z_signal_name})";}
1723
                    }
1724
                  }
1725
                }
1726
 
1727 126 jt_eaton
     #print ".";
1728 119 jt_eaton
     push @instantiations  , ");\n\n";
1729
     }
1730
     }
1731
     }
1732
 
1733
 
1734
 
1735
 
1736
 
1737
 
1738
 
1739 120 jt_eaton
 
1740
 
1741 119 jt_eaton
#/*********************************************************************************************/
1742
#/                                                                                            */
1743
#/                                                                                            */
1744
#/                                                                                            */
1745
#/                                                                                            */
1746
#/                                                                                            */
1747
#/                                                                                            */
1748
#/*********************************************************************************************/
1749
 
1750
 
1751
 
1752
 
1753
sub parse_component_file
1754
   {
1755
   my @params     = @_;
1756
   my $spirit_component_file      = pop(@params);
1757
 
1758
 
1759 126 jt_eaton
#print "\n";
1760 120 jt_eaton
foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:vendor"))
1761
   {
1762
   my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
1763
   my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
1764
   my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
1765
   my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
1766 126 jt_eaton
   if($opt_verbose){print "parse_component_file   $new_vendor $new_library $new_name $new_version  COMPONENT \n";}
1767 120 jt_eaton
   }
1768
 
1769
 
1770
 
1771
 
1772 121 jt_eaton
     #/**********************************************************************/
1773
     #/*                                                                    */
1774
     #/* parse parameters and values                                        */
1775
     #/*                                                                    */
1776
     #/**********************************************************************/
1777
 
1778
     foreach  my   $i_name ($spirit_component_file->findnodes('//spirit:model/spirit:modelParameters/spirit:modelParameter/spirit:name'))
1779
        {
1780
        my($parameter_name)     = $i_name ->to_literal;
1781
        my($parameter_default)  = $i_name ->findnodes('../spirit:value/text()')->to_literal ;
1782
 
1783
        unless(defined $parameter_values{$parameter_name})
1784
         {
1785
         push ( @parameters,  "$parameter_name");
1786 125 jt_eaton
         $parameter_values{$parameter_name} = ${parameter_default};
1787
         };
1788 121 jt_eaton
 
1789
        }
1790
 
1791
 
1792
 
1793
 
1794
 
1795
 
1796
 
1797 125 jt_eaton
foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef"))
1798 120 jt_eaton
   {
1799 125 jt_eaton
    my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
1800
    my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
1801
    my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
1802
    my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
1803
    my $hier_ref_type = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
1804
    if($hier_ref_type eq "spirit:component")
1805 120 jt_eaton
     {
1806
     my $spirit_sub_component_file           = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_library,$new_name,$new_version));
1807
     parse_component_file($spirit_sub_component_file);
1808
     }
1809
 
1810 125 jt_eaton
   }
1811 120 jt_eaton
 
1812
 
1813
 
1814
 
1815
 
1816 119 jt_eaton
     #/**********************************************************************/
1817
     #/*                                                                    */
1818
     #/* Read each  busInterface and save master/slave direction            */
1819
     #/*                                                                    */
1820
     #/**********************************************************************/
1821
 
1822
     my @mas_slave;
1823
 
1824
     push @mas_slave  , "master";
1825
     push @mas_slave  , "slave";
1826
 
1827
     foreach $seek_type (@mas_slave)
1828
        {
1829
 
1830
         foreach my $bus_iface ($spirit_component_file->findnodes("//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:${seek_type}"))
1831
            {
1832
            my($mmm_cname)         = $bus_iface->findnodes('../spirit:name/text()')->to_literal ;
1833
            my($mmm_vendor)        = $bus_iface->findnodes('../spirit:abstractionType/@spirit:vendor')->to_literal ;
1834
            my($mmm_library)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:library')->to_literal ;
1835
            my($mmm_name)          = $bus_iface->findnodes('../spirit:abstractionType/@spirit:name')->to_literal ;
1836
            my($mmm_version)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:version')->to_literal ;
1837
 
1838
            foreach my $port_face ($spirit_component_file->findnodes('//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:portMaps/spirit:portMap/spirit:logicalPort'))
1839
               {
1840
               my($rrr_log_name)      = $port_face->findnodes('./spirit:name/text()')->to_literal ;
1841
               my($rrr_phy_name)      = $port_face->findnodes('../spirit:physicalPort/spirit:name/text()')->to_literal ;
1842
               my($rrr_type_name)     = $port_face->findnodes('../spirit:physicalPort/spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
1843
               my($rrr_int_name)      = $port_face->findnodes('../../../spirit:name/text()')->to_literal ;
1844
               my($rrr_left_value)    = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
1845
               my($rrr_right_value)   = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
1846
 
1847
               unless ($rrr_type_name)  {$rrr_type_name = "wire";}
1848
 
1849
               if(   $mmm_cname  eq  $rrr_int_name )
1850
                 {
1851
 
1852
                 my $busdef_parser = XML::LibXML->new();
1853 125 jt_eaton
 
1854
 
1855
                 my $spirit_abstractor_filename    = yp::lib::find_ipxact("spirit:abstractionDefinition",$mmm_vendor,$mmm_library,$mmm_name,$mmm_version);
1856
 
1857
                 unless($spirit_abstractor_filename)
1858
 
1859 126 jt_eaton
                 {#print "  $mmm_vendor $mmm_library $mmm_name $mmm_version  \n";
1860 125 jt_eaton
}
1861
 
1862 122 jt_eaton
                 my $spirit_abstractor_file    = ($parser->parse_file(yp::lib::find_ipxact("spirit:abstractionDefinition",$mmm_vendor,$mmm_library,$mmm_name,$mmm_version))
1863 119 jt_eaton
 
1864 122 jt_eaton
                ) || die "(OOPs $mmm_vendor $mmm_library $mmm_name $mmm_version )";
1865
 
1866
 
1867
 
1868 119 jt_eaton
                 foreach my $abstr_view ($spirit_abstractor_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$rrr_log_name']"))
1869
                    {
1870
                    my($sss_m_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onMaster/spirit:direction/text()')->to_literal ;
1871
                    my($sss_s_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onSlave/spirit:direction/text()')->to_literal ;
1872
 
1873
                    if    ($sss_m_dir eq "in")  { $sss_m_dir = "input";}
1874
                    elsif ($sss_m_dir eq "out") { $sss_m_dir = "output";}
1875
 
1876
                    if    ($sss_s_dir eq "in")  { $sss_s_dir = "input";}
1877
                    elsif ($sss_s_dir eq "out") { $sss_s_dir = "output";}
1878
 
1879
                    my $rrr_direction = "";
1880
 
1881
                    if( $seek_type eq "master") {        $rrr_direction = $sss_m_dir;}
1882
                    else                        {        $rrr_direction = $sss_s_dir;}
1883
 
1884
                    my $rrr_dir = "";
1885
                    if   ($rrr_direction  eq "in" )  {$rrr_dir = "input" ;}
1886
                    elsif($rrr_direction  eq "out" ) {$rrr_dir = "output" ;}
1887
                    else                             {$rrr_dir = $rrr_direction;     }
1888
 
1889 122 jt_eaton
                    if($rrr_left_value ne "")
1890 119 jt_eaton
                        {
1891
                        push @wire_decs , ":::${mmm_cname}_${rrr_log_name}:::${rrr_phy_name}:::${rrr_dir}:::${rrr_type_name}:::vector:::${rrr_left_value}:::${$rrr_right_value}:::none:::0:::${rrr_phy_name}:::XXX:::${rrr_log_name}:::";
1892
                        }
1893
                      else
1894
                        {
1895
                        push @wire_decs , ":::${mmm_cname}_${rrr_log_name}:::${rrr_phy_name}:::${rrr_dir}:::${rrr_type_name}:::scaler:::none:::none:::none:::0:::${rrr_phy_name}:::XXX:::${rrr_log_name}:::";
1896
                        }
1897
                    }
1898
                 }
1899
               }
1900 122 jt_eaton
        }
1901 119 jt_eaton
     }
1902
 
1903
 
1904
 
1905
 
1906
     #/**********************************************************************/
1907
     #/*                                                                    */
1908
     #/* Read all ports and store into array                                */
1909
     #/*                                                                    */
1910
     #/**********************************************************************/
1911
 
1912
     foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:ports/spirit:port/spirit:name"))
1913
        {
1914
        my($port_name)       = $i_name ->findnodes('./text()')->to_literal ;
1915
        my($direction)       = $i_name ->findnodes('../spirit:wire/spirit:direction/text()')->to_literal ;
1916
        my($left)            = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
1917
        my($right)           = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
1918
        my($type)            = $i_name ->findnodes('../spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
1919
 
1920
 
1921
        if    ($direction eq "in")  { $direction = "input";}
1922
        elsif ($direction eq "out") { $direction = "output";}
1923
 
1924
 
1925 122 jt_eaton
        if($left ne "")  { push @wire_decs , ":::${port_name}:::${port_name}:::${direction}:::${type}:::vector:::${left}:::${right}:::none:::0:::${port_name}:::XXX:::${port_name}:::";  }
1926 119 jt_eaton
        else       { push @wire_decs , ":::${port_name}:::${port_name}:::${direction}:::${type}:::scaler:::none:::none:::none:::0:::${port_name}:::XXX:::${port_name}:::";          }
1927
        }
1928
 
1929
 
1930
 
1931
 
1932
}
1933
 
1934
 
1935
1
1936
 

powered by: WebSVN 2.1.0

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